summaryrefslogtreecommitdiff
path: root/src/gsmd/vendor_wavecom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsmd/vendor_wavecom.c')
-rw-r--r--src/gsmd/vendor_wavecom.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gsmd/vendor_wavecom.c b/src/gsmd/vendor_wavecom.c
index b1b6929..dc309ab 100644
--- a/src/gsmd/vendor_wavecom.c
+++ b/src/gsmd/vendor_wavecom.c
@@ -213,10 +213,34 @@ static int sais_parse(const char *buf, int len, const char *param,
return 0;
};
+static int cops_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
+{
+ struct gsmd_atcmd fake_atcmd;
+
+ if (!g_use_ATatCOPS)
+ return 0;
+
+ if (!strcmp(buf, "+COPS: ERROR\r\n"))
+ return 0;
+
+ if (!g_use_ATatCOPS || !g_last_cops_user)
+ return 0;
+
+ fake_atcmd.id = g_last_cops_id;
+
+ network_opers_cb(&fake_atcmd, g_last_cops_user, buf);
+
+ return 0;
+};
+
+
static const struct gsmd_unsolicit wavecom_unsolicit[] = {
{ "+CCED", &cced_parse }, /* Cell Environment Report */
{ "+SYSMOCOM_GPS", &sgps_parse },
{ "+SYSMOCOM_AIS", &sais_parse },
+ /* proprietary non-blocking response to AT@COPS=? */
+ { "+COPS", &cops_parse },
};
static int wavecom_detect(struct gsmd *g)
@@ -225,6 +249,15 @@ static int wavecom_detect(struct gsmd *g)
return 1;
}
+static int at_atcops_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ /* if the result is successful, at@cops is supported */
+ if (cmd->ret == 0)
+ g_use_ATatCOPS = 1;
+
+ return 0;
+}
+
static int wavecom_initsettings(struct gsmd *g)
{
int rc = 0;
@@ -255,6 +288,9 @@ static int wavecom_initsettings(struct gsmd *g)
rc |= gsmd_simplecmd(g, "AT+WREGC=0");
rc |= gsmd_simplecmd(g, "AT+CCED=1,3");
+ cmd = atcmd_fill("AT@COPS=?", 9+1, &at_atcops_cb, NULL, 0, NULL);
+ rc |= atcmd_submit(g, cmd);
+
return rc;
}
personal git repositories of Harald Welte. Your mileage may vary