summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-11-12 09:38:04 +0000
committertick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-11-12 09:38:04 +0000
commit2d4b954be95ad5bef23f9a0068c9c97a8f4037c4 (patch)
tree9871b34501a483569810d9dd2efa41a8f05afb66 /src
parent00277d6968f1dbe81f3b2ec62f7a11c22881ec6d (diff)
keeping track of current registration state internally in gsmd. Without this the"gsmd->dev_state.registered" variable had bogus values. (Andrew)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3390 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src')
-rw-r--r--src/gsmd/atcmd.c2
-rw-r--r--src/gsmd/unsolicited.c33
2 files changed, 26 insertions, 9 deletions
diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c
index 3592918..1f2e04e 100644
--- a/src/gsmd/atcmd.c
+++ b/src/gsmd/atcmd.c
@@ -668,7 +668,7 @@ int cancel_atcmd(struct gsmd *g, struct gsmd_atcmd *cmd)
}
llist_add(&cmd->list, &g->pending_atcmds);
- return atcmd_done(g, cur, "OK");
+ return atcmd_done(g, cur, "ERROR");
}
void atcmd_drain(int fd)
diff --git a/src/gsmd/unsolicited.c b/src/gsmd/unsolicited.c
index e9f3568..4819571 100644
--- a/src/gsmd/unsolicited.c
+++ b/src/gsmd/unsolicited.c
@@ -145,9 +145,31 @@ static int creg_parse(char *buf, int len, const char *param,
struct gsmd *gsmd)
{
const char *comma = strchr(param, ',');
- struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_NETREG,
- sizeof(struct gsmd_evt_auxdata));
+ struct gsmd_ucmd *ucmd;
struct gsmd_evt_auxdata *aux;
+ int prev_registered = gsmd->dev_state.registered;
+ int state;
+ char *end;
+
+ state = strtol(param, &end, 10);
+ if (!(end > param)) {
+ gsmd_log(GSMD_ERROR, "Bad +CREG format, not updating state\n");
+ return -EINVAL;
+ }
+
+ /* Update our knowledge about our state */
+ gsmd->dev_state.registered =
+ (state == GSMD_NETREG_REG_HOME ||
+ state == GSMD_NETREG_REG_ROAMING);
+
+ /* Intialise things that depend on network registration */
+ if (gsmd->dev_state.registered && !prev_registered) {
+ sms_cb_network_init(gsmd);
+ }
+
+ /* Notify clients */
+ ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_NETREG,
+ sizeof(struct gsmd_evt_auxdata));
if (!ucmd)
return -ENOMEM;
aux = (struct gsmd_evt_auxdata *) ucmd->buf;
@@ -163,13 +185,8 @@ static int creg_parse(char *buf, int len, const char *param,
} else
aux->u.netreg.lac = aux->u.netreg.ci = 0;
- /* Intialise things that depend on network registration */
- if (aux->u.netreg.state == GSMD_NETREG_REG_HOME ||
- aux->u.netreg.state == GSMD_NETREG_REG_ROAMING) {
- sms_cb_network_init(gsmd);
- }
-
return usock_evt_send(gsmd, ucmd, GSMD_EVT_NETREG);
+
}
/* Chapter 7.11, call waiting */
personal git repositories of Harald Welte. Your mileage may vary