All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] atmodem: export generic netreg funcs
@ 2019-07-18 10:23 Jonas Bonn
  2019-07-18 10:23 ` [PATCH 02/10] atmodem: export struct netreg Jonas Bonn
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4696 bytes --]

An upcoming netreg driver for uBlox modems will need to override the
probe method in order to set itself up, but for further functionality
the "generic" AT implementations are sufficient.  The easiest way to do
this is to just set up a vtable with a custom probe implementation and
defer all other methods to the common/generic methods.

The problem is that the AT methods are not actually exported.  This
generic AT functionality was not intended to be hooked directly into
other drivers.

This patch exports all the methods of the atmodem network-registration
driver implementation so that they can be used as generic/common
implementations for other drivers.
---
 drivers/atmodem/network-registration.c | 16 +++++++++-------
 drivers/atmodem/network-registration.h | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 7 deletions(-)
 create mode 100644 drivers/atmodem/network-registration.h

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 67380b73..0f83977b 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -41,6 +41,8 @@
 #include "atmodem.h"
 #include "vendor.h"
 
+#include "network-registration.h"
+
 static const char *none_prefix[] = { NULL };
 static const char *creg_prefix[] = { "+CREG:", NULL };
 static const char *cops_prefix[] = { "+COPS:", NULL };
@@ -270,7 +272,7 @@ static void option_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		nd->tech = -1;
 }
 
-static void at_registration_status(struct ofono_netreg *netreg,
+void at_registration_status(struct ofono_netreg *netreg,
 					ofono_netreg_status_cb_t cb,
 					void *data)
 {
@@ -450,7 +452,7 @@ error:
 	g_free(cbd);
 }
 
-static void at_current_operator(struct ofono_netreg *netreg,
+void at_current_operator(struct ofono_netreg *netreg,
 				ofono_netreg_operator_cb_t cb, void *data)
 {
 	struct netreg_data *nd = ofono_netreg_get_data(netreg);
@@ -589,7 +591,7 @@ static void cops_list_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	g_free(list);
 }
 
-static void at_list_operators(struct ofono_netreg *netreg,
+void at_list_operators(struct ofono_netreg *netreg,
 				ofono_netreg_operator_list_cb_t cb, void *data)
 {
 	struct netreg_data *nd = ofono_netreg_get_data(netreg);
@@ -615,7 +617,7 @@ static void register_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	cb(&error, cbd->data);
 }
 
-static void at_register_auto(struct ofono_netreg *netreg,
+void at_register_auto(struct ofono_netreg *netreg,
 				ofono_netreg_register_cb_t cb, void *data)
 {
 	struct netreg_data *nd = ofono_netreg_get_data(netreg);
@@ -630,7 +632,7 @@ static void at_register_auto(struct ofono_netreg *netreg,
 	CALLBACK_WITH_FAILURE(cb, data);
 }
 
-static void at_register_manual(struct ofono_netreg *netreg,
+void at_register_manual(struct ofono_netreg *netreg,
 				const char *mcc, const char *mnc,
 				ofono_netreg_register_cb_t cb, void *data)
 {
@@ -1228,7 +1230,7 @@ static void csq_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	cb(&error, strength, cbd->data);
 }
 
-static void at_signal_strength(struct ofono_netreg *netreg,
+void at_signal_strength(struct ofono_netreg *netreg,
 				ofono_netreg_strength_cb_t cb, void *data)
 {
 	struct netreg_data *nd = ofono_netreg_get_data(netreg);
@@ -2144,7 +2146,7 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
 	return 0;
 }
 
-static void at_netreg_remove(struct ofono_netreg *netreg)
+void at_netreg_remove(struct ofono_netreg *netreg)
 {
 	struct netreg_data *nd = ofono_netreg_get_data(netreg);
 
diff --git a/drivers/atmodem/network-registration.h b/drivers/atmodem/network-registration.h
new file mode 100644
index 00000000..0f622411
--- /dev/null
+++ b/drivers/atmodem/network-registration.h
@@ -0,0 +1,17 @@
+#pragma once
+
+void at_registration_status(struct ofono_netreg *netreg,
+					ofono_netreg_status_cb_t cb,
+					void *data);
+void at_current_operator(struct ofono_netreg *netreg,
+				ofono_netreg_operator_cb_t cb, void *data);
+void at_list_operators(struct ofono_netreg *netreg,
+				ofono_netreg_operator_list_cb_t cb, void *data);
+void at_register_auto(struct ofono_netreg *netreg,
+				ofono_netreg_register_cb_t cb, void *data);
+void at_register_manual(struct ofono_netreg *netreg,
+				const char *mcc, const char *mnc,
+				ofono_netreg_register_cb_t cb, void *data);
+void at_signal_strength(struct ofono_netreg *netreg,
+				ofono_netreg_strength_cb_t cb, void *data);
+void at_netreg_remove(struct ofono_netreg *netreg);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] atmodem: export struct netreg
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 03/10] ublox: network-registration atom Jonas Bonn
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 16712 bytes --]

In order to do inheritance by composition.
---
 drivers/atmodem/network-registration.c | 94 +++++++++++---------------
 drivers/atmodem/network-registration.h | 14 ++++
 2 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 0f83977b..cc702c2c 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -53,20 +53,6 @@ static const char *smoni_prefix[] = { "^SMONI:", NULL };
 static const char *zpas_prefix[] = { "+ZPAS:", NULL };
 static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
 
-struct netreg_data {
-	GAtChat *chat;
-	char mcc[OFONO_MAX_MCC_LENGTH + 1];
-	char mnc[OFONO_MAX_MNC_LENGTH + 1];
-	int signal_index; /* If strength is reported via CIND */
-	int signal_min; /* min strength reported via CIND */
-	int signal_max; /* max strength reported via CIND */
-	int signal_invalid; /* invalid strength reported via CIND */
-	int tech;
-	struct ofono_network_time time;
-	guint nitz_timeout;
-	unsigned int vendor;
-};
-
 struct tech_query {
 	int status;
 	int lac;
@@ -211,7 +197,7 @@ static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	ofono_netreg_status_cb_t cb = cbd->cb;
 	int status, lac, ci, tech;
 	struct ofono_error error;
-	struct netreg_data *nd = cbd->user;
+	struct at_netreg_data *nd = cbd->user;
 
 	decode_at_error(&error, g_at_result_final_response(result));
 
@@ -252,7 +238,7 @@ static void zte_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	struct ofono_netreg *netreg = cbd->data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	if (ok)
 		nd->tech = zte_parse_tech(result);
@@ -264,7 +250,7 @@ static void option_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	struct ofono_netreg *netreg = cbd->data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	if (ok)
 		nd->tech = option_parse_tech(result);
@@ -276,7 +262,7 @@ void at_registration_status(struct ofono_netreg *netreg,
 					ofono_netreg_status_cb_t cb,
 					void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 
 	cbd->user = nd;
@@ -339,7 +325,7 @@ void at_registration_status(struct ofono_netreg *netreg,
 static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(cbd->user);
+	struct at_netreg_data *nd = ofono_netreg_get_data(cbd->user);
 	ofono_netreg_operator_cb_t cb = cbd->cb;
 	struct ofono_network_operator op;
 	GAtResultIter iter;
@@ -400,7 +386,7 @@ error:
 static void cops_numeric_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(cbd->user);
+	struct at_netreg_data *nd = ofono_netreg_get_data(cbd->user);
 	ofono_netreg_operator_cb_t cb = cbd->cb;
 	GAtResultIter iter;
 	const char *str;
@@ -455,7 +441,7 @@ error:
 void at_current_operator(struct ofono_netreg *netreg,
 				ofono_netreg_operator_cb_t cb, void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 	gboolean ok;
 
@@ -594,7 +580,7 @@ static void cops_list_cb(gboolean ok, GAtResult *result, gpointer user_data)
 void at_list_operators(struct ofono_netreg *netreg,
 				ofono_netreg_operator_list_cb_t cb, void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 
 	if (g_at_chat_send(nd->chat, "AT+COPS=?", cops_prefix,
@@ -620,7 +606,7 @@ static void register_cb(gboolean ok, GAtResult *result, gpointer user_data)
 void at_register_auto(struct ofono_netreg *netreg,
 				ofono_netreg_register_cb_t cb, void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 
 	if (g_at_chat_send(nd->chat, "AT+COPS=0", none_prefix,
@@ -636,7 +622,7 @@ void at_register_manual(struct ofono_netreg *netreg,
 				const char *mcc, const char *mnc,
 				ofono_netreg_register_cb_t cb, void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 	char buf[128];
 
@@ -725,7 +711,7 @@ static void ifx_xhomezr_notify(GAtResult *result, gpointer user_data)
 static void ifx_xreg_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int state;
 	const char *band;
 	GAtResultIter iter;
@@ -824,7 +810,7 @@ static void ifx_xcsq_notify(GAtResult *result, gpointer user_data)
 static void ciev_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int strength, ind;
 	GAtResultIter iter;
 
@@ -853,7 +839,7 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
 static void telit_ciev_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	const char *signal_identifier = "rssi";
 	const char *ind_str;
 	int strength;
@@ -884,7 +870,7 @@ static void telit_ciev_notify(GAtResult *result, gpointer user_data)
 static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	const char *signal_identifier = "rssi";
 	const char *ind_str;
 	int strength;
@@ -917,7 +903,7 @@ static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
 static void ctzv_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	const char *tz;
 	GAtResultIter iter;
 
@@ -939,7 +925,7 @@ static void ctzv_notify(GAtResult *result, gpointer user_data)
 static void tlts_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int year, mon, mday, hour, min, sec;
 	char tz[4];
 	const char *time;
@@ -974,7 +960,7 @@ static void tlts_notify(GAtResult *result, gpointer user_data)
 static gboolean notify_time(gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	nd->nitz_timeout = 0;
 
@@ -986,7 +972,7 @@ static gboolean notify_time(gpointer user_data)
 static void ifx_ctzv_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int year, mon, mday, hour, min, sec;
 	const char *tz, *time;
 	GAtResultIter iter;
@@ -1024,7 +1010,7 @@ static void ifx_ctzv_notify(GAtResult *result, gpointer user_data)
 static void ifx_ctzdst_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int dst;
 	GAtResultIter iter;
 
@@ -1052,7 +1038,7 @@ static void cind_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	ofono_netreg_strength_cb_t cb = cbd->cb;
-	struct netreg_data *nd = cbd->user;
+	struct at_netreg_data *nd = cbd->user;
 	int index;
 	int strength;
 	GAtResultIter iter;
@@ -1106,7 +1092,7 @@ static void huawei_rssi_notify(GAtResult *result, gpointer user_data)
 static void huawei_mode_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	int mode, submode;
 
@@ -1134,7 +1120,7 @@ static void huawei_mode_notify(GAtResult *result, gpointer user_data)
 static void huawei_hcsq_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	const char *mode;
 
@@ -1155,7 +1141,7 @@ static void huawei_hcsq_notify(GAtResult *result, gpointer user_data)
 static void huawei_nwtime_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int year, mon, mday, hour, min, sec;
 	char tz[4];
 	const char *date, *time, *dst;
@@ -1233,7 +1219,7 @@ static void csq_cb(gboolean ok, GAtResult *result, gpointer user_data)
 void at_signal_strength(struct ofono_netreg *netreg,
 				ofono_netreg_strength_cb_t cb, void *data)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct cb_data *cbd = cb_data_new(cb, data);
 
 	cbd->user = nd;
@@ -1260,7 +1246,7 @@ void at_signal_strength(struct ofono_netreg *netreg,
 static void mbm_etzv_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	int year, mon, mday, hour, min, sec;
 	const char *tz, *time, *timestamp;
 	GAtResultIter iter;
@@ -1309,7 +1295,7 @@ static void mbm_etzv_notify(GAtResult *result, gpointer user_data)
 static void mbm_erinfo_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	int mode, gsm, umts;
 
@@ -1361,7 +1347,7 @@ static void mbm_erinfo_notify(GAtResult *result, gpointer user_data)
 static void icera_nwstate_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	const char *mccmnc, *tech, *state;
 	int rssi;
@@ -1429,7 +1415,7 @@ static int cnti_to_tech(const char *cnti)
 static void gobi_cnti_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	const char *tech;
 	int option;
@@ -1454,7 +1440,7 @@ static void gobi_cnti_notify(GAtResult *result, gpointer user_data)
 static void nw_cnti_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	const char *tech;
 	int option;
@@ -1480,7 +1466,7 @@ static void cnti_query_tech_cb(gboolean ok, GAtResult *result,
 						gpointer user_data)
 {
 	struct tech_query *tq = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(tq->netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(tq->netreg);
 
 	ofono_netreg_status_notify(tq->netreg,
 			tq->status, tq->lac, tq->ci, nd->tech);
@@ -1520,7 +1506,7 @@ static void creg_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
 	int status, lac, ci, tech;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	struct tech_query *tq;
 
 	if (at_util_parse_reg_unsolicited(result, "+CREG:", &status,
@@ -1589,7 +1575,7 @@ static void at_cmer_not_supported(struct ofono_netreg *netreg)
 static void at_cmer_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	if (!ok) {
 		at_cmer_not_supported(netreg);
@@ -1648,7 +1634,7 @@ static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap,
 }
 
 static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
-					struct netreg_data *nd)
+					struct at_netreg_data *nd)
 {
 	const char *ind;
 	int len = sprintf(buf, "AT+CMER=");
@@ -1717,7 +1703,7 @@ static void at_cmer_query_cb(ofono_bool_t ok, GAtResult *result,
 				gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	int cmer_opts_cnt = 5; /* See 27.007 Section 8.10 */
 	int cmer_opts[cmer_opts_cnt];
@@ -1765,7 +1751,7 @@ error:
 static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	GAtResultIter iter;
 	const char *str;
 	char *signal_identifier = "signal";
@@ -1872,7 +1858,7 @@ error:
 static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	if (!ok) {
 		ofono_error("Unable to initialize Network Registration");
@@ -2075,7 +2061,7 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 static void at_creg_test_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_netreg *netreg = user_data;
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 	gint range[2];
 	GAtResultIter iter;
 	int creg1 = 0;
@@ -2123,9 +2109,9 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
 				void *data)
 {
 	GAtChat *chat = data;
-	struct netreg_data *nd;
+	struct at_netreg_data *nd;
 
-	nd = g_new0(struct netreg_data, 1);
+	nd = g_new0(struct at_netreg_data, 1);
 
 	nd->chat = g_at_chat_clone(chat);
 	nd->vendor = vendor;
@@ -2148,7 +2134,7 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
 
 void at_netreg_remove(struct ofono_netreg *netreg)
 {
-	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
 
 	if (nd->nitz_timeout)
 		g_source_remove(nd->nitz_timeout);
diff --git a/drivers/atmodem/network-registration.h b/drivers/atmodem/network-registration.h
index 0f622411..8a5401cf 100644
--- a/drivers/atmodem/network-registration.h
+++ b/drivers/atmodem/network-registration.h
@@ -1,5 +1,19 @@
 #pragma once
 
+struct at_netreg_data {
+	GAtChat *chat;
+	char mcc[OFONO_MAX_MCC_LENGTH + 1];
+	char mnc[OFONO_MAX_MNC_LENGTH + 1];
+	int signal_index; /* If strength is reported via CIND */
+	int signal_min; /* min strength reported via CIND */
+	int signal_max; /* max strength reported via CIND */
+	int signal_invalid; /* invalid strength reported via CIND */
+	int tech;
+	struct ofono_network_time time;
+	guint nitz_timeout;
+	unsigned int vendor;
+};
+
 void at_registration_status(struct ofono_netreg *netreg,
 					ofono_netreg_status_cb_t cb,
 					void *data);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] ublox: network-registration atom
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
  2019-07-18 10:23 ` [PATCH 02/10] atmodem: export struct netreg Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-19  6:40   ` Denis Kenzior
  2019-07-18 10:23 ` [PATCH 04/10] Makefile Jonas Bonn
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 12812 bytes --]

