Fwd: AT driver patch
Aarno Syvänen <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi List, Anybody committing this patch to cvs? I tested it with keyspan 19hs adapter and siemens tc35 modem (which combination initialised very slowly), and it seems to work ok. Aarno Begin forwarded message: > From: Andreas Fink <[email protected]> > Date: 21. helmikuuta 2005 14:20:15 GMT+01:00 > To: Aarno Syvänen <[email protected]> > Subject: Fwd: AT driver patch > > > > Begin forwarded message: > >> From: Andreas Fink <[email protected]> >> Date: 3. Dezember 2004 08:45:51 GMT+01:00 >> To: [email protected] >> Cc: Subject: AT driver patch >> >> Hi folks. >> >> A user reported to me having problems while initializing the modem >> after a while. >> The log shows it gets no "OK" after AT&F. I however realized that it >> might simply not wait long enough. AT&F resets the modem and this >> might take a while on some old slow phones. Our default timeout of 3 >> seconds might simply be too slow for those. >> >> I wrote the attached patch to work around this issue and also to >> retry the first few commands if it failed. This should make >> initialization more robust. Before I commit it to CVS I however want >> to have it tested by a couple of modem users with different types of >> modems to be sure it doesn't screw up something else. >> >> >> Andreas Fink >> Fink Consulting GmbH >> >> --------------------------------------------------------------- >> Tel: +41-61-6666332 Fax: +41-61-6666331 Mobile: +41-79-2457333 >> Address: Clarastrasse 3, 4058 Basel, Switzerland >> E-Mail: [email protected] >> Homepage: http://www.finkconsulting.com >> --------------------------------------------------------------- >> >> > > Andreas Fink > Global Networks Switzerland AG > > ------------------------------------------------------------------ > Tel: +41-61-6666330 Fax: +41-61-6666334 Mobile: +41-79-2457333 > Global Networks, Inc. Clarastrasse 3, 4058 Basel, Switzerland > Web: http://www.global-networks.ch/ [email protected] > ------------------------------------------------------------------ > PGP Fingerprint: B982 00B7 FFB5 0B33 BFF8 0F77 1E23 F3CA B4A3 D0B8 >
patch-at.c
(text/plain, 2 KB)
--- gw/smsc/smsc_at.c 17 Sep 2004 22:20:50 -0000 1.17
+++ gw/smsc/smsc_at.c 3 Dec 2004 07:38:53 -0000
@@ -417,20 +417,28 @@
gwthread_sleep(0.10);
/* reset the modem */
- if (at2_send_modem_command(privdata, "ATZ", 0, 0) == -1)
- return -1;
+ if (at2_send_modem_command(privdata, "ATZ", 0, 0) == -1) {
+ error(0, "AT2[%s]: modem doesnt like me :(. I'll ignore it for now", octstr_get_cstr(privdata->name));
+ }
/* check if the modem responded */
if (at2_send_modem_command(privdata, "AT", 0, 0) == -1) {
- error(0, "AT2[%s]: no answer from modem", octstr_get_cstr(privdata->name));
- return -1;
+ error(0, "AT2[%s]: Wrong or no answer from modem. Trying again", octstr_get_cstr(privdata->name));
+ if (at2_send_modem_command(privdata, "AT", 0, 0) == -1) {
+ error(0, "AT2[%s]: No luck. get something more reliable", octstr_get_cstr(privdata->name));
+ return -1;
+ }
}
at2_flush_buffer(privdata);
- if (at2_send_modem_command(privdata, "AT&F", 0, 0) == -1)
- return -1;
-
+ /* AT&F might need a bit a longer timeout as usual */
+ if (at2_send_modem_command(privdata, "AT&F", 7, 0) == -1) {
+ error(0, "AT2[%s]: Modem didnt like my AT&F. Lets give it a second try", octstr_get_cstr(privdata->name));
+ if (at2_send_modem_command(privdata, "AT&F", 7, 0) == -1) {
+ return -1;
+ }
+ }
if (at2_send_modem_command(privdata, "ATE0", 0, 0) == -1)
return -1;
@@ -565,9 +573,21 @@
}
+/* at_wait_modem_command waits for the response of a previous
+ sent AT command. The return values are
+ -1: got ERROR
+ 0: got OK
+ 1: got >
+ 2: got SIM PIN
+ the function also handles interceptions like "RING"
+ or incoming SMS and handles them accordingly and transparently
+ timeout is 3 seconds by default
+*/
+
int at2_wait_modem_command(PrivAT2data *privdata, time_t timeout, int gt_flag,
int *output)
{
+
Octstr *line = NULL;
Octstr *line2 = NULL;
Octstr *pdu = NULL;