Style changes only

Travis astyle check pointed out some of the style mismatches in the code.
Not all of them are worth changing as they make the code unreadable and
some of them are semantically wrong.

So in this commit, we have attempted to pick the most important style
mismatches and rectify.
pull/6938/head
Hasnain Virk 2018-05-17 11:51:11 +03:00
parent e438846c2d
commit 9ac7f21140
10 changed files with 345 additions and 332 deletions

View File

@ -502,8 +502,14 @@ public:
*/
virtual lorawan_status_t cancel_sending(void);
void lock(void) { _lw_stack.lock(); }
void unlock(void) { _lw_stack.unlock(); }
void lock(void)
{
_lw_stack.lock();
}
void unlock(void)
{
_lw_stack.unlock();
}
private:

View File

@ -56,7 +56,7 @@ using namespace events;
#else
#error "Must set LoRa PHY layer parameters."
#endif
#endif
#endif //defined(LORAWAN_COMPLIANCE_TEST)
/**
* Bit mask for message flags
@ -170,10 +170,11 @@ lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
return LORAWAN_STATUS_NOT_INITIALIZED;
}
if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA) &&
!(connect.connect_type == LORAWAN_CONNECTION_ABP)) {
if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA)
&& !(connect.connect_type == LORAWAN_CONNECTION_ABP)) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
bool is_otaa = (connect.connect_type == LORAWAN_CONNECTION_OTAA);
lorawan_status_t status = _loramac.prepare_join(&connect, is_otaa);
@ -374,8 +375,8 @@ int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, i
// check the length of received message whether we can fit into user
// buffer completely or not
if (_rx_msg.msg.mcps_indication.buffer_size > length &&
_rx_msg.prev_read_size == 0) {
if (_rx_msg.msg.mcps_indication.buffer_size > length
&& _rx_msg.prev_read_size == 0) {
// we can't fit into user buffer. Invoke counter measures
_rx_msg.pending_size = _rx_msg.msg.mcps_indication.buffer_size - length;
base_size = length;
@ -1138,8 +1139,7 @@ void LoRaWANStack::process_connected_state()
void LoRaWANStack::process_connecting_state(lorawan_status_t &op_status)
{
if (_device_current_state != DEVICE_STATE_IDLE
&&
_device_current_state != DEVICE_STATE_SHUTDOWN) {
&& _device_current_state != DEVICE_STATE_SHUTDOWN) {
op_status = LORAWAN_STATUS_BUSY;
return;
}

View File

@ -425,8 +425,14 @@ public:
*/
lorawan_status_t stop_sending(void);
void lock(void) { _loramac.lock(); }
void unlock(void) { _loramac.unlock(); }
void lock(void)
{
_loramac.lock();
}
void unlock(void)
{
_loramac.unlock();
}
private:
typedef mbed::ScopedLock<LoRaWANStack> Lock;

View File