For uBlox modems, a bit of custom setup is required, but after that the
generic "atmodem" (27.007-compatible) method implementations are
sufficient.  This driver, therefore, just puts the custom probe method
into place and defers remaining functionality to the recently exported
atmodem implementations.
---
 drivers/ubloxmodem/network-registration.c | 425 ++++++++++++++++++++++
 drivers/ubloxmodem/ubloxmodem.c           |   2 +
 drivers/ubloxmodem/ubloxmodem.h           |   3 +
 3 files changed, 430 insertions(+)
 create mode 100644 drivers/ubloxmodem/network-registration.c

diff --git a/drivers/ubloxmodem/network-registration.c b/drivers/ubloxmodem/network-registration.c
new file mode 100644
index 00000000..cfd194a9
--- /dev/null
+++ b/drivers/ubloxmodem/network-registration.c
@@ -0,0 +1,425 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010  ST-Ericsson AB.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/netreg.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "common.h"
+#include "ubloxmodem.h"
+#include "drivers/atmodem/vendor.h"
+
+#include "drivers/atmodem/network-registration.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cmer_prefix[] = { "+CMER:", NULL };
+static const char *ureg_prefix[] = { "+UREG:", NULL };
+
+struct netreg_data {
+	struct at_netreg_data at_data;
+
+	const struct ublox_model *model;
+};
+
+struct tech_query {
+	int status;
+	int lac;
+	int ci;
+	struct ofono_netreg *netreg;
+};
+
+static void ciev_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+	int strength, ind;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CIEV:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &ind))
+		return;
+
+	if (ind != nd->signal_index)
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &strength))
+		return;
+
+	if (strength == nd->signal_invalid)
+		strength = -1;
+	else
+		strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+
+	ofono_netreg_strength_notify(netreg, strength);
+}
+
+static gboolean notify_time(gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+
+	nd->nitz_timeout = 0;
+
+	ofono_netreg_time_notify(netreg, &nd->time);
+
+	return FALSE;
+}
+
+static void ctzdst_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+	int dst;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CTZDST:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &dst))
+		return;
+
+	DBG("dst %d", dst);
+
+	nd->time.dst = dst;
+
+	if (nd->nitz_timeout > 0) {
+		g_source_remove(nd->nitz_timeout);
+		nd->nitz_timeout = 0;
+	}
+
+	ofono_netreg_time_notify(netreg, &nd->time);
+}
+
+static void ctzv_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+	int year, mon, mday, hour, min, sec;
+	const char *tz, *time;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CTZV:"))
+		return;
+
+	if (!g_at_result_iter_next_unquoted_string(&iter, &tz))
+		return;
+
+	if (!g_at_result_iter_next_string(&iter, &time))
+		return;
+
+	DBG("tz %s time %s", tz, time);
+
+	if (sscanf(time, "%u/%u/%u,%u:%u:%u", &year, &mon, &mday,
+						&hour, &min, &sec) != 6)
+		return;
+
+	nd->time.sec = sec;
+	nd->time.min = min;
+	nd->time.hour = hour;
+	nd->time.mday = mday;
+	nd->time.mon = mon;
+	nd->time.year = 2000 + year;
+
+	nd->time.utcoff = atoi(tz) * 15 * 60;
+
+	/* Delay notification in case there's a DST update coming */
+	if (nd->nitz_timeout > 0)
+		g_source_remove(nd->nitz_timeout);
+
+	nd->nitz_timeout = g_timeout_add_seconds(1, notify_time, user_data);
+}
+
+static void ctze_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+	int year, mon, mday, hour, min, sec;
+	int dst;
+	const char *tz, *time;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CTZE:"))
+		return;
+
+	if (!g_at_result_iter_next_unquoted_string(&iter, &tz))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &dst))
+		return;
+
+	if (!g_at_result_iter_next_string(&iter, &time))
+		return;
+
+	DBG("tz %s dst %d time %s", tz, dst, time);
+
+	if (sscanf(time, "%u/%u/%u,%u:%u:%u", &year, &mon, &mday,
+						&hour, &min, &sec) != 6)
+		return;
+
+	nd->time.sec = sec;
+	nd->time.min = min;
+	nd->time.hour = hour;
+	nd->time.mday = mday;
+	nd->time.mon = mon;
+	nd->time.year = 2000 + year;
+
+	nd->time.utcoff = atoi(tz) * 15 * 60;
+	nd->time.dst = dst;
+
+	ofono_netreg_time_notify(netreg, &nd->time);
+}
+
+
+static void ublox_query_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct tech_query *tq = user_data;
+	GAtResultIter iter;
+	gint enabled, state;
+	int tech = -1;
+
+	if (!ok)
+		goto error;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+UREG:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &enabled))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &state))
+		return;
+
+	switch (state) {
+	case 4:
+		tech = 5;
+		break;
+	case 5:
+		tech = 4;
+		break;
+	case 8:
+		tech = 1;
+		break;
+	case 9:
+		tech = 2;
+		break;
+	default:
+		tech = state;
+	}
+
+error:
+	ofono_netreg_status_notify(tq->netreg,
+			tq->status, tq->lac, tq->ci, tech);
+}
+
+static void creg_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	int status, lac, ci, tech;
+	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+	struct tech_query *tq;
+
+	if (at_util_parse_reg_unsolicited(result, "+CREG:", &status,
+			&lac, &ci, &tech, OFONO_VENDOR_GENERIC) == FALSE)
+		return;
+
+	if (status != 1 && status != 5)
+		goto notify;
+
+	if (ublox_is_toby_l4(nd->model)) {
+		tq = g_new0(struct tech_query, 1);
+
+		tq->status = status;
+		tq->lac = lac;
+		tq->ci = ci;
+		tq->netreg = netreg;
+
+		if (g_at_chat_send(nd->at_data.chat, "AT+UREG?", ureg_prefix,
+				ublox_query_tech_cb, tq, g_free) > 0)
+			return;
+
+		g_free(tq);
+	}
+
+	if ((status == 1 || status == 5) && tech == -1)
+		tech = nd->at_data.tech;
+
+notify:
+	ofono_netreg_status_notify(netreg, status, lac, ci, tech);
+}
+
+static void at_cmer_not_supported(struct ofono_netreg *netreg)
+{
+	ofono_error("+CMER not supported by this modem.  If this is an error"
+			" please submit patches to support this hardware");
+
+	ofono_netreg_remove(netreg);
+}
+
+static void ublox_cmer_set_cb(gboolean ok,
+				GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+
+	if (!ok) {
+		at_cmer_not_supported(netreg);
+		return;
+	}
+
+	g_at_chat_register(nd->chat, "+CIEV:",
+			ciev_notify, FALSE, netreg, NULL);
+
+	g_at_chat_register(nd->chat, "+CREG:",
+				creg_notify, FALSE, netreg, NULL);
+
+	ofono_netreg_register(netreg);
+}
+
+static void ublox_creg_set_cb(gboolean ok,
+				GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	struct netreg_data *nd = ofono_netreg_get_data(netreg);
+
+	if (!ok) {
+		ofono_error("Unable to initialize Network Registration");
+		ofono_netreg_remove(netreg);
+		return;
+	}
+
+	if (ublox_is_toby_l4(nd->model)) {
+		/* FIXME */
+		ofono_error("TOBY L4 requires polling of ECSQ");
+		ofono_error("TOBY L4 wants UREG notifications for tech updates");
+	}
+
+	/* Register for network time update reports */
+	if (ublox_is_toby_l2(nd->model)) {
+		/* TOBY L2 does not support CTZDST */
+		g_at_chat_register(nd->at_data.chat, "+CTZE:", ctze_notify,
+						FALSE, netreg, NULL);
+		g_at_chat_send(nd->at_data.chat, "AT+CTZR=2", none_prefix,
+						NULL, NULL, NULL);
+	} else {
+		g_at_chat_register(nd->at_data.chat, "+CTZV:", ctzv_notify,
+						FALSE, netreg, NULL);
+		g_at_chat_register(nd->at_data.chat, "+CTZDST:", ctzdst_notify,
+						FALSE, netreg, NULL);
+		g_at_chat_send(nd->at_data.chat, "AT+CTZR=1", none_prefix,
+						NULL, NULL, NULL);
+	}
+
+	/* AT+CMER NOTES:
+	 * - For all u-blox models, mode 3 is equivalent to mode 1;
+	 * since some models do not support setting modes 2 nor 3
+	 * (see UBX-13002752), we prefer mode 1 for all models.
+	 * - The TOBY L4 does not support ind=2
+	 */
+	g_at_chat_send(nd->at_data.chat, "AT+CMER=1,0,0,1", cmer_prefix,
+			ublox_cmer_set_cb, netreg, NULL);
+}
+
+/*
+ * uBlox netreg atom probe.
+ * - takes uBlox model ID parameter instead of AT vendor ID
+ */
+static int ublox_netreg_probe(struct ofono_netreg *netreg,
+				unsigned int model_id,
+				void *data)
+{
+	GAtChat *chat = data;
+	struct netreg_data *nd;
+
+	nd = g_new0(struct netreg_data, 1);
+
+	nd->model = ublox_model_from_id(model_id);
+
+	/* There should be no uBlox-specific quirks in the 'generic'
+	 * AT driver
+	 */
+	nd->at_data.vendor = OFONO_VENDOR_GENERIC;
+
+	nd->at_data.chat = g_at_chat_clone(chat);
+	nd->at_data.tech = -1;
+	nd->at_data.time.sec = -1;
+	nd->at_data.time.min = -1;
+	nd->at_data.time.hour = -1;
+	nd->at_data.time.mday = -1;
+	nd->at_data.time.mon = -1;
+	nd->at_data.time.year = -1;
+	nd->at_data.time.dst = 0;
+	nd->at_data.time.utcoff = 0;
+	ofono_netreg_set_data(netreg, nd);
+
+	/* All uBlox devices support n=2 so no need to query this */
+	g_at_chat_send(nd->at_data.chat, "AT+CREG=2", none_prefix,
+			ublox_creg_set_cb, netreg, NULL);
+
+	return 0;
+}
+
+static const struct ofono_netreg_driver driver = {
+	.name				= "ubloxmodem",
+	.probe				= ublox_netreg_probe,
+	.remove				= at_netreg_remove,
+	.registration_status		= at_registration_status,
+	.current_operator		= at_current_operator,
+	.list_operators			= at_list_operators,
+	.register_auto			= at_register_auto,
+	.register_manual		= at_register_manual,
+	.strength			= at_signal_strength,
+};
+
+void ublox_netreg_init(void)
+{
+	ofono_netreg_driver_register(&driver);
+}
+
+void ublox_netreg_exit(void)
+{
+	ofono_netreg_driver_unregister(&driver);
+}
diff --git a/drivers/ubloxmodem/ubloxmodem.c b/drivers/ubloxmodem/ubloxmodem.c
index a52a67ea..719c77a0 100644
--- a/drivers/ubloxmodem/ubloxmodem.c
+++ b/drivers/ubloxmodem/ubloxmodem.c
@@ -115,6 +115,7 @@ int ublox_is_toby_l4(const struct ublox_model *model)
 static int ubloxmodem_init(void)
 {
 	ublox_gprs_context_init();
+	ublox_netreg_init();
 	ublox_netmon_init();
 	ublox_lte_init();
 
@@ -124,6 +125,7 @@ static int ubloxmodem_init(void)
 static void ubloxmodem_exit(void)
 {
 	ublox_gprs_context_exit();
+	ublox_netreg_exit();
 	ublox_netmon_exit();
 	ublox_lte_exit();
 }
diff --git a/drivers/ubloxmodem/ubloxmodem.h b/drivers/ubloxmodem/ubloxmodem.h
index 2c5b7433..81fe9481 100644
--- a/drivers/ubloxmodem/ubloxmodem.h
+++ b/drivers/ubloxmodem/ubloxmodem.h
@@ -43,6 +43,9 @@ int ublox_is_toby_l4(const struct ublox_model *model);
 extern void ublox_gprs_context_init(void);
 extern void ublox_gprs_context_exit(void);
 
+void ublox_netreg_init(void);
+void ublox_netreg_exit(void);
+
 extern void ublox_netmon_init(void);
 extern void ublox_netmon_exit(void);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] Makefile
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
  2019-07-18 10:23 ` [PATCH 02/10] atmodem: export struct netreg Jonas Bonn
  2019-07-18 10:23 ` [PATCH 03/10] ublox: network-registration atom Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 05/10] ublox: use custom netreg atom Jonas Bonn
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]

