File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1193,6 +1193,9 @@ lorawan_status_t LoRaWANStack::lora_state_machine()
1193
1193
*/
1194
1194
drop_channel_list ();
1195
1195
1196
+ // Shutdown LoRaMac
1197
+ _loramac.disconnect ();
1198
+
1196
1199
// Stop sending messages and set joined status to false.
1197
1200
#if defined(LORAWAN_COMPLIANCE_TEST)
1198
1201
_loramac.LoRaMacStopTxTimer ();
Original file line number Diff line number Diff line change @@ -1834,6 +1834,36 @@ lorawan_status_t LoRaMac::LoRaMacInitialization(loramac_primitives_t *primitives
1834
1834
return LORAWAN_STATUS_OK;
1835
1835
}
1836
1836
1837
+ void LoRaMac::disconnect ()
1838
+ {
1839
+ // Cancel all timers
1840
+ _lora_time.TimerStop (_params.timers .mac_state_check_timer );
1841
+ _lora_time.TimerStop (_params.timers .tx_delayed_timer );
1842
+ _lora_time.TimerStop (_params.timers .rx_window1_timer );
1843
+ _lora_time.TimerStop (_params.timers .rx_window2_timer );
1844
+ _lora_time.TimerStop (_params.timers .ack_timeout_timer );
1845
+
1846
+ // Put radio to sleep
1847
+ lora_phy->put_radio_to_sleep ();
1848
+
1849
+ // Reset internal state
1850
+ _params.is_nwk_joined = false ;
1851
+ _params.is_ack_retry_timeout_expired = false ;
1852
+ _params.is_rx_window_enabled = true ;
1853
+ _params.is_node_ack_requested = false ;
1854
+ _params.is_srv_ack_requested = false ;
1855
+ _params.flags .value = 0 ;
1856
+ _params.mac_state = 0 ;
1857
+
1858
+ // Clear MAC commands
1859
+ mac_commands.ClearCommandBuffer ();
1860
+ mac_commands.ClearRepeatBuffer ();
1861
+ mac_commands.ClearMacCommandsInNextTx ();
1862
+
1863
+ // Set internal state to idle.
1864
+ _params.mac_state = LORAMAC_IDLE;
1865
+ }
1866
+
1837
1867
lorawan_status_t LoRaMac::LoRaMacQueryTxPossible ( uint8_t size, loramac_tx_info_t * txInfo )
1838
1868
{
1839
1869
AdrNextParams_t adrNext;
Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ class LoRaMac
91
91
LoRaPHY *phy,
92
92
events::EventQueue *queue);
93
93
94
+ /* !
95
+ * \brief Disconnect LoRaMac layer
96
+ *
97
+ * \details Cancels all outstanding requests and sets LoRaMac's
98
+ * internal state to idle.
99
+ */
100
+ void disconnect (void );
101
+
94
102
/* !
95
103
* \brief Queries the LoRaMAC whether it is possible to send the next frame with
96
104
* a given payload size. The LoRaMAC takes the scheduled MAC commands into
You can’t perform that action at this time.
0 commit comments