diff options
author | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-16 08:55:01 +0000 |
---|---|---|
committer | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-16 08:55:01 +0000 |
commit | 5e9fde8743d4d3d733303bef99e20000c0769148 (patch) | |
tree | 2f094302f9bbdc74a5e599c509215fa4c82aa7c0 | |
parent | cd687c0c2f3e9a77d344d8806d0072cc8fb8084a (diff) |
[gsmd] Adding timeout scheme, and merge gta01 wakeup scheme as machine plug-in with timeout. (L. Sean)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3430 99fdad57-331a-0410-800a-d7fa5415bdb3
-rw-r--r-- | include/gsmd/atcmd.h | 5 | ||||
-rw-r--r-- | include/gsmd/gsmd.h | 7 | ||||
-rw-r--r-- | include/gsmd/machineplugin.h | 1 | ||||
-rw-r--r-- | src/gsmd/Makefile.am | 3 | ||||
-rw-r--r-- | src/gsmd/atcmd.c | 159 | ||||
-rw-r--r-- | src/gsmd/gsmd.c | 48 | ||||
-rw-r--r-- | src/gsmd/machine.c | 4 | ||||
-rw-r--r-- | src/gsmd/machine_generic.c | 1 | ||||
-rw-r--r-- | src/gsmd/machine_gta01.c | 109 | ||||
-rw-r--r-- | src/gsmd/machine_tihtc.c | 1 | ||||
-rw-r--r-- | src/gsmd/sms_cb.c | 26 | ||||
-rw-r--r-- | src/gsmd/usock.c | 64 | ||||
-rw-r--r-- | src/gsmd/vendor_ti.c | 4 | ||||
-rw-r--r-- | src/gsmd/vendor_tihtc.c | 4 |
14 files changed, 277 insertions, 159 deletions
diff --git a/include/gsmd/atcmd.h b/include/gsmd/atcmd.h index 719b943..e328934 100644 --- a/include/gsmd/atcmd.h +++ b/include/gsmd/atcmd.h @@ -7,11 +7,14 @@ typedef int atcmd_cb_t(struct gsmd_atcmd *cmd, void *ctx, char *resp); -extern struct gsmd_atcmd *atcmd_fill(const char *cmd, int rlen, atcmd_cb_t *cb, void *ctx, u_int16_t id); +extern struct gsmd_atcmd *atcmd_fill(const char *cmd, int rlen, atcmd_cb_t *cb, void *ctx, u_int16_t id, + create_timer_t ct); extern int atcmd_submit(struct gsmd *g, struct gsmd_atcmd *cmd); extern int cancel_atcmd(struct gsmd *g, struct gsmd_atcmd *cmd); extern int atcmd_init(struct gsmd *g, int sockfd); extern void atcmd_drain(int fd); +extern void atcmd_wake_pending_queue (struct gsmd *g); +extern void atcmd_wait_pending_queue (struct gsmd *g); #endif /* __GSMD__ */ diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h index c511fc3..5b2a9e6 100644 --- a/include/gsmd/gsmd.h +++ b/include/gsmd/gsmd.h @@ -19,6 +19,7 @@ void *gsmd_tallocs; #define LGSM_ATCMD_F_PARAM 0x02 /* as opposed to action */ #define LGSM_ATCMD_F_LFCR 0x04 /* accept LFCR as a line terminator */ +typedef struct gsmd_timer * (create_timer_t)(struct gsmd *data); struct gsmd_atcmd { struct llist_head list; void *ctx; @@ -28,6 +29,8 @@ struct gsmd_atcmd { u_int32_t buflen; u_int16_t id; u_int8_t flags; + struct gsmd_timer *timeout; + create_timer_t * create_timer_func; char *cur; char buf[]; }; @@ -67,7 +70,7 @@ struct gsmd; #define GSMD_FLAG_V0 0x0001 /* V0 responses to be expected from TA */ #define GSMD_FLAG_SMS_FMT_TEXT 0x0002 /* TODO Use TEXT rather than PDU mode */ -#define GSMD_MODEM_WAKEUP_TIMEOUT 3 +#define GSMD_ATCMD_TIMEOUT 60 /* If doesn get respond within 60 secs, discard */ struct gsmd { unsigned int flags; @@ -86,7 +89,7 @@ struct gsmd { unsigned char *mlbuf; /* ml_parse buffer */ unsigned int mlbuf_len; int mlunsolicited; - struct gsmd_timer *wakeup_timer; + int alive_responded; }; struct gsmd_user { diff --git a/include/gsmd/machineplugin.h b/include/gsmd/machineplugin.h index aee5d65..7a66031 100644 --- a/include/gsmd/machineplugin.h +++ b/include/gsmd/machineplugin.h @@ -11,6 +11,7 @@ struct gsmd; struct gsmd_machine_plugin { struct llist_head list; unsigned char *name; + int (*ex_submit)(struct gsmd *g); int (*detect)(struct gsmd *g); int (*init)(struct gsmd *g, int fd); }; diff --git a/src/gsmd/Makefile.am b/src/gsmd/Makefile.am index 06d925c..e65b70a 100644 --- a/src/gsmd/Makefile.am +++ b/src/gsmd/Makefile.am @@ -24,6 +24,7 @@ gsmd_LDFLAGS = -Wl,--export-dynamic plugin_LTLIBRARIES = libgsmd-machine_generic.la \ libgsmd-machine_tihtc.la \ + libgsmd-machine_gta01.la \ libgsmd-vendor_ti.la \ libgsmd-vendor_tihtc.la \ libgsmd-vendor_qc.la \ @@ -33,6 +34,8 @@ libgsmd_machine_generic_la_SOURCES = machine_generic.c libgsmd_machine_generic_la_LDFLAGS = -module libgsmd_machine_tihtc_la_SOURCES = machine_tihtc.c libgsmd_machine_tihtc_la_LDFLAGS = -module +libgsmd_machine_gta01_la_SOURCES = machine_gta01.c +libgsmd_machine_gta01_la_LDFLAGS = -module libgsmd_vendor_ti_la_SOURCES = vendor_ti.c libgsmd_vendor_ti_la_LDFLAGS = -module diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c index 1f2e04e..747000b 100644 --- a/src/gsmd/atcmd.c +++ b/src/gsmd/atcmd.c @@ -41,6 +41,7 @@ #include <gsmd/unsolicited.h> static void *__atcmd_ctx; +static int remove_timer(struct gsmd_atcmd * cmd); enum final_result_codes { GSMD_RESULT_OK = 0, @@ -200,12 +201,12 @@ static int parse_final_result(const char *res) return -1; } -static inline void atcmd_wake_pending_queue (struct gsmd *g) +void atcmd_wake_pending_queue (struct gsmd *g) { g->gfd_uart.when |= GSMD_FD_WRITE; } -static inline void atcmd_wait_pending_queue (struct gsmd *g) +void atcmd_wait_pending_queue (struct gsmd *g) { g->gfd_uart.when &= ~GSMD_FD_WRITE; } @@ -214,6 +215,8 @@ static inline void atcmd_wait_pending_queue (struct gsmd *g) static int atcmd_done(struct gsmd *g, struct gsmd_atcmd *cmd, const char *buf) { int rc = 0; + /* remove timer if get respond before timeout */ + remove_timer(cmd); if (!cmd->cb) { gsmd_log(GSMD_NOTICE, "command without cb!!!\n"); } else { @@ -359,6 +362,8 @@ static int ml_parse(const char *buf, int len, void *ctx) /* it might be a multiline response, so if there's a previous response, send out mlbuf and start afresh with an empty buffer */ if (g->mlbuf_len) { + /* remove timer if get respond before timeout */ + remove_timer(cmd); if (!cmd->cb) { gsmd_log(GSMD_NOTICE, "command without cb!!!\n"); } else { @@ -512,6 +517,8 @@ static int atcmd_select_cb(int fd, unsigned int what, void *data) write(fd, "\r", 1); if (!pos->buflen) { + /* success: create atcommand timeout timer */ + pos->timeout = pos->create_timer_func(g); /* success: remove from global list of * to-be-sent atcmds */ llist_del(&pos->list); @@ -536,9 +543,56 @@ static int atcmd_select_cb(int fd, unsigned int what, void *data) return 0; } +static void discard_timeout(struct gsmd_timer *tmr, void *data) +{ + struct gsmd *g=data; + struct gsmd_atcmd *cmd=NULL; + DEBUGP("discard time out!!\n"); + if (!llist_empty(&g->busy_atcmds)) { + cmd = llist_entry(g->busy_atcmds.next,struct gsmd_atcmd, list); + } + if (!cmd) { + DEBUGP("ERROR!! busy_atcmds is NULL\n"); + return; + } + if (cmd->timeout != tmr) { + DEBUGP("ERROR!! cmd->timeout != tmr\n"); + return; + } + + gsmd_timer_free(cmd->timeout); + cmd->timeout = NULL; + + if (cmd->cb) { + cmd->resp = "Timeout"; + cmd->cb(cmd, cmd->ctx, cmd->resp); + } + + // discard the timeout at command + llist_del(&cmd->list); + talloc_free(cmd); + + // pass the next pending at command + if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { + atcmd_wake_pending_queue(g); + } +} + +static struct gsmd_timer * discard_timer(struct gsmd *g) +{ + + struct timeval tv; + tv.tv_sec = GSMD_ATCMD_TIMEOUT; + tv.tv_usec = 0; + + DEBUGP("Create discard timer\n"); + + return gsmd_timer_create(&tv, &discard_timeout, g); +} struct gsmd_atcmd *atcmd_fill(const char *cmd, int rlen, - atcmd_cb_t cb, void *ctx, u_int16_t id) + atcmd_cb_t cb, void *ctx, u_int16_t id, + create_timer_t ct) { int buflen = strlen(cmd); struct gsmd_atcmd *atcmd; @@ -559,95 +613,48 @@ struct gsmd_atcmd *atcmd_fill(const char *cmd, int rlen, atcmd->cur = atcmd->buf; atcmd->cb = cb; atcmd->resp = NULL; + atcmd->timeout = NULL; strncpy(atcmd->buf, cmd, buflen-1); - return atcmd; -} - -static int null_wakeup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd *g = ctx; - if (g->wakeup_timer) { - DEBUGP("modem is awake, remove timer!\n"); - gsmd_timer_unregister(g->wakeup_timer); - gsmd_timer_free(g->wakeup_timer); - g->wakeup_timer=NULL; - } else { - DEBUGP("ERROR!! The wake up response comes too late!!\n"); - } - return 0; -} + if (!ct) + atcmd->create_timer_func = discard_timer; + else + atcmd->create_timer_func = ct; -static void wakeup_timeout(struct gsmd_timer *tmr, void *data) -{ - struct gsmd *g=data; - struct gsmd_atcmd *cmd=NULL; - DEBUGP("Wakeup time out!!\n"); - if (g->wakeup_timer != tmr) { - DEBUGP("ERROR!! g->wakeup_timer != tmr\n"); - return; - } - g->wakeup_timer = NULL; - gsmd_timer_free(tmr); - if (!llist_empty(&g->busy_atcmds)) { - cmd = llist_entry(g->busy_atcmds.next,struct gsmd_atcmd, list); - } - if (!cmd) { - DEBUGP("ERROR!! busy_atcmds is NULL\n"); - return; - } - // It's a wakeup command - if ( cmd->buf[0]==' ') { - llist_del(&cmd->list); - talloc_free(cmd); - // discard the wakeup command, and pass the real command. - if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { - atcmd_wake_pending_queue(g); - } - } else { - DEBUGP("ERROR!! Wakeup timeout and cmd->buf is not wakeup command!! %s\n",cmd->buf); - } + return atcmd; } -void wakeup_timer (struct gsmd *g) +static int remove_timer(struct gsmd_atcmd * cmd) { - struct timeval tv; - struct gsmd_timer *timer; - tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT; - tv.tv_usec = 0; - timer=gsmd_timer_create(&tv,&wakeup_timeout,g); - g->wakeup_timer=timer; - -} + if (cmd->timeout) { + DEBUGP("Get respond before timeout, remove timer!\n"); + gsmd_timer_unregister(cmd->timeout); + gsmd_timer_free(cmd->timeout); + cmd->timeout = NULL; + } else { + DEBUGP("ERROR!! The %s response comes too late!!\n", cmd->buf); + } -/// adding a null '\r' before real at command. -struct gsmd_atcmd * atcmd_wakeup_modem(struct gsmd *g) -{ - if (!g->wakeup_timer) { - DEBUGP("try to wake up\n"); - struct gsmd_atcmd * cmd= atcmd_fill(" \r",2,null_wakeup_cb,g,0); - wakeup_timer(g); - if (llist_empty(&g->pending_atcmds)) { - atcmd_wake_pending_queue(g); - } - llist_add_tail(&cmd->list, &g->pending_atcmds); - } + return 0; } - /* submit an atcmd in the global queue of pending atcmds */ int atcmd_submit(struct gsmd *g, struct gsmd_atcmd *cmd) { int empty; - atcmd_wakeup_modem(g); + + if (g->machinepl->ex_submit) { + DEBUGP("extra-submiting command\n"); + g->machinepl->ex_submit(g); + } DEBUGP("submitting command `%s'\n", cmd->buf); - empty = llist_empty(&g->pending_atcmds); llist_add_tail(&cmd->list, &g->pending_atcmds); - if (empty) { - atcmd_wake_pending_queue(g); - } + if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { + atcmd_wake_pending_queue(g); + } + return 0; } @@ -701,7 +708,7 @@ int atcmd_init(struct gsmd *g, int sockfd) g->mlbuf_len = 0; g->mlunsolicited = 0; - g->wakeup_timer=NULL; + g->alive_responded = 0; g->llp.cur = g->llp.buf; g->llp.len = sizeof(g->llp.buf); diff --git a/src/gsmd/gsmd.c b/src/gsmd/gsmd.c index ebc9126..87f6dfe 100644 --- a/src/gsmd/gsmd.c +++ b/src/gsmd/gsmd.c @@ -56,29 +56,23 @@ static int daemonize = 0; * either OK or ERROR is allowed since, both mean the modem still responds */ - -struct gsmd_alive_priv { - struct gsmd *gsmd; - int alive_responded; -}; - static int gsmd_alive_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { - struct gsmd_alive_priv *alp = ctx; + struct gsmd *g = ctx; if (!strcmp(resp, "OK") || !strcmp(resp, "ERROR") || - ((alp->gsmd->flags & GSMD_FLAG_V0) && resp[0] == '0')) - alp->alive_responded = 1; + ((g->flags & GSMD_FLAG_V0) && resp[0] == '0')) + g->alive_responded = 1; return 0; } static void alive_tmr_cb(struct gsmd_timer *tmr, void *data) { - struct gsmd_alive_priv *alp = data; + struct gsmd *g = data; - DEBUGP("gsmd_alive timer expired\n", alp); + DEBUGP("gsmd_alive timer expired\n"); - if (alp->alive_responded == 0) { + if (g->alive_responded == 0) { gsmd_log(GSMD_FATAL, "modem dead!\n"); exit(3); } else @@ -87,33 +81,29 @@ static void alive_tmr_cb(struct gsmd_timer *tmr, void *data) /* FIXME: update some global state */ gsmd_timer_free(tmr); - talloc_free(alp); +} + +static struct gsmd_timer * alive_timer(struct gsmd *g) +{ + struct timeval tv; + tv.tv_sec = GSMD_ALIVE_TIMEOUT; + tv.tv_usec = 0; + + return gsmd_timer_create(&tv, &alive_tmr_cb, g); } static int gsmd_modem_alive(struct gsmd *gsmd) { struct gsmd_atcmd *cmd; - struct gsmd_alive_priv *alp; - struct timeval tv; - - alp = talloc(gsmd_tallocs, struct gsmd_alive_priv); - if (!alp) - return -ENOMEM; - alp->gsmd = gsmd; - alp->alive_responded = 0; + gsmd->alive_responded = 0; cmd = atcmd_fill(GSMD_ALIVECMD, strlen(GSMD_ALIVECMD)+1, - &gsmd_alive_cb, alp, 0); + &gsmd_alive_cb, gsmd, 0, alive_timer); if (!cmd) { - talloc_free(alp); return -ENOMEM; } - tv.tv_sec = GSMD_ALIVE_TIMEOUT; - tv.tv_usec = 0; - gsmd_timer_create(&tv, &alive_tmr_cb, alp); - return atcmd_submit(gsmd, cmd); } @@ -158,7 +148,7 @@ static int gsmd_test_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp) int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt) { struct gsmd_atcmd *cmd; - cmd = atcmd_fill(cmdtxt, strlen(cmdtxt)+1, &gsmd_test_atcb, NULL, 0); + cmd = atcmd_fill(cmdtxt, strlen(cmdtxt)+1, &gsmd_test_atcb, NULL, 0, NULL); if (!cmd) return -ENOMEM; @@ -239,7 +229,7 @@ int gsmd_initsettings(struct gsmd *gsmd) struct gsmd_atcmd *cmd; struct timeval tv; - cmd = atcmd_fill("ATZ", strlen("ATZ")+1, &firstcmd_atcb, gsmd, 0); + cmd = atcmd_fill("ATZ", strlen("ATZ")+1, &firstcmd_atcb, gsmd, 0, NULL); if (!cmd) return -ENOMEM; diff --git a/src/gsmd/machine.c b/src/gsmd/machine.c index 8a5d5c9..0909928 100644 --- a/src/gsmd/machine.c +++ b/src/gsmd/machine.c @@ -94,8 +94,8 @@ struct machines { char *machine; char *vendor; } machines[] = { - { "GTA01", "generic", "ti" }, - { "GTA02", "generic", "ti" }, + { "GTA01", "gta01", "ti" }, + { "GTA02", "gta01", "ti" }, { "HTC Blueangel", "tihtc", "tihtc" }, { "HTC Himalaya", "tihtc", "tihtc" }, { "HTC Magician", "tihtc", "tihtc" }, diff --git a/src/gsmd/machine_generic.c b/src/gsmd/machine_generic.c index b9e960a..3d80bbf 100644 --- a/src/gsmd/machine_generic.c +++ b/src/gsmd/machine_generic.c @@ -56,6 +56,7 @@ static int generic_init(struct gsmd *g, int fd) struct gsmd_machine_plugin gsmd_machine_plugin = { .name = "generic", + .ex_submit = NULL, .detect = &generic_detect, .init = &generic_init, }; diff --git a/src/gsmd/machine_gta01.c b/src/gsmd/machine_gta01.c new file mode 100644 index 0000000..f035ab1 --- /dev/null +++ b/src/gsmd/machine_gta01.c @@ -0,0 +1,109 @@ +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> + +#include "gsmd.h" + +#include <gsmd/gsmd.h> +#include <gsmd/usock.h> +#include <gsmd/event.h> +#include <gsmd/talloc.h> +#include <gsmd/extrsp.h> +#include <gsmd/machineplugin.h> +#include <gsmd/atcmd.h> + +#define GSMD_MODEM_WAKEUP_TIMEOUT 3 + +static int null_wakeup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + DEBUGP("The wake up callback!!\n"); + return 0; +} + +static void wakeup_timeout(struct gsmd_timer *tmr, void *data) +{ + struct gsmd *g=data; + struct gsmd_atcmd *cmd=NULL; + DEBUGP("Wakeup time out!!\n"); + if (!llist_empty(&g->busy_atcmds)) { + cmd = llist_entry(g->busy_atcmds.next,struct gsmd_atcmd, list); + } + if (!cmd) { + DEBUGP("ERROR!! busy_atcmds is NULL\n"); + return; + } + + if (cmd->timeout != tmr) { + DEBUGP("ERROR!! cmd->timeout != tmr\n"); + return; + } + + gsmd_timer_free(cmd->timeout); + cmd->timeout = NULL; + + // It's a wakeup command + if ( cmd->buf[0]==' ') { + llist_del(&cmd->list); + talloc_free(cmd); + // discard the wakeup command, and pass the real command. + if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { + atcmd_wake_pending_queue(g); + } + } else { + DEBUGP("ERROR!! Wakeup timeout and cmd->buf is not wakeup command!! %s\n",cmd->buf); + } +} + +static struct gsmd_timer * wakeup_timer(struct gsmd *g) +{ + struct timeval tv; + tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT; + tv.tv_usec = 0; + DEBUGP("Create wake up timer\n"); + + return gsmd_timer_create(&tv,&wakeup_timeout,g); +} + +/// adding a null '\r' before real at command. +static int atcmd_wakeup_modem(struct gsmd *g) +{ + DEBUGP("try to wake up\n"); + struct gsmd_atcmd * cmd= atcmd_fill(" \r", 2, null_wakeup_cb, g, 0, wakeup_timer); + + llist_add_tail(&cmd->list, &g->pending_atcmds); + if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { + atcmd_wake_pending_queue(g); + } + + return 0; +} + +static int gta01_detect(struct gsmd *g) +{ + /* FIXME: do actual detection of machine if we have multiple machines */ + return 1; +} + +static int gta01_init(struct gsmd *g, int fd) +{ + int rc; + + /* + * We assume that the GSM chipset can take + * input immediately, so we don't have to + * wait for the "AT-Command Interpreter ready" + * message before trying to send commands. + */ + g->interpreter_ready = 1; + + return 0; +} + +struct gsmd_machine_plugin gsmd_machine_plugin = { + .name = "TI Calypso / FIC firmware", + .ex_submit = &atcmd_wakeup_modem, + .detect = >a01_detect, + .init = >a01_init, +}; diff --git a/src/gsmd/machine_tihtc.c b/src/gsmd/machine_tihtc.c index e1fa4da..6fe52f0 100644 --- a/src/gsmd/machine_tihtc.c +++ b/src/gsmd/machine_tihtc.c @@ -66,6 +66,7 @@ static int tihtc_init(struct gsmd *g, int fd) struct gsmd_machine_plugin gsmd_machine_plugin = { .name = "TI Calypso / HTC firmware", + .ex_submit = NULL, .detect = &tihtc_detect, .init = &tihtc_init, }; diff --git a/src/gsmd/sms_cb.c b/src/gsmd/sms_cb.c index f205665..d7db8e5 100644 --- a/src/gsmd/sms_cb.c +++ b/src/gsmd/sms_cb.c @@ -320,7 +320,7 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) atcmd_len = sprintf(buf, "AT+CMGL=%i", *stat); cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_list_cb, gu, gph->id); + &sms_list_cb, gu, gph->id, NULL); break; case GSMD_SMS_READ: @@ -331,7 +331,7 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) atcmd_len = sprintf(buf, "AT+CMGR=%i", *index); cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_read_cb, gu, gph->id); + &sms_read_cb, gu, gph->id, NULL); break; case GSMD_SMS_SEND: @@ -353,7 +353,7 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) buf[atcmd_len ++] = 26; /* ^Z ends the message */ buf[atcmd_len ++] = 0; - cmd = atcmd_fill(buf, atcmd_len, &sms_send_cb, gu, gph->id); + cmd = atcmd_fill(buf, atcmd_len, &sms_send_cb, gu, gph->id, NULL); break; case GSMD_SMS_WRITE: @@ -378,7 +378,7 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) buf[atcmd_len ++] = 26; /* ^Z ends the message */ buf[atcmd_len ++] = 0; - cmd = atcmd_fill(buf, atcmd_len, &sms_write_cb, gu, gph->id); + cmd = atcmd_fill(buf, atcmd_len, &sms_write_cb, gu, gph->id, NULL); break; case GSMD_SMS_DELETE: @@ -390,11 +390,11 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) gsd->index, gsd->delflg); cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_delete_cb, gu, gph->id); + &sms_delete_cb, gu, gph->id, NULL); break; case GSMD_SMS_GET_MSG_STORAGE: - cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0); + cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0, NULL); break; case GSMD_SMS_SET_MSG_STORAGE: @@ -406,11 +406,11 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) ts0705_memtype_name[storage[0]], ts0705_memtype_name[storage[1]], ts0705_memtype_name[storage[2]]); - cmd = atcmd_fill(buf, atcmd_len + 1, NULL, gu, gph->id); + cmd = atcmd_fill(buf, atcmd_len + 1, NULL, gu, gph->id, NULL); break; case GSMD_SMS_GET_SERVICE_CENTRE: - cmd = atcmd_fill("AT+CSCA?", 8 + 1, &usock_get_smsc_cb, gu, 0); + cmd = atcmd_fill("AT+CSCA?", 8 + 1, &usock_get_smsc_cb, gu, 0, NULL); break; case GSMD_SMS_SET_SERVICE_CENTRE: @@ -419,7 +419,7 @@ int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) ga = (struct gsmd_addr *) ((void *) gph + sizeof(*gph)); atcmd_len = sprintf(buf, "AT+CSCA=\"%s\",%i", ga->number, ga->type); - cmd = atcmd_fill(buf, atcmd_len + 1, NULL, gu, gph->id); + cmd = atcmd_fill(buf, atcmd_len + 1, NULL, gu, gph->id, NULL); break; default: @@ -440,10 +440,10 @@ int usock_rcv_cb(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) switch (gph->msg_subtype) { case GSMD_CB_SUBSCRIBE: - cmd = atcmd_fill("AT+CSCB=1", 9 + 1, NULL, gu->gsmd, 0); + cmd = atcmd_fill("AT+CSCB=1", 9 + 1, NULL, gu->gsmd, 0, NULL); break; case GSMD_CB_UNSUBSCRIBE: - cmd = atcmd_fill("AT+CSCB=0", 9 + 1, NULL, gu->gsmd, 0); + cmd = atcmd_fill("AT+CSCB=0", 9 + 1, NULL, gu->gsmd, 0, NULL); break; default: return -ENOSYS; @@ -681,7 +681,7 @@ int sms_cb_init(struct gsmd *gsmd) /* If text mode, set the encoding */ if (gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) { - atcmd = atcmd_fill("AT+CSCS=\"IRA\"", 13 + 1, NULL, gsmd, 0); + atcmd = atcmd_fill("AT+CSCS=\"IRA\"", 13 + 1, NULL, gsmd, 0, NULL); if (!atcmd) return -ENOMEM; atcmd_submit(gsmd, atcmd); @@ -692,7 +692,7 @@ int sms_cb_init(struct gsmd *gsmd) "AT+CMGF=%i", (gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) ? GSMD_SMS_FMT_TEXT : GSMD_SMS_FMT_PDU) + 1, - NULL, gsmd, 0); + NULL, gsmd, 0, NULL); if (!atcmd) return -ENOMEM; diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 5f6389f..6b29125 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -90,7 +90,7 @@ typedef int usock_msg_handler(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, in static int usock_rcv_passthrough(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) { struct gsmd_atcmd *cmd; - cmd = atcmd_fill((char *)gph+sizeof(*gph), gph->len, &usock_cmd_cb, gu, gph->id); + cmd = atcmd_fill((char *)gph+sizeof(*gph), gph->len, &usock_cmd_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; @@ -127,7 +127,7 @@ static int usock_rcv_voicecall(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, ga = (struct gsmd_addr *) ((void *)gph + sizeof(*gph)); ga->number[GSMD_ADDR_MAXLEN] = '\0'; cmd = atcmd_fill("ATD", 5 + strlen(ga->number), - &usock_cmd_cb, gu, gph->id); + &usock_cmd_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "ATD%s;", ga->number); @@ -135,7 +135,7 @@ static int usock_rcv_voicecall(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, break; case GSMD_VOICECALL_HANGUP: /* ATH0 is not supported by QC, we hope ATH is supported by everone */ - cmd = atcmd_fill("ATH", 4, &usock_cmd_cb, gu, gph->id); + cmd = atcmd_fill("ATH", 4, &usock_cmd_cb, gu, gph->id, NULL); /* This command is special because it needs to be sent to * the MS even if a command is currently executing. */ @@ -144,7 +144,7 @@ static int usock_rcv_voicecall(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, } break; case GSMD_VOICECALL_ANSWER: - cmd = atcmd_fill("ATA", 4, &usock_cmd_cb, gu, gph->id); + cmd = atcmd_fill("ATA", 4, &usock_cmd_cb, gu, gph->id, NULL); break; case GSMD_VOICECALL_DTMF: if (len < sizeof(*gph) + sizeof(*gd)) @@ -160,7 +160,7 @@ static int usock_rcv_voicecall(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, atcmd_len = 1 + strlen("AT+VTS=") + (gd->len * 2); cmd = atcmd_fill("AT+VTS=", atcmd_len, &usock_cmd_cb, - gu, gph->id); + gu, gph->id, NULL); if (!cmd) return -ENOMEM; @@ -224,7 +224,7 @@ static int usock_rcv_pin(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, } cmd = atcmd_fill("AT+CPIN=\"", 9+GSMD_PIN_MAXLEN+3+GSMD_PIN_MAXLEN+2, - &pin_cmd_cb, gu, 0); + &pin_cmd_cb, gu, 0, NULL); if (!cmd) return -ENOMEM; @@ -271,12 +271,12 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, switch (gph->msg_subtype) { case GSMD_PHONE_POWERUP: cmd = atcmd_fill("AT+CFUN=1", 9+1, - &phone_powerup_cb, gu, 0); + &phone_powerup_cb, gu, 0, NULL); break; case GSMD_PHONE_POWERDOWN: cmd = atcmd_fill("AT+CFUN=0", 9+1, - &null_cmd_cb, gu, 0); + &null_cmd_cb, gu, 0, NULL); gu->gsmd->dev_state.on = 0; break; default: @@ -592,7 +592,7 @@ static int network_ownnumbers_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) num->service = GSMD_SERVICE_UNKNOWN; num->name[len] = 0; num->addr.type = type; - num->is_last = (cmd->ret == 0); + num->is_last = (cmd->ret == 0, NULL); usock_cmd_enqueue(ucmd, gu); @@ -615,52 +615,52 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, sizeof(gsmd_oper_numeric), oper); else cmdlen = sprintf(buffer, "AT+COPS=0"); - cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0); + cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL); break; case GSMD_NETWORK_DEREGISTER: - cmd = atcmd_fill("AT+COPS=2", 9+1, &null_cmd_cb, gu, 0); + cmd = atcmd_fill("AT+COPS=2", 9+1, &null_cmd_cb, gu, 0, NULL); break; case GSMD_NETWORK_VMAIL_GET: - cmd = atcmd_fill("AT+CSVM?", 8+1, &network_vmail_cb, gu, 0); + cmd = atcmd_fill("AT+CSVM?", 8+1, &network_vmail_cb, gu, 0, NULL); break; case GSMD_NETWORK_VMAIL_SET: - cmd = atcmd_fill("AT+CSVM=", 8+1, &network_vmail_cb, gu, 0); + cmd = atcmd_fill("AT+CSVM=", 8+1, &network_vmail_cb, gu, 0, NULL); break; case GSMD_NETWORK_SIGQ_GET: - cmd = atcmd_fill("AT+CSQ", 6+1, &network_sigq_cb, gu, 0); + cmd = atcmd_fill("AT+CSQ", 6+1, &network_sigq_cb, gu, 0, NULL); break; case GSMD_NETWORK_OPER_GET: /* Set long alphanumeric format */ atcmd_submit(gu->gsmd, atcmd_fill("AT+COPS=3,0", 11+1, - &null_cmd_cb, gu, 0)); - cmd = atcmd_fill("AT+COPS?", 8+1, &network_oper_cb, gu, 0); + &null_cmd_cb, gu, 0, NULL)); + cmd = atcmd_fill("AT+COPS?", 8+1, &network_oper_cb, gu, 0, NULL); break; case GSMD_NETWORK_OPER_LIST: - cmd = atcmd_fill("AT+COPS=?", 9+1, &network_opers_cb, gu, 0); + cmd = atcmd_fill("AT+COPS=?", 9+1, &network_opers_cb, gu, 0, NULL); break; case GSMD_NETWORK_PREF_LIST: /* Set long alphanumeric format */ atcmd_submit(gu->gsmd, atcmd_fill("AT+CPOL=,0", 10 + 1, - &null_cmd_cb, gu, 0)); + &null_cmd_cb, gu, 0, NULL)); cmd = atcmd_fill("AT+CPOL?", 8 + 1, - &network_pref_opers_cb, gu, 0); + &network_pref_opers_cb, gu, 0, NULL); break; case GSMD_NETWORK_PREF_DEL: cmdlen = sprintf(buffer, "AT+CPOL=%i", *(int *) gph->data); - cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0); + cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL); break; case GSMD_NETWORK_PREF_ADD: cmdlen = sprintf(buffer, "AT+CPOL=,2,\"%.*s\"", sizeof(gsmd_oper_numeric), oper); - cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0); + cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL); break; case GSMD_NETWORK_PREF_SPACE: cmd = atcmd_fill("AT+CPOL=?", 9 + 1, - &network_pref_num_cb, gu, 0); + &network_pref_num_cb, gu, 0, NULL); break; case GSMD_NETWORK_GET_NUMBER: cmd = atcmd_fill("AT+CNUM", 7 + 1, - &network_ownnumbers_cb, gu, 0); + &network_ownnumbers_cb, gu, 0, NULL); break; default: return -EINVAL; @@ -987,7 +987,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, case GSMD_PHONEBOOK_LIST_STORAGE: cmd = atcmd_fill("AT+CPBS=?", 9 + 1, &phonebook_list_storage_cb, - gu, gph->id); + gu, gph->id, NULL); break; case GSMD_PHONEBOOK_SET_STORAGE: if (len < sizeof(*gph) + 3) @@ -998,7 +998,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, /* ex. AT+CPBS="ME" */ atcmd_len = 1 + strlen("AT+CPBS=\"") + 2 + strlen("\""); cmd = atcmd_fill("AT+CPBS=\"", atcmd_len, - &usock_cmd_cb, gu, gph->id); + &usock_cmd_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; @@ -1013,7 +1013,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, atcmd_len = 1 + strlen("AT+CPBF=\"") + strlen(gpf->findtext) + strlen("\""); cmd = atcmd_fill("AT+CPBF=\"", atcmd_len, - &phonebook_find_cb, gu, gph->id); + &phonebook_find_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "AT+CPBF=\"%s\"", gpf->findtext); @@ -1029,7 +1029,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, /* ex, AT+CPBR=23 */ atcmd_len = 1 + strlen("AT+CPBR=") + strlen(buf); cmd = atcmd_fill("AT+CPBR=", atcmd_len, - &phonebook_read_cb, gu, gph->id); + &phonebook_read_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "AT+CPBR=%d", *index); @@ -1044,7 +1044,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, /* ex, AT+CPBR=1,100 */ atcmd_len = 1 + strlen("AT+CPBR=") + strlen(buf); cmd = atcmd_fill("AT+CPBR=", atcmd_len, - &phonebook_readrg_cb, gu, gph->id); + &phonebook_readrg_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "AT+CPBR=%s", buf); @@ -1059,7 +1059,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, atcmd_len = 1 + strlen("AT+CPBW=") + strlen(buf); cmd = atcmd_fill("AT+CPBW=", atcmd_len, - &phonebook_write_cb, gu, gph->id); + &phonebook_write_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "AT+CPBW=%s", buf); @@ -1074,14 +1074,14 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, /* ex, AT+CPBW=3*/ atcmd_len = 1 + strlen("AT+CPBW=") + strlen(buf); cmd = atcmd_fill("AT+CPBW=", atcmd_len, - &phonebook_delete_cb, gu, gph->id); + &phonebook_delete_cb, gu, gph->id, NULL); if (!cmd) return -ENOMEM; sprintf(cmd->buf, "AT+CPBW=%s", buf); break; case GSMD_PHONEBOOK_GET_SUPPORT: cmd = atcmd_fill("AT+CPBR=?", 9+1, - &phonebook_get_support_cb, gu, gph->id); + &phonebook_get_support_cb, gu, gph->id, NULL); break; case GSMD_PHONEBOOK_RETRIEVE_READRG: if (len < sizeof(*gph) + sizeof(int)) @@ -1145,7 +1145,7 @@ static int usock_rcv_phonebook(struct gsmd_user *gu, break; case GSMD_PHONEBOOK_GET_IMSI: - cmd = atcmd_fill("AT+CIMI", 7 + 1, &get_imsi_cb, gu, 0); + cmd = atcmd_fill("AT+CIMI", 7 + 1, &get_imsi_cb, gu, 0, NULL); break; default: diff --git a/src/gsmd/vendor_ti.c b/src/gsmd/vendor_ti.c index 52fbb70..c384cc6 100644 --- a/src/gsmd/vendor_ti.c +++ b/src/gsmd/vendor_ti.c @@ -262,7 +262,7 @@ static int cpi_detect_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) return -EINVAL; /* retrieve voicemail number */ - cmd = atcmd_fill("AT%CPMB=1", 10, &cpmb_detect_cb, g, 0); + cmd = atcmd_fill("AT%CPMB=1", 10, &cpmb_detect_cb, g, 0, NULL); if (cmd) atcmd_submit(g, cmd); @@ -304,7 +304,7 @@ static int ticalypso_initsettings(struct gsmd *g) rc |= gsmd_simplecmd(g, "AT%CPHS=1"); /* enable %CPI: call progress indication */ - cmd = atcmd_fill("AT%CPI=?", 9, &cpi_detect_cb, g, 0); + cmd = atcmd_fill("AT%CPI=?", 9, &cpi_detect_cb, g, 0, NULL); if (cmd) atcmd_submit(g, cmd); diff --git a/src/gsmd/vendor_tihtc.c b/src/gsmd/vendor_tihtc.c index 98f6a12..7e51851 100644 --- a/src/gsmd/vendor_tihtc.c +++ b/src/gsmd/vendor_tihtc.c @@ -45,7 +45,7 @@ static int gsmd_test_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp) int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt) { struct gsmd_atcmd *cmd; - cmd = atcmd_fill(cmdtxt, strlen(cmdtxt)+1, &gsmd_test_atcb, NULL, 0); + cmd = atcmd_fill(cmdtxt, strlen(cmdtxt)+1, &gsmd_test_atcb, NULL, 0, NULL); if (!cmd) return -ENOMEM; @@ -261,7 +261,7 @@ static int tihtc_initsettings(struct gsmd *g) rc |= gsmd_simplecmd(g, "AT%CUNS=0"); /* enable %CPI: call progress indication */ - cmd = atcmd_fill("AT%CPI=?", 9, &cpi_detect_cb, g, 0); + cmd = atcmd_fill("AT%CPI=?", 9, &cpi_detect_cb, g, 0, NULL); if (cmd) atcmd_submit(g, cmd); |