---
 Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 39777abc..7fb45d35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -471,6 +471,7 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/ubloxmodem/ubloxmodem.h \
 			drivers/ubloxmodem/ubloxmodem.c \
 			drivers/ubloxmodem/gprs-context.c \
+			drivers/ubloxmodem/network-registration.c \
 			drivers/ubloxmodem/netmon.c \
 			drivers/ubloxmodem/lte.c
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] ublox: use custom netreg atom
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (2 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 04/10] Makefile Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 06/10] ublox: determine gprs-context driver from network interface Jonas Bonn
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

---
 plugins/ublox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index ff08a6a1..918bd3ec 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -399,7 +399,8 @@ static void ublox_post_online(struct ofono_modem *modem)
 {
 	struct ublox_data *data = ofono_modem_get_data(modem);
 
-	ofono_netreg_create(modem, data->vendor_family, "atmodem", data->aux);
+	ofono_netreg_create(modem,
+		ublox_model_to_id(data->model), "ubloxmodem", data->aux);
 
 	ofono_netmon_create(modem, data->vendor_family, "ubloxmodem", data->aux);
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] ublox: determine gprs-context driver from network interface
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (3 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 05/10] ublox: use custom netreg atom Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-19  6:43   ` Denis Kenzior
  2019-07-18 10:23 ` [PATCH 07/10] ublox: create only 1 gprs context Jonas Bonn
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1571 bytes --]

