Hi Jonas,
On 03/01/2018 04:48 AM, Jonas Bonn wrote:
When an LTE modem registers with the network, a default bearer is
automatically established. The APN used for this bearer is taken from
whatever default settings the modem has.
In order to properly set up the ofono context, we need to find out what
APN the modem has used when negotiating this bearer. Ideally, we would
want to query the 'current settings', but those aren't available until
start_net has been called and that's done in the gprs-context atom. As
such, we query the 'default settings' here under the assumption that
that's what the modem will have used.
I don't recall exactly, but from what I remember the default attach APN
is not guaranteed to be honored by the operator. So the default attach
settings used for the actual active context might be different. It
might be better to query those instead.
If we can't get the APN, we do what the AT driver does: pretend the
bearer wasn't established. This is a reasonable fallback, currently,
because connman can't handle zero-length APN's anyway; the previous
approach of setting the APN to 'automatic' breaks connman badly when it
needs to switch between LTE and non-LTE networks.
---
drivers/qmimodem/gprs.c | 90 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 82 insertions(+), 8 deletions(-)
diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c
index a80d55fe..567e8925 100644
--- a/drivers/qmimodem/gprs.c
+++ b/drivers/qmimodem/gprs.c
@@ -29,12 +29,16 @@
#include "qmi.h"
#include "nas.h"
+#include "wds.h"
#include "src/common.h"
#include "qmimodem.h"
struct gprs_data {
+ struct qmi_device* dev;
struct qmi_service *nas;
+ struct qmi_service *wds;
+ unsigned int last_auto_context_id;
Just a nitpick, but why do you have the '*' in different places here?
};
static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
@@ -64,8 +68,57 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
int *tech)
return true;
}
+static void get_default_settings_cb(struct qmi_result *result, void *user_data)
+{
+ struct ofono_gprs* gprs = user_data;
+ struct gprs_data *data = ofono_gprs_get_data(gprs);
+ char* apn = NULL;
+ uint16_t error;
+
+ DBG("");
+
+ if (qmi_result_set_error(result, &error)) {
+ ofono_error("Failed to query default settings: %hd", error);
+ goto error;
+ }
+
+ apn = qmi_result_get_string(result, QMI_WDS_RESULT_APN);
+ if (!apn) {
+ DBG("Default profile has no APN setting");
+ }
+
+error:
+ if (apn) {
+ if (!data->last_auto_context_id) {
+ data->last_auto_context_id = 1;
+ ofono_gprs_cid_activated(gprs, 1, apn);
+ }
Why is a success path under an error: label? This really should be
reworked to be more readable.
+ } else {
+ ofono_warn("LTE context activated but APN missing");
+ }
+}
+
Regards,
-Denis