Skip to content

Commit 20bce2f

Browse files
author
Hasnain Virk
committed
Style changes for LoRaWANTimer & a warning fix
Method naming, doxygen style etc are made to follow Mbed-OS guidelines. A warning fix in LoRaWANstack.
1 parent f0fe122 commit 20bce2f

File tree

10 files changed

+87
-92
lines changed

10 files changed

+87
-92
lines changed

features/lorawan/LoRaWANStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
153153
_compliance_test.app_data_buffer = compliance_test_buffer;
154154
#endif
155155

156-
_lora_time.TimerTimeCounterInit(queue);
156+
_lora_time.activate_timer_subsystem(queue);
157157
_loramac.LoRaMacInitialization(&LoRaMacPrimitives, &_lora_phy, queue);
158158

159159
loramac_mib_req_confirm_t mib_req;
@@ -680,7 +680,7 @@ int16_t LoRaWANStack::handle_tx(uint8_t port, const uint8_t* data,
680680

681681
// send user the length of data which is scheduled now.
682682
// user should take care of the pending data.
683-
return (status == LORAWAN_STATUS_OK) ? _tx_msg.f_buffer_size : status;
683+
return (status == LORAWAN_STATUS_OK) ? _tx_msg.f_buffer_size : (int16_t) status;
684684
}
685685

686686
int16_t LoRaWANStack::handle_rx(const uint8_t port, uint8_t* data,

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void LoRaMac::OnRadioTxDone( void )
222222
get_phy_params_t getPhy;
223223
phy_param_t phyParam;
224224
set_band_txdone_params_t txDone;
225-
lorawan_time_t curTime = _lora_time.TimerGetCurrentTime( );
225+
lorawan_time_t curTime = _lora_time.get_current_time( );
226226
loramac_mlme_confirm_t mlme_confirm = mlme.get_confirmation();
227227

228228
if( _params.dev_class != CLASS_C )
@@ -237,16 +237,16 @@ void LoRaMac::OnRadioTxDone( void )
237237
// Setup timers
238238
if( _params.is_rx_window_enabled == true )
239239
{
240-
_lora_time.TimerStart( _params.timers.rx_window1_timer, _params.rx_window1_delay );
240+
_lora_time.start( _params.timers.rx_window1_timer, _params.rx_window1_delay );
241241
if( _params.dev_class != CLASS_C )
242242
{
243-
_lora_time.TimerStart( _params.timers.rx_window2_timer, _params.rx_window2_delay );
243+
_lora_time.start( _params.timers.rx_window2_timer, _params.rx_window2_delay );
244244
}
245245
if( ( _params.dev_class == CLASS_C ) || ( _params.is_node_ack_requested == true ) )
246246
{
247247
getPhy.attribute = PHY_ACK_TIMEOUT;
248248
phyParam = lora_phy->get_phy_params(&getPhy);
249-
_lora_time.TimerStart( _params.timers.ack_timeout_timer, _params.rx_window2_delay + phyParam.value );
249+
_lora_time.start( _params.timers.ack_timeout_timer, _params.rx_window2_delay + phyParam.value );
250250
}
251251
}
252252
else
@@ -301,7 +301,7 @@ void LoRaMac::PrepareRxDoneAbort( void )
301301
_params.flags.bits.mac_done = 1;
302302

303303
// Trig OnMacCheckTimerEvent call as soon as possible
304-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, 1 );
304+
_lora_time.start( _params.timers.mac_state_check_timer, 1 );
305305
}
306306

307307
void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
@@ -349,7 +349,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
349349

350350
lora_phy->put_radio_to_sleep();
351351

352-
_lora_time.TimerStop( _params.timers.rx_window2_timer );
352+
_lora_time.stop( _params.timers.rx_window2_timer );
353353

354354
macHdr.value = payload[pktHeaderLen++];
355355

@@ -702,7 +702,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
702702

703703
// Stop the AckTimeout timer as no more retransmissions
704704
// are needed.
705-
_lora_time.TimerStop( _params.timers.ack_timeout_timer );
705+
_lora_time.stop( _params.timers.ack_timeout_timer );
706706
}
707707
else
708708
{
@@ -712,7 +712,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
712712
{
713713
// Stop the AckTimeout timer as no more retransmissions
714714
// are needed.
715-
_lora_time.TimerStop( _params.timers.ack_timeout_timer );
715+
_lora_time.stop( _params.timers.ack_timeout_timer );
716716
}
717717
}
718718
}
@@ -750,7 +750,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
750750
_params.flags.bits.mac_done = 1;
751751