Some u-blox devices present a USB network class device for data and some
just switch to PPP on (one of) the communication channel(s).  Whether
the atmodem or ubloxmodem gprs-context driver should be used depends on
whether or not the network interface is present; check this condition
directly when deciding which driver to us.
---
 plugins/ublox.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 918bd3ec..c6ff7eaa 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -359,6 +359,7 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	const char *driver;
 	/* Toby L2: Create same number of contexts as supported PDP contexts. */
 	int ncontexts = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ? 8 : 1;
+	const char *iface;
 	int variant;
 
 	DBG("%p", modem);
@@ -366,17 +367,10 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	gprs = ofono_gprs_create(modem, data->vendor_family, "atmodem",
 					data->aux);
 
-	if (ublox_is_toby_l4(data->model)) {
+	iface = ofono_modem_get_string(modem, "NetworkInterface");
+	if (iface) {
 		driver = "ubloxmodem";
 		variant = ublox_model_to_id(data->model);
-	} else if (ublox_is_toby_l2(data->model)) {
-		if (data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE) {
-			driver = "ubloxmodem";
-			variant = ublox_model_to_id(data->model);
-		} else {
-			driver = "atmodem";
-			variant = OFONO_VENDOR_UBLOX;
-		}
 	} else {
 		driver = "atmodem";
 		variant = OFONO_VENDOR_UBLOX;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] ublox: create only 1 gprs context
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (4 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 06/10] ublox: determine gprs-context driver from network interface Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 08/10] ublox: add voicecall support Jonas Bonn
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1546 bytes --]

