All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qmimodem: return all serial numbers
@ 2019-04-05 16:15 Joshua Watt
  2019-04-05 17:46 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Watt @ 2019-04-05 16:15 UTC (permalink / raw)
  To: ofono

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

From: Tom Nguyen <tom.nguyen@garmin.com>

ESN and MEID are used for CDMA devices. IMEI is used for GSM devices.
Some modems, eg. Quectel EC25E, have variants that support each network
for in various regions. So, the modems may return the ESN, MEID, and
IMEI regardless of the variant. To support this case, the ESN, MEID,
and IMEI should all be reported. Then the user application can decide
which to use.
---
 drivers/qmimodem/devinfo.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/qmimodem/devinfo.c b/drivers/qmimodem/devinfo.c
index af976b77..08e71fdf 100644
--- a/drivers/qmimodem/devinfo.c
+++ b/drivers/qmimodem/devinfo.c
@@ -117,7 +117,10 @@ static void get_ids_cb(struct qmi_result *result, void *user_data)
 {
 	struct cb_data *cbd = user_data;
 	ofono_devinfo_query_cb_t cb = cbd->cb;
-	char *str;
+	char *esn;
+	char *imei;
+	char *meid;
+	char buf[64];
 
 	DBG("");
 
@@ -126,20 +129,22 @@ static void get_ids_cb(struct qmi_result *result, void *user_data)
 		return;
 	}
 
-	str = qmi_result_get_string(result, QMI_DMS_RESULT_ESN);
-	/* Telit qmi modems return a "0" string when ESN is not available. */
-	if (!str || strcmp(str, "0") == 0) {
-		qmi_free(str);
-		str = qmi_result_get_string(result, QMI_DMS_RESULT_IMEI);
-		if (!str) {
-			CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
-			return;
-		}
-	}
-
-	CALLBACK_WITH_SUCCESS(cb, str, cbd->data);
+	esn = qmi_result_get_string(result, QMI_DMS_RESULT_ESN);
+	imei = qmi_result_get_string(result, QMI_DMS_RESULT_IMEI);
+	meid = qmi_result_get_string(result, QMI_DMS_RESULT_MEID);
+
+	if (esn || imei || meid) {
+		sprintf(buf, "ESN:%s,IMEI:%s,MEID:%s",
+					(esn) ? esn : "unknown",
+					(imei) ? imei : "unknown",
+					(meid) ? meid : "unknown");
+		CALLBACK_WITH_SUCCESS(cb, buf, cbd->data);
+	} else
+		CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
 
-	qmi_free(str);
+	qmi_free(esn);
+	qmi_free(imei);
+	qmi_free(meid);
 }
 
 static void qmi_query_serial(struct ofono_devinfo *devinfo,
-- 
2.20.1


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

end of thread, other threads:[~2019-04-05 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <46465886edbd45a3bc563ee11286575f@garmin.com>
2019-04-05 22:04 ` [PATCH] qmimodem: return all serial numbers Denis Kenzior
2019-04-05 16:15 Joshua Watt
2019-04-05 17:46 ` 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.