Hello,
This ticket actually build upon the previous ticket I did here Possible Bug: Cellular modem sample with nRF9151 running SLM.
To recap, running cellular modem sample on nRF54L15 and communicating with Thingy91x that is running on SLM, the communication in detail is described in the previous ticket.
Basically, when running the cellular modem sample, the fetching of modem information is successful, however the fetching of SIM information is not. Namely, the ICCID and IMSI are always empty.
I think this is a bug as if you take a look in modem_cellular.c, the code is waiting to match +ICCID:, whereas for nRF91 we use command %XICCID. I fixed this issue by changing this and also adding a script cmd define, please have a look at the diff for modem_cellular.c
>git diff HEAD^
diff --git a/drivers/modem/modem_cellular.c b/drivers/modem/modem_cellular.c
index 826240beab9..1bd34ef11a9 100644
--- a/drivers/modem/modem_cellular.c
+++ b/drivers/modem/modem_cellular.c
@@ -498,7 +498,7 @@ MODEM_CHAT_MATCH_DEFINE(cgmm_match, "", "", modem_cellular_chat_on_cgmm);
MODEM_CHAT_MATCH_DEFINE(csq_match, "+CSQ: ", ",", modem_cellular_chat_on_csq);
MODEM_CHAT_MATCH_DEFINE(cesq_match, "+CESQ: ", ",", modem_cellular_chat_on_cesq);
MODEM_CHAT_MATCH_DEFINE(qccid_match __maybe_unused, "+QCCID: ", "", modem_cellular_chat_on_iccid);
-MODEM_CHAT_MATCH_DEFINE(iccid_match __maybe_unused, "+ICCID: ", "", modem_cellular_chat_on_iccid);
+MODEM_CHAT_MATCH_DEFINE(iccid_match, "%XICCID: ", "", modem_cellular_chat_on_iccid);
MODEM_CHAT_MATCH_DEFINE(cimi_match __maybe_unused, "", "", modem_cellular_chat_on_imsi);
MODEM_CHAT_MATCH_DEFINE(cgmi_match __maybe_unused, "", "", modem_cellular_chat_on_cgmi);
MODEM_CHAT_MATCH_DEFINE(cgmr_match __maybe_unused, "", "", modem_cellular_chat_on_cgmr);
@@ -1518,6 +1518,11 @@ static inline int modem_cellular_csq_parse_rssi(uint8_t rssi, int16_t *value)
return 0;
}
+MODEM_CHAT_SCRIPT_CMDS_DEFINE(get_iccid_chat_script_cmds,
+ MODEM_CHAT_SCRIPT_CMD_RESP("AT%XICCID", iccid_match));
+MODEM_CHAT_SCRIPT_DEFINE(get_iccid_chat_script, get_iccid_chat_script_cmds, abort_matches,
+modem_cellular_chat_callback_handler, 2);
+
MODEM_CHAT_SCRIPT_CMDS_DEFINE(get_signal_cesq_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CESQ", cesq_match),
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match));
@@ -1573,7 +1578,6 @@ static int modem_cellular_get_signal(const struct device *dev,
case CELLULAR_SIGNAL_RSRQ:
ret = modem_chat_run_script(&data->chat, &get_signal_cesq_chat_script);
break;
-
default:
ret = -ENOTSUP;
break;
@@ -1630,7 +1634,10 @@ static int modem_cellular_get_modem_info(const struct device *dev,
strncpy(info, &data->model_id[0], MIN(size, sizeof(data->model_id)));
break;
case CELLULAR_MODEM_INFO_SIM_ICCID:
- strncpy(info, &data->iccid[0], MIN(size, sizeof(data->iccid)));
+ ret = modem_chat_run_script(&data->chat, &get_iccid_chat_script);
+ if (ret == EXIT_SUCCESS) {
+ strncpy(info, &data->iccid[0], MIN(size, sizeof(data->iccid)));
+ }
break;
default:
ret = -ENODATA;
Not sure if this is the optimal fix, therefore I am raising it here. I haven't fixed the IMSI as I don't need that in my application but probably needs something similar.
Thanks