[svn-commits] mnicholson: trunk r870 - /trunk/channels/chan_mobile.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Apr 14 15:28:42 CDT 2009
Author: mnicholson
Date: Tue Apr 14 15:28:39 2009
New Revision: 870
URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=870
Log:
add better error detection for receiving SMS messages
Modified:
trunk/channels/chan_mobile.c
Modified: trunk/channels/chan_mobile.c
URL: http://svn.digium.com/svn-view/asterisk-addons/trunk/channels/chan_mobile.c?view=diff&rev=870&r1=869&r2=870
==============================================================================
--- trunk/channels/chan_mobile.c (original)
+++ trunk/channels/chan_mobile.c Tue Apr 14 15:28:39 2009
@@ -3040,6 +3040,7 @@
&& (entry->expected == AT_OK
|| entry->expected == AT_ERROR
|| entry->expected == AT_CMS_ERROR
+ || entry->expected == AT_CMGR
|| entry->expected == AT_SMS_PROMPT)) {
switch (entry->response_to) {
@@ -3278,7 +3279,13 @@
int index = hfp_parse_cmti(pvt->hfp, buf);
if (index > 0) {
ast_debug(1, "[%s] incoming sms message\n", pvt->id);
- hfp_send_cmgr(pvt->hfp, index);
+
+ if (hfp_send_cmgr(pvt->hfp, index)
+ || msg_queue_push(pvt, AT_CMGR, AT_CMGR)) {
+ ast_debug(1, "[%s] error sending CMGR to retrieve SMS message\n", pvt->id);
+ return -1;
+ }
+
pvt->incoming_sms = 1;
return 0;
} else {
@@ -3298,27 +3305,34 @@
{
char *from_number, *text;
struct ast_channel *chan;
-
- if (hfp_parse_cmgr(pvt->hfp, buf, &from_number, &text)
- || msg_queue_push(pvt, AT_OK, AT_CMGR)) {
-
- ast_debug(1, "[%s] error parsing sms message, disconnecting\n", pvt->id);
- return -1;
- }
-
- /* XXX this channel probably does not need to be associated with this pvt */
- if (!(chan = mbl_new(AST_STATE_DOWN, pvt, NULL))) {
- ast_debug(1, "[%s] error creating sms message channel, disconnecting\n", pvt->id);
- return -1;
- }
-
- strcpy(chan->exten, "sms");
- pbx_builtin_setvar_helper(chan, "SMSSRC", from_number);
- pbx_builtin_setvar_helper(chan, "SMSTXT", text);
-
- if (ast_pbx_start(chan)) {
- ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming sms\n", pvt->id);
- mbl_ast_hangup(pvt);
+ struct msg_queue_entry *msg;
+
+ if ((msg = msg_queue_head(pvt)) && msg->expected == AT_CMGR) {
+ msg_queue_free_and_pop(pvt);
+
+ if (hfp_parse_cmgr(pvt->hfp, buf, &from_number, &text)
+ || msg_queue_push(pvt, AT_OK, AT_CMGR)) {
+
+ ast_debug(1, "[%s] error parsing sms message, disconnecting\n", pvt->id);
+ return -1;
+ }
+
+ /* XXX this channel probably does not need to be associated with this pvt */
+ if (!(chan = mbl_new(AST_STATE_DOWN, pvt, NULL))) {
+ ast_debug(1, "[%s] error creating sms message channel, disconnecting\n", pvt->id);
+ return -1;
+ }
+
+ strcpy(chan->exten, "sms");
+ pbx_builtin_setvar_helper(chan, "SMSSRC", from_number);
+ pbx_builtin_setvar_helper(chan, "SMSTXT", text);
+
+ if (ast_pbx_start(chan)) {
+ ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming sms\n", pvt->id);
+ mbl_ast_hangup(pvt);
+ }
+ } else {
+ ast_debug(1, "[%s] got unexpected +CMGR message, ignoring\n", pvt->id);
}
return 0;
More information about the svn-commits
mailing list