AT-Mode: how not to overwrite OTAA config when uploading new firmware (DevEui, etc)

I am using AT-mode (LORAWAN_AT_SUPPORT => on) on a HTCC-AB01. I configure the board with AT-Commands:

AT+DevEui=XXXX
AT+AppEui=YYYY
AT+AppKey=ZZZZ
AT+RESET=1

The problem I have is that after a FW-Update, the settings are gone!

Do I have to a duplicate of these configuration settings in flash (I already have some other configs that I read and these are not lost when doing a FW-Update)?

I now save the OTAA-params in flash also and it works for me. Maybe there is an easier solution, but at least it works.

Variable declaration without initialization:

/* OTAA para*/
uint8_t devEui[8];
uint8_t appEui[8];
uint8_t appKey[16];

In setup function:

  // read config_data from flash...
  ReadConfigDataFromFlash();
  memcpy(devEui, config_data.devEui, sizeof(config_data.devEui));
  memcpy(appEui, config_data.appEui, sizeof(config_data.appEui));
  memcpy(appKey, config_data.appKey, sizeof(config_data.appKey));

User command to write to flash:

  if (strcmp(cmd, "SAVE_OTAA_CONFIG") == 0)
  {
    if (content[0] == '1')
    {
      memcpy(config_data.devEui, devEui, sizeof(devEui));
      memcpy(config_data.appEui, appEui, sizeof(appEui));
      memcpy(config_data.appKey, appKey, sizeof(appKey));
      WriteConfigDataToFlash();
      Serial.printf("saved OTAA configuration to flash\n");
    }
    return true;
  }
1 Like

hi,

Thank you for you sharing.

We will also update the corresponding routines in the near future.