From: Tom Nguyen <[email protected]>
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
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono