diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gsmd/atcmd.c | 2 | ||||
| -rw-r--r-- | src/gsmd/unsolicited.c | 33 | 
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 */  | 
