From 23dfcf4ff925f61bcb2c3bdd712ff0f70bde4fcb Mon Sep 17 00:00:00 2001 From: laforge Date: Tue, 24 Oct 2006 13:07:08 +0000 Subject: - clean up header files (all in include/gmsd now) - finish vendor plugin support - add call progress indicator and signal quality unsolicited support to vendor_ti.c git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@120 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/gsmd/vendor_ti.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 6 deletions(-) (limited to 'src/gsmd/vendor_ti.c') diff --git a/src/gsmd/vendor_ti.c b/src/gsmd/vendor_ti.c index ac67b92..53ca7ed 100644 --- a/src/gsmd/vendor_ti.c +++ b/src/gsmd/vendor_ti.c @@ -5,6 +5,15 @@ #include #include +#include "gsmd.h" + +#include +#include +#include +#include +#include + +#if 0 #include "vendorplugin.h" static int @@ -31,8 +40,60 @@ ti_setopt(struct gsmd *gh, int optname, const void *optval, int optlen) } } -static int ti_parseunsolicit(struct gsmd *gh) +#endif + + +static int csq_parse(char *buf, int len, char *param, + struct gsmd *gsmd) +{ + char *tok; + struct gsmd_evt_auxdata *aux; + struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL, + sizeof(*aux)); + + DEBUGP("entering csq_parse param=`%s'\n", param); + if (!ucmd) + return -EINVAL; + + + aux = (struct gsmd_evt_auxdata *) ucmd->buf; + tok = strtok(param, ","); + if (!tok) + goto out_free_io; + + aux->u.signal.sigq.rssi = atoi(tok); + + tok = strtok(NULL, ","); + if (!tok) + goto out_free_io; + + aux->u.signal.sigq.ber = atoi(tok); + + DEBUGP("sending EVT_SIGNAL\n"); + usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL); + + return 0; + +out_free_io: + free(ucmd); + return -EIO; +} + +static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd) +{ + +} + +static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd) { + +} + +static const struct gsmd_unsolicit ticalypso_unsolicit[] = { + { "\%CSQ", &csq_parse }, /* Signal Quality */ + { "\%CPRI", &cpri_parse }, /* Ciphering Indication */ + { "\%CPI", &cpi_parse }, /* Call Progress Information */ + /* FIXME: parse all the below and generate the respective events */ /* %CPROAM: CPHS Home Country Roaming Indicator */ @@ -43,11 +104,29 @@ static int ti_parseunsolicit(struct gsmd *gh) /* %CPKY: Press Key */ /* %CMGRS: Message Retransmission Service */ /* %CGEV: reports GPRS network events */ - return -EINVAL; +}; + +static int ticalypso_detect(struct gsmd *g) +{ + /* FIXME: do actual detection of vendor if we have multiple vendors */ + return 1; } -struct gsmd_vendorspecific ti_vendorspec = { - .getopt = &ti_getopt, - .setopt = &ti_setopt, - .parse_unsolicit = &ti_parseunsolicit, +static int ticalypso_initsettings(struct gsmd *g) +{ + return gsmd_simplecmd(g, "AT\%CPI=3;\%CPRI=1;\%CSQ=1"); +} + +static struct gsmd_vendor_plugin plugin_ticalypso = { + .name = "TI Calypso", + .num_unsolicit = ARRAY_SIZE(ticalypso_unsolicit), + .unsolicit = &ticalypso_unsolicit, + .detect = &ticalypso_detect, + .initsettings = &ticalypso_initsettings, }; + +/* FIXME: this will be _init() when we make this a plugin */ +int ticalypso_init(void) +{ + return gsmd_vendor_plugin_register(&plugin_ticalypso); +} -- cgit v1.2.3