Skip to content

Commit d335f82

Browse files
author
Hasnain Virk
committed
Remaining style fixes
1 parent 27290bb commit d335f82

File tree

4 files changed

+172
-172
lines changed

4 files changed

+172
-172
lines changed

features/lorawan/LoRaWANStack.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ using namespace events;
6868
* Constructor *
6969
****************************************************************************/
7070
LoRaWANStack::LoRaWANStack()
71-
: _loramac(),
72-
_device_current_state(DEVICE_STATE_NOT_INITIALIZED),
73-
_lw_session(),
74-
_tx_msg(),
75-
_rx_msg(),
76-
_tx_metadata(),
77-
_rx_metadata(),
78-
_num_retry(1),
79-
_ctrl_flags(IDLE_FLAG),
80-
_app_port(INVALID_PORT),
81-
_link_check_requested(false),
82-
_automatic_uplink_ongoing(false),
83-
_ready_for_rx(true),
84-
_queue(NULL)
71+
: _loramac(),
72+
_device_current_state(DEVICE_STATE_NOT_INITIALIZED),
73+
_lw_session(),
74+
_tx_msg(),
75+
_rx_msg(),
76+
_tx_metadata(),
77+
_rx_metadata(),
78+
_num_retry(1),
79+
_ctrl_flags(IDLE_FLAG),
80+
_app_port(INVALID_PORT),
81+
_link_check_requested(false),
82+
_automatic_uplink_ongoing(false),
83+
_ready_for_rx(true),
84+
_queue(NULL)
8585
{
8686
_tx_metadata.stale = true;
8787
_rx_metadata.stale = true;
@@ -481,7 +481,7 @@ lorawan_status_t LoRaWANStack::acquire_rx_metadata(lorawan_rx_metadata &metadata
481481
return LORAWAN_STATUS_METADATA_NOT_AVAILABLE;
482482
}
483483

484-
lorawan_status_t LoRaWANStack::acquire_backoff_metadata(int& backoff)
484+
lorawan_status_t LoRaWANStack::acquire_backoff_metadata(int &backoff)
485485
{
486486
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
487487
return LORAWAN_STATUS_NOT_INITIALIZED;
@@ -1362,9 +1362,11 @@ void LoRaWANStack::compliance_test_handler(loramac_mcps_indication_t *mcps_indic
13621362
} else if (mcps_indication->buffer_size == 7) {
13631363
loramac_mlme_req_t mlme_req;
13641364
mlme_req.type = MLME_TXCW_1;
1365-
mlme_req.cw_tx_mode.timeout = (uint16_t)((mcps_indication->buffer[1] << 8) | mcps_indication->buffer[2]);
1366-
mlme_req.cw_tx_mode.frequency = (uint32_t)((mcps_indication->buffer[3] << 16) | (mcps_indication->buffer[4] << 8)
1367-
| mcps_indication->buffer[5]) * 100;
1365+
mlme_req.cw_tx_mode.timeout = (uint16_t)((mcps_indication->buffer[1] << 8)
1366+
| mcps_indication->buffer[2]);
1367+
mlme_req.cw_tx_mode.frequency = (uint32_t)((mcps_indication->buffer[3] << 16)
1368+
| (mcps_indication->buffer[4] << 8)
1369+
| mcps_indication->buffer[5]) * 100;
13681370
mlme_req.cw_tx_mode.power = mcps_indication->buffer[6];
13691371
_loramac.mlme_request(&mlme_req);
13701372
}

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ using namespace mbed;
7272

7373

7474
LoRaMac::LoRaMac()
75-
: _lora_time(),
76-
_lora_phy(_lora_time),
77-
_mac_commands(),
78-
_channel_plan(),
79-
_lora_crypto(),
80-
_ev_queue(NULL),
81-
_mcps_indication(),
82-
_mcps_confirmation(),
83-
_mlme_indication(),
84-
_mlme_confirmation(),
85-
_is_nwk_joined(false),
86-
_continuous_rx2_window_open(false),
87-
_device_class(CLASS_A)
75+
: _lora_time(),
76+
_lora_phy(_lora_time),
77+
_mac_commands(),
78+
_channel_plan(),
79+
_lora_crypto(),
80+
_ev_queue(NULL),
81+
_mcps_indication(),
82+
_mcps_confirmation(),
83+
_mlme_indication(),
84+
_mlme_confirmation(),
85+
_is_nwk_joined(false),
86+
_continuous_rx2_window_open(false),
87+
_device_class(CLASS_A)
8888
{
8989
_params.keys.dev_eui = NULL;
9090
_params.keys.app_eui = NULL;
@@ -284,7 +284,7 @@ void LoRaMac::check_frame_size(uint16_t size)
284284
uint8_t value = _lora_phy.get_max_payload(_mcps_indication.rx_datarate,
285285
_params.is_repeater_supported);
286286

287-
if (MAX(0, (int16_t) ((int16_t)size - (int16_t)LORA_MAC_FRMPAYLOAD_OVERHEAD))
287+
if (MAX(0, (int16_t)((int16_t)size - (int16_t)LORA_MAC_FRMPAYLOAD_OVERHEAD))
288288
> (int32_t) value) {
289289
tr_error("Invalid frame size");
290290
}
@@ -312,7 +312,7 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
312312
mic_rx |= ((uint32_t) payload[size - LORAMAC_MFR_LEN + 2] << 16);
313313
mic_rx |= ((uint32_t) payload[size - LORAMAC_MFR_LEN + 3] << 24);
314314

315-
sequence_counter_prev = (uint16_t) *downlink_counter;
315+
sequence_counter_prev = (uint16_t)*downlink_counter;
316316
sequence_counter_diff = sequence_counter - sequence_counter_prev;
317317
*downlink_counter += sequence_counter_diff;
318318
if (sequence_counter < sequence_counter_prev) {
@@ -417,7 +417,7 @@ void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload,
417417
if (_lora_crypto.decrypt_payload(payload + payload_start_index,
418418
frame_len,
419419
app_skey,
420-
sizeof(_params.keys.app_skey)*8,
420+
sizeof(_params.keys.app_skey) * 8,
421421
address,
422422
DOWN_LINK,
423423
downlink_counter,
@@ -638,7 +638,7 @@ void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp)
638638
_lora_phy.put_radio_to_sleep();
639639
}
640640

641-
if(_params.is_rx_window_enabled == true) {
641+
if (_params.is_rx_window_enabled == true) {
642642
lorawan_time_t time_diff = _lora_time.get_current_time() - timestamp;
643643
// start timer after which rx1_window will get opened
644644
_lora_time.start(_params.timers.rx_window1_timer,
@@ -742,12 +742,12 @@ void LoRaMac::on_radio_rx_timeout(bool is_timeout)
742742
if (_params.rx_slot == RX_SLOT_WIN_1) {
743743
if (_params.is_node_ack_requested == true) {
744744
_mcps_confirmation.status = is_timeout ?
745-
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
746-
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
745+
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
746+
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
747747
}
748748
_mlme_confirmation.status = is_timeout ?
749-
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
750-
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
749+
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
750+
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
751751

752752
if (_device_class != CLASS_C) {
753753
if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time) >= _params.rx_window2_delay) {
@@ -757,13 +757,13 @@ void LoRaMac::on_radio_rx_timeout(bool is_timeout)
757757
} else {
758758
if (_params.is_node_ack_requested == true) {
759759
_mcps_confirmation.status = is_timeout ?
760-
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
761-
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
760+
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
761+
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
762762
}
763763

764764
_mlme_confirmation.status = is_timeout ?
765-
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
766-
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
765+
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
766+
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
767767
}
768768
}
769769

@@ -800,8 +800,8 @@ lorawan_status_t LoRaMac::send_join_request()
800800
loramac_mhdr_t mac_hdr;
801801
loramac_frame_ctrl_t fctrl;
802802

803-
_params.sys_params.channel_data_rate = _lora_phy.get_alternate_DR(
804-
_params.join_request_trial_counter + 1);
803+
_params.sys_params.channel_data_rate =
804+
_lora_phy.get_alternate_DR(_params.join_request_trial_counter + 1);
805805

806806
mac_hdr.value = 0;
807807
mac_hdr.bits.mtype = FRAME_TYPE_JOIN_REQ;
@@ -846,7 +846,7 @@ void LoRaMac::on_backoff_timer_expiry(void)
846846
{
847847
Lock lock(*this);
848848
lorawan_status_t status = schedule_tx();
849-
MBED_ASSERT(status==LORAWAN_STATUS_OK);
849+
MBED_ASSERT(status == LORAWAN_STATUS_OK);
850850
(void) status;
851851
}
852852

@@ -888,7 +888,7 @@ void LoRaMac::open_rx2_window()
888888
_params.rx_window2_config.dl_dwell_time = _params.sys_params.downlink_dwell_time;
889889
_params.rx_window2_config.is_repeater_supported = _params.is_repeater_supported;
890890
_params.rx_window2_config.rx_slot = _params.rx_window2_config.is_rx_continuous ?
891-
RX_SLOT_WIN_CLASS_C : RX_SLOT_WIN_2;
891+
RX_SLOT_WIN_CLASS_C : RX_SLOT_WIN_2;
892892

893893
if (get_device_class() == CLASS_C) {
894894
_params.rx_window2_config.is_rx_continuous = true;
@@ -950,7 +950,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
950950

951951
// now that is a critical failure
952952
lorawan_status_t status = handle_retransmission();
953-
MBED_ASSERT(status==LORAWAN_STATUS_OK);
953+
MBED_ASSERT(status == LORAWAN_STATUS_OK);
954954
(void) status;
955955
}
956956

@@ -1092,19 +1092,19 @@ lorawan_status_t LoRaMac::schedule_tx()
10921092

10931093
if (!_is_nwk_joined) {
10941094
_params.rx_window1_delay = _params.sys_params.join_accept_delay1
1095-
+ _params.rx_window1_config.window_offset;
1095+
+ _params.rx_window1_config.window_offset;
10961096
_params.rx_window2_delay = _params.sys_params.join_accept_delay2
1097-
+ _params.rx_window2_config.window_offset;
1097+
+ _params.rx_window2_config.window_offset;
10981098
} else {
10991099
if (validate_payload_length(_params.tx_buffer_len,
11001100
_params.sys_params.channel_data_rate,
11011101
_mac_commands.get_mac_cmd_length()) == false) {
11021102
return LORAWAN_STATUS_LENGTH_ERROR;
11031103
}
11041104
_params.rx_window1_delay = _params.sys_params.recv_delay1
1105-
+ _params.rx_window1_config.window_offset;
1105+
+ _params.rx_window1_config.window_offset;
11061106
_params.rx_window2_delay = _params.sys_params.recv_delay2
1107-
+ _params.rx_window2_config.window_offset;
1107+
+ _params.rx_window2_config.window_offset;
11081108
}
11091109

11101110
// handle the ack to the server here so that if the sending was cancelled
@@ -1245,9 +1245,9 @@ int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port,
12451245

12461246
// Handles unconfirmed messages
12471247
if (flags & MSG_UNCONFIRMED_FLAG) {
1248-
_ongoing_tx_msg.type = MCPS_UNCONFIRMED;
1249-
_ongoing_tx_msg.fport = port;
1250-
_ongoing_tx_msg.nb_trials = 1;
1248+
_ongoing_tx_msg.type = MCPS_UNCONFIRMED;
1249+
_ongoing_tx_msg.fport = port;
1250+
_ongoing_tx_msg.nb_trials = 1;
12511251
}
12521252

12531253
// Handles confirmed messages
@@ -1537,7 +1537,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
15371537

15381538
_params.tx_buffer[pkt_header_len++] = _params.ul_frame_counter & 0xFF;
15391539
_params.tx_buffer[pkt_header_len++] = (_params.ul_frame_counter >> 8)
1540-
& 0xFF;
1540+
& 0xFF;
15411541

15421542
_mac_commands.copy_repeat_commands_to_buffer();
15431543

@@ -1551,8 +1551,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
15511551
// Update FCtrl field with new value of OptionsLength
15521552
_params.tx_buffer[0x05] = fctrl->value;
15531553

1554-
const uint8_t *buffer =
1555-
_mac_commands.get_mac_commands_buffer();
1554+
const uint8_t *buffer = _mac_commands.get_mac_commands_buffer();
15561555
for (i = 0; i < mac_commands_len; i++) {
15571556
_params.tx_buffer[pkt_header_len++] = buffer[i];
15581557
}
@@ -1577,13 +1576,13 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
15771576
_params.tx_buffer[pkt_header_len++] = frame_port;
15781577

15791578
uint8_t *key = _params.keys.app_skey;
1580-
uint32_t key_length = sizeof(_params.keys.app_skey)*8;
1579+
uint32_t key_length = sizeof(_params.keys.app_skey) * 8;
15811580
if (frame_port == 0) {
15821581
_mac_commands.clear_command_buffer();
15831582
key = _params.keys.nwk_skey;
1584-
key_length = sizeof(_params.keys.nwk_skey)*8;
1583+
key_length = sizeof(_params.keys.nwk_skey) * 8;
15851584
}
1586-
if (0 != _lora_crypto.encrypt_payload((uint8_t*) payload, _params.tx_buffer_len,
1585+
if (0 != _lora_crypto.encrypt_payload((uint8_t *) payload, _params.tx_buffer_len,
15871586
key, key_length,
15881587
_params.dev_addr, UP_LINK,
15891588
_params.ul_frame_counter,
@@ -1595,7 +1594,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
15951594
_params.tx_buffer_len = pkt_header_len + _params.tx_buffer_len;
15961595

15971596
if (0 != _lora_crypto.compute_mic(_params.tx_buffer, _params.tx_buffer_len,
1598-
_params.keys.nwk_skey, sizeof(_params.keys.nwk_skey)*8,
1597+
_params.keys.nwk_skey, sizeof(_params.keys.nwk_skey) * 8,
15991598
_params.dev_addr,
16001599
UP_LINK, _params.ul_frame_counter, &mic)) {
16011600
status = LORAWAN_STATUS_CRYPTO_FAIL;
@@ -1770,7 +1769,7 @@ uint8_t LoRaMac::get_max_possible_tx_size(uint8_t size)
17701769
uint8_t max_possible_payload_size = 0;
17711770
uint8_t current_payload_size = 0;
17721771
uint8_t fopt_len = _mac_commands.get_mac_cmd_length()
1773-
+ _mac_commands.get_repeat_commands_length();
1772+
+ _mac_commands.get_repeat_commands_length();
17741773

17751774
if (_params.sys_params.adr_on) {
17761775
_lora_phy.get_next_ADR(false, _params.sys_params.channel_data_rate,
@@ -1918,16 +1917,16 @@ lorawan_status_t LoRaMac::mlme_request(loramac_mlme_req_t *mlmeRequest)
19181917

19191918
if (MLME_TXCW == mlmeRequest->type) {
19201919
set_tx_continuous_wave(_params.channel, _params.sys_params.channel_data_rate, _params.sys_params.channel_tx_power,
1921-
_params.sys_params.max_eirp, _params.sys_params.antenna_gain, mlmeRequest->cw_tx_mode.timeout);
1920+
_params.sys_params.max_eirp, _params.sys_params.antenna_gain, mlmeRequest->cw_tx_mode.timeout);
19221921
_lora_time.start(_params.timers.mac_state_check_timer,
1923-
MAC_STATE_CHECK_TIMEOUT);
1922+
MAC_STATE_CHECK_TIMEOUT);
19241923

19251924
_params.mac_state |= LORAMAC_TX_RUNNING;
19261925
status = LORAWAN_STATUS_OK;
19271926
} else if (MLME_TXCW_1 == mlmeRequest->type) {
19281927
set_tx_continuous_wave(0, 0, mlmeRequest->cw_tx_mode.power, 0, 0, mlmeRequest->cw_tx_mode.timeout);
19291928
_lora_time.start(_params.timers.mac_state_check_timer,
1930-
MAC_STATE_CHECK_TIMEOUT);
1929+
MAC_STATE_CHECK_TIMEOUT);
19311930

19321931
_params.mac_state |= LORAMAC_TX_RUNNING;
19331932
status = LORAWAN_STATUS_OK;
@@ -1941,7 +1940,7 @@ lorawan_status_t LoRaMac::mlme_request(loramac_mlme_req_t *mlmeRequest)
19411940
return status;
19421941
}
19431942

1944-
lorawan_status_t LoRaMac::test_request( loramac_compliance_test_req_t *mcpsRequest )
1943+
lorawan_status_t LoRaMac::test_request(loramac_compliance_test_req_t *mcpsRequest)
19451944
{
19461945
if (_params.mac_state != LORAMAC_IDLE) {
19471946
return LORAWAN_STATUS_BUSY;
@@ -1976,7 +1975,7 @@ lorawan_status_t LoRaMac::test_request( loramac_compliance_test_req_t *mcpsReque
19761975
break;
19771976
}
19781977
default:
1979-
return LORAWAN_STATUS_PARAMETER_INVALID;
1978+
return LORAWAN_STATUS_PARAMETER_INVALID;
19801979
}
19811980

19821981
// Filter fPorts
@@ -1994,7 +1993,7 @@ lorawan_status_t LoRaMac::test_request( loramac_compliance_test_req_t *mcpsReque
19941993
}
19951994

19961995
lorawan_status_t status = send(&machdr, mcpsRequest->fport, mcpsRequest->f_buffer,
1997-
mcpsRequest->f_buffer_size);
1996+
mcpsRequest->f_buffer_size);
19981997
if (status == LORAWAN_STATUS_OK) {
19991998
_mcps_confirmation.req_type = mcpsRequest->type;
20001999
_params.flags.bits.mcps_req = 1;
@@ -2005,38 +2004,37 @@ lorawan_status_t LoRaMac::test_request( loramac_compliance_test_req_t *mcpsReque
20052004
return status;
20062005
}
20072006

2008-
lorawan_status_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
2007+
lorawan_status_t LoRaMac::LoRaMacSetTxTimer(uint32_t TxDutyCycleTime)
20092008
{
20102009
_lora_time.start(tx_next_packet_timer, TxDutyCycleTime);
20112010
return LORAWAN_STATUS_OK;
20122011
}
20132012

2014-
lorawan_status_t LoRaMac::LoRaMacStopTxTimer( )
2013+
lorawan_status_t LoRaMac::LoRaMacStopTxTimer()
20152014
{
20162015
_lora_time.stop(tx_next_packet_timer);
20172016
return LORAWAN_STATUS_OK;
20182017
}
20192018

2020-
void LoRaMac::LoRaMacTestRxWindowsOn( bool enable )
2019+
void LoRaMac::LoRaMacTestRxWindowsOn(bool enable)
20212020
{
20222021
_params.is_rx_window_enabled = enable;
20232022
}
20242023

2025-
void LoRaMac::LoRaMacTestSetMic( uint16_t txPacketCounter )
2024+
void LoRaMac::LoRaMacTestSetMic(uint16_t txPacketCounter)
20262025
{
20272026
_params.ul_frame_counter = txPacketCounter;
20282027
_params.is_ul_frame_counter_fixed = true;
20292028
}
20302029

2031-
void LoRaMac::LoRaMacTestSetDutyCycleOn( bool enable )
2030+
void LoRaMac::LoRaMacTestSetDutyCycleOn(bool enable)
20322031
{
2033-
if(_lora_phy.verify_duty_cycle(enable) == true)
2034-
{
2032+
if (_lora_phy.verify_duty_cycle(enable) == true) {
20352033
_params.is_dutycycle_on = enable;
20362034
}
20372035
}
20382036

2039-
void LoRaMac::LoRaMacTestSetChannel( uint8_t channel )
2037+
void LoRaMac::LoRaMacTestSetChannel(uint8_t channel)
20402038
{
20412039
_params.channel = channel;
20422040
}

0 commit comments

Comments
 (0)