smsc_at and CNMA+OK
Marius Huysamen <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Function at2_wait_modem_command in smsc_at.c exits prematurely if messages were received, and acknowledged with AT+CNMA, since the modem will respond to the CNMA with an OK. This patch keeps a counter for every OK that should be ignored within the function's main loop. I have been running Kannel versions 1.4.0 and 1.4.1 for more than a year with this change in place, and I haven't experienced a "random" modem reset since.
smsc_at.c-CNMA_OK.patch
(text/x-patch, 1.1 KB)
--- smsc_at.c.orig 2008-03-01 12:37:35.000000000 +0200
+++ smsc_at.c 2008-03-01 12:43:01.000000000 +0200
@@ -628,6 +628,7 @@
Msg *msg;
int len;
int cmgr_flag = 0;
+ int expect_extra_ok = 0;
time(&end_time);
if (timeout == 0)
@@ -650,8 +651,11 @@
goto end;
}
if (octstr_search(line, octstr_imm("OK"), 0) != -1) {
- ret = 0;
- goto end;
+ if(!expect_extra_ok) {
+ ret = 0;
+ goto end;
+ } else
+ --expect_extra_ok;
}
if ((gt_flag ) && (octstr_search(line, octstr_imm(">"), 0) != -1)) {
ret = 1;
@@ -720,8 +724,10 @@
}
if (!cmgr_flag) {
- if (privdata->phase2plus)
+ if (privdata->phase2plus) {
at2_write_line(privdata, "AT+CNMA");
+ ++expect_extra_ok;
+ }
}
O_DESTROY(pdu);