Commit 21e7c6c5 authored by Guillaume Gonnet's avatar Guillaume Gonnet
Browse files

Save OTAA join response to EEPROM.

parent 8bfc3d37
......@@ -48,6 +48,7 @@ USEMODULE += loramac-crypto
# Application dependencies.
USEMODULE += $(DRIVER)
USEMODULE += random
USEMODULE += periph_eeprom
USEMODULE += periph_uart
......
......@@ -11,23 +11,28 @@ This project is under the MIT license
#include "app.h"
#include <debug.h>
#include <periph/eeprom.h>
// Configure LoRaMAC driver with provider information.
void pvd_otaa_enable(provider_t *pvd)
{
// TODO: read join response and frame counter from EEPROM.
pvd_otta_t *otaa = pvd->data;
uint8_t data[32];
(void)pvd;
// Replay OTAA with join message from EEPROM.
eeprom_read(otaa->eeprom_addr, data, 32);
lorariot_replay_otaa(data);
// TODO: read frame counter from EEPROM.
// lorariot_replay_otaa();
}
// Save frame counter from last uplink message.
void pvd_otaa_update(provider_t *pvd)
{
// TODO.
// TODO: save frame counter.
(void)pvd;
}
......@@ -47,17 +52,16 @@ void pvd_otaa_reset(provider_t *pvd)
PANIC("Can't join network using OTAA");
}
// Save OTAA join response data.
uint8_t *data = loraraiot_retrieve_otaa();
eeprom_write(otaa->eeprom_addr, data, 32);
// TODO: save join response.
(void)data;
// TODO: save frame counter.
// Resend the join message to port 6.
lorariot_mcps_t mcps = LORARIOT_CONFIRMED(DR_0);
// TODO: fill msg with join data.
mcps.buffer = data;
mcps.len = 32;
mcps.port = 10;
lorariot_send(&mcps);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment