Esempio n. 1
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
//--------------------------------------------------------------------------------------------------
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;
}
Esempio n. 7
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 8
0
//--------------------------------------------------------------------------------------------------
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;
}
Esempio n. 9
0
//--------------------------------------------------------------------------------------------------
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");
}
Esempio n. 10
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 11
0
//--------------------------------------------------------------------------------------------------
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);
}
Esempio n. 12
0
//--------------------------------------------------------------------------------------------------
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;
}
Esempio n. 13
0
//--------------------------------------------------------------------------------------------------
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);
    }
}
Esempio n. 14
0
//--------------------------------------------------------------------------------------------------
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;
}
Esempio n. 15
0
// -------------------------------------------------------------------------------------------------
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;
}