@@ -41,13 +41,6 @@ using namespace events;
41
41
*/
42
42
static EventQueue *ev_queue;
43
43
44
- /* !
45
- * TODO: We should get rid of this
46
- *
47
- * Static handle to LoRaMac object. This is needed for static callback methods.
48
- */
49
- static LoRaMac* isrHandler = NULL ;
50
-
51
44
/* !
52
45
* Maximum length of the fOpts field
53
46
*/
@@ -93,8 +86,6 @@ LoRaMac::LoRaMac(LoRaWANTimeHandler &lora_time)
93
86
: mac_commands(*this ),
94
87
_lora_time(lora_time)
95
88
{
96
- isrHandler = this ;
97
-
98
89
lora_phy = NULL ;
99
90
// radio_events_t RadioEvents;
100
91
LoRaMacDevEui = NULL ;
@@ -172,64 +163,64 @@ LoRaMac::~LoRaMac()
172
163
**************************************************************************/
173
164
void LoRaMac::handle_tx_done (void )
174
165
{
175
- ev_queue->call (isrHandler , &LoRaMac::OnRadioTxDone);
166
+ ev_queue->call (this , &LoRaMac::OnRadioTxDone);
176
167
}
177
168
178
169
void LoRaMac::handle_rx_done (uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
179
170
{
180
- ev_queue->call (isrHandler , &LoRaMac::OnRadioRxDone, payload, size, rssi, snr);
171
+ ev_queue->call (this , &LoRaMac::OnRadioRxDone, payload, size, rssi, snr);
181
172
}
182
173
183
174
void LoRaMac::handle_rx_error (void )
184
175
{
185
- ev_queue->call (isrHandler , &LoRaMac::OnRadioRxError);
176
+ ev_queue->call (this , &LoRaMac::OnRadioRxError);
186
177
}
187
178
188
179
void LoRaMac::handle_rx_timeout (void )
189
180
{
190
- ev_queue->call (isrHandler , &LoRaMac::OnRadioRxTimeout);
181
+ ev_queue->call (this , &LoRaMac::OnRadioRxTimeout);
191
182
}
192
183
193
184
void LoRaMac::handle_tx_timeout (void )
194
185
{
195
- ev_queue->call (isrHandler , &LoRaMac::OnRadioTxTimeout);
186
+ ev_queue->call (this , &LoRaMac::OnRadioTxTimeout);
196
187
}
197
188
198
189
void LoRaMac::handle_cad_done (bool cad)
199
190
{
200
191
// TODO Not implemented yet
201
- // ev_queue->call(isrHandler , &LoRaMac::OnRadioCadDone, cad);
192
+ // ev_queue->call(this , &LoRaMac::OnRadioCadDone, cad);
202
193
}
203
194
204
195
void LoRaMac::handle_fhss_change_channel (uint8_t cur_channel)
205
196
{
206
197
// TODO Not implemented yet
207
- // ev_queue->call(isrHandler , &LoRaMac::OnRadioFHSSChangeChannel, cur_channel);
198
+ // ev_queue->call(this , &LoRaMac::OnRadioFHSSChangeChannel, cur_channel);
208
199
}
209
200
210
201
void LoRaMac::handle_mac_state_check_timer_event (void )
211
202
{
212
- ev_queue->call (isrHandler , &LoRaMac::OnMacStateCheckTimerEvent);
203
+ ev_queue->call (this , &LoRaMac::OnMacStateCheckTimerEvent);
213
204
}
214
205
215
206
void LoRaMac::handle_delayed_tx_timer_event (void )
216
207
{
217
- ev_queue->call (isrHandler , &LoRaMac::OnTxDelayedTimerEvent);
208
+ ev_queue->call (this , &LoRaMac::OnTxDelayedTimerEvent);
218
209
}
219
210
220
211
void LoRaMac::handle_ack_timeout ()
221
212
{
222
- ev_queue->call (isrHandler , &LoRaMac::OnAckTimeoutTimerEvent);
213
+ ev_queue->call (this , &LoRaMac::OnAckTimeoutTimerEvent);
223
214
}
224
215
225
216
void LoRaMac::handle_rx1_timer_event (void )
226
217
{
227
- ev_queue->call (isrHandler , &LoRaMac::OnRxWindow1TimerEvent);
218
+ ev_queue->call (this , &LoRaMac::OnRxWindow1TimerEvent);
228
219
}
229
220
230
221
void LoRaMac::handle_rx2_timer_event (void )
231
222
{
232
- ev_queue->call (isrHandler , &LoRaMac::OnRxWindow2TimerEvent);
223
+ ev_queue->call (this , &LoRaMac::OnRxWindow2TimerEvent);
233
224
}
234
225
235
226
/* **************************************************************************
@@ -1794,13 +1785,13 @@ LoRaMacStatus_t LoRaMac::LoRaMacInitialization(LoRaMacPrimitives_t *primitives,
1794
1785
lora_phy->put_radio_to_sleep ();
1795
1786
1796
1787
// Initialize timers
1797
- _lora_time.TimerInit (&MacStateCheckTimer, handle_mac_state_check_timer_event);
1788
+ _lora_time.TimerInit (&MacStateCheckTimer, mbed::callback ( this , &LoRaMac:: handle_mac_state_check_timer_event) );
1798
1789
_lora_time.TimerSetValue (&MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT);
1799
1790
1800
- _lora_time.TimerInit (&TxDelayedTimer, handle_delayed_tx_timer_event);
1801
- _lora_time.TimerInit (&RxWindowTimer1, handle_rx1_timer_event);
1802
- _lora_time.TimerInit (&RxWindowTimer2, handle_rx2_timer_event);
1803
- _lora_time.TimerInit (&AckTimeoutTimer, handle_ack_timeout);
1791
+ _lora_time.TimerInit (&TxDelayedTimer, mbed::callback ( this , &LoRaMac:: handle_delayed_tx_timer_event) );
1792
+ _lora_time.TimerInit (&RxWindowTimer1, mbed::callback ( this , &LoRaMac:: handle_rx1_timer_event) );
1793
+ _lora_time.TimerInit (&RxWindowTimer2, mbed::callback ( this , &LoRaMac:: handle_rx2_timer_event) );
1794
+ _lora_time.TimerInit (&AckTimeoutTimer, mbed::callback ( this , &LoRaMac:: handle_ack_timeout) );
1804
1795
1805
1796
// Store the current initialization time
1806
1797
LoRaMacInitializationTime = _lora_time.TimerGetCurrentTime ();
@@ -2694,11 +2685,11 @@ LoRaMacStatus_t LoRaMac::LoRaMacMcpsRequest( McpsReq_t *mcpsRequest )
2694
2685
2695
2686
radio_events_t *LoRaMac::GetPhyEventHandlers ()
2696
2687
{
2697
- RadioEvents.tx_done = mbed::callback (handle_tx_done);
2698
- RadioEvents.rx_done = mbed::callback (handle_rx_done);
2699
- RadioEvents.rx_error = mbed::callback (handle_rx_error);
2700
- RadioEvents.tx_timeout = mbed::callback (handle_tx_timeout);
2701
- RadioEvents.rx_timeout = mbed::callback (handle_rx_timeout);
2688
+ RadioEvents.tx_done = mbed::callback (this , &LoRaMac:: handle_tx_done);
2689
+ RadioEvents.rx_done = mbed::callback (this , &LoRaMac:: handle_rx_done);
2690
+ RadioEvents.rx_error = mbed::callback (this , &LoRaMac:: handle_rx_error);
2691
+ RadioEvents.tx_timeout = mbed::callback (this , &LoRaMac:: handle_tx_timeout);
2692
+ RadioEvents.rx_timeout = mbed::callback (this , &LoRaMac:: handle_rx_timeout);
2702
2693
2703
2694
return &RadioEvents;
2704
2695
}
0 commit comments