Some uBlox modems support multiple, simultaneously active contexts.  These
contexts are either bridged to the network interface or handled
transparently by the modem acting like a router.

The problem with this approach is that ofono and ofono clients (e.g.
mmsd) expect a dedicated _local_ network interface for each context.

As such, it doesn't make sense for ofono to set up the multiple gprs
contexts.
---
 plugins/ublox.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index c6ff7eaa..1da7101e 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -357,8 +357,6 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs_context *gc;
 	GAtChat *chat = data->modem ? data->modem : data->aux;
 	const char *driver;
-	/* Toby L2: Create same number of contexts as supported PDP contexts. */
-	int ncontexts = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ? 8 : 1;
 	const char *iface;
 	int variant;
 
@@ -376,14 +374,9 @@ static void ublox_post_sim(struct ofono_modem *modem)
 		variant = OFONO_VENDOR_UBLOX;
 	}
 
-	while (ncontexts) {
-		gc = ofono_gprs_context_create(modem, variant, driver, chat);
-
-		if (gprs && gc)
-			ofono_gprs_add_context(gprs, gc);
-
-		--ncontexts;
-	}
+	gc = ofono_gprs_context_create(modem, variant, driver, chat);
+	if (gprs && gc)
+		ofono_gprs_add_context(gprs, gc);
 
 	ofono_lte_create(modem,
 		ublox_model_to_id(data->model), "ubloxmodem", data->aux);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] ublox: add voicecall support
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (5 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 07/10] ublox: create only 1 gprs context Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 09/10] ublox: add SMS support Jonas Bonn
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]

