All of lore.kernel.org
 help / color / mirror / Atom feed
From: poeschel@lemonage.de
To: ofono@ofono.org
Subject: [PATCH 3/7] quectel: Query the model before setting up the mux
Date: Tue, 26 May 2020 12:16:21 +0200	[thread overview]
Message-ID: <20200526101625.31871-4-poeschel@lemonage.de> (raw)
In-Reply-To: <20200526101625.31871-1-poeschel@lemonage.de>

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

From: Lars Poeschel <poeschel@lemonage.de>

This is a change for the EC21. It will require specific handling before
and right after setting up the mux. So this change prepares this. It
queries the modem model before the mux (CMUX) is activated.
---
 plugins/quectel.c | 86 +++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/plugins/quectel.c b/plugins/quectel.c
index 0f6896b1..1d312c45 100644
--- a/plugins/quectel.c
+++ b/plugins/quectel.c
@@ -765,46 +765,6 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
 		cfun_enable(TRUE, NULL, modem);
 }
 
-static void cgmm_cb(int ok, GAtResult *result, void *user_data)
-{
-	struct ofono_modem *modem = user_data;
-	struct quectel_data *data = ofono_modem_get_data(modem);
-	const char *model;
-
-	DBG("%p ok %d", modem, ok);
-
-	if (!at_util_parse_attr(result, "", &model)) {
-		ofono_error("Failed to query modem model");
-		close_serial(modem);
-		return;
-	}
-
-	if (strcmp(model, "UC15") == 0) {
-		DBG("%p model UC15", modem);
-		data->vendor = OFONO_VENDOR_QUECTEL;
-		data->model = QUECTEL_UC15;
-	} else if (strcmp(model, "Quectel_M95") == 0) {
-		DBG("%p model M95", modem);
-		data->vendor = OFONO_VENDOR_QUECTEL_SERIAL;
-		data->model = QUECTEL_M95;
-	} else if (strcmp(model, "Quectel_MC60") == 0) {
-		DBG("%p model MC60", modem);
-		data->vendor = OFONO_VENDOR_QUECTEL_SERIAL;
-		data->model = QUECTEL_MC60;
-	} else if (strcmp(model, "EC21") == 0) {
-		DBG("%p model EC21", modem);
-		data->vendor = OFONO_VENDOR_QUECTEL;
-		data->model = QUECTEL_EC21;
-	} else {
-		ofono_warn("%p unknown model: '%s'", modem, model);
-		data->vendor = OFONO_VENDOR_QUECTEL;
-		data->model = QUECTEL_UNKNOWN;
-	}
-
-	g_at_chat_send(data->aux, "AT+CFUN?", cfun_prefix, cfun_query, modem,
-			NULL);
-}
-
 static void setup_aux(struct ofono_modem *modem)
 {
 	struct quectel_data *data = ofono_modem_get_data(modem);
@@ -814,7 +774,7 @@ static void setup_aux(struct ofono_modem *modem)
 	g_at_chat_set_slave(data->modem, data->aux);
 	g_at_chat_send(data->aux, "ATE0; &C0; +CMEE=1; +QIURC=0", none_prefix,
 			NULL, NULL, NULL);
-	g_at_chat_send(data->aux, "AT+CGMM", cgmm_prefix, cgmm_cb, modem,
+	g_at_chat_send(data->aux, "AT+CFUN?", cfun_prefix, cfun_query, modem,
 			NULL);
 }
 
@@ -1034,17 +994,57 @@ static void cmux_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	close_serial(modem);
 }
 
-static void ate_cb(int ok, GAtResult *result, void *user_data)
+static void cgmm_cb(int ok, GAtResult *result, void *user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct quectel_data *data = ofono_modem_get_data(modem);
+	const char *model;
 
-	DBG("%p", modem);
+	DBG("%p ok %d", modem, ok);
+
+	if (!at_util_parse_attr(result, "", &model)) {
+		ofono_error("Failed to query modem model");
+		close_serial(modem);
+		return;
+	}
+
+	if (strcmp(model, "UC15") == 0) {
+		DBG("%p model UC15", modem);
+		data->vendor = OFONO_VENDOR_QUECTEL;
+		data->model = QUECTEL_UC15;
+	} else if (strcmp(model, "Quectel_M95") == 0) {
+		DBG("%p model M95", modem);
+		data->vendor = OFONO_VENDOR_QUECTEL_SERIAL;
+		data->model = QUECTEL_M95;
+	} else if (strcmp(model, "Quectel_MC60") == 0) {
+		DBG("%p model MC60", modem);
+		data->vendor = OFONO_VENDOR_QUECTEL_SERIAL;
+		data->model = QUECTEL_MC60;
+	} else if (strcmp(model, "EC21") == 0) {
+		DBG("%p model EC21", modem);
+		data->vendor = OFONO_VENDOR_QUECTEL;
+		data->model = QUECTEL_EC21;
+	} else {
+		ofono_warn("%p unknown model: '%s'", modem, model);
+		data->vendor = OFONO_VENDOR_QUECTEL;
+		data->model = QUECTEL_UNKNOWN;
+	}
 
 	g_at_chat_send(data->uart, "AT+CMUX=0,0,5,127,10,3,30,10,2", NULL,
 			cmux_cb, modem, NULL);
 }
 
+static void ate_cb(int ok, GAtResult *result, void *user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct quectel_data *data = ofono_modem_get_data(modem);
+
+	DBG("%p", modem);
+
+	g_at_chat_send(data->uart, "AT+CGMM", cgmm_prefix, cgmm_cb, modem,
+			NULL);
+}
+
 static void init_cmd_cb(gboolean ok, GAtResult *result, void *user_data)
 {
 	struct ofono_modem *modem = user_data;
-- 
2.26.2

  parent reply	other threads:[~2020-05-26 10:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 10:16 [PATCH 0/7] Add quectel EC21 in serial mode poeschel
2020-05-26 10:16 ` [PATCH 1/7] quectel: Add Quectel EC21 to known serial modems poeschel
2020-05-26 10:16 ` [PATCH 2/7] quectel: use lte atom on EC21 poeschel
2020-05-26 10:16 ` poeschel [this message]
2020-05-26 10:16 ` [PATCH 4/7] quectel: EC21 needs aux channel to be the first mux channel poeschel
2020-05-26 16:14   ` Denis Kenzior
2020-05-27 15:08     ` Lars Poeschel
2020-05-28  9:32       ` [PATCH v2] " poeschel
2020-05-28 16:25         ` Denis Kenzior
2020-05-29 12:43           ` [PATCH v3] " poeschel
2020-05-29 14:58             ` Denis Kenzior
2020-07-24 11:02               ` Lars Poeschel
2020-07-28 16:40                 ` Denis Kenzior
2020-08-04 11:56                   ` [PATCH] Revert "quectel: EC21 needs aux channel to be the first mux channel" poeschel
2020-08-07 16:07                     ` Denis Kenzior
2020-05-26 10:16 ` [PATCH 5/7] quectel: EC21 does not understand AT+QIURC poeschel
2020-05-26 10:16 ` [PATCH 6/7] voicecall: Quectel modem do not understand AT+CNAP poeschel
2020-05-26 10:16 ` [PATCH 7/7] quectel: EC21 add ussd with atmodem driver poeschel
2020-05-26 16:09 ` [PATCH 0/7] Add quectel EC21 in serial mode Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200526101625.31871-4-poeschel@lemonage.de \
    --to=poeschel@lemonage.de \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.