save OTAA config in config_data (flash)
This commit is contained in:
parent
fe434b1918
commit
4adaf33835
|
|
@ -12,19 +12,16 @@ BME280 bme280;
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Firmware Version */
|
/* Firmware Version */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
static const int32_t fwVersion = 20210205;
|
static const int32_t fwVersion = 20210206;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* LoraWAN Settings */
|
/* LoraWAN Settings */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/* OTAA para*/
|
/* OTAA para*/
|
||||||
//uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 };
|
uint8_t devEui[8];
|
||||||
//uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
uint8_t appEui[8];
|
||||||
//uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 };
|
uint8_t appKey[16];
|
||||||
uint8_t devEui[] = { 0x00, 0x00, 0xd3, 0xa6, 0x59, 0x83, 0x3b, 0x25 };
|
|
||||||
uint8_t appEui[] = { 0x70, 0xb3, 0xd5, 0x7e, 0xd0, 0x02, 0xe5, 0xab };
|
|
||||||
uint8_t appKey[] = { 0x00, 0x00, 0xd3, 0xa6, 0x59, 0x83, 0x3b, 0x25, 0x00, 0x00, 0xd3, 0xa6, 0x59, 0x83, 0x3b, 0x25 };
|
|
||||||
|
|
||||||
/* ABP para*/
|
/* ABP para*/
|
||||||
uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda, 0x85 };
|
uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda, 0x85 };
|
||||||
|
|
@ -170,6 +167,9 @@ typedef struct {
|
||||||
float cal_a_factor; // 4 Bytes, Kalibrationsfaktor Waegezelle 1
|
float cal_a_factor; // 4 Bytes, Kalibrationsfaktor Waegezelle 1
|
||||||
float cal_b_factor; // 4 Bytes, Kalibrationsfaktor Waegezelle 2
|
float cal_b_factor; // 4 Bytes, Kalibrationsfaktor Waegezelle 2
|
||||||
byte debug_level; // 0 => no debugging, no led, 1 => infos, no led, 2 => infos, 3 => error, 4 => highest level
|
byte debug_level; // 0 => no debugging, no led, 1 => infos, no led, 2 => infos, 3 => error, 4 => highest level
|
||||||
|
uint8_t devEui[8]; // keep OTAA settings so that new fw-updates does not overwrite it
|
||||||
|
uint8_t appEui[8]; // dito
|
||||||
|
uint8_t appKey[16]; // dito
|
||||||
} __attribute__((packed)) CONFIG_data;
|
} __attribute__((packed)) CONFIG_data;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -655,6 +655,19 @@ bool checkUserAt(char *cmd, char *content)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(cmd, "READ_SENSORS") == 0)
|
if (strcmp(cmd, "READ_SENSORS") == 0)
|
||||||
{
|
{
|
||||||
if (content[0] == '?')
|
if (content[0] == '?')
|
||||||
|
|
@ -763,6 +776,10 @@ void setup_platform(void)
|
||||||
|
|
||||||
// read config_data from flash...
|
// read config_data from flash...
|
||||||
ReadConfigDataFromFlash();
|
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));
|
||||||
|
|
||||||
if (config_data.debug_level > 0) {
|
if (config_data.debug_level > 0) {
|
||||||
Serial.printf("Setup_platform, this is the configuration\n");
|
Serial.printf("Setup_platform, this is the configuration\n");
|
||||||
Serial.printf("cal_a_0: %d\n", config_data.cal_a_0);
|
Serial.printf("cal_a_0: %d\n", config_data.cal_a_0);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ func main() {
|
||||||
sendCommand(s, "AT+DevEui="+devEui)
|
sendCommand(s, "AT+DevEui="+devEui)
|
||||||
sendCommand(s, "AT+AppEui="+appEui)
|
sendCommand(s, "AT+AppEui="+appEui)
|
||||||
sendCommand(s, "AT+AppKey="+devEui+devEui)
|
sendCommand(s, "AT+AppKey="+devEui+devEui)
|
||||||
|
sendCommand(s, "AT+SAVE_OTAA_CONFIG=1")
|
||||||
sendCommand(s, "AT+RESET=1")
|
sendCommand(s, "AT+RESET=1")
|
||||||
readSerial(s)
|
readSerial(s)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue