Skip to contentSkip to conversation

ublox: netreg: reuse at_registration_status

PATCH Applied [email protected] 2 participants 2 messages Feb 4, 2020 – Feb 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ublox: netreg: reuse at_registration_status

From: Richard Röjfors <[email protected]>

Instead of implementing an own copy of requesting and parsing CREG, reuse the existing one from at-modem.

---
 drivers/ubloxmodem/network-registration.c | 40 +++++++++--------------
 1 file changed, 16 insertions(+), 24 deletions(-)
drivers/ubloxmodem/network-registration.c +16 -24
index 25f239a6..6a524f47 100644
@@ -48,7 +48,6 @@
 static const char *none_prefix[] = { NULL };
 static const char *cmer_prefix[] = { "+CMER:", NULL };
 static const char *ureg_prefix[] = { "+UREG:", NULL };
-static const char *creg_prefix[] = { "+CREG:", NULL };
 
 struct netreg_data {
 	struct at_netreg_data at_data;
@@ -249,30 +248,28 @@ static gboolean is_registered(int status)
 		status == NETWORK_REGISTRATION_STATUS_ROAMING;
 }
 
-static void ublox_creg_cb(gboolean ok, GAtResult *result,
-				gpointer user_data)
+static void registration_status_cb(const struct ofono_error *error,
+				   int status, int lac, int ci, int tech,
+				   void *user_data)
 {
 	struct tech_query *tq = user_data;
 	struct netreg_data *nd = ofono_netreg_get_data(tq->netreg);
-	int status;
-	int lac;
-	int ci;
-	int tech;
-
-	nd->updating_status = false;
-
-	if (!ok)
-		return;
-
-	if (at_util_parse_reg(result, "+CREG:", NULL, &status,
-				&lac, &ci, &tech, OFONO_VENDOR_GENERIC) == FALSE)
-		return;
+	struct ofono_netreg *netreg = tq->netreg;
 
 	/* The query provided a tech, use that */
 	if (is_registered(status) && tq->tech != -1)
 		tech = tq->tech;
 
-	ofono_netreg_status_notify(tq->netreg, status, lac, ci, tech);
+	g_free(tq);
+
+	nd->updating_status = false;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		DBG("Error during registration status query");
+		return;
+	}
+
+	ofono_netreg_status_notify(netreg, status, lac, ci, tech);
 }
 
 static void ublox_ureg_cb(gboolean ok, GAtResult *result,
@@ -334,13 +331,8 @@ static void ureg_notify(GAtResult *result, gpointer user_data)
 	tq->tech = ublox_ureg_state_to_tech(state);
 	tq->netreg = netreg;
 
-	if (g_at_chat_send(nd->at_data.chat, "AT+CREG?", creg_prefix,
-			ublox_creg_cb, tq, g_free) > 0) {
-		nd->updating_status = true;
-		return;
-	}
-
-	g_free(tq);
+	nd->updating_status = true;
+	at_registration_status(netreg, registration_status_cb, tq);
 }
 
 static void creg_notify(GAtResult *result, gpointer user_data)
Signature · 1 line
2.20.1
#1 lore raw

Hi Richard,

Quoted 8 lines · richard.rojfors(a)gmail.com

From: Richard Röjfors <[email protected]>

Instead of implementing an own copy of requesting and parsing CREG, reuse the existing one from at-modem.

---
  drivers/ubloxmodem/network-registration.c | 40 +++++++++--------------
  1 file changed, 16 insertions(+), 24 deletions(-)

Applied, thanks.

Regards,
-Denis