[asterisk-addons-commits] mnicholson: branch mnicholson/chan-mobile-refactor r759 - /team/mnicholson/ch...

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Wed Jan 28 15:23:34 CST 2009


Author: mnicholson
Date: Wed Jan 28 15:23:34 2009
New Revision: 759

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=759
Log:
fix sending of SMS messages by handling reading of the SMS prompt in
rfcomm_read() in chan_mobile

Modified:
    team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c

Modified: team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c
URL: http://svn.digium.com/svn-view/asterisk-addons/team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c?view=diff&rev=759&r1=758&r2=759
==============================================================================
--- team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c (original)
+++ team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c Wed Jan 28 15:23:34 2009
@@ -1094,6 +1094,9 @@
  * call. We handle this by blocking until we can read an entire response.  If
  * the given buffer is not large enough to hold the response, what does not fit
  * in the buffer will be dropped.
+ *
+ * \note an exception is made for the special message '\r\n> ', which is used
+ * to prompt for an SMS message
  */
 static ssize_t rfcomm_read(int rsock, char *buf, size_t count)
 {
@@ -1136,6 +1139,10 @@
 			in_count++;
 			*buf++ = c;
 		}
+
+		/* check for sms prompt */
+		if (in_count == 2 && !strncmp(buf - 2, "> ", 2))
+			break;
 	}
 
 	if (res < 1)
@@ -1698,7 +1705,7 @@
 				rfcomm_write(pvt->rfcomm_socket, buf);
 				pvt->state = MBL_STATE_OUTSMS1;
 			} else if (pvt->state == MBL_STATE_OUTSMS1) {
-				if (pvt->rfcomm_buf[0] == '>') {
+				if (!strcmp(buf, "> ")) {
 					snprintf(buf, sizeof(buf), "%s%c", pvt->sms_txt, 0x1a);
 					rfcomm_write(pvt->rfcomm_socket, buf);
 					pvt->state = MBL_STATE_OUTSMS2;




More information about the asterisk-addons-commits mailing list