add shutdown_method to ttn in order reduce power consumption while in deep sleep

This commit is contained in:
vrees 2020-05-29 11:26:13 +02:00
parent e29477fa7e
commit ba9c28e038
2 changed files with 18 additions and 0 deletions

View File

@ -72,6 +72,12 @@ public:
*/ */
void reset(); void reset();
/**
* @brief Shutdown the LoRaWAN radio and reduce power consumption
*
*/
void shutdown();
/** /**
* @brief Configures the pins used to communicate with the LoRaWAN radio chip. * @brief Configures the pins used to communicate with the LoRaWAN radio chip.
* *

View File

@ -118,6 +118,18 @@ void TheThingsNetwork::reset()
ttn_hal.leaveCriticalSection(); ttn_hal.leaveCriticalSection();
} }
void TheThingsNetwork::shutdown()
{
ttn_hal.enterCriticalSection();
LMIC_shutdown();
waitingReason = eWaitingNone;
if (lmicEventQueue != nullptr)
{
xQueueReset(lmicEventQueue);
}
ttn_hal.leaveCriticalSection();
}
bool TheThingsNetwork::provision(const char *devEui, const char *appEui, const char *appKey) bool TheThingsNetwork::provision(const char *devEui, const char *appEui, const char *appKey)
{ {
if (!provisioning.decodeKeys(devEui, appEui, appKey)) if (!provisioning.decodeKeys(devEui, appEui, appKey))