752752
// Trig OnMacCheckTimerEvent call as soon as possible
753-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, 1 );
753+
_lora_time.start( _params.timers.mac_state_check_timer, 1 );
754754
}
755755

756756
void LoRaMac::OnRadioTxTimeout( void )
@@ -791,9 +791,9 @@ void LoRaMac::OnRadioRxError( void )
791791

792792
mlme.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
793793

794-
if( _lora_time.TimerGetElapsedTime( _params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay )
794+
if( _lora_time.get_elapsed_time( _params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay )
795795
{
796-
_lora_time.TimerStop( _params.timers.rx_window2_timer );
796+
_lora_time.stop( _params.timers.rx_window2_timer );
797797
_params.flags.bits.mac_done = 1;
798798
}
799799
}
@@ -829,9 +829,9 @@ void LoRaMac::OnRadioRxTimeout( void )
829829
}
830830
mlme.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT;
831831

832-
if( _lora_time.TimerGetElapsedTime( _params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay )
832+
if( _lora_time.get_elapsed_time( _params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay )
833833
{
834-
_lora_time.TimerStop( _params.timers.rx_window2_timer );
834+
_lora_time.stop( _params.timers.rx_window2_timer );
835835
_params.flags.bits.mac_done = 1;
836836
}
837837
}
@@ -860,7 +860,7 @@ void LoRaMac::OnMacStateCheckTimerEvent( void )
860860
phy_param_t phyParam;
861861
bool txTimeout = false;
862862

863-
_lora_time.TimerStop( _params.timers.mac_state_check_timer );
863+
_lora_time.stop( _params.timers.mac_state_check_timer );
864864

865865
if( _params.flags.bits.mac_done == 1 )
866866
{
@@ -1045,7 +1045,7 @@ void LoRaMac::OnMacStateCheckTimerEvent( void )
10451045
else
10461046
{
10471047
// Operation not finished restart timer
1048-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
1048+
_lora_time.start( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
10491049
}
10501050

10511051
// Handle MCPS indication
@@ -1078,7 +1078,7 @@ void LoRaMac::OnTxDelayedTimerEvent( void )
10781078

10791079
lorawan_status_t status = LORAWAN_STATUS_OK;
10801080

1081-
_lora_time.TimerStop( _params.timers.tx_delayed_timer );
1081+
_lora_time.stop( _params.timers.tx_delayed_timer );
10821082
_params.mac_state &= ~LORAMAC_TX_DELAYED;
10831083

10841084
if( ( _params.flags.bits.mlme_req == 1 ) && ( mlme.get_confirmation().req_type == MLME_JOIN ) )
@@ -1108,7 +1108,7 @@ void LoRaMac::OnTxDelayedTimerEvent( void )
11081108

11091109
void LoRaMac::OnRxWindow1TimerEvent( void )
11101110
{
1111-
_lora_time.TimerStop( _params.timers.rx_window1_timer );
1111+
_lora_time.stop( _params.timers.rx_window1_timer );
11121112
_params.rx_slot= RX_SLOT_WIN_1;
11131113

11141114
_params.rx_window1_config.channel = _params.channel;
@@ -1129,7 +1129,7 @@ void LoRaMac::OnRxWindow1TimerEvent( void )
11291129

11301130
void LoRaMac::OnRxWindow2TimerEvent( void )
11311131
{
1132-
_lora_time.TimerStop( _params.timers.rx_window2_timer );
1132+
_lora_time.stop( _params.timers.rx_window2_timer );
11331133

11341134
_params.rx_window2_config.channel = _params.channel;
11351135
_params.rx_window2_config.frequency = _params.sys_params.rx2_channel.frequency;
@@ -1156,7 +1156,7 @@ void LoRaMac::OnRxWindow2TimerEvent( void )
11561156

11571157
void LoRaMac::OnAckTimeoutTimerEvent( void )
11581158
{
1159-
_lora_time.TimerStop( _params.timers.ack_timeout_timer );
1159+
_lora_time.stop( _params.timers.ack_timeout_timer );
11601160

11611161
if( _params.is_node_ack_requested == true )
11621162
{
@@ -1325,7 +1325,7 @@ lorawan_status_t LoRaMac::ScheduleTx( void )
13251325
_params.mac_state |= LORAMAC_TX_DELAYED;
13261326
tr_debug("Next Transmission in %lu ms", dutyCycleTimeOff);
13271327

1328-
_lora_time.TimerStart( _params.timers.tx_delayed_timer, dutyCycleTimeOff );
1328+
_lora_time.start( _params.timers.tx_delayed_timer, dutyCycleTimeOff );
13291329

13301330
return LORAWAN_STATUS_OK;
13311331
}
@@ -1339,7 +1339,7 @@ void LoRaMac::CalculateBackOff( uint8_t channel )
13391339
_params.is_dutycycle_on = MBED_CONF_LORA_DUTY_CYCLE_ON;
13401340
calcBackOff.dc_enabled = _params.is_dutycycle_on;
13411341
calcBackOff.channel = channel;
1342-
calcBackOff.elapsed_time = _lora_time.TimerGetElapsedTime( _params.timers.mac_init_time );
1342+
calcBackOff.elapsed_time = _lora_time.get_elapsed_time( _params.timers.mac_init_time );
13431343
calcBackOff.tx_toa = _params.timers.tx_toa;
13441344
calcBackOff.last_tx_was_join_req = _params.is_last_tx_join_request;
13451345

@@ -1668,7 +1668,7 @@ lorawan_status_t LoRaMac::SendFrameOnChannel( uint8_t channel )
16681668
mlme.get_confirmation().tx_toa = _params.timers.tx_toa;
16691669

16701670
// Starts the MAC layer status check timer
1671-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
1671+
_lora_time.start( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
16721672

16731673
if( _params.is_nwk_joined == false )
16741674
{
@@ -1697,7 +1697,7 @@ lorawan_status_t LoRaMac::SetTxContinuousWave( uint16_t timeout )
16971697
lora_phy->set_tx_cont_mode(&continuousWave);
16981698

16991699
// Starts the MAC layer status check timer
1700-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
1700+
_lora_time.start( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
17011701

17021702
_params.mac_state |= LORAMAC_TX_RUNNING;
17031703

@@ -1718,7 +1718,7 @@ lorawan_status_t LoRaMac::SetTxContinuousWave1( uint16_t timeout, uint32_t frequ
17181718
lora_phy->set_tx_cont_mode(&continuousWave);
17191719

17201720
// Starts the MAC layer status check timer
1721-
_lora_time.TimerStart( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
1721+
_lora_time.start( _params.timers.mac_state_check_timer, MAC_STATE_CHECK_TIMEOUT );
17221722

17231723
_params.mac_state |= LORAMAC_TX_RUNNING;
17241724

@@ -1846,31 +1846,31 @@ lorawan_status_t LoRaMac::LoRaMacInitialization(loramac_primitives_t *primitives
18461846
lora_phy->put_radio_to_sleep();
18471847

18481848
// Initialize timers
1849-
_lora_time.TimerInit(_params.timers.mac_state_check_timer,
1849+
_lora_time.init(_params.timers.mac_state_check_timer,
18501850
mbed::callback(this, &LoRaMac::handle_mac_state_check_timer_event));
1851-
_lora_time.TimerInit(_params.timers.tx_delayed_timer,
1851+
_lora_time.init(_params.timers.tx_delayed_timer,
18521852
mbed::callback(this, &LoRaMac::handle_delayed_tx_timer_event));
1853-
_lora_time.TimerInit(_params.timers.rx_window1_timer,
1853+
_lora_time.init(_params.timers.rx_window1_timer,
18541854
mbed::callback(this, &LoRaMac::handle_rx1_timer_event));
1855-
_lora_time.TimerInit(_params.timers.rx_window2_timer,
1855+
_lora_time.init(_params.timers.rx_window2_timer,
18561856
mbed::callback(this, &LoRaMac::handle_rx2_timer_event));
1857-
_lora_time.TimerInit(_params.timers.ack_timeout_timer,
1857+
_lora_time.init(_params.timers.ack_timeout_timer,
18581858
mbed::callback(this, &LoRaMac::handle_ack_timeout));
18591859

18601860
// Store the current initialization time
1861-
_params.timers.mac_init_time = _lora_time.TimerGetCurrentTime();
1861+
_params.timers.mac_init_time = _lora_time.get_current_time();
18621862

18631863
return LORAWAN_STATUS_OK;
18641864
}
18651865

18661866
void LoRaMac::disconnect()
18671867
{
18681868
// Cancel all timers
1869-
_lora_time.TimerStop(_params.timers.mac_state_check_timer);
1870-
_lora_time.TimerStop(_params.timers.tx_delayed_timer);
1871-
_lora_time.TimerStop(_params.timers.rx_window1_timer);
1872-
_lora_time.TimerStop(_params.timers.rx_window2_timer);
1873-
_lora_time.TimerStop(_params.timers.ack_timeout_timer);
1869+
_lora_time.stop(_params.timers.mac_state_check_timer);
1870+
_lora_time.stop(_params.timers.tx_delayed_timer);
1871+
_lora_time.stop(_params.timers.rx_window1_timer);
1872+
_lora_time.stop(_params.timers.rx_window2_timer);
1873+
_lora_time.stop(_params.timers.ack_timeout_timer);
18741874

18751875
// Put radio to sleep
18761876
lora_phy->put_radio_to_sleep();
@@ -2110,13 +2110,13 @@ radio_events_t *LoRaMac::GetPhyEventHandlers()
21102110

21112111
lorawan_status_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
21122112
{
2113-
_lora_time.TimerStart(tx_next_packet_timer, TxDutyCycleTime);
2113+
_lora_time.start(tx_next_packet_timer, TxDutyCycleTime);
21142114
return LORAWAN_STATUS_OK;
21152115
}
21162116

21172117
lorawan_status_t LoRaMac::LoRaMacStopTxTimer( )
21182118
{
2119-
_lora_time.TimerStop(tx_next_packet_timer);
2119+
_lora_time.stop(tx_next_packet_timer);
21202120
return LORAWAN_STATUS_OK;
21212121
}
21222122

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
264264
for (uint8_t i = 0; i < nb_bands; i++) {
265265

266266
if (joined == false) {
267-
uint32_t txDoneTime = MAX(_lora_time.TimerGetElapsedTime(bands[i].last_join_tx_time),
267+
uint32_t txDoneTime = MAX(_lora_time.get_elapsed_time(bands[i].last_join_tx_time),
268268
(duty_cycle == true) ?
269-
_lora_time.TimerGetElapsedTime(bands[i].last_tx_time) : 0);
269+
_lora_time.get_elapsed_time(bands[i].last_tx_time) : 0);
270270

271271
if (bands[i].off_time <= txDoneTime) {
272272
bands[i].off_time = 0;
@@ -280,12 +280,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
280280
// if network has been joined
281281
if (duty_cycle == true) {
282282

283-
if( bands[i].off_time <= _lora_time.TimerGetElapsedTime(bands[i].last_tx_time)) {
283+
if( bands[i].off_time <= _lora_time.get_elapsed_time(bands[i].last_tx_time)) {
284284
bands[i].off_time = 0;
285285
}
286286

287287
if(bands[i].off_time != 0 ) {
288-
next_tx_delay = MIN(bands[i].off_time - _lora_time.TimerGetElapsedTime(bands[i].last_tx_time),
288+
next_tx_delay = MIN(bands[i].off_time - _lora_time.get_elapsed_time(bands[i].last_tx_time),
289289
next_tx_delay);
290290
}
291291
} else {
@@ -1230,7 +1230,7 @@ bool LoRaPHY::set_next_channel(channel_selection_params_t* params,
12301230
}
12311231

12321232
if (params->aggregate_timeoff
1233-
<= _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time)) {
1233+
<= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
12341234
// Reset Aggregated time off
12351235
*aggregate_timeoff = 0;
12361236

@@ -1247,7 +1247,7 @@ bool LoRaPHY::set_next_channel(channel_selection_params_t* params,
12471247
} else {
12481248
delay_tx++;
12491249
next_tx_delay = params->aggregate_timeoff
1250-
- _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time);
1250+
- _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
12511251
}
12521252

12531253
if (channel_count > 0) {

features/lorawan/lorastack/phy/LoRaPHYAS923.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool LoRaPHYAS923::set_next_channel(channel_selection_params_t* next_channel_pra
349349
channel_masks[0] |= LC(1) + LC(2);
350350
}
351351

352-
if (next_channel_prams->aggregate_timeoff <= _lora_time.TimerGetElapsedTime(next_channel_prams->last_aggregate_tx_time)) {
352+
if (next_channel_prams->aggregate_timeoff <= _lora_time.get_elapsed_time(next_channel_prams->last_aggregate_tx_time)) {
353353
// Reset Aggregated time off
354354
*aggregate_timeoff = 0;
355355

@@ -366,7 +366,7 @@ bool LoRaPHYAS923::set_next_channel(channel_selection_params_t* next_channel_pra
366366
enabled_channels, &delay_tx);
367367
} else {
368368
delay_tx++;
369-
next_tx_delay = next_channel_prams->aggregate_timeoff - _lora_time.TimerGetElapsedTime(next_channel_prams->last_aggregate_tx_time);
369+
next_tx_delay = next_channel_prams->aggregate_timeoff - _lora_time.get_elapsed_time(next_channel_prams->last_aggregate_tx_time);
370370
}
371371

372372
if (nb_enabled_channels > 0) {

features/lorawan/lorastack/phy/LoRaPHYAU915.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ bool LoRaPHYAU915::set_next_channel(channel_selection_params_t* next_chan_params
578578
}
579579
}
580580

581-
if (next_chan_params->aggregate_timeoff <= _lora_time.TimerGetElapsedTime(next_chan_params->last_aggregate_tx_time)) {
581+
if (next_chan_params->aggregate_timeoff <= _lora_time.get_elapsed_time(next_chan_params->last_aggregate_tx_time)) {
582582
// Reset Aggregated time off
583583
*aggregated_timeOff = 0;
584584

@@ -595,7 +595,7 @@ bool LoRaPHYAU915::set_next_channel(channel_selection_params_t* next_chan_params
595595
enabled_channels, &delay_tx);
596596
} else {
597597
delay_tx++;
598-
next_tx_delay = next_chan_params->aggregate_timeoff - _lora_time.TimerGetElapsedTime(next_chan_params->last_aggregate_tx_time);
598+
next_tx_delay = next_chan_params->aggregate_timeoff - _lora_time.get_elapsed_time(next_chan_params->last_aggregate_tx_time);
599599
}
600600

601601
if (nb_enabled_channels > 0) {

features/lorawan/lorastack/phy/LoRaPHYKR920.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ bool LoRaPHYKR920::set_next_channel(channel_selection_params_t* params,
419419
channel_masks[0] |= LC(1) + LC(2) + LC(3);
420420
}
421421

422-
if (params->aggregate_timeoff <= _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time)) {
422+
if (params->aggregate_timeoff <= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
423423
// Reset Aggregated time off
424424
*aggregate_timeoff = 0;
425425

@@ -433,7 +433,7 @@ bool LoRaPHYKR920::set_next_channel(channel_selection_params_t* params,
433433
enabled_channels, &delay_tx);
434434
} else {
435435
delay_tx++;
436-
nextTxDelay = params->aggregate_timeoff - _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time);
436+
nextTxDelay = params->aggregate_timeoff - _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
437437
}
438438

439439
if (nb_enabled_channels > 0) {

features/lorawan/lorastack/phy/LoRaPHYUS915.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ bool LoRaPHYUS915::set_next_channel(channel_selection_params_t* params,
628628
}
629629
}
630630

631-
if (params->aggregate_timeoff <= _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time)) {
631+
if (params->aggregate_timeoff <= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
632632
// Reset Aggregated time off
633633
*aggregate_timeOff = 0;
634634

@@ -642,7 +642,7 @@ bool LoRaPHYUS915::set_next_channel(channel_selection_params_t* params,
642642
enabled_channels, &delay_tx);
643643
} else {
644644
delay_tx++;
645-
next_tx_delay = params->aggregate_timeoff - _lora_time.TimerGetElapsedTime(params->last_aggregate_tx_time);
645+
next_tx_delay = params->aggregate_timeoff - _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
646646
}
647647

648648
if (nb_enabled_channels > 0) {

0 commit comments

Comments
 (0)