Summary:ASTERISK-15169: [patch] Incoming multiline SMS causes chan_mobile to stop working
Reporter:Artem Makhutov (artem)Labels:
Date Opened:2009-11-18 17:04:30.000-0600Date Closed:2009-12-02 15:44:55.000-0600
Versions:Frequency of
Environment:Attachments:( 0) multiline-sms-fix1.diff
( 1) multiline-sms-fix2.diff

multiline SMS messages makes the channel driver get "out of sync" with the mobile phone.

Here is an example of an incoming SMS:

+CMGR: \"REC UNREAD\",\"+49xxxxxxxx\",,\"09/11/15,22:35:56+04\"\r\n
0xxxxxxx hat  versucht Sie anzurufen (15.11. um 22:35 Uhr)\r\n
* Diese SMS ist fuer Sie kostenlos\r\n

The only part of the SMS that chan_mobile reads is the line "Anruf-Info:\r\n".
Then it expects the OK response and other (further) commands.

Each command it expects should have this format:

But after receiving this sms the OK message of will look like this for the channel driver:

\r\n   <-- next AT command could start, but chan_mobile thinks, that this is the rest of the OK command)
RING\r\n <-- chan_mobile will start to read in the next command just here

(1st Command would be: OK\r\n\r\n   and the 2nd comand would be RING\r\n ....)

So new incoming commands/responses will not be read in anymore in the correct format. It will not possible to receive or place new calls and so on.

I am not sure how to fix this problem. I am thinking about getting the rest of the message directly in hfp_parse_cmgr by reading from the rfcomm until we get a \r\nOK\r\n.

What do you think?
Comments:By: Matthew Nicholson (mnicholson) 2009-11-24 15:09:24.000-0600

I plan to fix this by parsing the entire SMS message including the terminating \r\nOK\r\n in rfcomm_read_result().

By: Matthew Nicholson (mnicholson) 2009-11-24 15:51:36.000-0600

Test the patch I uploaded, it should properly parse multiline SMS messages.

By: Artem Makhutov (artem) 2009-11-25 16:14:12.000-0600


I had not the time to review the patch but I did a quick functionality test:

It works.

But I have noticed that I am getting the "rfcomm_read_cmgr: error  +CMGR message on rfcomm socket" error message and the \r\n are trimmed away and are not passed through.

By: Matthew Nicholson (mnicholson) 2009-12-01 15:38:36.000-0600

There is a bug in the patch that always causes that message to be printed.  Please be more specific about where and how the \r\n characters are being stripped.

By: Matthew Nicholson (mnicholson) 2009-12-01 15:41:22.000-0600

Try the new patch I just uploaded, it should fix the errors you found.

By: Artem Makhutov (artem) 2009-12-02 15:38:58.000-0600

Yes, it works fine.

By: Digium Subversion (svnbot) 2009-12-02 15:44:54.000-0600

Repository: asterisk
Revision: 232580

U   trunk/addons/chan_mobile.c

r232580 | mnicholson | 2009-12-02 15:44:54 -0600 (Wed, 02 Dec 2009) | 8 lines

Fix support for multiline SMS messages in chan_mobile.

(closes issue ASTERISK-15169)
Reported by: Artem
?\194?\160?\194?\160?\194?\160?\194?\160?\194?\160 multiline-sms-fix2.diff uploaded by mnicholson (license 96)
Tested by: Artem