Can't get ICCID after 0.7.0 update

Hey everyone,

As part of my code I get the ICCID from the electron… the following code worked fine at 0.6.4 but since the latest update to 0.7.0 I get garbage characters…

void getICCID() {

  CellularDevice device;
  memset( & device, 0, sizeof(device));
  device.size = sizeof(device);
  cellular_device_info( & device, NULL);
  Serial.println(device.iccid);
  int N = 4;
  int sublen = strlen(device.iccid) - N;
  memcpy(ICCID, device.iccid + sublen, N);
  ICCID[N] = '\0';
  Serial.print("My ICCID is: ");
  Serial.println(ICCID);

}

Anyone else encounter this?

Thanks,
Peatear

This code works fine for me

        CellularDevice dev;
        cellular_device_info(&dev, NULL);
        String id = spark_deviceID();
        Serial.print("Device ID: ");
        Serial.print(id.c_str());
        Serial.print("\r\n");
        Serial.print("IMEI: ");
        Serial.print(dev.imei);
        Serial.print("\r\n");
        Serial.print("ICCID: ");
        Serial.print(dev.iccid);
        Serial.print("\r\n");
1 Like

When I run that I get the following..

Device ID: 370032000151363131363432
IMEI:
ICCID:

Do you get a cloud connection with that SIM?

Moved the call further down my setup routine, not sure why but my version started working again…

Are you using SYSTEM_THREAD(ENABLED) or a non-AUTOMATIC mode?
This could mean a race condition between powering up the cellular module and your code hitting that block.

1 Like

it’s in SYSTEM_MODE(SEMI_AUTOMATIC);

haven’t messed with the SYSTEM_THREAD…

I guess the question is how do I know that it will always succeed in getting the ICCID…

You can check for Cellular.ready() or just add some extra delay after Cellular.on() before requesting the info.
SYSTEM_MODE(SEMI_AUTOMATIC) comes with the cellular modem off, so you need to switch it on first and wait for it to power up.