static void SmsRxHandler ( le_sms_MsgRef_t msg, void* contextPtr // not used ) { char textBuffer[1024]; le_sms_GetSenderTel(msg, textBuffer, sizeof(textBuffer)); switch (le_sms_GetFormat(msg)) { case LE_SMS_FORMAT_PDU: printf("Received SMS in PDU format from %s.\n", textBuffer); break; case LE_SMS_FORMAT_TEXT: printf("Received text SMS from %s: ", textBuffer); le_sms_GetText(msg, textBuffer, sizeof(textBuffer)); printf("%s\n", textBuffer); break; case LE_SMS_FORMAT_BINARY: printf("Received SMS in binary format from %s.\n", textBuffer); break; case LE_SMS_FORMAT_UNKNOWN: printf("Received SMS in unknown format from %s.\n", textBuffer); break; } le_sms_Delete(msg); }
//-------------------------------------------------------------------------------------------------- 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); }
// ------------------------------------------------------------------------------------------------- static void SmsReceivedHandler ( le_sms_MsgRef_t messagePtr, ///< [IN] Message object received from the modem. void* contextPtr ///< [IN] The handler's context. ) { // First off, make sure this is a message that we can handle. LE_DEBUG("smsReceivedHandler called."); if (le_sms_GetFormat(messagePtr) != LE_SMS_FORMAT_TEXT) { LE_INFO("Non-text message received!"); return; } // Now, extract the relavant information and record the message in the appropriate places. char tel[LE_MDMDEFS_PHONE_NUM_MAX_BYTES] = { 0 }; char text[LE_SMS_TEXT_MAX_BYTES] = { 0 }; le_sms_GetSenderTel(messagePtr, tel, LE_MDMDEFS_PHONE_NUM_MAX_BYTES); le_sms_GetText(messagePtr, text, LE_SMS_TEXT_MAX_BYTES); // We are now reporting to this person DestNumValid = true; strncpy(DestNum, tel, LE_MDMDEFS_PHONE_NUM_MAX_LEN); DestNum[LE_MDMDEFS_PHONE_NUM_MAX_LEN] = '\0'; LE_INFO("Message: %s: %s", tel, text); le_sms_DeleteFromStorage(messagePtr); if (OutputFilePtr) { fprintf(OutputFilePtr, "recv (%s): %s\n", tel, text); fflush(OutputFilePtr); } // If this message was in fact a command, handle it now. ProcessCommand(text, tel); }
//-------------------------------------------------------------------------------------------------- static void TestRxHandler ( le_sms_MsgRef_t msg, void* contextPtr ) { le_sms_Format_t myformat; le_sms_Type_t myType; uint16_t myMessageId = 0; uint16_t myMessageSerialNumber = 0; le_result_t res; size_t pduLen; char timestamp[LE_SMS_TIMESTAMP_MAX_BYTES]; char text[LE_SMS_TEXT_MAX_BYTES] = {0}; uint8_t pdu[LE_SMS_PDU_MAX_BYTES] = {0}; uint8_t bin[50] = {0}; LE_INFO("-TEST- New SMS message received ! msg.%p", msg); myformat = le_sms_GetFormat(msg); myType = le_sms_GetType(msg); LE_INFO("-TEST- New SMS message format %d, Type %d", myformat, myType); if (myType != LE_SMS_TYPE_BROADCAST_RX) { LE_ERROR("-TEST 1- Check le_sms_GetType failure! %d", myType); return; } else { LE_INFO("-TEST 1- Check le_sms_GetType LE_SMS_TYPE_CB"); } res = le_sms_GetCellBroadcastId(msg, &myMessageId); if (res != LE_OK) { LE_ERROR("-TEST 2- Check le_sms_GetMessageIdCellBroadcast failure! %d", res); return; } else { LE_INFO("-TEST 2- Check le_sms_GetMessageIdCellBroadcast OK Message Id 0x%04X (%d)", myMessageId, myMessageId); } res = le_sms_GetCellBroadcastSerialNumber(msg, &myMessageSerialNumber); if (res != LE_OK) { LE_ERROR("-TEST 3- Check le_sms_GetCellBroadcastSerialNumber failure! %d", res); return; } else { LE_INFO("-TEST 3- Check le_sms_GetCellBroadcastSerialNumber OK Message Id 0x%04X (%d)", myMessageSerialNumber, myMessageSerialNumber); } if (myformat == LE_SMS_FORMAT_TEXT) { res = le_sms_GetTimeStamp(msg, timestamp, sizeof(timestamp)); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 4- Check le_sms_GetTimeStamp failure! %d", res); return; } else { LE_INFO("-TEST 4- Check le_sms_GetTimeStamp LE_NOT_PERMITTED"); } res = le_sms_GetText(msg, text, sizeof(text)); if(res != LE_OK) { LE_ERROR("-TEST 5- Check le_sms_GetText failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("SMS CB text=> '%s'",text); LE_INFO("-TEST 5- Check le_sms_GetText OK."); } pduLen = le_sms_GetPDULen(msg); if( (pduLen <= 0) || (pduLen > LE_SMS_PDU_MAX_BYTES)) { LE_ERROR("-TEST 6 Check le_sms_GetPDULen failure!"); LE_ERROR("FAILED !!"); return; } else { LE_INFO("SMS CB Pdu len %d", (int) pduLen); LE_INFO("-TEST 6- Check le_sms_GetPDULen OK."); } res = le_sms_GetPDU(msg, pdu, &pduLen); if(res != LE_OK) { LE_ERROR("-TEST 7 Check le_sms_GetPDU failure! %d", res); LE_ERROR("FAILED !!"); return; } else { Dump("SMS CB PDU", pdu, pduLen); LE_INFO("-TEST 7 Check le_sms_GetPDU OK."); } res = le_sms_DeleteFromStorage(msg); if(res != LE_NO_MEMORY) { LE_ERROR("-TEST 8 Check le_sms_DeleteFromStorage failure! %d", res); LE_ERROR("FAILED !!"); return; } else { Dump("SMS CB PDU", pdu, pduLen); LE_INFO("-TEST 8 Check le_sms_DeleteFromStorage LE_NO_MEMORY."); } res = le_sms_SetText(msg, "TOTO"); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 9 Check le_sms_SetText failure !%d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 9 Check le_sms_SetText OK."); } res = le_sms_SetDestination(msg, "0123456789"); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 10 Check le_sms_SetDestination failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 10 Check le_sms_SetDestination LE_NOT_PERMITTED."); } res = le_sms_SetBinary(msg, bin, sizeof(bin)); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 11 Check le_sms_SetBinary failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 11 Check le_sms_SetBinary LE_NOT_PERMITTED."); } size_t binLen = sizeof(bin); res = le_sms_GetBinary(msg, bin, &binLen); if(res != LE_FORMAT_ERROR) { LE_ERROR("-TEST 12 Check le_sms_GetBinary failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 12 Check le_sms_GetBinary LE_FORMAT_ERROR."); } } else if (myformat == LE_SMS_FORMAT_BINARY) { LE_INFO("SMS Cell Broadcast in binary format"); res = le_sms_GetTimeStamp(msg, timestamp, sizeof(timestamp)); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 4- Check le_sms_GetTimeStamp failure! %d", res); return; } else { LE_INFO("-TEST 4- Check le_sms_GetTimeStamp LE_NOT_PERMITTED"); } res = le_sms_GetText(msg, text, sizeof(text)); if(res != LE_FORMAT_ERROR) { LE_ERROR("-TEST 5- Check le_sms_GetText failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("SMS CB text=> '%s'",text); LE_INFO("-TEST 5- Check le_sms_GetText LE_FORMAT_ERROR."); } pduLen = le_sms_GetPDULen(msg); if( (pduLen <= 0) || (pduLen > LE_SMS_PDU_MAX_BYTES)) { LE_ERROR("-TEST 6 Check le_sms_GetPDULen failure!"); LE_ERROR("FAILED !!"); return; } else { LE_INFO("SMS CB Pdu len %d", (int) pduLen); LE_INFO("-TEST 6- Check le_sms_GetPDULen OK."); } res = le_sms_GetPDU(msg, pdu, &pduLen); if(res != LE_OK) { LE_ERROR("-TEST 7 Check le_sms_GetPDU failure! %d", res); LE_ERROR("FAILED !!"); return; } else { Dump("SMS CB PDU", pdu, pduLen); LE_INFO("-TEST 7 Check le_sms_GetPDU OK."); } res = le_sms_DeleteFromStorage(msg); if(res != LE_NO_MEMORY) { LE_ERROR("-TEST 8 Check le_sms_DeleteFromStorage failure! %d", res); LE_ERROR("FAILED !!"); return; } else { Dump("SMS CB PDU", pdu, pduLen); LE_INFO("-TEST 8 Check le_sms_DeleteFromStorage LE_NO_MEMORY."); } res = le_sms_SetText(msg, "TOTO"); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 9 Check le_sms_SetText failure !%d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 9 Check le_sms_SetText LE_NOT_PERMITTED."); } res = le_sms_SetDestination(msg, "0123456789"); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 10 Check le_sms_SetDestination failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 10 Check le_sms_SetDestination LE_NOT_PERMITTED."); } res = le_sms_SetBinary(msg, bin, sizeof(bin)); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 11 Check le_sms_SetBinary failure! %d", res); LE_ERROR("FAILED !!"); return; } else { LE_INFO("-TEST 11 Check le_sms_SetBinary LE_NOT_PERMITTED."); } size_t binLen = sizeof(bin); res = le_sms_GetBinary(msg, bin, &binLen); if(res != LE_OK) { LE_ERROR("-TEST 12 Check le_sms_GetBinary failure! %d", res); LE_ERROR("FAILED !!"); return; } else { bin[binLen] = 0; LE_INFO("SMS CB binary (%d)=> '%s'",(int) binLen, bin); LE_INFO("-TEST 12 Check le_sms_GetBinary OK."); } } else { LE_INFO("SMS Cell Broadcast not in test format"); } le_sms_Delete(msg); LE_INFO("smsCBTest sequence PASSED"); }
//--------------------- ----------------------------------------------------------------------------- static void RxMessageHandler ( le_sms_MsgRef_t msgRef, void* contextPtr ) { le_result_t res; char tel[LE_MDMDEFS_PHONE_NUM_MAX_LEN]; char timestamp[LE_SMS_TIMESTAMP_MAX_LEN]; char text[LE_SMS_TEXT_MAX_LEN]; char text_return[LE_SMS_TEXT_MAX_LEN]; LE_INFO("A New SMS message is received with ref.%p", msgRef); if (le_sms_GetFormat(msgRef) == LE_SMS_FORMAT_TEXT) { res = le_sms_GetSenderTel(msgRef, tel, sizeof(tel)); if(res != LE_OK) { LE_ERROR("le_sms_GetSenderTel has failed (res.%d)!", res); } else { LE_INFO("Message is received from %s.", tel); } res = le_sms_GetTimeStamp(msgRef, timestamp, sizeof(timestamp)); if(res != LE_OK) { LE_ERROR("le_sms_GetTimeStamp has failed (res.%d)!", res); } else { LE_INFO("Message timestamp is %s.", timestamp); } res = le_sms_GetText(msgRef, text, sizeof(text)); if(res != LE_OK) { LE_ERROR("le_sms_GetText has failed (res.%d)!", res); } else { LE_INFO("Message content: \"%s\"", text); } snprintf(text_return, LE_SMS_TEXT_MAX_LEN, MESSAGE_FEEDBACK, tel); // Return a message to sender with phone number include (see smsMO.c file) res = smsmo_SendMessage(tel, text_return); if (res != LE_OK) { LE_ERROR("SmsMoMessage has failed (res.%d)!", res); } else { LE_INFO("the message has been successfully sent."); } res = le_sms_DeleteFromStorage(msgRef); if(res != LE_OK) { LE_ERROR("le_sms_DeleteFromStorage has failed (res.%d)!", res); } else { LE_INFO("the message has been successfully deleted from storage."); } } else { LE_WARN("Warning! I read only Text messages!"); } le_sms_Delete(msgRef); }
//-------------------------------------------------------------------------------------------------- static void TestRxHandler(le_sms_MsgRef_t msg, void* contextPtr) { le_sms_Format_t myformat; le_sms_Status_t mystatus; le_result_t res; char tel[LE_MDMDEFS_PHONE_NUM_MAX_LEN]; char timestamp[LE_SMS_TIMESTAMP_MAX_LEN]; char text[LE_SMS_TEXT_MAX_LEN]; size_t uintval; LE_INFO("-TEST- New SMS message received ! msg.%p", msg); myformat=le_sms_GetFormat(msg); if (myformat == LE_SMS_FORMAT_TEXT) { receivedTextMsg=msg; res=le_sms_GetSenderTel(msg, tel, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 1/13- Check le_sms_GetSenderTel failure (LE_OVERFLOW expected) !"); } else { LE_INFO("-TEST 1/13- Check le_sms_GetSenderTel passed (LE_OVERFLOW expected)."); } res=le_sms_GetSenderTel(msg, tel, sizeof(tel)); if(res != LE_OK) { LE_ERROR("-TEST 2/13- Check le_sms_GetSenderTel failure (LE_OK expected) !"); } else { LE_INFO("-TEST 2/13- Check le_sms_GetSenderTel passed (%s) (LE_OK expected).", tel); } if(strncmp(&tel[strlen(tel)-4], &DEST_TEST_PATTERN[strlen(DEST_TEST_PATTERN)-4], 4)) { LE_ERROR("-TEST 3/13- Check le_sms_GetSenderTel, bad Sender Telephone number! (%s)", tel); } else { LE_INFO("-TEST 3/13- Check le_sms_GetSenderTel, Sender Telephone number OK."); } uintval=le_sms_GetUserdataLen(msg); if((uintval != strlen(TEXT_TEST_PATTERN)) && (uintval != strlen(SHORT_TEXT_TEST_PATTERN)) && (uintval != strlen(LARGE_TEXT_TEST_PATTERN))) { LE_ERROR("-TEST 4/13- Check le_sms_GetLen, bad expected text length! (%zd)", uintval); } else { LE_INFO("-TEST 4/13- Check le_sms_GetLen OK."); } res=le_sms_GetTimeStamp(msg, timestamp, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 5/13- Check le_sms_GetTimeStamp -LE_OVERFLOW error- failure!"); } else { LE_INFO("-TEST 5/13- Check le_sms_GetTimeStamp -LE_OVERFLOW error- OK."); } res=le_sms_GetTimeStamp(msg, timestamp, sizeof(timestamp)); if(res != LE_OK) { LE_ERROR("-TEST 6/13- Check le_sms_GetTimeStamp failure!"); } else { LE_INFO("-TEST 6/13- Check le_sms_GetTimeStamp OK (%s).", timestamp); } res=le_sms_GetText(msg, text, sizeof(text)); if(res != LE_OK) { LE_ERROR("-TEST 7/13- Check le_sms_GetText failure!"); } else { LE_INFO("-TEST 7/13- Check le_sms_GetText OK."); } if((strncmp(text, TEXT_TEST_PATTERN, strlen(TEXT_TEST_PATTERN)) != 0) && (strncmp(text, SHORT_TEXT_TEST_PATTERN, strlen(SHORT_TEXT_TEST_PATTERN)) != 0) && (strncmp(text, LARGE_TEXT_TEST_PATTERN, strlen(LARGE_TEXT_TEST_PATTERN)) != 0) ) { LE_ERROR("-TEST 8/13- Check le_sms_GetText, bad expected received text! (%s)", text); } else { LE_INFO("-TEST 8/13- Check le_sms_GetText, received text OK."); } // Verify that the message is read-only res=le_sms_SetDestination(msg, DEST_TEST_PATTERN); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 9/13- Check le_sms_SetDestination, parameter check failure!"); } else { LE_INFO("-TEST 9/13- Check le_sms_SetDestination OK."); } res=le_sms_SetText(msg, TEXT_TEST_PATTERN); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 10/13- Check le_sms_SetText, parameter check failure!"); } else { LE_INFO("-TEST 10/13- Check le_sms_SetText OK."); } // Verify Mark Read/Unread functions le_sms_MarkRead(msg); mystatus=le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_READ) { LE_ERROR("-TEST 11/13- Check le_sms_GetStatus, bad status (%d)!", mystatus); } else { LE_INFO("-TEST 11/13- Check le_sms_GetStatus, status OK."); } le_sms_MarkUnread(msg); mystatus=le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_UNREAD) { LE_ERROR("-TEST 12/13- Check le_sms_GetStatus, bad status (%d)!", mystatus); } else { LE_INFO("-TEST 12/13- Check le_sms_GetStatus, status OK."); } res=le_sms_DeleteFromStorage(msg); if(res != LE_OK) { LE_ERROR("-TEST 13/13- Check le_sms_DeleteFromStorage failure!"); } else { LE_INFO("-TEST 13/13- Check le_sms_DeleteFromStorage OK."); } } else { LE_WARN("-TEST- I check only Text message!"); } le_sms_Delete(msg); }
//-------------------------------------------------------------------------------------------------- static void TestRxHandler(le_sms_MsgRef_t msg, void* contextPtr) { le_sms_Format_t myformat; le_sms_Status_t mystatus; le_result_t res; char tel[LE_MDMDEFS_PHONE_NUM_MAX_BYTES]; char timestamp[LE_SMS_TIMESTAMP_MAX_BYTES]; char text[LE_SMS_TEXT_MAX_BYTES] = {0}; uint8_t smsPduDataPtr[LE_SMS_PDU_MAX_BYTES] = {0}; uint16_t smsUcs2Ptr[LE_SMS_UCS2_MAX_CHARS] = {0}; size_t smsUcs2Len; char smsPduDataHexString[(LE_SMS_PDU_MAX_BYTES * 2) + 1] = {0}; size_t uintval; size_t smsPduLen1, smsPduLen2; LE_INFO("-TEST- New SMS message received ! msg.%p", msg); myformat = le_sms_GetFormat(msg); // Define the smsPduDataPtr buffer size smsPduLen1 = LE_SMS_PDU_MAX_BYTES; res = le_sms_GetPDU(msg, smsPduDataPtr, &smsPduLen1); if (res != LE_OK) { LE_ERROR("step FAILED !!"); return; } smsPduLen2 = le_sms_GetPDULen(msg); // Check consistent between both APIs. LE_ASSERT(smsPduLen1 == smsPduLen2); if ( le_hex_BinaryToString(smsPduDataPtr, smsPduLen2, smsPduDataHexString, sizeof(smsPduDataHexString)) < 1 ) { LE_ERROR("Failed to convert in hex string format!"); } else { LE_INFO("Dump of PDU message (%d bytes): \"%s\"", (int) smsPduLen2, smsPduDataHexString); } if (myformat == LE_SMS_FORMAT_TEXT) { LE_INFO("SMS TEXT received"); res = le_sms_GetSenderTel(msg, tel, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 1- Check le_sms_GetSenderTel failure (LE_OVERFLOW expected) !"); LE_ASSERT(res != LE_OVERFLOW); } else { LE_INFO("-TEST 1- Check le_sms_GetSenderTel passed (LE_OVERFLOW expected)."); } res = le_sms_GetSenderTel(msg, tel, sizeof(tel)); if(res != LE_OK) { LE_ERROR("-TEST 2- Check le_sms_GetSenderTel failure (LE_OK expected) !"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 2- Check le_sms_GetSenderTel passed (%s) (LE_OK expected).", tel); } if(strncmp(&tel[strlen(tel)-4], &DEST_TEST_PATTERN[strlen(DEST_TEST_PATTERN)-4], 4)) { LE_ERROR("-TEST 3- Check le_sms_GetSenderTel, bad Sender Telephone number! (%s)", tel); LE_ASSERT(true); } else { LE_INFO("-TEST 3- Check le_sms_GetSenderTel, Sender Telephone number OK."); } uintval = le_sms_GetUserdataLen(msg); if((uintval != strlen(TEXT_TEST_PATTERN)) && (uintval != strlen(SHORT_TEXT_TEST_PATTERN)) && (uintval != strlen(LARGE_TEXT_TEST_PATTERN))) { LE_ERROR("-TEST 4- Check le_sms_GetLen, bad expected text length! (%zd)", uintval); LE_ASSERT(true); } else { LE_INFO("-TEST 4- Check le_sms_GetLen OK."); } res = le_sms_GetTimeStamp(msg, timestamp, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 5- Check le_sms_GetTimeStamp -LE_OVERFLOW error- failure!"); LE_ASSERT(res != LE_OVERFLOW); } else { LE_INFO("-TEST 5- Check le_sms_GetTimeStamp -LE_OVERFLOW error- OK."); } res = le_sms_GetTimeStamp(msg, timestamp, sizeof(timestamp)); if(res != LE_OK) { LE_ERROR("-TEST 6- Check le_sms_GetTimeStamp failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 6- Check le_sms_GetTimeStamp OK (%s).", timestamp); } res = le_sms_GetText(msg, text, sizeof(text)); if(res != LE_OK) { LE_ERROR("-TEST 7- Check le_sms_GetText failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 7- Check le_sms_GetText OK."); } if((strncmp(text, TEXT_TEST_PATTERN, strlen(TEXT_TEST_PATTERN)) != 0) && (strncmp(text, SHORT_TEXT_TEST_PATTERN, strlen(SHORT_TEXT_TEST_PATTERN)) != 0) && (strncmp(text, LARGE_TEXT_TEST_PATTERN, strlen(LARGE_TEXT_TEST_PATTERN)) != 0) ) { LE_ERROR("-TEST 8- Check le_sms_GetText, bad expected received text! (%s)", text); LE_ASSERT(true); } else { LE_INFO("-TEST 8- Check le_sms_GetText, received text OK."); } // Verify that the message is read-only res = le_sms_SetDestination(msg, DEST_TEST_PATTERN); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 9- Check le_sms_SetDestination, parameter check failure!"); LE_ASSERT(res != LE_NOT_PERMITTED); } else { LE_INFO("-TEST 9- Check le_sms_SetDestination OK."); } res = le_sms_SetText(msg, TEXT_TEST_PATTERN); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 10- Check le_sms_SetText, parameter check failure!"); LE_ASSERT(res != LE_NOT_PERMITTED); } else { LE_INFO("-TEST 10- Check le_sms_SetText OK."); } // Verify Mark Read/Unread functions le_sms_MarkRead(msg); mystatus = le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_READ) { LE_ERROR("-TEST 11- Check le_sms_GetStatus, bad status (%d)!", mystatus); LE_ASSERT(mystatus != LE_SMS_RX_READ); } else { LE_INFO("-TEST 11- Check le_sms_GetStatus, status OK."); } le_sms_MarkUnread(msg); mystatus = le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_UNREAD) { LE_ERROR("-TEST 12- Check le_sms_GetStatus, bad status (%d)!", mystatus); LE_ASSERT(mystatus != LE_SMS_RX_UNREAD); } else { LE_INFO("-TEST 12- Check le_sms_GetStatus, status OK."); } res = le_sms_DeleteFromStorage(msg); if(res != LE_OK) { LE_ERROR("-TEST 13- Check le_sms_DeleteFromStorage failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 13- Check le_sms_DeleteFromStorage OK."); } NbSmsRx --; } if (myformat == LE_SMS_FORMAT_UCS2) { LE_INFO("SMS UCS2 received"); res = le_sms_GetSenderTel(msg, tel, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 1- Check le_sms_GetSenderTel failure (LE_OVERFLOW expected) !"); LE_ASSERT(res != LE_OVERFLOW); } else { LE_INFO("-TEST 1- Check le_sms_GetSenderTel passed (LE_OVERFLOW expected)."); } res = le_sms_GetSenderTel(msg, tel, sizeof(tel)); if(res != LE_OK) { LE_ERROR("-TEST 2- Check le_sms_GetSenderTel failure (LE_OK expected) !"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 2- Check le_sms_GetSenderTel passed (%s) (LE_OK expected).", tel); } if(strncmp(&tel[strlen(tel)-4], &DEST_TEST_PATTERN[strlen(DEST_TEST_PATTERN)-4], 4)) { LE_ERROR("-TEST 3- Check le_sms_GetSenderTel, bad Sender Telephone number! (%s)", tel); LE_ASSERT(true); } else { LE_INFO("-TEST 3- Check le_sms_GetSenderTel, Sender Telephone number OK."); } uintval = le_sms_GetUserdataLen(msg); if(uintval != (sizeof(UCS2_TEST_PATTERN) /2)) { LE_ERROR("-TEST 4- Check le_sms_GetLen, bad expected text length! (%zd)", uintval); LE_ASSERT(uintval != (sizeof(UCS2_TEST_PATTERN) /2)); } else { LE_INFO("-TEST 4- Check le_sms_GetLen OK."); } res = le_sms_GetTimeStamp(msg, timestamp, 1); if(res != LE_OVERFLOW) { LE_ERROR("-TEST 5- Check le_sms_GetTimeStamp -LE_OVERFLOW error- failure!"); LE_ASSERT(res != LE_OVERFLOW); } else { LE_INFO("-TEST 5- Check le_sms_GetTimeStamp -LE_OVERFLOW error- OK."); } res = le_sms_GetTimeStamp(msg, timestamp, sizeof(timestamp)); if(res != LE_OK) { LE_ERROR("-TEST 6- Check le_sms_GetTimeStamp failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 6- Check le_sms_GetTimeStamp OK (%s).", timestamp); } smsUcs2Len = sizeof(smsUcs2Ptr) / 2; res = le_sms_GetUCS2(msg, smsUcs2Ptr, &smsUcs2Len); if(res != LE_OK) { LE_ERROR("-TEST 7- Check le_sms_GetUcs2 failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 7- Check le_sms_GetUcs2 OK."); } if(memcmp(smsUcs2Ptr, UCS2_TEST_PATTERN, sizeof(UCS2_TEST_PATTERN)) != 0) { LE_ERROR("-TEST 8- Check le_sms_GetUcs2, bad expected received UCS2!"); LE_ASSERT(true); } else { LE_INFO("-TEST 8- Check le_sms_GetUcs2, received text OK."); } // Verify that the message is read-only res = le_sms_SetDestination(msg, DEST_TEST_PATTERN); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 9- Check le_sms_SetDestination, parameter check failure!"); LE_ASSERT(res != LE_NOT_PERMITTED); } else { LE_INFO("-TEST 9- Check le_sms_SetDestination OK."); } res = le_sms_SetUCS2(msg, UCS2_TEST_PATTERN, sizeof(UCS2_TEST_PATTERN) / 2); if(res != LE_NOT_PERMITTED) { LE_ERROR("-TEST 10- Check le_sms_SetUCS2, parameter check failure!"); LE_ASSERT(res != LE_NOT_PERMITTED); } else { LE_INFO("-TEST 10- Check UCS2_TEST_PATTERN OK."); } // Verify Mark Read/Unread functions le_sms_MarkRead(msg); mystatus = le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_READ) { LE_ERROR("-TEST 11- Check le_sms_GetStatus, bad status (%d)!", mystatus); LE_ASSERT(mystatus != LE_SMS_RX_READ); } else { LE_INFO("-TEST 11- Check le_sms_GetStatus, status OK."); } le_sms_MarkUnread(msg); mystatus = le_sms_GetStatus(msg); if(mystatus != LE_SMS_RX_UNREAD) { LE_ERROR("-TEST 12- Check le_sms_GetStatus, bad status (%d)!", mystatus); LE_ASSERT(mystatus != LE_SMS_RX_UNREAD); } else { LE_INFO("-TEST 12- Check le_sms_GetStatus, status OK."); } res = le_sms_DeleteFromStorage(msg); if(res != LE_OK) { LE_ERROR("-TEST 13- Check le_sms_DeleteFromStorage failure!"); LE_ASSERT(res != LE_OK); } else { LE_INFO("-TEST 13- Check le_sms_DeleteFromStorage OK."); } NbSmsRx --; } else { LE_WARN("-TEST- I check only Text message!"); } le_sms_Delete(msg); LE_INFO("Number of SMS remaining %d", NbSmsRx); if (NbSmsRx == 0) { sem_post(&SmsRxSynchronization); } }