@ -425,10 +425,11 @@ void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload,
if (fopts_len > 0) {
// Decode Options field MAC commands. Omit the fPort.
if (_mac_commands.process_mac_commands(payload, 8,
payload_start_index - 1, snr,
payload_start_index - 1,
snr,
_mlme_confirmation,
_params.sys_params, _lora_phy)
!= LORAWAN_STATUS_OK) {
_params.sys_params,
_lora_phy) != LORAWAN_STATUS_OK) {
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
return;
}
@ -738,11 +739,13 @@ rx_slot_t LoRaMac::on_radio_rx_timeout(bool is_timeout)
if (_params.rx_slot == RX_SLOT_WIN_1) {
if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
_mcps_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
}
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
_mlme_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
if (_device_class != CLASS_C) {
if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time) >= _params.rx_window2_delay) {
@ -751,12 +754,14 @@ rx_slot_t LoRaMac::on_radio_rx_timeout(bool is_timeout)
}
} else {
if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
_mcps_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
}
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
_mlme_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
}
if (_device_class == CLASS_C) {
@ -929,8 +934,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
if ((_params.ack_timeout_retry_counter % 2)
&& (_params.sys_params.adr_on)) {
tr_debug("Trading datarate for range");
_params.sys_params.channel_data_rate = _lora_phy.get_next_lower_tx_datarate(
_params.sys_params.channel_data_rate);
_params.sys_params.channel_data_rate = _lora_phy.get_next_lower_tx_datarate(_params.sys_params.channel_data_rate);
}
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
@ -945,6 +949,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
_mac_commands.clear_command_buffer();
_params.is_node_ack_requested = false;
_mcps_confirmation.ack_received = false;
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
// now that is a critical failure
lorawan_status_t status = handle_retransmission();
@ -1331,12 +1336,12 @@ void LoRaMac::set_device_class(const device_class_t& device_class,
} else if (CLASS_C == _device_class) {
_params.is_node_ack_requested = false;
_lora_phy.put_radio_to_sleep();
_lora_phy.compute_rx_win_params(
_params.sys_params.rx2_channel.datarate,
_lora_phy.compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
_params.sys_params.min_rx_symb,
_params.sys_params.max_sys_rx_error,
&_params.rx_window2_config);
}
if (CLASS_C == _device_class) {
tr_debug("Changing device class to -> CLASS_C");
open_rx2_window();
@ -1358,10 +1363,10 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
{
if (params) {
if (is_otaa) {
if ((params->connection_u.otaa.dev_eui == NULL) ||
(params->connection_u.otaa.app_eui == NULL) ||
(params->connection_u.otaa.app_key == NULL) ||
(params->connection_u.otaa.nb_trials == 0)) {
if ((params->connection_u.otaa.dev_eui == NULL)
|| (params->connection_u.otaa.app_eui == NULL)
|| (params->connection_u.otaa.app_key == NULL)
|| (params->connection_u.otaa.nb_trials == 0)) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
_params.keys.dev_eui = params->connection_u.otaa.dev_eui;
@ -1411,13 +1416,12 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
_params.net_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
_params.dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
memcpy(_params.keys.nwk_skey, nwk_skey,
sizeof(_params.keys.nwk_skey));
memcpy(_params.keys.nwk_skey, nwk_skey, sizeof(_params.keys.nwk_skey));
memcpy(_params.keys.app_skey, app_skey,
sizeof(_params.keys.app_skey));
memcpy(_params.keys.app_skey, app_skey, sizeof(_params.keys.app_skey));
#endif
}
return LORAWAN_STATUS_OK;
}
@ -1856,8 +1860,7 @@ lorawan_status_t LoRaMac::multicast_channel_link(multicast_params_t *channel_par
return LORAWAN_STATUS_OK;
}
lorawan_status_t LoRaMac::multicast_channel_unlink(
multicast_params_t *channel_param)
lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_param)
{
if (channel_param == NULL) {
return LORAWAN_STATUS_PARAMETER_INVALID;
@ -1933,7 +1936,6 @@ lorawan_status_t LoRaMac::mlme_request( loramac_mlme_req_t *mlmeRequest )
_params.flags.bits.mlme_req = 0;
}
return status;
}

View File

@ -460,8 +460,16 @@ public:
* the stack thread safe.
*/
#if MBED_CONF_RTOS_PRESENT
void lock(void) { osStatus status = _mutex.lock(); MBED_ASSERT(status == osOK); }
void unlock(void) { osStatus status = _mutex.unlock(); MBED_ASSERT(status == osOK); }
void lock(void)
{
osStatus status = _mutex.lock();
MBED_ASSERT(status == osOK);
}
void unlock(void)
{
osStatus status = _mutex.unlock();
MBED_ASSERT(status == osOK);
}
#else
void lock(void) { }
void unlock(void) { }

View File

@ -272,8 +272,7 @@
/**
* TX configuration parameters.
*/
typedef struct
{
typedef struct {
/**
* The TX channel.
*/
@ -304,8 +303,7 @@ typedef struct
* This structure contains parameters for ADR request coming from
* network server.
*/
typedef struct
{
typedef struct {
/*!
* A pointer to the payload containing the MAC commands.
*/
@ -339,8 +337,7 @@ typedef struct
/**
* Structure containing data for local ADR settings
*/
typedef struct link_adr_params_s
{
typedef struct link_adr_params_s {
/**
* The number of repetitions.
*/
@ -367,8 +364,7 @@ typedef struct link_adr_params_s
* Structure used to store ADR values received from network
* for verification (legality) purposes.
*/
typedef struct verify_adr_params_s
{
typedef struct verify_adr_params_s {
/*!
* The current status of the AdrLinkRequest.
*/
@ -412,8 +408,7 @@ typedef struct verify_adr_params_s
* Contains rx parameter setup request coming from
* network server.
*/
typedef struct rx_param_setup_req_s
{
typedef struct rx_param_setup_req_s {
/**
* The datarate to set up.
*/
@ -431,8 +426,7 @@ typedef struct rx_param_setup_req_s
/**
* The parameter structure for the function RegionNextChannel.
*/
typedef struct channel_selection_params_s
{
typedef struct channel_selection_params_s {
/**
* The aggregated time-off time.
*/
@ -458,8 +452,7 @@ typedef struct channel_selection_params_s
/*!
* The parameter structure for the function RegionContinuousWave.
*/
typedef struct continuous_wave_mode_params_s
{
typedef struct continuous_wave_mode_params_s {
/*!
* The current channel index.
*/

View File

@ -431,8 +431,7 @@ typedef union {
/*!
* The structure containing single access to header bits.
*/
struct hdr_bits_s
{
struct hdr_bits_s {
/*!
* Major version.
*/
@ -461,8 +460,7 @@ typedef union {
/*!
* The structure containing single access to bits.
*/
struct ctrl_bits_s
{
struct ctrl_bits_s {
/*!
* Frame options length.
*/