ofono with sim5320 module
by David Ashley
Hello, I'm at my wits' end trying to get ofono working with the
sim5320 module. I'm using the plugins/sim900.c module as a starting
point. I think the issue has something to do with the difference
between the MUX functionality between the 900 and the 5320. The sim900
supports the elaborate parameters sent on the
AT+CMUX=0,x,x,x,x, etc.
but the SIM5320 only supports
AT+CMUX=0
There's that... but also the way the sim900 plugin creates a
SETUP_DLC, initiates muxing, then deletes the setup DLC and creates 4
new DLC's... it didn't work for the sim5320 until I remapped the DLC's
somewhat like this:
#define NUM_DLC 4
#define VOICE_DLC 2
#define NETREG_DLC 1
//#define SMS_DLC 2
#define GPRS_DLC 3
#define SETUP_DLC 0
static char *dlc_prefixes[NUM_DLC] = {
[VOICE_DLC]="Voice: ",
[NETREG_DLC]="Net: ",
// [SMS_DLC]= "SMS: ",
[GPRS_DLC]= "GPRS: " ,
[SETUP_DLC]= "Setup: ",
};
Note I have to eliminate the SMS_DLC usage later in sim5320_post_sim:
// ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
// data->dlcs[SMS_DLC]);
OK everything is *ALMOST* working. ofonod interacts fine with
connmand, connmand tells ofonod to activate the sim5320, which
actually establishes a ppp connection and sets up a ppp device:
ppp0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-0
inet addr:30.97.132.47 P-t-P:30.97.132.47 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:124 (124.0 B)
Here's the rub: No matter what I do, I never get any RX packets from
that ppp device, and even when it appears to TX packets (I'm trying to
ping out) the machine on the internet isn't actually receiving them.
I'm running on a beaglebone with a custom board with a sim5320 module on it.
I have no idea what to try... Any advice would be appreciated...
Thanks very much!!!!
-Dave
3 years, 2 months
[PATCH v3 0/7] ubloxmodem add netmon interface
by Djalal Harouni
Hi,
These patches add netmon interface to ubloxmodem. This allows to query
and get data returned by +CESQ command through D-Bus.
The following types will be exposed as Network Monitor Property Types.
RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
Thank you!
Changes since v2
* Fixed subject of header message: we have 0/7 patches and not 0/5
* Tag all subject of patches with v3, easy to read.
* Fixed a bug we have to return when finishing please see:
https://lists.ofono.org/pipermail/ofono/2016-November/016693.html
Changes since v1:
* Re-worked patches to follow 'Submitting patches' section.
Each top-level directory change should be in a separate patch
* Removed OFONO_NETMON_INFO_OPERATOR
* Documented all added fields in networkmonitor-api.txt
* We only use one channel for communication, dropped the other one.
* Fixed a cbd memory leak, now we try to be conservative and always
report what we have collected so far. We only fail hard in case
+COPS failed or sending +CESQ failed. Otherwise we report the result
and make sure to free cbd.
* Various fixes to follow the coding style.
v2 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016685.html
V1 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016671.html
Djalal Harouni (7):
netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus
doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
ubloxmodem: add the netmon driver
ubloxmodem: register and initialize the netmon driver
build: build the ublox netmon driver
test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}
Makefile.am | 1 +
doc/networkmonitor-api.txt | 22 +++
drivers/ubloxmodem/netmon.c | 335 ++++++++++++++++++++++++++++++++++++++++
drivers/ubloxmodem/ubloxmodem.c | 2 +
drivers/ubloxmodem/ubloxmodem.h | 3 +
include/netmon.h | 4 +
plugins/ublox.c | 3 +
src/netmon.c | 28 ++++
test/get-serving-cell-info | 20 +++
9 files changed, 418 insertions(+)
create mode 100644 drivers/ubloxmodem/netmon.c
4 years, 2 months
[PATCH v2 0/5] ubloxmodem add netmon interface
by Djalal Harouni
Hi,
These patches add netmon interface to ubloxmodem. This allows to query
and get data returned by +CESQ command through D-Bus.
The following types will be exposed as Network Monitor Property Types.
RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
V1 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016671.html
Thank you!
Changes since v1:
* Re-worked patches to follow 'Submitting patches' section.
Each top-level directory change should be in a separate patch
* Removed OFONO_NETMON_INFO_OPERATOR
* Documented all added fields in networkmonitor-api.txt
* We only use one channel for communication, dropped the other one.
* Fixed a cbd memory leak, now we try to be conservative and always
report what we have collected so far. We only fail hard in case
+COPS failed or sending +CESQ failed. Otherwise we report the result
and make sure to free cbd.
* Various fixes to follow the coding style.
Djalal Harouni (7):
netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus
doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
ubloxmodem: add the netmon driver
ubloxmodem: register and initialize the netmon driver
build: build the ublox netmon driver
test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}
Makefile.am | 1 +
doc/networkmonitor-api.txt | 22 +++
drivers/ubloxmodem/netmon.c | 335 ++++++++++++++++++++++++++++++++++++++++
drivers/ubloxmodem/ubloxmodem.c | 2 +
drivers/ubloxmodem/ubloxmodem.h | 3 +
include/netmon.h | 4 +
plugins/ublox.c | 3 +
src/netmon.c | 28 ++++
test/get-serving-cell-info | 20 +++
9 files changed, 418 insertions(+)
create mode 100644 drivers/ubloxmodem/netmon.c
4 years, 3 months
[PATCH 0/5] RFC: ubloxmodem add netmon interface
by djalal@endocode.com
From: Djalal Harouni <djalal(a)endocode.com>
Hi,
These patches add netmon interface to ubloxmodem. This allows to query
and get data returned by +CESQ command through D-Bus.
The following types will be exposed as Network Monitor Property Types.
RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
OPERATOR: the operator
The 5 patches are:
0001: add the ofono netmon types that we are interesting in
OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR}
These will be collected from +COPS and +CESQ
0002: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR} in D-Bus
0003: ubloxmodem: add the netmon driver
This adds the actual netmon driver. It also contains the code to
do +COPS and +CESQ and send back result.
0004: ubloxmodem: intialize and register the netmon driver
This adds the code to intialize and register the driver that was
added in patch 0003
0005: test: support OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR}
This makes get-serving-cell-info script return the all data that
we did expose.
Questions:
How we should document these new fields in doc/networkmonitor-api.txt ?
Should we use the official values from the ublox AT manual ?
Thank you!
Djalal Harouni (5):
netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR}
netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR} in D-Bus
ubloxmodem: add the netmon driver
ubloxmodem: intialize and register the netmon driver
test: support OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR}
Makefile.am | 1 +
drivers/ubloxmodem/netmon.c | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
drivers/ubloxmodem/ubloxmodem.c | 2 +
drivers/ubloxmodem/ubloxmodem.h | 3 ++
include/netmon.h | 5 ++
plugins/ublox.c | 3 ++
src/netmon.c | 40 +++++++++++++++-
test/get-serving-cell-info | 24 ++++++++++
8 files changed, 416 insertions(+), 1 deletion(-)
create mode 100644 drivers/ubloxmodem/netmon.c
--
2.5.5
4 years, 3 months
[PATCH] gprs: lte: set attached after successful activation
by Dragos Tatulea
Otherwise the attached state gets to be set before the actual LTE
automatic context is ready. This triggers a race between connman
and ofono: connman sees status attached before the context is active
so connman will try to activate another context with same apn and will
fail over and over again.
---
src/gprs.c | 50 +++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 5f7620b..5015a2f 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -959,6 +959,24 @@ static void pri_deactivate_callback(const struct ofono_error *error, void *data)
}
}
+static void gprs_set_attached_property(struct ofono_gprs *gprs,
+ ofono_bool_t attached)
+{
+ const char *path;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t value = attached;
+
+ if (gprs->attached == attached)
+ return;
+
+ gprs->attached = attached;
+
+ path = __ofono_atom_get_path(gprs->atom);
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_CONNECTION_MANAGER_INTERFACE,
+ "Attached", DBUS_TYPE_BOOLEAN, &value);
+}
+
static void pri_read_settings_callback(const struct ofono_error *error,
void *data)
{
@@ -987,6 +1005,9 @@ static void pri_read_settings_callback(const struct ofono_error *error,
}
value = pri_ctx->active;
+
+ gprs_set_attached_property(pri_ctx->gprs, TRUE);
+
ofono_dbus_signal_property_changed(conn, pri_ctx->path,
OFONO_CONNECTION_CONTEXT_INTERFACE,
"Active", DBUS_TYPE_BOOLEAN, &value);
@@ -1596,24 +1617,6 @@ static void release_active_contexts(struct ofono_gprs *gprs)
}
}
-static void gprs_set_attached_property(struct ofono_gprs *gprs,
- ofono_bool_t attached)
-{
- const char *path;
- DBusConnection *conn = ofono_dbus_get_connection();
- dbus_bool_t value = attached;
-
- if (gprs->attached == attached)
- return;
-
- gprs->attached = attached;
-
- path = __ofono_atom_get_path(gprs->atom);
- ofono_dbus_signal_property_changed(conn, path,
- OFONO_CONNECTION_MANAGER_INTERFACE,
- "Attached", DBUS_TYPE_BOOLEAN, &value);
-}
-
static void gprs_attached_update(struct ofono_gprs *gprs)
{
ofono_bool_t attached;
@@ -1717,11 +1720,12 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
DBG("attach: %u, driver_attached: %u", attach, gprs->driver_attached);
if (ofono_netreg_get_technology(gprs->netreg) ==
- ACCESS_TECHNOLOGY_EUTRAN) {
- /* Ignore attach logic for LTE. There is no such concept. */
- gprs_set_attached_property(gprs, attach);
- return;
- }
+ ACCESS_TECHNOLOGY_EUTRAN)
+ /*
+ * For LTE we set attached status only on successful
+ * context activation.
+ */
+ return;
if (gprs->driver_attached == attach)
return;
--
2.7.4
4 years, 3 months
[PATCH] gprs: lte: set attached after successful activation
by Dragos Tatulea
Otherwise the attached state gets to be set before the actual LTE
automatic context is ready. This triggers a race between connman
and ofono: connman sees status attached before the context is active
so connman will try to activate another context with same apn and will
fail over and over again.
---
src/gprs.c | 52 +++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 5f7620b..c5fda35 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -959,6 +959,24 @@ static void pri_deactivate_callback(const struct ofono_error *error, void *data)
}
}
+static void gprs_set_attached_property(struct ofono_gprs *gprs,
+ ofono_bool_t attached)
+{
+ const char *path;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t value = attached;
+
+ if (gprs->attached == attached)
+ return;
+
+ gprs->attached = attached;
+
+ path = __ofono_atom_get_path(gprs->atom);
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_CONNECTION_MANAGER_INTERFACE,
+ "Attached", DBUS_TYPE_BOOLEAN, &value);
+}
+
static void pri_read_settings_callback(const struct ofono_error *error,
void *data)
{
@@ -987,6 +1005,9 @@ static void pri_read_settings_callback(const struct ofono_error *error,
}
value = pri_ctx->active;
+
+ gprs_set_attached_property(pri_ctx->gprs, TRUE);
+
ofono_dbus_signal_property_changed(conn, pri_ctx->path,
OFONO_CONNECTION_CONTEXT_INTERFACE,
"Active", DBUS_TYPE_BOOLEAN, &value);
@@ -1596,24 +1617,6 @@ static void release_active_contexts(struct ofono_gprs *gprs)
}
}
-static void gprs_set_attached_property(struct ofono_gprs *gprs,
- ofono_bool_t attached)
-{
- const char *path;
- DBusConnection *conn = ofono_dbus_get_connection();
- dbus_bool_t value = attached;
-
- if (gprs->attached == attached)
- return;
-
- gprs->attached = attached;
-
- path = __ofono_atom_get_path(gprs->atom);
- ofono_dbus_signal_property_changed(conn, path,
- OFONO_CONNECTION_MANAGER_INTERFACE,
- "Attached", DBUS_TYPE_BOOLEAN, &value);
-}
-
static void gprs_attached_update(struct ofono_gprs *gprs)
{
ofono_bool_t attached;
@@ -1644,8 +1647,6 @@ static void gprs_attached_update(struct ofono_gprs *gprs)
gprs->flags |= GPRS_FLAG_ATTACHED_UPDATE;
return;
}
-
- gprs_set_attached_property(gprs, attached);
}
static void registration_status_cb(const struct ofono_error *error,
@@ -1717,11 +1718,12 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
DBG("attach: %u, driver_attached: %u", attach, gprs->driver_attached);
if (ofono_netreg_get_technology(gprs->netreg) ==
- ACCESS_TECHNOLOGY_EUTRAN) {
- /* Ignore attach logic for LTE. There is no such concept. */
- gprs_set_attached_property(gprs, attach);
- return;
- }
+ ACCESS_TECHNOLOGY_EUTRAN)
+ /*
+ * For LTE we set attached status only on successful
+ * context activation.
+ */
+ return;
if (gprs->driver_attached == attach)
return;
--
2.7.4
4 years, 3 months
[PATCH] lte: fix early imsi free
by Dragos Tatulea
storage_close was creating an empty sync file in /var/lib/ofono/lte
when it should have been closing the proper file
/var/lig/ofono/<imsi>/lte.
---
src/lte.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lte.c b/src/lte.c
index 82da868..518103a 100644
--- a/src/lte.c
+++ b/src/lte.c
@@ -259,9 +259,6 @@ static void lte_atom_remove(struct ofono_atom *atom)
if (lte == NULL)
return;
- g_free(lte->imsi);
- lte->imsi = NULL;
-
if (lte->settings) {
storage_close(lte->imsi, SETTINGS_STORE, lte->settings, TRUE);
lte->settings = NULL;
@@ -270,6 +267,9 @@ static void lte_atom_remove(struct ofono_atom *atom)
if (lte->driver && lte->driver->remove)
lte->driver->remove(lte);
+ g_free(lte->imsi);
+ lte->imsi = NULL;
+
g_free(lte);
}
--
2.7.4
4 years, 3 months
[PATCH] smsutil: Fix receiving UTF-16 encoded messages with split 4-byte char
by Slava Monich
The spec supports UCS2, but in reality UTF-16 is used, which supports
4-byte characters, which could be split into different message
fragments. Accumulate the entire UTF-16 message before converting to
UTF8.
Author: Martin Jones <martin.jones(a)jolla.com>
---
src/smsutil.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/smsutil.c b/src/smsutil.c
index b6f7348..cfede03 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -2218,6 +2218,7 @@ char *sms_decode_text(GSList *sms_list)
const struct sms *sms;
int guess_size = g_slist_length(sms_list);
char *utf8;
+ GByteArray *utf16 = 0;
if (guess_size == 1)
guess_size = 160;
@@ -2289,8 +2290,12 @@ char *sms_decode_text(GSList *sms_list)
NULL, NULL, 0,
locking_shift,
single_shift);
+ if (converted) {
+ g_string_append(str, converted);
+ g_free(converted);
+ }
} else {
- const gchar *from = (const gchar *) (ud + taken);
+ const guint8 *from = ud + taken;
/*
* According to the spec: A UCS2 character shall not be
* split in the middle; if the length of the User Data
@@ -2300,15 +2305,32 @@ char *sms_decode_text(GSList *sms_list)
gssize num_ucs2_chars = (udl_in_bytes - taken) >> 1;
num_ucs2_chars = num_ucs2_chars << 1;
- converted = g_convert(from, num_ucs2_chars,
- "UTF-8//TRANSLIT", "UCS-2BE",
- NULL, NULL, NULL);
+ /*
+ * In theory SMS supports encoding using UCS2 which
+ * is 16-bit, however in the real world messages
+ * are encoded in UTF-16 which can be 4 bytes and
+ * a multiple fragment message can split a 4-byte
+ * character in the middle. So accumulate the
+ * entire message before converting to UTF-8.
+ */
+ if (!utf16)
+ utf16 = g_byte_array_new();
+
+ g_byte_array_append(utf16, from, num_ucs2_chars);
}
+ }
+
+ if (utf16) {
+ char *converted = g_convert_with_fallback((const gchar *)
+ utf16->data, utf16->len,
+ "UTF-8//TRANSLIT", "UTF-16BE",
+ NULL, NULL, NULL, NULL);
if (converted) {
g_string_append(str, converted);
g_free(converted);
}
+ g_byte_array_free(utf16, TRUE);
}
utf8 = g_string_free(str, FALSE);
--
1.9.1
4 years, 3 months
[PATCH] ubloxmodem: gprscontext: adapt for newer firmware
by Dragos Tatulea
The U-Blox documentation specifies the following:
* get interface ip and dns from +CGDCONTRDP
* get gw ip and netmask from +UIPADDR
However, different firmware versions have different befaviour:
* On newer firmware, +UIPADDR returns error. But it's possible to configure
gateway ip == ipterface ip (read from CGDCONTRDP).
* On older firmware, we can actually use the commands specified in the
docs.
This patch runs +CGDCONTRDP, configures everything and then tries to run
+UIPADDR. In that works, reconfigures gw ip and netmask.
---
drivers/ubloxmodem/gprs-context.c | 51 +++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/ubloxmodem/gprs-context.c b/drivers/ubloxmodem/gprs-context.c
index 3069e88..61b4090 100644
--- a/drivers/ubloxmodem/gprs-context.c
+++ b/drivers/ubloxmodem/gprs-context.c
@@ -43,6 +43,7 @@
static const char *none_prefix[] = { NULL };
static const char *cgcontrdp_prefix[] = { "+CGCONTRDP:", NULL };
+static const char *uipaddr_prefix[] = { "+UIPADDR:", NULL };
struct gprs_context_data {
GAtChat *chat;
@@ -51,6 +52,44 @@ struct gprs_context_data {
void *cb_data;
};
+static void uipaddr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_gprs_context *gc = user_data;
+ struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ GAtResultIter iter;
+
+ const char *gw = NULL;
+ const char *netmask = NULL;
+
+ DBG("ok %d", ok);
+
+ if (!ok) {
+ CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ while (g_at_result_iter_next(&iter, "+UIPADDR:")) {
+ g_at_result_iter_skip_next(&iter);
+ g_at_result_iter_skip_next(&iter);
+
+ if (!g_at_result_iter_next_string(&iter, &gw))
+ break;
+
+ if (!g_at_result_iter_next_string(&iter, &netmask))
+ break;
+ }
+
+ if (gw)
+ ofono_gprs_context_set_ipv4_gateway(gc, gw);
+
+ if (netmask)
+ ofono_gprs_context_set_ipv4_netmask(gc, netmask);
+
+ CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+}
+
/*
* CGCONTRDP returns addr + netmask in the same string in the form
* of "a.b.c.d.m.m.m.m" for IPv4. IPv6 is not supported so we ignore it.
@@ -113,6 +152,7 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
const char *laddrnetmask = NULL;
const char *gw = NULL;
const char *dns[3] = { NULL, NULL, NULL };
+ char buf[64];
DBG("ok %d", ok);
@@ -159,7 +199,18 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (dns[0])
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
+ /* Some older versions of Toby L2 need to issue AT+UIPADDR to get the
+ * the correct gateway and netmask. The newer version will return an
+ * empty ok reply.
+ */
+ snprintf(buf, sizeof(buf), "AT+UIPADDR=%u", gcd->active_context);
+ if (g_at_chat_send(gcd->chat, buf, uipaddr_prefix,
+ uipaddr_cb, gc, NULL) > 0)
+ return;
+
+ /* Even if UIPADDR failed, we still have enough data. */
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+
}
static int ublox_send_cgcontrdp(struct ofono_gprs_context *gc)
--
2.7.4
4 years, 3 months
[PATCH] lte: add support for provisioning
by Dragos Tatulea
Provision if there's no DefaultAPN key in the settings file.
---
src/lte.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/lte.c b/src/lte.c
index 99a61fc..82da868 100644
--- a/src/lte.c
+++ b/src/lte.c
@@ -54,6 +54,30 @@ struct ofono_lte {
static GSList *g_drivers = NULL;
+static void lte_try_provision(struct ofono_lte *lte)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ ofono_bool_t ret;
+ struct ofono_gprs_provision_data *pd = NULL;
+ int count = 0;
+
+ ret = __ofono_gprs_provision_get_settings(
+ ofono_sim_get_mcc(sim), ofono_sim_get_mnc(sim),
+ ofono_sim_get_spn(sim), &pd, &count
+ );
+
+ if (ret == FALSE) {
+ ofono_warn(DEFAULT_APN_KEY " provisioning failed.");
+ return;
+ }
+
+ if (is_valid_apn(pd[0].apn))
+ strcpy(lte->info.apn, pd[0].apn);
+
+ __ofono_gprs_provision_free_settings(pd, count);
+}
+
static void lte_load_settings(struct ofono_lte *lte)
{
char *apn;
@@ -74,6 +98,9 @@ static void lte_load_settings(struct ofono_lte *lte)
if (apn) {
strcpy(lte->info.apn, apn);
g_free(apn);
+ } else {
+ DBG(DEFAULT_APN_KEY " doesn't exist, try provisioning.");
+ lte_try_provision(lte);
}
}
--
2.7.4
4 years, 3 months