# WP7702 sms receive is unstable

**URL:** <https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274>\
**Category:** mangOH Red\
**Created:** [June 2, 2021, 5:29am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274 "2021-06-02T05:29:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 5:29am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/1 "2021-06-02T05:29:19Z")

</div>

I have a Legato app running on WP7702 which can receive sms from cell phones, but it doesn’t work consistently. I had it working this afternoon, but now it stops decode incoming sms, the log displays the following:

> Jun 1 22:23:08 swi-mdm9x28-wp user.info Legato: INFO | modemDaemon[1199]/modemDaemon T=main | smsPdu.c DecodeUserDataField() 1071 | messageLen 24, pos 29, size 24  
> Jun 1 22:23:08 swi-mdm9x28-wp user.info Legato: INFO | avcDaemon[1149]/avcDaemon T=main | avcServer.c ProcessWakeupSms() 4359 | SMS is too short or doesn’t start with prefix ‘LWM2M’, ignoring

Can anyone help?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 2, 2021, 5:35am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/2 "2021-06-02T05:35:33Z")

</div>

suggest you stopping your application and try CM tool first to monitor incoming SMS:

cm sms monitor &

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 5:51am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/3 "2021-06-02T05:51:57Z")

</div>

I suspect it might because the sim on WP7702 is a French number(I locate in Canada though). Despite it had no problem to receive in the past, there is a terrible delay on SMS transmission…  
Is it possible I insert a local sim card on WP7702?

* * *

I might be wrong, I tried with cm sms monitor, it received instantly, but the app didn’t get it… because it didn’t print on the log

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 2, 2021, 6:15am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/4 "2021-06-02T06:15:51Z")

</div>

Then seems your app has problem

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 6:19am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/5 "2021-06-02T06:19:01Z")

</div>

Where can I find the sample code to receive sms?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 2, 2021, 6:20am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/6 "2021-06-02T06:20:22Z")

</div>

> <https://github.com/legatoproject/legato-af/blob/master/apps/tools/cm/cm_sms.c>

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 7:34am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/7 "2021-06-02T07:34:34Z")

</div>

Thank you!!  
However, what is the difference if I wrote it in this way:

> static void RxMessageHandler
> 
> (
> 
> ```
> le_sms_MsgRef_t msgRef,
> 
> void* contextPtr
> 
> ```
> 
> )
> 
> {
> 
> ```
> le_result_t res;
> 
> char text[LE_SMS_TEXT_MAX_BYTES] = {0};
> 
> if(!textReceived) {
> 
> textReceived = true;
> 
> LE_INFO("A New SMS message is received with ref.%p", msgRef);
> 
> if (le_sms_GetFormat(msgRef) == LE_SMS_FORMAT_TEXT)
> 
> {
> 
> //get sender number
> 
> 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);
> 
> }
> 
> //get text content
> 
> res = le_sms_GetText(msgRef, text, sizeof(text));
> 
> if(res != LE_OK)
> 
> {
> 
> LE_ERROR("le_sms_GetText has failed (res.%d)!", res);
> 
> }
> 
> else
> 
> {
> 
> 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.");
> 
> }
> 
> le_sms_Delete(msgRef);
> 
> LE_INFO("message object deleted from memory.");
> 
> LE_INFO("Message content: \"%s\"", text);
> }
> }
> 
> ```
> 
> }
> 
> le\_result\_t sms\_Receiver
> 
> (
> 
> ```
> void
> 
> ```
> 
> )
> 
> {
> 
> ```
> RxHdlrRef = le_sms_AddRxMessageHandler(RxMessageHandler, NULL);
> 
> if (!RxHdlrRef)
> 
> {
> 
> LE_ERROR("le_sms_AddRxMessageHandler has failed!");
> 
> return LE_FAULT;
> 
> }
> 
> else
> 
> {
> 
> return LE_OK;
> 
> }
> 
> ```
> 
> }

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 2, 2021, 7:36am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/8 "2021-06-02T07:36:14Z")

</div>

does it work if you use the code in CM tool?

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 10:23pm UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/9 "2021-06-02T22:23:35Z")

</div>

It works, but not constantly stable. I pointed out in the previous reply, an incoming sms can be detected by `cm sms monitor`, but not always by the code

---

<div class="post-metadata">

**Author:** ![jeremyzhang](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jeremyzhang](https://mangoh.discourse.group/u/jeremyzhang)\
**Post date:** [June 2, 2021, 10:25pm UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/10 "2021-06-02T22:25:56Z")

</div>

I looked at the sample code you posted, I’m wondering how can I reset `smsType` and `format` on WP7702, I think by default they are `LE_SMS_TYPE_RX` and `LE_SMS_FORMAT_TEXT`

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 3, 2021, 12:02am UTC](https://mangoh.discourse.group/t/wp7702-sms-receive-is-unstable/9274/11 "2021-06-03T00:02:42Z")

</div>

do you mean you have ported the CM sample code to your application already, but it is not always working, and “cm sms monitor” is always working fine?
