diff options
Diffstat (limited to 'src/gsmd/vendor_wavecom.c')
-rw-r--r-- | src/gsmd/vendor_wavecom.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/gsmd/vendor_wavecom.c b/src/gsmd/vendor_wavecom.c index c1683ea..e5a9f08 100644 --- a/src/gsmd/vendor_wavecom.c +++ b/src/gsmd/vendor_wavecom.c @@ -120,8 +120,61 @@ out: return 0; } +#define AIS_PFX "+SYSMOCOM_AIS: " + +struct gsmd_ucmd *usock_build_gps(uint8_t subtype, const char *data, uint16_t len) +{ + struct gsmd_evt_auxdata *aux; + struct gsmd_ucmd *ucmd; + int remain_len; + + if (len <= strlen(AIS_PFX)) + return NULL; + + remain_len = len - strlen(AIS_PFX); + + ucmd = usock_build_event(GSMD_MSG_EVENT, subtype, sizeof(*aux)+remain_len+1); + if (!ucmd) + return NULL; + aux = (struct gsmd_evt_auxdata *) ucmd->buf; + + memcpy(aux->data, data+strlen(AIS_PFX), remain_len); + aux->data[remain_len] = '\0'; + + return ucmd; +} + +static int sgps_parse(const char *buf, int len, const char *param, + struct gsmd *gsmd) +{ + struct gsmd_ucmd *ucmd = usock_build_gps(GSMD_EVT_GPS, buf, len); + + if (!ucmd) + return -ENOMEM; + + usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL); + + return 0; +}; + +static int sais_parse(const char *buf, int len, const char *param, + struct gsmd *gsmd) +{ + + struct gsmd_ucmd *ucmd = usock_build_gps(GSMD_EVT_AIS, buf, len); + + if (!ucmd) + return -ENOMEM; + + usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL); + + return 0; +}; + static const struct gsmd_unsolicit wavecom_unsolicit[] = { - { "+CCED", &cced_parse }, /* Cell Environment Report */ + { "+CCED", &cced_parse }, /* Cell Environment Report */ + { "+SYSMOCOM_GPS", &sgps_parse }, + { "+SYSMOCOM_AIS", &sais_parse }, }; static int wavecom_detect(struct gsmd *g) |