From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8727876207544994062==" MIME-Version: 1.0 From: dragos@endocode.com Subject: [PATCH 18/19] plugins/ublox: read network mode Date: Wed, 09 Mar 2016 17:06:14 +0100 Message-ID: <1457539574-9051-1-git-send-email-dragos@endocode.com> List-Id: To: ofono@ofono.org --===============8727876207544994062== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Dongsu Park Read network mode into modem string. This will let the gprs-context drive know what to do. --- plugins/ublox.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/plugins/ublox.c b/plugins/ublox.c index 76f7fcf..9cfba33 100644 --- a/plugins/ublox.c +++ b/plugins/ublox.c @@ -42,6 +42,7 @@ #include #include = +static const char *ubmconf_prefix[] =3D { "+UBMCONF:", NULL }; static const char *none_prefix[] =3D { NULL }; = enum supported_models { @@ -52,11 +53,17 @@ enum supported_models { TOBYL2_HIGH_THROUGHPUT_MODE =3D 1146, }; = +enum ublox_net_mode { + UBLOX_TOBYL2_NET_MODE_ROUTER =3D 1, + UBLOX_TOBYL2_NET_MODE_BRIDGE =3D 2, +}; + struct ublox_data { GAtChat *modem; GAtChat *aux; int model_id; enum ofono_vendor vendor_family; + enum ublox_net_mode net_mode; }; = static void ublox_debug(const char *str, void *user_data) @@ -93,6 +100,39 @@ static void ublox_remove(struct ofono_modem *modem) g_free(data); } = +static void read_ubmconf_cb(gboolean ok, GAtResult *result, gpointer user_= data) +{ + struct ofono_modem *modem =3D (struct ofono_modem *) user_data; + struct ublox_data *data =3D ofono_modem_get_data(modem); + int mode =3D 0; + GAtResultIter iter; + + g_at_result_iter_init(&iter, result); + + while (!g_at_result_iter_next(&iter, "+UBMCONF:")) + ; /* skip every other line that is not UBMCONF */ + + g_at_result_iter_next_number(&iter, &mode); + + data->net_mode =3D mode; + DBG("mode=3D%d", mode); + if (mode =3D=3D 1) + ofono_modem_set_string(modem, "NetworkMode", "routed"); + else if (mode =3D=3D 2) + ofono_modem_set_string(modem, "NetworkMode", "bridged"); +} + +static void read_net_mode(struct ofono_modem *modem) +{ + struct ublox_data *data =3D ofono_modem_get_data(modem); + + if (!data->aux) + return; + + g_at_chat_send(data->aux, "AT+UBMCONF?", + ubmconf_prefix, read_ubmconf_cb, modem, NULL); +} + static GAtChat *open_device(struct ofono_modem *modem, const char *key, char *debug) { @@ -142,11 +182,6 @@ static void cfun_enable(gboolean ok, GAtResult *result= , gpointer user_data) return; } = - if (data->model_id =3D=3D TOBYL2_HIGH_THROUGHPUT_MODE) - /* use bridged mode until routed mode support is added */ - g_at_chat_send(data->aux, "AT+UBMCONF=3D2", none_prefix, - NULL, NULL, NULL); - ofono_modem_set_powered(modem, TRUE); } = @@ -207,6 +242,8 @@ static int ublox_enable(struct ofono_modem *modem) g_at_chat_send(data->aux, "ATE0 +CMEE=3D1", none_prefix, NULL, NULL, NULL); = + read_net_mode(modem); + g_at_chat_send(data->aux, "AT+CFUN=3D4", none_prefix, cfun_enable, modem, NULL); = -- = 2.5.0 --===============8727876207544994062==--