//-------------------------------------------------------------------------------------------------- void Testle_sms_SendText() { le_result_t res; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); LE_DEBUG("-TEST- Create Msg %p", myMsg); testHdlrRef=le_sms_AddRxMessageHandler(TestRxHandler, NULL); CU_ASSERT_PTR_NOT_NULL(testHdlrRef); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetText(myMsg, LARGE_TEXT_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); res=le_sms_SetText(myMsg, SHORT_TEXT_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- void Testle_sms_SendPdu() { le_result_t res; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); LE_DEBUG("Create Msg %p", myMsg); res=le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0])); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); res=le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_8BITS, sizeof(PDU_TEST_PATTERN_8BITS)/sizeof(PDU_TEST_PATTERN_8BITS[0])); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); le_sms_Delete(myMsg); }
static le_result_t LeSmsSendtextTime ( const char* destStr, ///< [IN] ///< Telephone number string. const char* textStr, ///< [IN] ///< SMS text. le_sms_CallbackResultFunc_t handlerPtr, ///< [IN] void* contextPtr, ///< [IN] uint32_t timeout ///< [IN] ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg = le_sms_Create(); if(myMsg == NULL) { return res; } res = le_sms_SetDestination(myMsg, destStr); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } res = le_sms_SetText(myMsg, textStr); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } res = le_sms_SetTimeout(myMsg, timeout); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } res = le_sms_SendAsync(myMsg, handlerPtr, contextPtr); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } return res; }
//-------------------------------------------------------------------------------------------------- void Testle_sms_SetGetBinary() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_Format_t myformat; char timestamp[LE_SMS_TIMESTAMP_MAX_LEN]; char tel[LE_MDMDEFS_PHONE_NUM_MAX_LEN]; uint8_t raw[LE_SMS_BINARY_MAX_LEN]; size_t uintval; uint32_t i; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetBinary(myMsg, BINARY_TEST_PATTERN, sizeof(BINARY_TEST_PATTERN)); CU_ASSERT_EQUAL(res, LE_OK); myformat=le_sms_GetFormat(myMsg); CU_ASSERT_EQUAL(myformat, LE_SMS_FORMAT_BINARY); res=le_sms_GetSenderTel(myMsg, tel, sizeof(tel)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); res=le_sms_GetTimeStamp(myMsg, timestamp, sizeof(timestamp)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); uintval=le_sms_GetUserdataLen(myMsg); CU_ASSERT_EQUAL(uintval, sizeof(BINARY_TEST_PATTERN)); uintval=1; res=le_sms_GetBinary(myMsg, raw, &uintval); CU_ASSERT_EQUAL(res, LE_OVERFLOW); uintval=sizeof(BINARY_TEST_PATTERN); res=le_sms_GetBinary(myMsg, raw, &uintval); CU_ASSERT_EQUAL(res, LE_OK); for(i=0; i<sizeof(BINARY_TEST_PATTERN) ; i++) { CU_ASSERT_EQUAL(raw[i], BINARY_TEST_PATTERN[i]); } CU_ASSERT_EQUAL(uintval, sizeof(BINARY_TEST_PATTERN)); res=le_sms_SetDestination(myMsg, VOID_PATTERN); CU_ASSERT_EQUAL(res, LE_BAD_PARAMETER); res=le_sms_SetBinary(myMsg, BINARY_TEST_PATTERN, 0); CU_ASSERT_EQUAL(res, LE_BAD_PARAMETER); le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_Send_Pdu ( void ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); if (myMsg) { LE_DEBUG("Create Msg %p", myMsg); res = le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS, sizeof(PDU_TEST_PATTERN_7BITS)/ sizeof(PDU_TEST_PATTERN_7BITS[0])); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_Send(myMsg); if ((res == LE_FAULT) || (res == LE_FORMAT_ERROR)) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_8BITS, sizeof(PDU_TEST_PATTERN_8BITS)/ sizeof(PDU_TEST_PATTERN_8BITS[0])); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_Send(myMsg); if ((res == LE_FAULT) || (res == LE_FORMAT_ERROR)) { le_sms_Delete(myMsg); return LE_FAULT; } le_sms_Delete(myMsg); res = LE_OK; } return res; }
static le_result_t LeSmsSendPduTime ( const uint8_t* pduPtr, ///< [IN] ///< PDU message. size_t pduNumElements, ///< [IN] le_sms_CallbackResultFunc_t handlerPtr, ///< [IN] void* contextPtr, uint32_t timeout ///< [IN] ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg = le_sms_Create(); if(myMsg == NULL) { return res; } res = le_sms_SetPDU(myMsg, pduPtr, pduNumElements); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } res = le_sms_SetTimeout(myMsg, timeout); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } res = le_sms_SendAsync(myMsg, handlerPtr, contextPtr); if(res != LE_OK) { le_sms_Delete(myMsg); return res; } return res; }
static void* MyTxThread ( void* context ///< See parameter documentation above. ) { le_sms_ConnectService(); bool pdu_type = *((bool *) context); int i; le_sms_MsgRef_t myMsg; for (i = NB_SMS_ASYNC_TO_SEND; i > 0; i--) { if (pdu_type) { myMsg = le_sms_SendPdu(PDU_TEST_PATTERN_7BITS, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0]), CallbackTestHandler, (void*) 1); } else { myMsg = le_sms_SendText(DEST_TEST_PATTERN, TEXT_TEST_PATTERN, CallbackTestHandler, NULL); } LE_INFO("-TEST- Create Async text Msg %p", myMsg); myMsg = le_sms_Create(); if (pdu_type) { le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0])); le_sms_SendAsync(myMsg, CallbackTestHandler, (void*) 1); } else { le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); le_sms_SetText(myMsg, TEXT_TEST_PATTERN); le_sms_SendAsync(myMsg, CallbackTestHandler, NULL); } LE_INFO("-TEST- Create Async text Msg %p", myMsg); } le_event_RunLoop(); return NULL; }
//-------------------------------------------------------------------------------------------------- void Testle_sms_SetGetText() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_Format_t myformat; char timestamp[LE_SMS_TIMESTAMP_MAX_LEN]; char tel[LE_MDMDEFS_PHONE_NUM_MAX_LEN]; char text[LE_SMS_TEXT_MAX_LEN]; size_t uintval; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetText(myMsg, TEXT_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); myformat=le_sms_GetFormat(myMsg); CU_ASSERT_EQUAL(myformat, LE_SMS_FORMAT_TEXT); res=le_sms_GetSenderTel(myMsg, tel, sizeof(tel)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); res=le_sms_GetTimeStamp(myMsg, timestamp, sizeof(timestamp)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); uintval=le_sms_GetUserdataLen(myMsg); CU_ASSERT_EQUAL(uintval, strlen(TEXT_TEST_PATTERN)); res=le_sms_GetText(myMsg, text, 1); CU_ASSERT_EQUAL(res, LE_OVERFLOW); res=le_sms_GetText(myMsg, text, sizeof(text)); CU_ASSERT_EQUAL(res, LE_OK); CU_ASSERT_STRING_EQUAL(text, TEXT_TEST_PATTERN); res=le_sms_SetDestination(myMsg, VOID_PATTERN); CU_ASSERT_EQUAL(res, LE_BAD_PARAMETER); res=le_sms_SetText(myMsg, VOID_PATTERN); CU_ASSERT_EQUAL(res, LE_BAD_PARAMETER); le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- void Testle_sms_SetGetPDU() { le_result_t res; le_sms_MsgRef_t myMsg; char timestamp[LE_SMS_TIMESTAMP_MAX_LEN]; char tel[LE_MDMDEFS_PHONE_NUM_MAX_LEN]; uint8_t pdu[LE_SMS_PDU_MAX_LEN]; size_t uintval; uint32_t i; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); res=le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0])); LE_INFO("le_sms_SetPDU return %d",res); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_GetSenderTel(myMsg, tel, sizeof(tel)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); res=le_sms_GetTimeStamp(myMsg, timestamp, sizeof(timestamp)); CU_ASSERT_EQUAL(res, LE_NOT_PERMITTED); uintval=le_sms_GetPDULen(myMsg); CU_ASSERT_EQUAL(uintval, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0])); uintval=1; res=le_sms_GetPDU(myMsg, pdu, &uintval); CU_ASSERT_EQUAL(res, LE_OVERFLOW); uintval=sizeof(pdu); res=le_sms_GetPDU(myMsg, pdu, &uintval); CU_ASSERT_EQUAL(res, LE_OK); for(i=0; i<sizeof(PDU_TEST_PATTERN_7BITS) ; i++) { CU_ASSERT_EQUAL(pdu[i], PDU_TEST_PATTERN_7BITS[i]); } CU_ASSERT_EQUAL(uintval, sizeof(PDU_TEST_PATTERN_7BITS)/sizeof(PDU_TEST_PATTERN_7BITS[0])); res=le_sms_SetPDU(myMsg, PDU_TEST_PATTERN_7BITS, 0); CU_ASSERT_EQUAL(res, LE_BAD_PARAMETER); le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- le_result_t smsmo_SendMessage ( const char* destinationPtr, ///< [IN] The destination number. const char* textPtr ///< [IN] The SMS message text. ) { le_result_t res; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); if (!myMsg) { LE_ERROR("SMS message creation has failed!"); return LE_FAULT; } res = le_sms_SetDestination(myMsg, destinationPtr); if (res != LE_OK) { LE_ERROR("le_sms_SetDestination has failed (res.%d)!", res); return LE_FAULT; } res = le_sms_SetText(myMsg, textPtr); if (res != LE_OK) { LE_ERROR("le_sms_SetText has failed (res.%d)!", res); return LE_FAULT; } res = le_sms_Send(myMsg); if (res != LE_OK) { LE_ERROR("le_sms_Send has failed (res.%d)!", res); return LE_FAULT; } else { LE_INFO("\"%s\" has been successfully sent to %s.", textPtr, destinationPtr); } le_sms_Delete(myMsg); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void Testle_sms_SendBinary() { le_result_t res; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); LE_DEBUG("-TEST- Create Msg %p", myMsg); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetBinary(myMsg, BINARY_TEST_PATTERN, sizeof(BINARY_TEST_PATTERN)/sizeof(BINARY_TEST_PATTERN[0])); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_Send_Binary ( void ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg; myMsg = le_sms_Create(); if (myMsg) { LE_DEBUG("-TEST- Create Msg %p", myMsg); res = le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); if (res != LE_OK) { return LE_FAULT; } res = le_sms_SetBinary(myMsg, BINARY_TEST_PATTERN, sizeof(BINARY_TEST_PATTERN)/ sizeof(BINARY_TEST_PATTERN[0])); if (res != LE_OK) { return LE_FAULT; } res = le_sms_Send(myMsg); if ((res == LE_FAULT) || (res == LE_FORMAT_ERROR)) { return LE_FAULT; } le_sms_Delete(myMsg); res = LE_OK; } return res; }
//-------------------------------------------------------------------------------------------------- void Testle_sms_ReceivedList() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_MsgRef_t lMsg1, lMsg2; le_sms_MsgListRef_t receivedList; le_sms_Status_t mystatus; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetText(myMsg, TEXT_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); if (res == LE_OK) { uint32_t i=0; fprintf(stderr, "\nPlease ensure that the device has received at least 2 messages, then press enter\n"); while ( getchar() != '\n' ); if ((res == LE_OK) && (i<10)) { // List Received messages receivedList=le_sms_CreateRxMsgList(); CU_ASSERT_PTR_NOT_NULL(receivedList); lMsg1=le_sms_GetFirst(receivedList); CU_ASSERT_PTR_NOT_NULL(lMsg1); if (lMsg1 != NULL) { mystatus=le_sms_GetStatus(lMsg1); CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 1.%p", lMsg1); le_sms_Delete(lMsg1); } lMsg2=le_sms_GetNext(receivedList); CU_ASSERT_PTR_NOT_NULL(lMsg2); if (lMsg2 != NULL) { mystatus=le_sms_GetStatus(lMsg2); CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 2.%p", lMsg2); le_sms_Delete(lMsg2); } LE_INFO("-TEST- Delete the ReceivedList"); le_sms_DeleteList(receivedList); } else { LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test"); } } else { LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test"); } // Delete sent message le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_Send_UCS2 ( void ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg; NbSmsRx = 1; // Init the semaphore for synchronous API (hangup, answer) sem_init(&SmsRxSynchronization,0,0); RxThread = le_thread_Create("Rx SMS reception", MyRxThread, NULL); le_thread_Start(RxThread); // Wait for thread starting. sleep(2); // Check if Thread SMS RX handler has been started if (!RxHdlrRef) { LE_ERROR("Handler not ready !!"); return LE_FAULT; } myMsg = le_sms_Create(); if (myMsg) { LE_DEBUG("-TEST- Create Msg %p", myMsg); res = le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_SetUCS2(myMsg, UCS2_TEST_PATTERN, sizeof(UCS2_TEST_PATTERN) / 2); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_Send(myMsg); if ((res == LE_FAULT) || (res == LE_FORMAT_ERROR)) { le_sms_Delete(myMsg); return LE_FAULT; } res = WaitFunction(&SmsRxSynchronization, 120000); LE_ERROR_IF(res != LE_OK, "SYNC FAILED"); le_sms_Delete(myMsg); } le_sms_RemoveRxMessageHandler(RxHdlrRef); le_thread_Cancel(RxThread); return res; }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_ReceivedList() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_MsgRef_t lMsg1, lMsg2; le_sms_MsgListRef_t receivedList; le_sms_Status_t mystatus; myMsg = le_sms_Create(); LE_ASSERT(!myMsg); res = le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); LE_ASSERT(res != LE_OK); res = le_sms_SetText(myMsg, TEXT_TEST_PATTERN); LE_ASSERT(res != LE_OK); res = le_sms_Send(myMsg); LE_ASSERT((res == LE_FAULT) || (res == LE_FORMAT_ERROR)); res = le_sms_Send(myMsg); LE_ASSERT((res == LE_FAULT) || (res == LE_FORMAT_ERROR)); sleep(10); // List Received messages receivedList = le_sms_CreateRxMsgList(); LE_ASSERT(!receivedList); lMsg1 = le_sms_GetFirst(receivedList); if (lMsg1 != NULL) { mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT((mystatus != LE_SMS_RX_READ) && (mystatus != LE_SMS_RX_UNREAD)); // Verify Mark Read functions on Rx message list le_sms_MarkRead(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_READ); // Verify Mark Unread functions on Rx message list le_sms_MarkUnread(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_UNREAD); // Verify Mark Read functions on Rx message list le_sms_MarkRead(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_READ); LE_INFO("-TEST- Delete Rx message 1 from storage.%p", lMsg1); le_sms_DeleteFromStorage(lMsg1); } else { LE_ERROR("Test required at less 2 SMSs in the storage"); return LE_FAULT; } lMsg2 = le_sms_GetNext(receivedList); if (lMsg2 != NULL) { mystatus = le_sms_GetStatus(lMsg2); LE_ASSERT((mystatus != LE_SMS_RX_READ) && (mystatus != LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 2 from storage.%p", lMsg2); le_sms_DeleteFromStorage(lMsg2); } else { LE_ERROR("Test requiered at less 2 SMSs in the storage"); le_sms_Delete(myMsg); return LE_FAULT; } LE_INFO("-TEST- Delete the ReceivedList"); le_sms_DeleteList(receivedList); // Delete sent message le_sms_Delete(myMsg); return LE_OK; }
// ------------------------------------------------------------------------------------------------- static le_result_t SendMessage ( const char* number, ///< [IN] The destination phone number of this message. const char* message ///< [IN] The message to be sent to the destination phone. ) { le_sms_MsgRef_t messageRef = NULL; le_result_t result; uint32_t messageSize = strlen(message); uint32_t messagePart; uint32_t i; if (messageSize % LE_SMS_TEXT_MAX_LEN) { messagePart = (messageSize/LE_SMS_TEXT_MAX_LEN)+1; } else { messagePart = messageSize/LE_SMS_TEXT_MAX_LEN; } for (i=0; i < messagePart; i++) { uint32_t messageCopySize; char messageToSend[LE_SMS_TEXT_MAX_BYTES] = {0}; if (i == (messagePart-1) ) { messageCopySize = messageSize % LE_SMS_TEXT_MAX_LEN; } else { messageCopySize = LE_SMS_TEXT_MAX_LEN; } memcpy(messageToSend, &message[i*LE_SMS_TEXT_MAX_LEN], messageCopySize); messageToSend[messageCopySize] = '\0'; // Allocate a message object from the SMS pool. If this fails, the application will halt, so // there's no point in checking for a valid object. messageRef = le_sms_Create(); // Populate the message parameters, and let the underlying API validate them. if ((result = le_sms_SetDestination(messageRef, number)) != LE_OK) { LE_ERROR("Failed to set message destination number. Result: %d", result); goto done; } if ((result = le_sms_SetText(messageRef, messageToSend)) != LE_OK) { LE_ERROR("Failed to set the message text. Result: %d", result); goto done; } // Now, attempt to send the message. if ((result = le_sms_Send(messageRef)) != LE_OK) { LE_ERROR("Message transmission failed. Result: %d", result); goto done; } // If we got here, then the send was successful. Record the message in the log. if (OutputFilePtr) { fprintf(OutputFilePtr, "send (%s): %s\n", number, messageToSend); fflush(OutputFilePtr); } le_sms_Delete(messageRef); messageRef = NULL; } // Finally, clean up our memory and let the caller know what happened. done: if (messageRef) { le_sms_Delete(messageRef); } return result; }