diff --git a/include/TheThingsNetwork.h b/include/TheThingsNetwork.h index f579244..7115604 100644 --- a/include/TheThingsNetwork.h +++ b/include/TheThingsNetwork.h @@ -72,6 +72,12 @@ public: */ 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. * diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 070bd3d..ff5d9b6 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -118,6 +118,18 @@ void TheThingsNetwork::reset() 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) { if (!provisioning.decodeKeys(devEui, appEui, appKey))