Why can't I get the ICCID number from 9160's modem on the ncs1.9.0 sdk?

After upgrading the SDK from 1.2.0 to 1.9.0, I found a problem: the ICCID numbers that could be read are now unreadable! I still use the AT instruction "AT% XICCID" to read, and it returns an error prompt. Why? The IMEI number and IMSI number can still be read.

my modem fw is V1.3.1,and this is my function:

#define CMD_GET_IMEI	"AT+CGSN"
#define CMD_GET_IMSI	"AT+CIMI"
#define CMD_GET_ICCID	"AT%XICCID"

void func(void)
{
    ...
    
	if(nrf_modem_at_cmd(tmpbuf, sizeof(tmpbuf), CMD_GET_IMEI) == 0)
	{
	#ifdef NB_DEBUG
		LOGD("imei:%s", tmpbuf);
	#endif
		strncpy(g_imei, tmpbuf, IMEI_MAX_LEN);
	}

	if(nrf_modem_at_cmd(tmpbuf, sizeof(tmpbuf), CMD_GET_IMSI) == 0)
	{
	#ifdef NB_DEBUG
		LOGD("imsi:%s", tmpbuf);
	#endif
		strncpy(g_imsi, tmpbuf, IMSI_MAX_LEN);
	}

	if(nrf_modem_at_cmd(tmpbuf, sizeof(tmpbuf), CMD_GET_ICCID) == 0)
	{
	#ifdef NB_DEBUG
		LOGD("iccid:%s", &tmpbuf[9]);
	#endif
		strncpy(g_iccid, &tmpbuf[9], ICCID_MAX_LEN);
	}
	
	...
	
}

Parents Reply Children
  • nrf_modem_at_cmd(buf, buf_len, fmt, ...) is expecting a text string that can be formatted.

    #define CMD_GET_ICCID    "AT%XICCID"

    must be changed to

    #define CMD_GET_ICCID    "AT%%XICCID"

    Please note the double '%'.

    We tried MFW 1.3.1 locally, and AT%XICCID seems to work(after having activated with AT+CFUN=1. Before activiating, the modem responds with 'ERROR', however, this is also true for AT+CIMI, like you probably know.

    duxinglang said:
    "AT+CRSM=176,12258,0,0,10"

    This will flip the bytes compared to AT%XICCID, e.g. +CRSM: <>,<>,"214365..." vs. %XICCID: 123456... So if you choose to use CRSM you would have to flip them back in the application.

  • Thank you for your reply. I added an additional% symbol to the instruction as you said. Now I can get the iccid number. It seems that I will change all the instructions that used to contain the '%' symbol into a double '%'.

  • I changed to %% but i still seem to have the issue,

    char *device_config_get_iccid(dev_config_shadow_id_t attribute)
    {
        nrf_modem_init();
        modem_info_init();
        char response[256];
        int response_size = sizeof(response);
        nrf_modem_at_cmd(response, response_size, "AT+CFUN=1");
        k_msleep(100);
        int result= nrf_modem_at_cmd(response, response_size, "AT%%XICCID");
       
        char *allocated_response = (char *) malloc(response_size);
        if (allocated_response == NULL) {
            // Error handling for malloc failure
            return NULL;
        }
       
        memcpy(allocated_response, response, response_size);
        return allocated_response;
    }
    Can someone help?
Related