---
 plugins/ublox.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 1da7101e..6e867666 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -41,6 +41,12 @@
 #include <ofono/netmon.h>
 #include <ofono/lte.h>
 #include <ofono/voicecall.h>
+#include <ofono/call-forwarding.h>
+#include <ofono/call-settings.h>
+#include <ofono/call-meter.h>
+#include <ofono/call-barring.h>
+#include <ofono/message-waiting.h>
+#include <ofono/ussd.h>
 
 #include <drivers/atmodem/vendor.h>
 #include <drivers/ubloxmodem/ubloxmodem.h>
@@ -356,6 +362,7 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	GAtChat *chat = data->modem ? data->modem : data->aux;
+	struct ofono_message_waiting *mw;
 	const char *driver;
 	const char *iface;
 	int variant;
@@ -380,6 +387,16 @@ static void ublox_post_sim(struct ofono_modem *modem)
 
 	ofono_lte_create(modem,
 		ublox_model_to_id(data->model), "ubloxmodem", data->aux);
+
+	ofono_ussd_create(modem, 0, "atmodem", data->aux);
+	ofono_call_forwarding_create(modem, 0, "atmodem", data->aux);
+	ofono_call_settings_create(modem, 0, "atmodem", data->aux);
+	ofono_call_meter_create(modem, 0, "atmodem", data->aux);
+	ofono_call_barring_create(modem, 0, "atmodem", data->aux);
+
+	mw = ofono_message_waiting_create(modem);
+	if (mw)
+		ofono_message_waiting_register(mw);
 }
 
 static void ublox_post_online(struct ofono_modem *modem)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] ublox: add SMS support
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (6 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 08/10] ublox: add voicecall support Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-18 10:23 ` [PATCH 10/10] ublox: be explicit about lack of IPv6 Jonas Bonn
  2019-07-19  6:40 ` [PATCH 01/10] atmodem: export generic netreg funcs Denis Kenzior
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

---
 plugins/ublox.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 6e867666..b65bc52a 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -40,6 +40,7 @@
 #include <ofono/gprs-context.h>
 #include <ofono/netmon.h>
 #include <ofono/lte.h>
+#include <ofono/sms.h>
 #include <ofono/voicecall.h>
 #include <ofono/call-forwarding.h>
 #include <ofono/call-settings.h>
@@ -388,6 +389,8 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	ofono_lte_create(modem,
 		ublox_model_to_id(data->model), "ubloxmodem", data->aux);
 
+	ofono_sms_create(modem, 0, "atmodem", data->aux);
+
 	ofono_ussd_create(modem, 0, "atmodem", data->aux);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->aux);
 	ofono_call_settings_create(modem, 0, "atmodem", data->aux);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] ublox: be explicit about lack of IPv6
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (7 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 09/10] ublox: add SMS support Jonas Bonn
@ 2019-07-18 10:23 ` Jonas Bonn
  2019-07-19  6:40 ` [PATCH 01/10] atmodem: export generic netreg funcs Denis Kenzior
  9 siblings, 0 replies; 13+ messages in thread
From: Jonas Bonn @ 2019-07-18 10:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

The TOBY L4 has no IPv6 support whatsoever.
---
 drivers/ubloxmodem/gprs-context.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/ubloxmodem/gprs-context.c b/drivers/ubloxmodem/gprs-context.c
index c5b789b6..ff78a42a 100644
--- a/drivers/ubloxmodem/gprs-context.c
+++ b/drivers/ubloxmodem/gprs-context.c
@@ -388,6 +388,14 @@ static void ublox_gprs_activate_primary(struct ofono_gprs_context *gc,
 {
 	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
 
+	if (ublox_is_toby_l4(gcd->model)) {
+		/* TOBY L4 does not support IPv6 */
+		if (ctx->proto != OFONO_GPRS_PROTO_IP) {
+			CALLBACK_WITH_FAILURE(cb, data);
+			return;
+		}
+	}
+
 	/* IPv6 support not implemented */
 	if (ctx->proto != OFONO_GPRS_PROTO_IP) {
 		CALLBACK_WITH_FAILURE(cb, data);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 03/10] ublox: network-registration atom
  2019-07-18 10:23 ` [PATCH 03/10] ublox: network-registration atom Jonas Bonn
@ 2019-07-19  6:40   ` Denis Kenzior
  0 siblings, 0 replies; 13+ messages in thread
From: Denis Kenzior @ 2019-07-19  6:40 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1949 bytes --]

On 7/18/19 5:23 AM, Jonas Bonn wrote:
> For uBlox modems, a bit of custom setup is required, but after that the
> generic "atmodem" (27.007-compatible) method implementations are
> sufficient.  This driver, therefore, just puts the custom probe method
> into place and defers remaining functionality to the recently exported
> atmodem implementations.
> ---
>   drivers/ubloxmodem/network-registration.c | 425 ++++++++++++++++++++++
>   drivers/ubloxmodem/ubloxmodem.c           |   2 +
>   drivers/ubloxmodem/ubloxmodem.h           |   3 +
>   3 files changed, 430 insertions(+)
>   create mode 100644 drivers/ubloxmodem/network-registration.c
> 

Also, please squash patch 4 into this one.

> diff --git a/drivers/ubloxmodem/network-registration.c b/drivers/ubloxmodem/network-registration.c
> new file mode 100644
> index 00000000..cfd194a9
> --- /dev/null
> +++ b/drivers/ubloxmodem/network-registration.c
> @@ -0,0 +1,425 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2010  ST-Ericsson AB.

Do you want to maybe update the copyrights for this new file?

> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +

Regards,
-Denis

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 01/10] atmodem: export generic netreg funcs
  2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
                   ` (8 preceding siblings ...)
  2019-07-18 10:23 ` [PATCH 10/10] ublox: be explicit about lack of IPv6 Jonas Bonn
@ 2019-07-19  6:40 ` Denis Kenzior
  9 siblings, 0 replies; 13+ messages in thread
From: Denis Kenzior @ 2019-07-19  6:40 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]

Hi Jonas,

On 7/18/19 5:23 AM, Jonas Bonn wrote:
> An upcoming netreg driver for uBlox modems will need to override the
> probe method in order to set itself up, but for further functionality
> the "generic" AT implementations are sufficient.  The easiest way to do
> this is to just set up a vtable with a custom probe implementation and
> defer all other methods to the common/generic methods.
> 
> The problem is that the AT methods are not actually exported.  This
> generic AT functionality was not intended to be hooked directly into
> other drivers.
> 
> This patch exports all the methods of the atmodem network-registration
> driver implementation so that they can be used as generic/common
> implementations for other drivers.
> ---
>   drivers/atmodem/network-registration.c | 16 +++++++++-------
>   drivers/atmodem/network-registration.h | 17 +++++++++++++++++
>   2 files changed, 26 insertions(+), 7 deletions(-)
>   create mode 100644 drivers/atmodem/network-registration.h
> 

Patches 1 & 2 applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 06/10] ublox: determine gprs-context driver from network interface
  2019-07-18 10:23 ` [PATCH 06/10] ublox: determine gprs-context driver from network interface Jonas Bonn
@ 2019-07-19  6:43   ` Denis Kenzior
  0 siblings, 0 replies; 13+ messages in thread
From: Denis Kenzior @ 2019-07-19  6:43 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

Hi Jonas,

On 7/18/19 5:23 AM, Jonas Bonn wrote:
> Some u-blox devices present a USB network class device for data and some
> just switch to PPP on (one of) the communication channel(s).  Whether
> the atmodem or ubloxmodem gprs-context driver should be used depends on
> whether or not the network interface is present; check this condition
> directly when deciding which driver to us.
> ---
>   plugins/ublox.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
> 

Patches 6-10 applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-07-19  6:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18 10:23 [PATCH 01/10] atmodem: export generic netreg funcs Jonas Bonn
2019-07-18 10:23 ` [PATCH 02/10] atmodem: export struct netreg Jonas Bonn
2019-07-18 10:23 ` [PATCH 03/10] ublox: network-registration atom Jonas Bonn
2019-07-19  6:40   ` Denis Kenzior
2019-07-18 10:23 ` [PATCH 04/10] Makefile Jonas Bonn
2019-07-18 10:23 ` [PATCH 05/10] ublox: use custom netreg atom Jonas Bonn
2019-07-18 10:23 ` [PATCH 06/10] ublox: determine gprs-context driver from network interface Jonas Bonn
2019-07-19  6:43   ` Denis Kenzior
2019-07-18 10:23 ` [PATCH 07/10] ublox: create only 1 gprs context Jonas Bonn
2019-07-18 10:23 ` [PATCH 08/10] ublox: add voicecall support Jonas Bonn
2019-07-18 10:23 ` [PATCH 09/10] ublox: add SMS support Jonas Bonn
2019-07-18 10:23 ` [PATCH 10/10] ublox: be explicit about lack of IPv6 Jonas Bonn
2019-07-19  6:40 ` [PATCH 01/10] atmodem: export generic netreg funcs Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.