Reset LMIC on AT command provisioning

This commit is contained in:
Manuel Bleichenbacher 2018-07-23 15:29:37 +02:00
parent 3e084a4ed9
commit 3a6d4a6501
2 changed files with 12 additions and 3 deletions

View File

@ -222,12 +222,12 @@ void onEvent (ev_t ev) {
} }
else if (clientAction == eActionJoining) else if (clientAction == eActionJoining)
{ {
if (ev != EV_JOINED && EV_REJOIN_FAILED) if (ev != EV_JOINED && ev != EV_REJOIN_FAILED && ev != EV_RESET)
return; return;
} }
else else
{ {
if (ev != EV_TXCOMPLETE && ev != EV_LINK_DEAD) if (ev != EV_TXCOMPLETE && ev != EV_LINK_DEAD && ev != EV_RESET)
return; return;
} }

View File

@ -16,6 +16,8 @@
#include "esp_log.h" #include "esp_log.h"
#include "nvs_flash.h" #include "nvs_flash.h"
#include "provisioning.h" #include "provisioning.h"
#include "lmic.h"
#include "hal_esp32.h"
#define UART_NUM CONFIG_TTN_PROVISION_UART_NUM #define UART_NUM CONFIG_TTN_PROVISION_UART_NUM
#define MAX_LINE_LENGTH 128 #define MAX_LINE_LENGTH 128
@ -212,13 +214,20 @@ void provisioning_process_line()
line_buf[24] = 0; line_buf[24] = 0;
line_buf[41] = 0; line_buf[41] = 0;
is_ok = provisioning_decode_keys(line_buf + 8, line_buf + 25, line_buf + 42); is_ok = provisioning_decode_keys(line_buf + 8, line_buf + 25, line_buf + 42);
if (is_ok)
{
hal_enterCriticalSection();
LMIC_reset();
hal_leaveCriticalSection();
onEvent(EV_RESET);
}
} }
else else
{ {
is_ok = false; is_ok = false;
} }
} }
else else if (strcmp(line_buf, "AT") != 0)
{ {
is_ok = false; is_ok = false;
} }