r3267 - in trunk/src/target/gsm: include/gsmd src/gsmd src/util
tick at sita.openmoko.org
tick at sita.openmoko.org
Thu Oct 25 13:53:11 CEST 2007
Author: tick
Date: 2007-10-25 13:53:03 +0200 (Thu, 25 Oct 2007)
New Revision: 3267
Modified:
trunk/src/target/gsm/include/gsmd/event.h
trunk/src/target/gsm/include/gsmd/usock.h
trunk/src/target/gsm/src/gsmd/atcmd.c
trunk/src/target/gsm/src/gsmd/unsolicited.c
trunk/src/target/gsm/src/util/event.c
Log:
handle CME and CMS errors (Erin Yueh)
Modified: trunk/src/target/gsm/include/gsmd/event.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/event.h 2007-10-25 11:48:53 UTC (rev 3266)
+++ trunk/src/target/gsm/include/gsmd/event.h 2007-10-25 11:53:03 UTC (rev 3267)
@@ -18,6 +18,7 @@
GSMD_EVT_CIPHER = 13, /* Chiphering Information */
GSMD_EVT_IN_CBM = 14, /* Incoming Cell Broadcat message */
GSMD_EVT_IN_DS = 15, /* SMS Status Report */
+ GSMD_EVT_IN_ERROR = 16, /* CME/CMS error */
__NUM_GSMD_EVT
};
Modified: trunk/src/target/gsm/include/gsmd/usock.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/usock.h 2007-10-25 11:48:53 UTC (rev 3266)
+++ trunk/src/target/gsm/include/gsmd/usock.h 2007-10-25 11:53:03 UTC (rev 3267)
@@ -2,7 +2,8 @@
#define _GSMD_USOCK_H
#include <gsmd/event.h>
-
+#include <gsmd/ts0707.h>
+#include <gsmd/ts0705.h>
#define GSMD_UNIX_SOCKET "\0gsmd"
//#define GSMD_UNIX_SOCKET_TYPE SOCK_SEQPACKET
#define GSMD_UNIX_SOCKET_TYPE SOCK_STREAM
@@ -361,8 +362,14 @@
u_int16_t net_state_gsm;
u_int16_t net_state_gprs;
} cipher;
+ struct {
+ enum gsm0707_cme_error number;
+ } cme_err;
+ struct {
+ enum gsm0705_cms_error number;
+ } cms_err;
} u;
- u_int8_t data[0];
+ u_int8_t data[0];
} __attribute__ ((packed));
/* Refer to GSM 07.05 subclause 3.5.4 */
Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c 2007-10-25 11:48:53 UTC (rev 3266)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c 2007-10-25 11:53:03 UTC (rev 3267)
@@ -206,6 +206,7 @@
struct gsmd_atcmd *cmd = NULL;
int rc = 0;
int cme_error = 0;
+ int cms_error = 0;
DEBUGP("buf=`%s'(%d)\n", buf, len);
@@ -269,6 +270,7 @@
DEBUGP("error number %lu\n", err_nr);
if (cmd)
cmd->ret = err_nr;
+ cms_error = 1;
goto final_cb;
}
@@ -399,6 +401,9 @@
if (cmd && cme_error)
generate_event_from_cme(g, cmd->ret);
+
+ if (cmd && cms_error)
+ generate_event_from_cms(g, cmd->ret);
if (!cmd->cb) {
gsmd_log(GSMD_NOTICE, "command without cb!!!\n");
Modified: trunk/src/target/gsm/src/gsmd/unsolicited.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/unsolicited.c 2007-10-25 11:48:53 UTC (rev 3266)
+++ trunk/src/target/gsm/src/gsmd/unsolicited.c 2007-10-25 11:53:03 UTC (rev 3267)
@@ -441,13 +441,13 @@
GSM0707_CME_SIM_NOT_INSERTED,
GSM0707_CME_SIM_PIN_REQUIRED,
GSM0707_CME_SIM_PUK_REQUIRED,
- GSM0707_CME_SIM_FAILURE,
+/* GSM0707_CME_SIM_FAILURE,
GSM0707_CME_SIM_BUSY,
- GSM0707_CME_SIM_WRONG,
+ GSM0707_CME_SIM_WRONG,*/
GSM0707_CME_SIM_PIN2_REQUIRED,
GSM0707_CME_SIM_PUK2_REQUIRED,
- GSM0707_CME_MEMORY_FULL,
- GSM0707_CME_MEMORY_FAILURE,
+/* GSM0707_CME_MEMORY_FULL,
+ GSM0707_CME_MEMORY_FAILURE,*/
GSM0707_CME_NETPERS_PIN_REQUIRED,
GSM0707_CME_NETPERS_PUK_REQUIRED,
GSM0707_CME_NETSUBSET_PIN_REQUIRED,
@@ -470,84 +470,106 @@
return 0;
}
-
int generate_event_from_cme(struct gsmd *g, unsigned int cme_error)
{
struct gsmd_ucmd *gu;
struct gsmd_evt_auxdata *eaux;
- if (!is_in_array(cme_error, errors_creating_events,
- ARRAY_SIZE(errors_creating_events)))
- return 0;
+
+ if (!is_in_array(cme_error, errors_creating_events,
+ ARRAY_SIZE(errors_creating_events))) {
+
+ gu = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_ERROR, sizeof(*eaux));
+ if (!gu)
+ return -1;
+ eaux = ((void *)gu) + sizeof(*gu);
+ eaux->u.cme_err.number = cme_error;
+ return usock_evt_send(g, gu, GSMD_EVT_IN_ERROR);
+ }
+ else {
+ gu = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_PIN, sizeof(*eaux));
+ if (!gu)
+ return -1;
+ eaux = ((void *)gu) + sizeof(*gu);
- gu = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_PIN, sizeof(*eaux));
+ switch (cme_error) {
+ case GSM0707_CME_PH_SIM_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_SIM_PIN;
+ break;
+ case GSM0707_CME_PH_FSIM_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_FSIM_PIN;
+ break;
+ case GSM0707_CME_PH_FSIM_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_FSIM_PUK;
+ break;
+ case GSM0707_CME_SIM_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_SIM_PIN;
+ break;
+ case GSM0707_CME_SIM_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_SIM_PUK;
+ break;
+ case GSM0707_CME_SIM_PIN2_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_SIM_PIN2;
+ break;
+ case GSM0707_CME_SIM_PUK2_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_SIM_PUK2;
+ break;
+ case GSM0707_CME_NETPERS_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_NET_PIN;
+ break;
+ case GSM0707_CME_NETPERS_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_NET_PUK;
+ break;
+ case GSM0707_CME_NETSUBSET_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_NETSUB_PIN;
+ break;
+ case GSM0707_CME_NETSUBSET_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_NETSUB_PUK;
+ break;
+ case GSM0707_CME_PROVIDER_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_SP_PIN;
+ break;
+ case GSM0707_CME_PROVIDER_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_SP_PUK;
+ break;
+ case GSM0707_CME_CORPORATE_PIN_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_CORP_PIN;
+ break;
+ case GSM0707_CME_CORPORATE_PUK_REQUIRED:
+ eaux->u.pin.type = GSMD_PIN_PH_CORP_PUK;
+ break;
+
+ case GSM0707_CME_SIM_FAILURE:
+ case GSM0707_CME_SIM_BUSY:
+ case GSM0707_CME_SIM_WRONG:
+ case GSM0707_CME_MEMORY_FULL:
+ case GSM0707_CME_MEMORY_FAILURE:
+ case GSM0707_CME_PHONE_FAILURE:
+ case GSM0707_CME_PHONE_NOCONNECT:
+ case GSM0707_CME_PHONE_ADAPT_RESERVED:
+ case GSM0707_CME_SIM_NOT_INSERTED:
+ /* FIXME */
+ talloc_free(gu);
+ return 0;
+ break;
+ default:
+ talloc_free(gu);
+ return 0;
+ break;
+ }
+ return usock_evt_send(g, gu, GSMD_EVT_PIN);
+ }
+}
+
+int generate_event_from_cms(struct gsmd *g, unsigned int cms_error)
+{
+ struct gsmd_ucmd *gu;
+ struct gsmd_evt_auxdata *eaux;
+
+ gu = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_ERROR, sizeof(*eaux));
if (!gu)
return -1;
eaux = ((void *)gu) + sizeof(*gu);
+ eaux->u.cms_err.number = cms_error;
+ return usock_evt_send(g, gu, GSMD_EVT_IN_ERROR);
+}
- switch (cme_error) {
- case GSM0707_CME_PH_SIM_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_SIM_PIN;
- break;
- case GSM0707_CME_PH_FSIM_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_FSIM_PIN;
- break;
- case GSM0707_CME_PH_FSIM_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_FSIM_PUK;
- break;
- case GSM0707_CME_SIM_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_SIM_PIN;
- break;
- case GSM0707_CME_SIM_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_SIM_PUK;
- break;
- case GSM0707_CME_SIM_PIN2_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_SIM_PIN2;
- break;
- case GSM0707_CME_SIM_PUK2_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_SIM_PUK2;
- break;
- case GSM0707_CME_NETPERS_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_NET_PIN;
- break;
- case GSM0707_CME_NETPERS_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_NET_PUK;
- break;
- case GSM0707_CME_NETSUBSET_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_NETSUB_PIN;
- break;
- case GSM0707_CME_NETSUBSET_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_NETSUB_PUK;
- break;
- case GSM0707_CME_PROVIDER_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_SP_PIN;
- break;
- case GSM0707_CME_PROVIDER_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_SP_PUK;
- break;
- case GSM0707_CME_CORPORATE_PIN_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_CORP_PIN;
- break;
- case GSM0707_CME_CORPORATE_PUK_REQUIRED:
- eaux->u.pin.type = GSMD_PIN_PH_CORP_PUK;
- break;
-
- case GSM0707_CME_SIM_FAILURE:
- case GSM0707_CME_SIM_BUSY:
- case GSM0707_CME_SIM_WRONG:
- case GSM0707_CME_MEMORY_FULL:
- case GSM0707_CME_MEMORY_FAILURE:
- case GSM0707_CME_PHONE_FAILURE:
- case GSM0707_CME_PHONE_NOCONNECT:
- case GSM0707_CME_PHONE_ADAPT_RESERVED:
- case GSM0707_CME_SIM_NOT_INSERTED:
- /* FIXME */
- talloc_free(gu);
- return 0;
- break;
- default:
- talloc_free(gu);
- return 0;
- break;
- }
- return usock_evt_send(g, gu, GSMD_EVT_PIN);
-}
Modified: trunk/src/target/gsm/src/util/event.c
===================================================================
--- trunk/src/target/gsm/src/util/event.c 2007-10-25 11:48:53 UTC (rev 3266)
+++ trunk/src/target/gsm/src/util/event.c 2007-10-25 11:53:03 UTC (rev 3267)
@@ -233,6 +233,16 @@
return 0;
}
+static int error_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+ if(aux->u.cme_err.number)
+ printf("cme error: %u\n", aux->u.cme_err.number);
+ else if(aux->u.cms_err.number)
+ printf("cme error: %u\n", aux->u.cms_err.number);
+
+ return 0;
+}
+
int event_init(struct lgsm_handle *lh)
{
int rc;
@@ -246,7 +256,7 @@
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_NETREG, &netreg_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_SIGNAL, &sigq_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_OUT_STATUS, &cprog_handler);
-
+ rc |= lgsm_evt_handler_register(lh, GSMD_EVT_IN_ERROR, &error_handler);
return rc;
}
More information about the commitlog
mailing list