Definition in file BasicSMTP.h.
#include "portmacro.h"
#include "shell.h"
Go to the source code of this file.
Functions | |
eExecStatus | e_smtpclient_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get smtp client config command: get the SMTP variables. Takes no parameter. | |
eExecStatus | e_smtpclient_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The set smtp client config command: set the SMTP variables. | |
portTASK_FUNCTION_PROTO (vBasicSMTPClient, pvParameters) | |
void | v_SMTP_Post (portCHAR *MailSubject, portCHAR *Filename) |
Post a message to send. | |
void | v_SMTP_PostFromISR (portCHAR *MailSubject, portCHAR *Filename) |
Post a message to send from ISR. |
eExecStatus e_smtpclient_cmd_get_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The get smtp client config command: get the SMTP variables. Takes no parameter.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 1. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 613 of file BasicSMTP.c.
References cMailFrom, cMailTo, cServerName, MAX_CONFIG_FILE_SIZE, SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, sprintf(), and uiSMTPPort.
Referenced by e_syscmds_cmd_get_config().
00616 { 00617 00618 if(ppcStringReply != NULL) 00619 { 00620 // allocate a buffer for answer 00621 *ppcStringReply = (signed portCHAR *)pvPortMalloc(MAX_CONFIG_FILE_SIZE); 00622 if( NULL == *ppcStringReply ) 00623 { 00624 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC; 00625 return( SHELL_EXECSTATUS_KO ); 00626 } 00627 #if (SMTP_USED == 1) 00628 // get SMTP variables and add them to the buffer 00629 sprintf((char *)*ppcStringReply,"port=%u\r\nserver=%s\r\nmailto=%s\r\nmailfrom=%s\r\n", 00630 uiSMTPPort, 00631 cServerName, 00632 cMailTo, 00633 cMailFrom); 00634 #else 00635 // get SMTP variables and add them to the buffer 00636 sprintf((char *)*ppcStringReply,"port=NotCompiled\r\nserver=NotCompiled\r\nmailto=NotCompiled\r\nmailfrom=NotCompiled\r\n"); 00637 #endif 00638 /* no error, return */ 00639 return( SHELL_EXECSTATUS_OK ); 00640 } 00641 return( SHELL_EXECSTATUS_KO ); 00642 }
eExecStatus e_smtpclient_cmd_set_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The set smtp client config command: set the SMTP variables.
* Takes 4 parameters : * port=ppppp * server=smtp.domain.com * mailto=recipient@domain.com * mailfrom=sender@domain.com *
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 1. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
* Takes 4 parameters : * port=ppppp * server=smtp.domain.com * mailto=recipient@domain.com * mailfrom=sender@domain.com *
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 1. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 546 of file BasicSMTP.c.
References cMailFrom, cMailTo, config_file_set_value(), cServerName, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK_NO_FREE, SHELL_MSG_CONFIG_SET, SMTP_CONFIG_FILE, SMTP_ERRMSG_CONFIGURESMTP, and uiSMTPPort.
Referenced by e_syscmds_cmd_set_config().
00549 { 00550 #if (SMTP_USED == 1) 00551 if (config_file_set_value(SMTP_CONFIG_FILE, ac, av) != 0) 00552 { 00553 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_CONFIGERROR; 00554 // return error 00555 return( SHELL_EXECSTATUS_KO ); 00556 } 00557 00558 if (!strcmp((char *)av[0] , "port")) 00559 { 00560 uiSMTPPort = atoi((char *)av[1]); 00561 *ppcStringReply = (signed portCHAR *)SHELL_MSG_CONFIG_SET; 00562 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00563 } 00564 else if (!strcmp((char *)av[0] , "mailto")) 00565 { 00566 cMailTo[0]='\0'; 00567 strncat(cMailTo, (char *)av[1], Min(sizeof(cMailTo),strlen((char *)av[1]))); 00568 *ppcStringReply = (signed portCHAR *)SHELL_MSG_CONFIG_SET; 00569 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00570 } 00571 else if (!strcmp((char *)av[0] , "mailfrom")) 00572 { 00573 cMailFrom[0]='\0'; 00574 strncat(cMailFrom, (char *)av[1], Min(sizeof(cMailFrom),strlen((char *)av[1]))); 00575 *ppcStringReply = (signed portCHAR *)SHELL_MSG_CONFIG_SET; 00576 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00577 } 00578 else if (!strcmp((char *)av[0] , "server")) 00579 { 00580 cServerName[0]='\0'; 00581 strncat(cServerName, (char *)av[1], Min(sizeof(cServerName),strlen((char *)av[1]))); 00582 *ppcStringReply = (signed portCHAR *)SHELL_MSG_CONFIG_SET; 00583 return( SHELL_EXECSTATUS_OK_NO_FREE ); 00584 } 00585 else 00586 { 00587 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_CONFIGERROR; 00588 return( SHELL_EXECSTATUS_KO ); 00589 } 00590 #else 00591 *ppcStringReply = (signed portCHAR *)SMTP_ERRMSG_CONFIGURESMTP; 00592 return( SHELL_EXECSTATUS_KO ); 00593 #endif 00594 }
portTASK_FUNCTION_PROTO | ( | vBasicSMTPClient | , | |
pvParameters | ||||
) |
void v_SMTP_Post | ( | portCHAR * | MailSubject, | |
portCHAR * | Filename | |||
) |
Post a message to send.
MailSubject | : the subject for the mail to send | |
Filename | : the filename for data to send as mail content |
Definition at line 182 of file BasicSMTP.c.
References xMailDef::File, xMailDef::NeedFree, xMailDef::Subject, and xMailsQueue.
Referenced by b_light_get_value(), b_potentiometer_get_value(), b_temperature_get_value(), and prv_xopen_current_logfile().
00183 { 00184 xMailDef * pxMail; 00185 00186 // try to allocate a descriptor for this mail 00187 pxMail = (xMailDef *) pvPortMalloc(sizeof(xMailDef)); 00188 // if allocation succeeds 00189 if (pxMail != NULL) 00190 { 00191 // try to allocate a buffer for the subject 00192 pxMail->Subject = (portCHAR *) pvPortMalloc(strlen(MailSubject)); 00193 // if allocation succeeds 00194 if (pxMail->Subject != NULL) 00195 { 00196 // copy the subject to mailbox item 00197 strcpy(pxMail->Subject, MailSubject ); 00198 // if a filename as been provided 00199 if (Filename != NULL) 00200 { 00201 // try to allocate a buffer for the filename 00202 pxMail->File = (portCHAR *) pvPortMalloc(strlen(Filename)); 00203 // if allocation succeeds 00204 if (pxMail->File != NULL) 00205 { 00206 // copy the filename to mailbox item 00207 strcpy(pxMail->File, Filename ); 00208 } 00209 } 00210 else 00211 { 00212 // mark field as unused 00213 pxMail->File = NULL; 00214 } 00215 // item must be free, so mark it so. 00216 pxMail->NeedFree = pdTRUE; 00217 // post item to the mailbox 00218 xQueueSend( xMailsQueue, (void *)&pxMail, 0 ); 00219 } 00220 } 00221 }
void v_SMTP_PostFromISR | ( | portCHAR * | MailSubject, | |
portCHAR * | Filename | |||
) |
Post a message to send from ISR.
MailSubject | : MUST be a const, no dynamic allocation in ISR | |
Filename | : MUST be a const, no dynamic allocation in ISR |
Definition at line 229 of file BasicSMTP.c.
References xMailDef::File, xMailDef::NeedFree, xMailDef::Subject, and xMailsQueue.
Referenced by prvjoystick_ISR_NonNakedBehaviour(), and prvpushb_ISR_NonNakedBehaviour().
00230 { 00231 xMailDef * pxMail = &xMailFromISR; 00232 portBASE_TYPE xYieldRequired = pdFALSE; 00233 00234 // reference mail subject 00235 pxMail->Subject = MailSubject; 00236 // reference file name 00237 pxMail->File = Filename; 00238 // reference IT field 00239 pxMail->NeedFree = pdFALSE; 00240 00241 // post message to queue, disable IT prior to do it 00242 portENTER_CRITICAL(); 00243 xQueueSendFromISR( xMailsQueue, (void *)&pxMail, &xYieldRequired ); 00244 portEXIT_CRITICAL(); 00245 }