Skip to content

Commit 4885739

Browse files
committed
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.
1 parent eec320c commit 4885739

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

connectivity/lorawan/system/LoRaWANTimer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ void LoRaWANTimeHandler::stop(timer_event_t &obj)
6464
_queue->cancel(obj.timer_id);
6565
obj.timer_id = 0;
6666
}
67+
68+
void LoRaWANTimeHandler::clear(timer_event_t &obj)
69+
{
70+
obj.timer_id = 0;
71+
}

connectivity/lorawan/system/LoRaWANTimer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ class LoRaWANTimeHandler {
7676
*/
7777
void stop(timer_event_t &obj);
7878

79+
/** Clear timer state so it is not inadvertently canceled. This function
80+
* must be called by the callback registered in init.
81+
*
82+
* @param [in] obj The structure containing the timer object parameters.
83+
*/
84+
void clear(timer_event_t &obj);
85+
7986
private:
8087
events::EventQueue *_queue;
8188
};

0 commit comments

Comments
 (0)