summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2013-02-27 16:46:39 +0100
committerHarald Welte <laforge@gnumonks.org>2013-02-27 18:08:17 +0100
commit821f3af2ac2d77f0f15bdea02c2f3efd0e1cf419 (patch)
treeb945efd852906e94c422b6069406aeaffe0b7f68
parent28e25ae42da7d65face9ad2472075f7c4fc87e92 (diff)
add support for encapsulating and forwarding GPS and AIS data
we simply convert the sysmocom specific unsolicited messages into an usock event which is transported to the client[s] who subscribed to it.
-rw-r--r--include/gsmd/event.h2
-rw-r--r--include/gsmd/usock.h1
-rw-r--r--src/gsmd/vendor_wavecom.c55
-rw-r--r--src/util/event.c8
4 files changed, 64 insertions, 2 deletions
diff --git a/include/gsmd/event.h b/include/gsmd/event.h
index 8da0832..b07a92f 100644
--- a/include/gsmd/event.h
+++ b/include/gsmd/event.h
@@ -20,6 +20,8 @@ enum gsmd_events {
GSMD_EVT_IN_DS = 15, /* SMS Status Report */
GSMD_EVT_IN_ERROR = 16, /* CME/CMS error */
GSMD_EVT_CELLINFO = 17, /* Cell Information (MCC/MNC/LAC/CI) */
+ GSMD_EVT_GPS = 18, /* GPS NMEA string */
+ GSMD_EVT_AIS = 19, /* AIS NMEA string */
__NUM_GSMD_EVT
};
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index d77869a..ba50cbd 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -50,7 +50,6 @@ enum gsmd_msg_voicecall_type {
GSMD_VOICECALL_FWD_ERAS = 13,
};
-
/* call direction from 3GPP TS 07.07, Clause 7.17 */
enum gsmd_call_dire {
GSMD_CALL_DIRE_MO = 0,
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)
diff --git a/src/util/event.c b/src/util/event.c
index f086d84..ae5ca7b 100644
--- a/src/util/event.c
+++ b/src/util/event.c
@@ -261,6 +261,12 @@ static int cinfo_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdat
return 0;
}
+static int gps_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+ printf("EVENT: %s: %s\n", evt == GSMD_EVT_GPS ? "GPS" : "AIS", aux->data);
+ return 0;
+}
+
int event_init(struct lgsm_handle *lh)
{
int rc;
@@ -277,6 +283,8 @@ int event_init(struct lgsm_handle *lh)
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_IN_ERROR, &error_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_CALL_WAIT, &ccwa_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_CELLINFO, &cinfo_handler);
+ rc |= lgsm_evt_handler_register(lh, GSMD_EVT_GPS, &gps_handler);
+ rc |= lgsm_evt_handler_register(lh, GSMD_EVT_AIS, &gps_handler);
return rc;
}
personal git repositories of Harald Welte. Your mileage may vary