 
   uint32_t seq_no;
 
-#define FLAG_SESSION_VARS_SET (1 << 0) // Set of DevAddr, NwkSKey, and AppSKey set.
+// Flag bit #0 used to mean something. To reuse it, bump the format number.
+#define FLAG_DEV_ADDR_SET (1 << 4)
   u1_t DevAddr[4];
+#define FLAG_NWK_SKEY_SET (1 << 5)
   u1_t NwkSKey[16];
+#define FLAG_APP_SKEY_SET (1 << 6)
   u1_t AppSKey[16];
+#define FLAG_SESSION_VARS_SET (FLAG_DEV_ADDR_SET | FLAG_NWK_SKEY_SET | FLAG_APP_SKEY_SET)
 
 // Separate set flags because BLE can't send all at once
 #define FLAG_APP_KEY_SET (1 << 1)

    static const PROGMEM u1_t devaddr[] = DEVADDR;
    static_assert(sizeof(settings.DevAddr) == sizeof(devaddr), "DEVADDR needs to be 4 bytes");
    _memcpy(settings.DevAddr, devaddr, sizeof(settings.DevAddr));
  #endif
  #if defined(APPSKEY)
    static const PROGMEM u1_t appskey[] = APPSKEY;
    static_assert(sizeof(settings.AppSKey) == sizeof(appskey), "APPSKEY needs to be 16 bytes");
    _memcpy(settings.AppSKey, appskey, sizeof(settings.AppSKey));
  #endif
  #if defined(NWKSKEY)
    static const PROGMEM u1_t nwkskey[] = NWKSKEY;
    static_assert(sizeof(settings.NwkSKey) == sizeof(nwkskey), "NWKSKEY needs to be 16 bytes");
    _memcpy(settings.NwkSKey, nwkskey, sizeof(settings.NwkSKey));
  #endif
  #if defined(DEVADDR) && defined(APPSKEY) && defined(NWKSKEY)
    settings.flags |= FLAG_SESSION_VARS_SET;
    write = true;
  #endif


  u1_t AppEUI[8];
#define FLAG_DEV_EUI_SET (1 << 3)
  u1_t DevEUI[8];
#define FLAG_JOIN_VARS_SET (FLAG_APP_KEY_SET | FLAG_APP_EUI_SET | FLAG_DEV_EUI_SET)
} PersistentSettings;

PersistentSettings settings;
