From 4885739c4eec2ad8678befef80bf4ee9e9092418 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 11 Mar 2021 20:59:45 +0000 Subject: [PATCH] Lora: Add clear method to LoRaWANTimer. This function must be called by the callback registered in init. It clears the timer_id to prevent abusive use of the stop methods on expired timer. --- connectivity/lorawan/system/LoRaWANTimer.cpp | 5 +++++ connectivity/lorawan/system/LoRaWANTimer.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/connectivity/lorawan/system/LoRaWANTimer.cpp b/connectivity/lorawan/system/LoRaWANTimer.cpp index d17b96b49e..dbcda55b7d 100644 --- a/connectivity/lorawan/system/LoRaWANTimer.cpp +++ b/connectivity/lorawan/system/LoRaWANTimer.cpp @@ -64,3 +64,8 @@ void LoRaWANTimeHandler::stop(timer_event_t &obj) _queue->cancel(obj.timer_id); obj.timer_id = 0; } + +void LoRaWANTimeHandler::clear(timer_event_t &obj) +{ + obj.timer_id = 0; +} \ No newline at end of file diff --git a/connectivity/lorawan/system/LoRaWANTimer.h b/connectivity/lorawan/system/LoRaWANTimer.h index e66d2680b6..c2fb3196fd 100644 --- a/connectivity/lorawan/system/LoRaWANTimer.h +++ b/connectivity/lorawan/system/LoRaWANTimer.h @@ -76,6 +76,13 @@ public: */ void stop(timer_event_t &obj); + /** Clear timer state so it is not inadvertently canceled. This function + * must be called by the callback registered in init. + * + * @param [in] obj The structure containing the timer object parameters. + */ + void clear(timer_event_t &obj); + private: events::EventQueue *_queue; };