lorawan: fix astyle coding style

pull/8591/head
Martin Kojtal 2018-10-30 15:10:03 +00:00
parent 7bd258154d
commit 884a7748b2
29 changed files with 330 additions and 315 deletions

View File

@ -289,7 +289,7 @@ void LoRaMac::handle_join_accept_frame(const uint8_t *payload, uint16_t size)
void LoRaMac::check_frame_size(uint16_t size)
{
uint8_t value = _lora_phy->get_max_payload(_mcps_indication.rx_datarate,
_params.is_repeater_supported);
_params.is_repeater_supported);
if (MAX(0, (int16_t)((int16_t)size - (int16_t)LORA_MAC_FRMPAYLOAD_OVERHEAD))
> (int32_t) value) {
@ -319,7 +319,7 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
mic_rx |= ((uint32_t) payload[size - LORAMAC_MFR_LEN + 2] << 16);
mic_rx |= ((uint32_t) payload[size - LORAMAC_MFR_LEN + 3] << 24);
sequence_counter_prev = (uint16_t)*downlink_counter;
sequence_counter_prev = (uint16_t) * downlink_counter;
sequence_counter_diff = sequence_counter - sequence_counter_prev;
*downlink_counter += sequence_counter_diff;
if (sequence_counter < sequence_counter_prev) {
@ -600,8 +600,8 @@ void LoRaMac::handle_data_frame(const uint8_t *const payload,
}
if (_device_class == CLASS_C) {
_lora_time.stop(_rx2_closure_timer_for_class_c);
}
_lora_time.stop(_rx2_closure_timer_for_class_c);
}
if (_params.is_node_ack_requested && fctrl.bits.ack) {
_mcps_confirmation.ack_received = fctrl.bits.ack;
@ -699,7 +699,7 @@ void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size,
if (_device_class == CLASS_C && !_continuous_rx2_window_open) {
_lora_time.stop(_rx2_closure_timer_for_class_c);
open_rx2_window();
} else if (_device_class != CLASS_C){
} else if (_device_class != CLASS_C) {
_lora_time.stop(_params.timers.rx_window1_timer);
_lora_phy->put_radio_to_sleep();
}
@ -1118,9 +1118,9 @@ lorawan_status_t LoRaMac::schedule_tx()
next_channel.last_aggregate_tx_time = _params.timers.aggregated_last_tx_time;
lorawan_status_t status = _lora_phy->set_next_channel(&next_channel,
&_params.channel,
&backoff_time,
&_params.timers.aggregated_timeoff);
&_params.channel,
&backoff_time,
&_params.timers.aggregated_timeoff);
switch (status) {
case LORAWAN_STATUS_NO_CHANNEL_FOUND:
@ -1139,20 +1139,20 @@ lorawan_status_t LoRaMac::schedule_tx()
}
uint8_t rx1_dr = _lora_phy->apply_DR_offset(_params.sys_params.channel_data_rate,
_params.sys_params.rx1_dr_offset);
_params.sys_params.rx1_dr_offset);
tr_debug("TX: Channel=%d, TX DR=%d, RX1 DR=%d",
_params.channel, _params.sys_params.channel_data_rate, rx1_dr);
_lora_phy->compute_rx_win_params(rx1_dr, MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window1_config);
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window1_config);
_lora_phy->compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window2_config);
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window2_config);
if (!_is_nwk_joined) {
_params.rx_window1_delay = _params.sys_params.join_accept_delay1
@ -1177,8 +1177,8 @@ lorawan_status_t LoRaMac::schedule_tx()
fopts_len) == false) {
tr_error("Allowed FRMPayload = %d, FRMPayload = %d, MAC commands pending = %d",
_lora_phy->get_max_payload(_params.sys_params.channel_data_rate,
_params.is_repeater_supported),
_ongoing_tx_msg.f_buffer_size, fopts_len);
_params.is_repeater_supported),
_ongoing_tx_msg.f_buffer_size, fopts_len);
return LORAWAN_STATUS_LENGTH_ERROR;
}
_params.rx_window1_delay = _params.sys_params.recv_delay1
@ -1201,7 +1201,7 @@ void LoRaMac::calculate_backOff(uint8_t channel)
{
lorawan_time_t elapsed_time = _lora_time.get_elapsed_time(_params.timers.mac_init_time);
_lora_phy->calculate_backoff(_is_nwk_joined, _params.is_last_tx_join_request, _params.is_dutycycle_on,
channel, elapsed_time, _params.timers.tx_toa);
channel, elapsed_time, _params.timers.tx_toa);
// Update aggregated time-off. This must be an assignment and no incremental
// update as we do only calculate the time-off based on the last transmission
@ -1301,7 +1301,7 @@ int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port,
_ongoing_tx_msg.port = port;
uint8_t max_possible_size = 0;
uint8_t fopts_len = _mac_commands.get_mac_cmd_length()
+ _mac_commands.get_repeat_commands_length();
+ _mac_commands.get_repeat_commands_length();
// Handles unconfirmed messages
if (flags & MSG_UNCONFIRMED_FLAG) {
@ -1420,9 +1420,9 @@ void LoRaMac::set_device_class(const device_class_t &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,
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window2_config);
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window2_config);
}
if (CLASS_C == _device_class) {
@ -1607,9 +1607,9 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
if (_params.sys_params.adr_on) {
if (_lora_phy->get_next_ADR(true,
_params.sys_params.channel_data_rate,
_params.sys_params.channel_tx_power,
_params.adr_ack_counter)) {
_params.sys_params.channel_data_rate,
_params.sys_params.channel_tx_power,
_params.adr_ack_counter)) {
fctrl->bits.adr_ack_req = 1;
}
}
@ -1696,7 +1696,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
_params.tx_buffer_len += LORAMAC_MFR_LEN;
}
break;
break;
case FRAME_TYPE_PROPRIETARY:
if ((fbuffer != NULL) && (_params.tx_buffer_len > 0)) {
memcpy(_params.tx_buffer + pkt_header_len, (uint8_t *) fbuffer,

View File

@ -38,7 +38,7 @@ void LoRaMacChannelPlan::activate_channelplan_subsystem(LoRaPHY *phy)
_lora_phy = phy;
}
lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t& plan)
lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t &plan)
{
lorawan_status_t status;
@ -66,8 +66,8 @@ lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t& plan)
return LORAWAN_STATUS_OK;
}
lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t& plan,
const channel_params_t* channel_list)
lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t &plan,
const channel_params_t *channel_list)
{
uint8_t max_num_channels;
uint16_t *channel_mask;

View File

@ -67,7 +67,7 @@ public:
* @return LORAWAN_STATUS_OK if everything goes well otherwise
* a negative error code is returned.
*/
lorawan_status_t set_plan(const lorawan_channelplan_t& plan);
lorawan_status_t set_plan(const lorawan_channelplan_t &plan);
/** Access the active channel plan
*
@ -81,7 +81,7 @@ public:
* @return LORAWAN_STATUS_OK if everything goes well otherwise
* a negative error code is returned.
*/
lorawan_status_t get_plan(lorawan_channelplan_t& plan, const channel_params_t* channel_list);
lorawan_status_t get_plan(lorawan_channelplan_t &plan, const channel_params_t *channel_list);
/** Remove the active channel plan
*

View File

@ -129,7 +129,7 @@ bool LoRaMacCommand::has_sticky_mac_cmd() const
lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, uint8_t mac_index,
uint8_t commands_size, uint8_t snr,
loramac_mlme_confirm_t& mlme_conf,
loramac_mlme_confirm_t &mlme_conf,
lora_mac_system_params_t &mac_sys_params,
LoRaPHY &lora_phy)
{
@ -180,7 +180,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
// Update MAC index
mac_index += link_adr_nb_bytes_pasred - 1;
}
break;
break;
case SRV_MAC_DUTY_CYCLE_REQ:
mac_sys_params.max_duty_cycle = payload[mac_index++];
mac_sys_params.aggregated_duty_cycle = 1 << mac_sys_params.max_duty_cycle;
@ -207,7 +207,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
}
ret_value = add_rx_param_setup_ans(status);
}
break;
break;
case SRV_MAC_DEV_STATUS_REQ: {
uint8_t battery_level = BAT_LEVEL_NO_MEASURE;
if (_battery_level_cb) {
@ -231,7 +231,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
ret_value = add_new_channel_ans(status);
}
break;
break;
case SRV_MAC_RX_TIMING_SETUP_REQ: {
uint8_t delay = payload[mac_index++] & 0x0F;
@ -242,7 +242,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
mac_sys_params.recv_delay2 = mac_sys_params.recv_delay1 + 1000;
ret_value = add_rx_timing_setup_ans();
}
break;
break;
case SRV_MAC_TX_PARAM_SETUP_REQ: {
uint8_t eirpDwellTime = payload[mac_index++];
uint8_t ul_dwell_time;
@ -270,7 +270,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
ret_value = add_tx_param_setup_ans();
}
}
break;
break;
case SRV_MAC_DL_CHANNEL_REQ: {
uint8_t channel_id = payload[mac_index++];
uint32_t rx1_frequency;
@ -283,7 +283,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
ret_value = add_dl_channel_ans(status);
}
break;
break;
default:
// Unknown command. ABORT MAC commands processing
tr_error("Invalid MAC command (0x%X)!", payload[mac_index]);

View File

@ -116,9 +116,9 @@ public:
*/
lorawan_status_t process_mac_commands(const uint8_t *payload, uint8_t mac_index,
uint8_t commands_size, uint8_t snr,
loramac_mlme_confirm_t& mlme_conf,
lora_mac_system_params_t& mac_params,
LoRaPHY& lora_phy);
loramac_mlme_confirm_t &mlme_conf,
lora_mac_system_params_t &mac_params,
LoRaPHY &lora_phy);
/**
* @brief Adds a new LinkCheckReq MAC command to be sent.

View File

@ -63,32 +63,37 @@ int LoRaMacCrypto::compute_mic(const uint8_t *buffer, uint16_t size,
mbedtls_cipher_init(aes_cmac_ctx);
const mbedtls_cipher_info_t* cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_ECB);
const mbedtls_cipher_info_t *cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_ECB);
if (NULL != cipher_info) {
ret = mbedtls_cipher_setup(aes_cmac_ctx, cipher_info);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_starts(aes_cmac_ctx, key, key_length);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_update(aes_cmac_ctx, mic_block_b0, sizeof(mic_block_b0));
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_update(aes_cmac_ctx, buffer, size & 0xFF);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_finish(aes_cmac_ctx, computed_mic);
if (0 != ret)
if (0 != ret) {
goto exit;
}
*mic = (uint32_t) ((uint32_t) computed_mic[3] << 24
| (uint32_t) computed_mic[2] << 16
| (uint32_t) computed_mic[1] << 8 | (uint32_t) computed_mic[0]);
*mic = (uint32_t)((uint32_t) computed_mic[3] << 24
| (uint32_t) computed_mic[2] << 16
| (uint32_t) computed_mic[1] << 8 | (uint32_t) computed_mic[0]);
} else {
ret = MBEDTLS_ERR_CIPHER_ALLOC_FAILED;
}
@ -112,8 +117,9 @@ int LoRaMacCrypto::encrypt_payload(const uint8_t *buffer, uint16_t size,
mbedtls_aes_init(&aes_ctx);
ret = mbedtls_aes_setkey_enc(&aes_ctx, key, key_length);
if (0 != ret)
if (0 != ret) {
goto exit;
}
a_block[0] = 0x01;
a_block[5] = dir;
@ -133,8 +139,9 @@ int LoRaMacCrypto::encrypt_payload(const uint8_t *buffer, uint16_t size,
ctr++;
ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, a_block,
s_block);
if (0 != ret)
if (0 != ret) {
goto exit;
}
for (i = 0; i < 16; i++) {
enc_buffer[bufferIndex + i] = buffer[bufferIndex + i] ^ s_block[i];
@ -147,8 +154,9 @@ int LoRaMacCrypto::encrypt_payload(const uint8_t *buffer, uint16_t size,
a_block[15] = ((ctr) & 0xFF);
ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, a_block,
s_block);
if (0 != ret)
if (0 != ret) {
goto exit;
}
for (i = 0; i < size; i++) {
enc_buffer[bufferIndex + i] = buffer[bufferIndex + i] ^ s_block[i];
@ -177,28 +185,32 @@ int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *buffer, uint16_t size,
int ret = 0;
mbedtls_cipher_init(aes_cmac_ctx);
const mbedtls_cipher_info_t* cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_ECB);
const mbedtls_cipher_info_t *cipher_info = mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_ECB);
if (NULL != cipher_info) {
ret = mbedtls_cipher_setup(aes_cmac_ctx, cipher_info);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_starts(aes_cmac_ctx, key, key_length);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_update(aes_cmac_ctx, buffer, size & 0xFF);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_cipher_cmac_finish(aes_cmac_ctx, computed_mic);
if (0 != ret)
if (0 != ret) {
goto exit;
}
*mic = (uint32_t) ((uint32_t) computed_mic[3] << 24
| (uint32_t) computed_mic[2] << 16
| (uint32_t) computed_mic[1] << 8 | (uint32_t) computed_mic[0]);
*mic = (uint32_t)((uint32_t) computed_mic[3] << 24
| (uint32_t) computed_mic[2] << 16
| (uint32_t) computed_mic[1] << 8 | (uint32_t) computed_mic[0]);
} else {
ret = MBEDTLS_ERR_CIPHER_ALLOC_FAILED;
}
@ -217,13 +229,15 @@ int LoRaMacCrypto::decrypt_join_frame(const uint8_t *buffer, uint16_t size,
mbedtls_aes_init(&aes_ctx);
ret = mbedtls_aes_setkey_enc(&aes_ctx, key, key_length);
if (0 != ret)
if (0 != ret) {
goto exit;
}
ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, buffer,
dec_buffer);
if (0 != ret)
if (0 != ret) {
goto exit;
}
// Check if optional CFList is included
if (size >= 16) {
@ -247,16 +261,18 @@ int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *key, uint32_t key
mbedtls_aes_init(&aes_ctx);
ret = mbedtls_aes_setkey_enc(&aes_ctx, key, key_length);
if (0 != ret)
if (0 != ret) {
goto exit;
}
memset(nonce, 0, sizeof(nonce));
nonce[0] = 0x01;
memcpy(nonce + 1, app_nonce, 6);
memcpy(nonce + 7, p_dev_nonce, 2);
ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, nonce, nwk_skey);
if (0 != ret)
if (0 != ret) {
goto exit;
}
memset(nonce, 0, sizeof(nonce));
nonce[0] = 0x02;
@ -279,7 +295,7 @@ LoRaMacCrypto::LoRaMacCrypto()
// user knows what is wrong and in addition to that these ensure that
// Mbed-OS compiles properly under normal conditions where LoRaWAN in conjunction
// with mbedTLS is not being used.
int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t,
uint8_t dir, uint32_t, uint32_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
@ -288,8 +304,8 @@ int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t , const uint8_t *, uint
return LORAWAN_STATUS_CRYPTO_FAIL;
}
int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
uint8_t , uint32_t , uint8_t *)
int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t,
uint8_t, uint32_t, uint8_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
@ -297,8 +313,8 @@ int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t , const uint8_t *,
return LORAWAN_STATUS_CRYPTO_FAIL;
}
int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
uint8_t , uint32_t , uint8_t *)
int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t,
uint8_t, uint32_t, uint8_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
@ -306,7 +322,7 @@ int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t , const uint8_t *,
return LORAWAN_STATUS_CRYPTO_FAIL;
}
int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t *)
int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
@ -314,7 +330,7 @@ int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t , const uint
return LORAWAN_STATUS_CRYPTO_FAIL;
}
int LoRaMacCrypto::decrypt_join_frame(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint8_t *)
int LoRaMacCrypto::decrypt_join_frame(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint8_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
@ -322,7 +338,7 @@ int LoRaMacCrypto::decrypt_join_frame(const uint8_t *, uint16_t , const uint8_t
return LORAWAN_STATUS_CRYPTO_FAIL;
}
int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t ,
int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t,
uint8_t *, uint8_t *)
{
MBED_ASSERT(0 && "[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");

View File

@ -34,8 +34,7 @@ SPDX-License-Identifier: BSD-3-Clause
#include "mbedtls/cmac.h"
class LoRaMacCrypto
{
class LoRaMacCrypto {
public:
/**
* Constructor

View File

@ -404,7 +404,7 @@ void LoRaPHY::get_rx_window_params(double t_symb, uint8_t min_rx_symb,
{
// Computed number of symbols
*window_timeout = MAX((uint32_t) ceil(((2 * min_rx_symb - 8) * t_symb + 2 * rx_error) / t_symb), min_rx_symb);
*window_offset = (int32_t) ceil((4.0 * t_symb) - ((*window_timeout * t_symb) / 2.0 ) - wakeup_time);
*window_offset = (int32_t) ceil((4.0 * t_symb) - ((*window_timeout * t_symb) / 2.0) - wakeup_time);
}
int8_t LoRaPHY::compute_tx_power(int8_t tx_power_idx, float max_eirp,

View File

@ -147,7 +147,7 @@ public:
*
* @return bit mask, according to the LoRaWAN spec 1.0.2.
*/
virtual uint8_t request_new_channel(int8_t channel_id, channel_params_t* new_channel);
virtual uint8_t request_new_channel(int8_t channel_id, channel_params_t *new_channel);
/** Process PHY layer state after a successful transmission.
* @brief set_last_tx_done Updates times of the last transmission for the particular channel and
@ -174,7 +174,7 @@ public:
* @param size Size of the payload.
*
*/
virtual void apply_cf_list(const uint8_t* payload, uint8_t size);
virtual void apply_cf_list(const uint8_t *payload, uint8_t size);
/** Calculates the next datarate to set, when ADR is on or off.
*
@ -189,8 +189,8 @@ public:
*
* @return True, if an ADR request should be performed.
*/
bool get_next_ADR(bool restore_channel_mask, int8_t& dr_out,
int8_t& tx_power_out, uint32_t& adr_ack_counter);
bool get_next_ADR(bool restore_channel_mask, int8_t &dr_out,
int8_t &tx_power_out, uint32_t &adr_ack_counter);
/** Configure radio reception.
*
@ -198,7 +198,7 @@ public:
*
* @return True, if the configuration was applied successfully.
*/
virtual bool rx_config(rx_config_params_t* config);
virtual bool rx_config(rx_config_params_t *config);
/** Computing Receive Windows
*
@ -268,8 +268,8 @@ public:
*
* @return True, if the configuration was applied successfully.
*/
virtual bool tx_config(tx_config_params_t* tx_config, int8_t* tx_power,
lorawan_time_t* tx_toa);
virtual bool tx_config(tx_config_params_t *tx_config, int8_t *tx_power,
lorawan_time_t *tx_toa);
/** Processes a Link ADR Request.
*
@ -285,10 +285,10 @@ public:
*
* @return The status of the operation, according to the LoRaMAC specification.
*/
virtual uint8_t link_ADR_request(adr_req_params_t* params,
int8_t* dr_out, int8_t* tx_power_out,
uint8_t* nb_rep_out,
uint8_t* nb_bytes_parsed);
virtual uint8_t link_ADR_request(adr_req_params_t *params,
int8_t *dr_out, int8_t *tx_power_out,
uint8_t *nb_rep_out,
uint8_t *nb_bytes_parsed);
/** Accept or rejects RxParamSetupReq MAC command
*
@ -299,7 +299,7 @@ public:
*
* @return The status of the operation, according to the LoRaWAN specification.
*/
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t* params);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params);
/**
* @brief accept_tx_param_setup_req Makes decision whether to accept or reject TxParamSetupReq MAC command.
@ -345,9 +345,9 @@ public:
*
* @return Function status [1: OK, 0: Unable to find a channel on the current datarate].
*/
virtual lorawan_status_t set_next_channel(channel_selection_params_t* nextChanParams,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregatedTimeOff);
virtual lorawan_status_t set_next_channel(channel_selection_params_t *nextChanParams,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregatedTimeOff);
/** Adds a channel to the channel list.
*
@ -361,7 +361,7 @@ public:
* @return LORAWAN_STATUS_OK if everything goes fine, negative error code
* otherwise.
*/
virtual lorawan_status_t add_channel(const channel_params_t* new_channel, uint8_t id);
virtual lorawan_status_t add_channel(const channel_params_t *new_channel, uint8_t id);
/** Removes a channel from the channel list.
*
@ -377,7 +377,7 @@ public:
*
* @param [in] frequency Frequency to transmit at
*/
virtual void set_tx_cont_mode(cw_mode_params_t* continuous_wave,
virtual void set_tx_cont_mode(cw_mode_params_t *continuous_wave,
uint32_t frequency = 0);
/** Computes new data rate according to the given offset
@ -474,7 +474,7 @@ public:
* @param get_default If true the default mask is returned, otherwise the current mask is returned
* @return A channel mask
*/
uint16_t* get_channel_mask(bool get_default = false);
uint16_t *get_channel_mask(bool get_default = false);
/**
* @brief get_max_nb_channels Gets maximum number of channels supported
@ -486,7 +486,7 @@ public:
* @brief get_phy_channels Gets PHY channels
* @return PHY channels
*/
channel_params_t* get_phy_channels();
channel_params_t *get_phy_channels();
/**
* @brief is_custom_channel_plan_supported Checks if custom channel plan is supported
@ -553,12 +553,12 @@ protected:
/**
* Verifies, if a datarate is available on an active channel.
*/
bool verify_channel_DR(uint16_t* channelsMask, int8_t dr);
bool verify_channel_DR(uint16_t *channelsMask, int8_t dr);
/**
* Disables a channel in a given channels mask.
*/
bool disable_channel(uint16_t* channel_mask, uint8_t id, uint8_t max_channels);
bool disable_channel(uint16_t *channel_mask, uint8_t id, uint8_t max_channels);
/**
* Counts number of bits on in a given mask
@ -568,38 +568,38 @@ protected:
/**
* Counts the number of active channels in a given channels mask.
*/
uint8_t num_active_channels(uint16_t* channel_mask, uint8_t start_idx,
uint8_t num_active_channels(uint16_t *channel_mask, uint8_t start_idx,
uint8_t stop_idx);
/**
* Copy channel masks.
*/
void copy_channel_mask(uint16_t* dest_mask, uint16_t* src_mask, uint8_t len);
void copy_channel_mask(uint16_t *dest_mask, uint16_t *src_mask, uint8_t len);
/**
* Updates the time-offs of the bands.
*/
lorawan_time_t update_band_timeoff(bool joined, bool dutyCycle, band_t* bands,
lorawan_time_t update_band_timeoff(bool joined, bool dutyCycle, band_t *bands,
uint8_t nb_bands);
/**
* Parses the parameter of an LinkAdrRequest.
*/
uint8_t parse_link_ADR_req(const uint8_t* payload, link_adr_params_t* adr_params);
uint8_t parse_link_ADR_req(const uint8_t *payload, link_adr_params_t *adr_params);
/**
* Verifies and updates the datarate, the TX power and the number of repetitions
* of a LinkAdrRequest.
*/
uint8_t verify_link_ADR_req(verify_adr_params_t* verify_params, int8_t* dr,
int8_t* tx_pow, uint8_t* nb_rep);
uint8_t verify_link_ADR_req(verify_adr_params_t *verify_params, int8_t *dr,
int8_t *tx_pow, uint8_t *nb_rep);
/**
* Computes the RX window timeout and the RX window offset.
*/
void get_rx_window_params(double t_symbol, uint8_t min_rx_symbols,
uint32_t rx_error, uint32_t wakeup_time,
uint32_t* window_timeout, int32_t* window_offset);
uint32_t *window_timeout, int32_t *window_offset);
/**
* Computes the txPower, based on the max EIRP and the antenna gain.
@ -622,8 +622,8 @@ protected:
uint8_t get_bandwidth(uint8_t dr_index);
uint8_t enabled_channel_count(uint8_t datarate,
const uint16_t *mask, uint8_t* enabledChannels,
uint8_t* delayTx);
const uint16_t *mask, uint8_t *enabledChannels,
uint8_t *delayTx);
bool is_datarate_supported(const int8_t datarate) const;
@ -632,7 +632,7 @@ private:
/**
* Computes the symbol time for LoRa modulation.
*/
double compute_symb_timeout_lora(uint8_t phy_dr, uint32_t bandwidth );
double compute_symb_timeout_lora(uint8_t phy_dr, uint32_t bandwidth);
/**
* Computes the symbol time for FSK modulation.

View File

@ -194,13 +194,13 @@ static const band_t AS923_BAND0 = {100, AS923_MAX_TX_POWER, 0, 0, 0, 923000000,
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t AS923_LC1 = { 923200000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t AS923_LC1 = { 923200000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t AS923_LC2 = { 923400000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t AS923_LC2 = { 923400000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac channels which are allowed for the join procedure
@ -228,12 +228,12 @@ static const uint8_t datarates_AS923[] = {12, 11, 10, 9, 8, 7, 7, 50};
static const uint32_t bandwidths_AS923[] = {125000, 125000, 125000, 125000, 125000, 125000, 250000, 0};
#if (MBED_CONF_LORA_DWELL_TIME == 0)
static const uint8_t max_payload_table[] = {51, 51, 51, 115, 242, 242, 242, 242};
static const uint8_t max_payload_table_with_repeater[] = {51, 51, 51, 115, 222, 222, 222, 222};
static const uint8_t max_payload_table[] = {51, 51, 51, 115, 242, 242, 242, 242};
static const uint8_t max_payload_table_with_repeater[] = {51, 51, 51, 115, 222, 222, 222, 222};
#else
// this is the default, i.e.,
static const uint8_t max_payload_table[] = {0, 0, 11, 53, 125, 242, 242, 242};
static const uint8_t max_payload_table_with_repeater[] = {0, 0, 11, 53, 125, 242, 242, 242};
// this is the default, i.e.,
static const uint8_t max_payload_table[] = {0, 0, 11, 53, 125, 242, 242, 242};
static const uint8_t max_payload_table_with_repeater[] = {0, 0, 11, 53, 125, 242, 242, 242};
#endif
/*!
@ -336,9 +336,9 @@ int8_t LoRaPHYAS923::get_alternate_DR(uint8_t nb_trials)
return AS923_DWELL_LIMIT_DATARATE;
}
lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next_channel_prams,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregate_timeoff)
lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t *next_channel_prams,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeoff)
{
uint8_t next_channel_idx = 0;
uint8_t nb_enabled_channels = 0;
@ -375,7 +375,7 @@ lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next
for (uint8_t i = 0, j = get_random(0, nb_enabled_channels - 1); i < AS923_MAX_NB_CHANNELS; i++) {
next_channel_idx = enabled_channels[j];
j = ( j + 1 ) % nb_enabled_channels;
j = (j + 1) % nb_enabled_channels;
// Perform carrier sense for AS923_CARRIER_SENSE_TIME
// If the channel is free, we can stop the LBT mechanism
@ -402,7 +402,7 @@ lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next
}
// Datarate not supported by any channel, restore defaults
channel_mask[0] |= LC( 1 ) + LC( 2 );
channel_mask[0] |= LC(1) + LC(2);
*time = 0;
return LORAWAN_STATUS_NO_CHANNEL_FOUND;
}

View File

@ -55,11 +55,11 @@ public:
virtual int8_t get_alternate_DR(uint8_t nb_trials);
virtual lorawan_status_t set_next_channel(channel_selection_params_t* nextChanParams,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregatedTimeOff );
virtual lorawan_status_t set_next_channel(channel_selection_params_t *nextChanParams,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregatedTimeOff);
virtual uint8_t apply_DR_offset(int8_t dr, int8_t drOffset );
virtual uint8_t apply_DR_offset(int8_t dr, int8_t drOffset);
private:
channel_params_t channels[AS923_MAX_NB_CHANNELS];

View File

@ -192,33 +192,38 @@ static const uint8_t datarates_AU915[] = {12, 11, 10, 9, 8, 7, 8, 0, 12, 11, 10,
* Bandwidths table definition in Hz
*/
static const uint32_t bandwidths_AU915[] = { 125000, 125000, 125000, 125000,
125000, 125000, 500000, 0, 500000, 500000, 500000, 500000, 500000, 500000,
0, 0 };
125000, 125000, 500000, 0, 500000, 500000, 500000, 500000, 500000, 500000,
0, 0
};
/*!
* Up/Down link data rates offset definition
*/
static const int8_t datarate_offsets_AU915[7][6] = { { DR_8, DR_8, DR_8, DR_8,
DR_8, DR_8 }, // DR_0
static const int8_t datarate_offsets_AU915[7][6] = { {
DR_8, DR_8, DR_8, DR_8,
DR_8, DR_8
}, // DR_0
{ DR_9, DR_8, DR_8, DR_8, DR_8, DR_8 }, // DR_1
{ DR_10, DR_9, DR_8, DR_8, DR_8, DR_8 }, // DR_2
{ DR_11, DR_10, DR_9, DR_8, DR_8, DR_8 }, // DR_3
{ DR_12, DR_11, DR_10, DR_9, DR_8, DR_8 }, // DR_4
{ DR_13, DR_12, DR_11, DR_10, DR_9, DR_8 }, // DR_5
{ DR_13, DR_13, DR_12, DR_11, DR_10, DR_9 }, // DR_6
};
};
/*!
* Maximum payload with respect to the datarate index. Cannot operate with repeater.
*/
static const uint8_t max_payload_AU915[] = { 51, 51, 51, 115, 242, 242,
242, 0, 53, 129, 242, 242, 242, 242, 0, 0 };
242, 0, 53, 129, 242, 242, 242, 242, 0, 0
};
/*!
* Maximum payload with respect to the datarate index. Can operate with repeater.
*/
static const uint8_t max_payload_with_repeater_AU915[] = { 51, 51, 51, 115,
222, 222, 222, 0, 33, 109, 222, 222, 222, 222, 0, 0 };
222, 222, 222, 0, 33, 109, 222, 222, 222, 222, 0, 0
};
static const uint16_t fsb_mask[] = MBED_CONF_LORA_FSB_MASK;
@ -232,14 +237,14 @@ LoRaPHYAU915::LoRaPHYAU915()
// 125 kHz channels Upstream only
for (uint8_t i = 0; i < AU915_MAX_NB_CHANNELS - 8; i++) {
channels[i].frequency = 915200000 + i * 200000;
channels[i].dr_range.value = ( DR_5 << 4) | DR_0;
channels[i].dr_range.value = (DR_5 << 4) | DR_0;
channels[i].band = 0;
}
// 500 kHz channels
// Upstream and downstream both
for (uint8_t i = AU915_MAX_NB_CHANNELS - 8; i < AU915_MAX_NB_CHANNELS; i++) {
channels[i].frequency = 915900000 + (i - ( AU915_MAX_NB_CHANNELS - 8)) * 1600000;
channels[i].dr_range.value = ( DR_6 << 4) | DR_6;
channels[i].frequency = 915900000 + (i - (AU915_MAX_NB_CHANNELS - 8)) * 1600000;
channels[i].dr_range.value = (DR_6 << 4) | DR_6;
channels[i].band = 0;
}
@ -335,7 +340,7 @@ LoRaPHYAU915::~LoRaPHYAU915()
{
}
bool LoRaPHYAU915::rx_config(rx_config_params_t* params)
bool LoRaPHYAU915::rx_config(rx_config_params_t *params)
{
int8_t dr = params->datarate;
uint8_t max_payload = 0;
@ -349,7 +354,7 @@ bool LoRaPHYAU915::rx_config(rx_config_params_t* params)
if (params->rx_slot == RX_SLOT_WIN_1) {
// Apply window 1 frequency
frequency = AU915_FIRST_RX1_CHANNEL
+ (params->channel % 8) * AU915_STEPWIDTH_RX1_CHANNEL;
+ (params->channel % 8) * AU915_STEPWIDTH_RX1_CHANNEL;
}
// Read the physical datarate from the datarates table
@ -377,8 +382,8 @@ bool LoRaPHYAU915::rx_config(rx_config_params_t* params)
return true;
}
bool LoRaPHYAU915::tx_config(tx_config_params_t* params, int8_t* tx_power,
lorawan_time_t* tx_toa)
bool LoRaPHYAU915::tx_config(tx_config_params_t *params, int8_t *tx_power,
lorawan_time_t *tx_toa)
{
int8_t phy_dr = datarates_AU915[params->datarate];
@ -414,10 +419,10 @@ bool LoRaPHYAU915::tx_config(tx_config_params_t* params, int8_t* tx_power,
return true;
}
uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t* params,
int8_t* dr_out, int8_t* tx_power_out,
uint8_t* nb_rep_out,
uint8_t* nb_bytes_parsed)
uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t *params,
int8_t *dr_out, int8_t *tx_power_out,
uint8_t *nb_rep_out,
uint8_t *nb_bytes_parsed)
{
uint8_t status = 0x07;
link_adr_params_t adr_settings = {};
@ -505,7 +510,7 @@ uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t* params,
return status;
}
uint8_t LoRaPHYAU915::accept_rx_param_setup_req(rx_param_setup_req_t* params)
uint8_t LoRaPHYAU915::accept_rx_param_setup_req(rx_param_setup_req_t *params)
{
uint8_t status = 0x07;
uint32_t freq = params->frequency;
@ -517,7 +522,7 @@ uint8_t LoRaPHYAU915::accept_rx_param_setup_req(rx_param_setup_req_t* params)
|| (freq < AU915_FIRST_RX1_CHANNEL)
|| (freq > AU915_LAST_RX1_CHANNEL)
|| (((freq - (uint32_t) AU915_FIRST_RX1_CHANNEL)
% (uint32_t) AU915_STEPWIDTH_RX1_CHANNEL) != 0)) {
% (uint32_t) AU915_STEPWIDTH_RX1_CHANNEL) != 0)) {
status &= 0xFE; // Channel frequency KO
}
@ -553,9 +558,9 @@ int8_t LoRaPHYAU915::get_alternate_DR(uint8_t nb_trials)
return datarate;
}
lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next_chan_params,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregated_timeOff)
lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t *next_chan_params,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregated_timeOff)
{
uint8_t nb_enabled_channels = 0;
uint8_t delay_tx = 0;
@ -619,7 +624,7 @@ uint8_t LoRaPHYAU915::apply_DR_offset(int8_t dr, int8_t dr_offset)
}
void LoRaPHYAU915::intersect_channel_mask(const uint16_t *source,
uint16_t *destination, uint8_t size)
uint16_t *destination, uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
destination[i] &= source[i];
@ -627,9 +632,9 @@ void LoRaPHYAU915::intersect_channel_mask(const uint16_t *source,
}
void LoRaPHYAU915::fill_channel_mask_with_fsb(const uint16_t *expectation,
const uint16_t *fsb_mask,
uint16_t *destination,
uint8_t size)
const uint16_t *fsb_mask,
uint16_t *destination,
uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
destination[i] = expectation[i] & fsb_mask[i];
@ -638,7 +643,7 @@ void LoRaPHYAU915::fill_channel_mask_with_fsb(const uint16_t *expectation,
}
void LoRaPHYAU915::fill_channel_mask_with_value(uint16_t *channel_mask,
uint16_t value, uint8_t size)
uint16_t value, uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
channel_mask[i] = value;

View File

@ -49,30 +49,30 @@
#define AU915_CHANNEL_MASK_SIZE 5
class LoRaPHYAU915 : public LoRaPHY{
class LoRaPHYAU915 : public LoRaPHY {
public:
LoRaPHYAU915();
virtual ~LoRaPHYAU915();
virtual bool rx_config(rx_config_params_t* config);
virtual bool rx_config(rx_config_params_t *config);
virtual bool tx_config(tx_config_params_t* config, int8_t* txPower,
lorawan_time_t* txTimeOnAir);
virtual bool tx_config(tx_config_params_t *config, int8_t *txPower,
lorawan_time_t *txTimeOnAir);
virtual uint8_t link_ADR_request(adr_req_params_t* params,
int8_t* drOut, int8_t* txPowOut,
uint8_t* nbRepOut,
uint8_t* nbBytesParsed);
virtual uint8_t link_ADR_request(adr_req_params_t *params,
int8_t *drOut, int8_t *txPowOut,
uint8_t *nbRepOut,
uint8_t *nbBytesParsed);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t* params);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params);
virtual int8_t get_alternate_DR(uint8_t nb_trials);
virtual lorawan_status_t set_next_channel(channel_selection_params_t* next_chan_params,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregate_timeoff);
virtual lorawan_status_t set_next_channel(channel_selection_params_t *next_chan_params,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeoff);
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset);

View File

@ -212,10 +212,9 @@ LoRaPHYCN470::LoRaPHYCN470()
// Channels
// 125 kHz channels
for( uint8_t i = 0; i < CN470_MAX_NB_CHANNELS; i++ )
{
for (uint8_t i = 0; i < CN470_MAX_NB_CHANNELS; i++) {
channels[i].frequency = 470300000 + i * 200000;
channels[i].dr_range.value = ( DR_5 << 4 ) | DR_0;
channels[i].dr_range.value = (DR_5 << 4) | DR_0;
channels[i].band = 0;
}
@ -359,7 +358,7 @@ lorawan_status_t LoRaPHYCN470::set_next_channel(channel_selection_params_t *para
return LORAWAN_STATUS_NO_CHANNEL_FOUND;
}
bool LoRaPHYCN470::rx_config(rx_config_params_t* config)
bool LoRaPHYCN470::rx_config(rx_config_params_t *config)
{
int8_t dr = config->datarate;
uint8_t max_payload = 0;
@ -375,8 +374,7 @@ bool LoRaPHYCN470::rx_config(rx_config_params_t* config)
_radio->unlock();
if( config->rx_slot == RX_SLOT_WIN_1 )
{
if (config->rx_slot == RX_SLOT_WIN_1) {
// Apply window 1 frequency
frequency = CN470_FIRST_RX1_CHANNEL + (config->channel % 48) * CN470_STEPWIDTH_RX1_CHANNEL;
}
@ -409,8 +407,8 @@ bool LoRaPHYCN470::rx_config(rx_config_params_t* config)
return true;
}
bool LoRaPHYCN470::tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa)
bool LoRaPHYCN470::tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa)
{
int8_t phy_dr = datarates_CN470[config->datarate];
@ -429,9 +427,9 @@ bool LoRaPHYCN470::tx_config(tx_config_params_t* config, int8_t* tx_power,
_radio->set_channel(channels[config->channel].frequency);
_radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, 0, phy_dr, 1,
MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH, false, true,
0, 0, false, 3000);
_radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, 0, phy_dr, 1,
MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH, false, true,
0, 0, false, 3000);
// Setup maximum payload lenght of the radio driver
_radio->set_max_payload_length(MODEM_LORA, config->pkt_len);
@ -446,10 +444,10 @@ bool LoRaPHYCN470::tx_config(tx_config_params_t* config, int8_t* tx_power,
return true;
}
uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t* params,
int8_t* dr_out, int8_t* tx_power_out,
uint8_t* nb_rep_out,
uint8_t* nb_bytes_parsed)
uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t *params,
int8_t *dr_out, int8_t *tx_power_out,
uint8_t *nb_rep_out,
uint8_t *nb_bytes_parsed)
{
uint8_t status = 0x07;
link_adr_params_t adr_settings;
@ -462,7 +460,7 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t* params,
// Initialize local copy of channels mask
copy_channel_mask(temp_channel_masks, channel_mask, CN470_CHANNEL_MASK_SIZE);
while(bytes_processed < params->payload_size) {
while (bytes_processed < params->payload_size) {
// Get ADR request parameters
next_index = parse_link_ADR_req(&(params->payload[bytes_processed]), &adr_settings);
@ -484,7 +482,7 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t* params,
temp_channel_masks[i] = 0xFFFF;
}
} else if( adr_settings.ch_mask_ctrl == 7 ) {
} else if (adr_settings.ch_mask_ctrl == 7) {
status &= 0xFE; // Channel mask KO
@ -492,8 +490,8 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t* params,
for (uint8_t i = 0; i < 16; i++) {
if (((adr_settings.channel_mask & (1 << i)) != 0 ) &&
(channels[adr_settings.ch_mask_ctrl * 16 + i].frequency == 0)) {
if (((adr_settings.channel_mask & (1 << i)) != 0) &&
(channels[adr_settings.ch_mask_ctrl * 16 + i].frequency == 0)) {
// Trying to enable an undefined channel
status &= 0xFE; // Channel mask KO
}
@ -533,7 +531,7 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t* params,
return status;
}
uint8_t LoRaPHYCN470::accept_rx_param_setup_req(rx_param_setup_req_t* params)
uint8_t LoRaPHYCN470::accept_rx_param_setup_req(rx_param_setup_req_t *params)
{
uint8_t status = 0x07;
uint32_t freq = params->frequency;

View File

@ -57,19 +57,19 @@ public:
virtual ~LoRaPHYCN470();
virtual lorawan_status_t set_next_channel(channel_selection_params_t *params,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeoff);
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeoff);
virtual bool rx_config(rx_config_params_t* config);
virtual bool rx_config(rx_config_params_t *config);
virtual bool tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa);
virtual bool tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa);
virtual uint8_t link_ADR_request(adr_req_params_t* params, int8_t* dr_out,
int8_t* tx_power_out, uint8_t* nb_rep_out,
uint8_t* nb_bytes_parsed);
virtual uint8_t link_ADR_request(adr_req_params_t *params, int8_t *dr_out,
int8_t *tx_power_out, uint8_t *nb_rep_out,
uint8_t *nb_bytes_parsed);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t* params);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params);
private:

View File

@ -191,18 +191,18 @@ static const band_t CN779_BAND0 = {100, CN779_MAX_TX_POWER, 0, 0, 0, 779500000,
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t CN779_LC1 = {779500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t CN779_LC1 = {779500000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t CN779_LC2 = {779700000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t CN779_LC2 = {779700000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac default channel 3
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t CN779_LC3 = {779900000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t CN779_LC3 = {779900000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac channels which are allowed for the join procedure

View File

@ -191,19 +191,19 @@ static const band_t EU433_BAND0 = {100, EU433_MAX_TX_POWER, 0, 0, 0, 433175000,
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU433_LC1 = {433175000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t EU433_LC1 = {433175000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU433_LC2 = {433375000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t EU433_LC2 = {433375000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac default channel 3
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU433_LC3 = {433575000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0};
static const channel_params_t EU433_LC3 = {433575000, 0, { ((DR_5 << 4) | DR_0) }, 0};
/*!
* LoRaMac channels which are allowed for the join procedure

View File

@ -182,12 +182,12 @@
* Band 0 definition
* { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t EU868_BAND0 = {100 , EU868_MAX_TX_POWER, 0, 0, 0,865000000, 868000000}; // 1.0 %
static const band_t EU868_BAND0 = {100, EU868_MAX_TX_POWER, 0, 0, 0, 865000000, 868000000}; // 1.0 %
/*!
* Band 1 definition
* { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t EU868_BAND1 = {100 , EU868_MAX_TX_POWER, 0, 0, 0, 868100000, 868600000}; // 1.0 %
static const band_t EU868_BAND1 = {100, EU868_MAX_TX_POWER, 0, 0, 0, 868100000, 868600000}; // 1.0 %
/*!
* Band 2 definition
@ -199,13 +199,13 @@ static const band_t EU868_BAND2 = {1000, EU868_MAX_TX_POWER, 0, 0, 0, 868700000,
* Band 3 definition
* Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t EU868_BAND3 = {10 , EU868_MAX_TX_POWER, 0, 0, 0, 869400000, 869650000}; // 10.0 %
static const band_t EU868_BAND3 = {10, EU868_MAX_TX_POWER, 0, 0, 0, 869400000, 869650000}; // 10.0 %
/*!
* Band 4 definition
* Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t EU868_BAND4 = {100 , EU868_MAX_TX_POWER, 0, 0, 0, 869700000, 870000000}; // 1.0 %
static const band_t EU868_BAND4 = {100, EU868_MAX_TX_POWER, 0, 0, 0, 869700000, 870000000}; // 1.0 %
/*!
* Band 5 definition - It's actually a sub part of Band 2
@ -217,19 +217,19 @@ static const band_t EU868_BAND5 = {1000, EU868_MAX_TX_POWER, 0, 0, 0, 863000000,
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU868_LC1 = {868100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1};
static const channel_params_t EU868_LC1 = {868100000, 0, { ((DR_5 << 4) | DR_0) }, 1};
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU868_LC2 = {868300000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1};
static const channel_params_t EU868_LC2 = {868300000, 0, { ((DR_5 << 4) | DR_0) }, 1};
/*!
* LoRaMac default channel 3
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t EU868_LC3 = {868500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1};
static const channel_params_t EU868_LC3 = {868500000, 0, { ((DR_5 << 4) | DR_0) }, 1};
/*!
* LoRaMac channels which are allowed for the join procedure

View File

@ -182,25 +182,25 @@
* Band 0 definition
* { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t IN865_BAND0 = { 1 , IN865_MAX_TX_POWER, 0, 0, 0, 865000000, 867000000 }; // 100.0 %
static const band_t IN865_BAND0 = { 1, IN865_MAX_TX_POWER, 0, 0, 0, 865000000, 867000000 }; // 100.0 %
/*!
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t IN865_LC1 = { 865062500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t IN865_LC1 = { 865062500, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t IN865_LC2 = { 865402500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t IN865_LC2 = { 865402500, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac default channel 3
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t IN865_LC3 = { 865985000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t IN865_LC3 = { 865985000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac channels which are allowed for the join procedure

View File

@ -55,7 +55,7 @@ public:
LoRaPHYIN865();
virtual ~LoRaPHYIN865();
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset );
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset);
private:
/*!

View File

@ -186,25 +186,25 @@
* Band 0 definition
* { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff }
*/
static const band_t KR920_BAND0 = { 1 , KR920_MAX_TX_POWER, 0, 0, 0 }; // 100.0 %
static const band_t KR920_BAND0 = { 1, KR920_MAX_TX_POWER, 0, 0, 0 }; // 100.0 %
/*!
* LoRaMac default channel 1
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t KR920_LC1 = { 922100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t KR920_LC1 = { 922100000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac default channel 2
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t KR920_LC2 = { 922300000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t KR920_LC2 = { 922300000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac default channel 3
* Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
*/
static const channel_params_t KR920_LC3 = { 922500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 };
static const channel_params_t KR920_LC3 = { 922500000, 0, { ((DR_5 << 4) | DR_0) }, 0 };
/*!
* LoRaMac channels which are allowed for the join procedure
@ -254,7 +254,7 @@ LoRaPHYKR920::LoRaPHYKR920()
channels[2].band = 0;
// Initialize the channels default mask
default_channel_mask[0] = LC( 1 ) + LC( 2 ) + LC( 3 );
default_channel_mask[0] = LC(1) + LC(2) + LC(3);
// Update the channels mask
copy_channel_mask(channel_mask, default_channel_mask, KR920_CHANNEL_MASK_SIZE);
@ -356,7 +356,7 @@ bool LoRaPHYKR920::verify_frequency_for_band(uint32_t freq, uint8_t band) const
// Verify if the frequency is valid. The frequency must be in a specified
// range and can be set to specific values.
if ((tmp_freq >= 920900000) && (tmp_freq <=923300000)) {
if ((tmp_freq >= 920900000) && (tmp_freq <= 923300000)) {
// Range ok, check for specific value
tmp_freq -= 920900000;
if ((tmp_freq % 200000) == 0) {
@ -367,8 +367,8 @@ bool LoRaPHYKR920::verify_frequency_for_band(uint32_t freq, uint8_t band) const
return false;
}
bool LoRaPHYKR920::tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa)
bool LoRaPHYKR920::tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa)
{
int8_t phy_dr = datarates_KR920[config->datarate];
@ -393,12 +393,12 @@ bool LoRaPHYKR920::tx_config(tx_config_params_t* config, int8_t* tx_power,
_radio->set_channel(channels[config->channel].frequency);
_radio->set_tx_config(MODEM_LORA, phy_tx_power, 0, bandwidth, phy_dr, 1, 8,
false, true, 0, 0, false, 3000 );
false, true, 0, 0, false, 3000);
// Setup maximum payload lenght of the radio driver
_radio->set_max_payload_length(MODEM_LORA, config->pkt_len);
// Get the time-on-air of the next tx frame
*tx_toa =_radio->time_on_air(MODEM_LORA, config->pkt_len);
*tx_toa = _radio->time_on_air(MODEM_LORA, config->pkt_len);
_radio->unlock();
@ -406,9 +406,9 @@ bool LoRaPHYKR920::tx_config(tx_config_params_t* config, int8_t* tx_power,
return true;
}
lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* params,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregate_timeoff)
lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t *params,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeoff)
{
uint8_t next_channel_idx = 0;
uint8_t nb_enabled_channels = 0;
@ -441,9 +441,9 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
if (nb_enabled_channels > 0) {
for (uint8_t i = 0, j = get_random(0, nb_enabled_channels - 1);
i < KR920_MAX_NB_CHANNELS; i++) {
i < KR920_MAX_NB_CHANNELS; i++) {
next_channel_idx = enabled_channels[j];
j = ( j + 1 ) % nb_enabled_channels;
j = (j + 1) % nb_enabled_channels;
// Perform carrier sense for KR920_CARRIER_SENSE_TIME
// If the channel is free, we can stop the LBT mechanism
@ -452,7 +452,7 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
if (_radio->perform_carrier_sense(MODEM_LORA,
channels[next_channel_idx].frequency,
KR920_RSSI_FREE_TH,
KR920_CARRIER_SENSE_TIME ) == true) {
KR920_CARRIER_SENSE_TIME) == true) {
// Free channel found
*channel = next_channel_idx;
*time = 0;
@ -480,7 +480,7 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
}
}
void LoRaPHYKR920::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_frequency)
void LoRaPHYKR920::set_tx_cont_mode(cw_mode_params_t *params, uint32_t given_frequency)
{
(void)given_frequency;
@ -495,7 +495,7 @@ void LoRaPHYKR920::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_fre
// Take the minimum between the max_eirp and params->max_eirp.
// The value of params->max_eirp could have changed during runtime,
// e.g. due to a MAC command.
max_eirp = MIN (params->max_eirp, max_eirp);
max_eirp = MIN(params->max_eirp, max_eirp);
// Calculate physical TX power
phy_tx_power = compute_tx_power(params->tx_power, max_eirp, params->antenna_gain);

View File

@ -56,14 +56,14 @@ public:
virtual bool verify_frequency_for_band(uint32_t freq, uint8_t band) const;
virtual bool tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa);
virtual bool tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa);
virtual lorawan_status_t set_next_channel(channel_selection_params_t* params, uint8_t* channel,
lorawan_time_t* time,
lorawan_time_t* aggregate_timeOff);
virtual lorawan_status_t set_next_channel(channel_selection_params_t *params, uint8_t *channel,
lorawan_time_t *time,
lorawan_time_t *aggregate_timeOff);
virtual void set_tx_cont_mode(cw_mode_params_t* continuousWave,
virtual void set_tx_cont_mode(cw_mode_params_t *continuousWave,
uint32_t frequency = 0);

View File

@ -192,10 +192,9 @@ static const uint32_t bandwidths_US915[] = {125000, 125000, 125000, 125000, 5000
/*!
* Up/Down link data rates offset definition
*/
static const int8_t datarate_offsets_US915[5][4] =
{
{ DR_10, DR_9 , DR_8 , DR_8 }, // DR_0
{ DR_11, DR_10, DR_9 , DR_8 }, // DR_1
static const int8_t datarate_offsets_US915[5][4] = {
{ DR_10, DR_9, DR_8, DR_8 }, // DR_0
{ DR_11, DR_10, DR_9, DR_8 }, // DR_1
{ DR_12, DR_11, DR_10, DR_9 }, // DR_2
{ DR_13, DR_12, DR_11, DR_10 }, // DR_3
{ DR_13, DR_13, DR_12, DR_11 }, // DR_4
@ -222,13 +221,13 @@ LoRaPHYUS915::LoRaPHYUS915()
// 125 kHz channels - Upstream
for (uint8_t i = 0; i < US915_MAX_NB_CHANNELS - 8; i++) {
channels[i].frequency = 902300000 + i * 200000;
channels[i].dr_range.value = ( DR_3 << 4) | DR_0;
channels[i].dr_range.value = (DR_3 << 4) | DR_0;
channels[i].band = 0;
}
// 500 kHz channels - Upstream
for (uint8_t i = US915_MAX_NB_CHANNELS - 8; i < US915_MAX_NB_CHANNELS; i++) {
channels[i].frequency = 903000000 + (i - ( US915_MAX_NB_CHANNELS - 8)) * 1600000;
channels[i].dr_range.value = ( DR_4 << 4) | DR_4;
channels[i].frequency = 903000000 + (i - (US915_MAX_NB_CHANNELS - 8)) * 1600000;
channels[i].dr_range.value = (DR_4 << 4) | DR_4;
channels[i].band = 0;
}
@ -325,16 +324,16 @@ int8_t LoRaPHYUS915::limit_tx_power(int8_t tx_power, int8_t max_band_tx_power,
int8_t tx_power_out = tx_power;
// Limit tx power to the band max
tx_power_out = MAX (tx_power, max_band_tx_power);
tx_power_out = MAX(tx_power, max_band_tx_power);
if (datarate == DR_4) {
// Limit tx power to max 26dBm
tx_power_out = MAX (tx_power, TX_POWER_2);
tx_power_out = MAX(tx_power, TX_POWER_2);
} else {
if (num_active_channels(channel_mask, 0, 4) < 50) {
// Limit tx power to max 21dBm
tx_power_out = MAX (tx_power, TX_POWER_5);
tx_power_out = MAX(tx_power, TX_POWER_5);
}
}
@ -350,7 +349,7 @@ void LoRaPHYUS915::restore_default_channels()
intersect_channel_mask(channel_mask, current_channel_mask, US915_CHANNEL_MASK_SIZE);
}
bool LoRaPHYUS915::rx_config(rx_config_params_t* config)
bool LoRaPHYUS915::rx_config(rx_config_params_t *config)
{
int8_t dr = config->datarate;
uint8_t max_payload = 0;
@ -410,8 +409,8 @@ bool LoRaPHYUS915::rx_config(rx_config_params_t* config)
return true;
}
bool LoRaPHYUS915::tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa)
bool LoRaPHYUS915::tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa)
{
int8_t phy_dr = datarates_US915[config->datarate];
int8_t tx_power_limited = limit_tx_power(config->tx_power,
@ -422,7 +421,7 @@ bool LoRaPHYUS915::tx_config(tx_config_params_t* config, int8_t* tx_power,
int8_t phy_tx_power = 0;
// Calculate physical TX power
phy_tx_power = compute_tx_power( tx_power_limited, US915_DEFAULT_MAX_ERP, 0 );
phy_tx_power = compute_tx_power(tx_power_limited, US915_DEFAULT_MAX_ERP, 0);
_radio->lock();
@ -445,9 +444,9 @@ bool LoRaPHYUS915::tx_config(tx_config_params_t* config, int8_t* tx_power,
return true;
}
uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t* params,
int8_t* dr_out, int8_t* tx_power_out,
uint8_t* nb_rep_out, uint8_t* nb_bytes_parsed)
uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t *params,
int8_t *dr_out, int8_t *tx_power_out,
uint8_t *nb_rep_out, uint8_t *nb_bytes_parsed)
{
uint8_t status = 0x07;
@ -504,7 +503,7 @@ uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t* params,
// FCC 15.247 paragraph F mandates to hop on at least 2 125 kHz channels
if ((adr_settings.datarate < DR_4) &&
(num_active_channels(temp_channel_masks, 0, 4) < 2)) {
(num_active_channels(temp_channel_masks, 0, 4) < 2)) {
status &= 0xFE; // Channel mask KO
@ -543,7 +542,7 @@ uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t* params,
return status;
}
uint8_t LoRaPHYUS915::accept_rx_param_setup_req(rx_param_setup_req_t* params)
uint8_t LoRaPHYUS915::accept_rx_param_setup_req(rx_param_setup_req_t *params)
{
uint8_t status = 0x07;
uint32_t freq = params->frequency;
@ -572,8 +571,7 @@ uint8_t LoRaPHYUS915::accept_rx_param_setup_req(rx_param_setup_req_t* params)
}
// Verify datarate offset
if (val_in_range( params->dr_offset, US915_MIN_RX1_DR_OFFSET, US915_MAX_RX1_DR_OFFSET ) == 0 )
{
if (val_in_range(params->dr_offset, US915_MIN_RX1_DR_OFFSET, US915_MAX_RX1_DR_OFFSET) == 0) {
status &= 0xFB; // Rx1DrOffset range KO
}
@ -593,9 +591,9 @@ int8_t LoRaPHYUS915::get_alternate_DR(uint8_t nb_trials)
return datarate;
}
lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t* params,
uint8_t* channel, lorawan_time_t* time,
lorawan_time_t* aggregate_timeOff)
lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t *params,
uint8_t *channel, lorawan_time_t *time,
lorawan_time_t *aggregate_timeOff)
{
uint8_t nb_enabled_channels = 0;
uint8_t delay_tx = 0;
@ -654,13 +652,13 @@ lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t* para
}
}
void LoRaPHYUS915::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_frequency)
void LoRaPHYUS915::set_tx_cont_mode(cw_mode_params_t *params, uint32_t given_frequency)
{
(void)given_frequency;
int8_t tx_power_limited = limit_tx_power(params->tx_power,
bands[channels[params->channel].band].max_tx_pwr,
params->datarate);
bands[channels[params->channel].band].max_tx_pwr,
params->datarate);
int8_t phyTxPower = 0;
uint32_t frequency = channels[params->channel].frequency;
@ -681,7 +679,7 @@ uint8_t LoRaPHYUS915::apply_DR_offset(int8_t dr, int8_t dr_offset)
void LoRaPHYUS915::intersect_channel_mask(const uint16_t *source,
uint16_t *destination, uint8_t size)
uint16_t *destination, uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
destination[i] &= source[i];
@ -689,9 +687,9 @@ void LoRaPHYUS915::intersect_channel_mask(const uint16_t *source,
}
void LoRaPHYUS915::fill_channel_mask_with_fsb(const uint16_t *expectation,
const uint16_t *fsb_mask,
uint16_t *destination,
uint8_t size)
const uint16_t *fsb_mask,
uint16_t *destination,
uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
destination[i] = expectation[i] & fsb_mask[i];
@ -700,7 +698,7 @@ void LoRaPHYUS915::fill_channel_mask_with_fsb(const uint16_t *expectation,
}
void LoRaPHYUS915::fill_channel_mask_with_value(uint16_t *channel_mask,
uint16_t value, uint8_t size)
uint16_t value, uint8_t size)
{
for (uint8_t i = 0; i < size; i++) {
channel_mask[i] = value;

View File

@ -56,24 +56,24 @@ public:
virtual void restore_default_channels();
virtual bool rx_config(rx_config_params_t* config);
virtual bool rx_config(rx_config_params_t *config);
virtual bool tx_config(tx_config_params_t* config, int8_t* tx_power,
lorawan_time_t* tx_toa);
virtual bool tx_config(tx_config_params_t *config, int8_t *tx_power,
lorawan_time_t *tx_toa);
virtual uint8_t link_ADR_request(adr_req_params_t* params,
int8_t* dr_out, int8_t* tx_power_out,
uint8_t* nb_rep_out,
uint8_t* nb_bytes_parsed);
virtual uint8_t link_ADR_request(adr_req_params_t *params,
int8_t *dr_out, int8_t *tx_power_out,
uint8_t *nb_rep_out,
uint8_t *nb_bytes_parsed);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t* params);
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params);
virtual int8_t get_alternate_DR(uint8_t nb_trials);
virtual lorawan_status_t set_next_channel(channel_selection_params_t* params, uint8_t* channel,
lorawan_time_t* time, lorawan_time_t* aggregate_timeOff);
virtual lorawan_status_t set_next_channel(channel_selection_params_t *params, uint8_t *channel,
lorawan_time_t *time, lorawan_time_t *aggregate_timeOff);
virtual void set_tx_cont_mode(cw_mode_params_t* continuousWave,
virtual void set_tx_cont_mode(cw_mode_params_t *continuousWave,
uint32_t frequency = 0);
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset);

View File

@ -307,7 +307,7 @@ typedef struct {
/*!
* A pointer to the payload containing the MAC commands.
*/
const uint8_t* payload;
const uint8_t *payload;
/*!
* The size of the payload.
*/
@ -402,7 +402,7 @@ typedef struct verify_adr_params_s {
/*!
* A pointer to the first element of the channels mask.
*/
uint16_t* channel_mask;
uint16_t *channel_mask;
} verify_adr_params_t;
/**

View File

@ -48,38 +48,38 @@
#define mbed_lora_concat(x) mbed_lora_concat_(x)
#define LORA_REGION mbed_lora_concat(MBED_CONF_LORA_PHY)
#if LORA_REGION == LORA_REGION_EU868
#include "lorawan/lorastack/phy/LoRaPHYEU868.h"
#define LoRaPHY_region LoRaPHYEU868
#elif LORA_REGION == LORA_REGION_AS923
#include "lorawan/lorastack/phy/LoRaPHYAS923.h"
#define LoRaPHY_region LoRaPHYAS923
#elif LORA_REGION == LORA_REGION_AU915
#include "lorawan/lorastack/phy/LoRaPHYAU915.h"
#define LoRaPHY_region LoRaPHYAU915
#elif LORA_REGION == LORA_REGION_CN470
#include "lorawan/lorastack/phy/LoRaPHYCN470.h"
#define LoRaPHY_region LoRaPHYCN470
#elif LORA_REGION == LORA_REGION_CN779
#include "lorawan/lorastack/phy/LoRaPHYCN779.h"
#define LoRaPHY_region LoRaPHYCN779
#elif LORA_REGION == LORA_REGION_EU433
#include "lorawan/lorastack/phy/LoRaPHYEU433.h"
#define LoRaPHY_region LoRaPHYEU433
#elif LORA_REGION == LORA_REGION_IN865
#include "lorawan/lorastack/phy/LoRaPHYIN865.h"
#define LoRaPHY_region LoRaPHYIN865
#elif LORA_REGION == LORA_REGION_KR920
#include "lorawan/lorastack/phy/LoRaPHYKR920.h"
#define LoRaPHY_region LoRaPHYKR920
#elif LORA_REGION == LORA_REGION_US915
#include "lorawan/lorastack/phy/LoRaPHYUS915.h"
#define LoRaPHY_region LoRaPHYUS915
#else
#error "Invalid region configuration, update mbed_app.json with correct MBED_CONF_LORA_PHY value"
#endif //MBED_CONF_LORA_PHY == VALUE
#if LORA_REGION == LORA_REGION_EU868
#include "lorawan/lorastack/phy/LoRaPHYEU868.h"
#define LoRaPHY_region LoRaPHYEU868
#elif LORA_REGION == LORA_REGION_AS923
#include "lorawan/lorastack/phy/LoRaPHYAS923.h"
#define LoRaPHY_region LoRaPHYAS923
#elif LORA_REGION == LORA_REGION_AU915
#include "lorawan/lorastack/phy/LoRaPHYAU915.h"
#define LoRaPHY_region LoRaPHYAU915
#elif LORA_REGION == LORA_REGION_CN470
#include "lorawan/lorastack/phy/LoRaPHYCN470.h"
#define LoRaPHY_region LoRaPHYCN470
#elif LORA_REGION == LORA_REGION_CN779
#include "lorawan/lorastack/phy/LoRaPHYCN779.h"
#define LoRaPHY_region LoRaPHYCN779
#elif LORA_REGION == LORA_REGION_EU433
#include "lorawan/lorastack/phy/LoRaPHYEU433.h"
#define LoRaPHY_region LoRaPHYEU433
#elif LORA_REGION == LORA_REGION_IN865
#include "lorawan/lorastack/phy/LoRaPHYIN865.h"
#define LoRaPHY_region LoRaPHYIN865
#elif LORA_REGION == LORA_REGION_KR920
#include "lorawan/lorastack/phy/LoRaPHYKR920.h"
#define LoRaPHY_region LoRaPHYKR920
#elif LORA_REGION == LORA_REGION_US915
#include "lorawan/lorastack/phy/LoRaPHYUS915.h"
#define LoRaPHY_region LoRaPHYUS915
#else
#error "Must set LoRa PHY layer parameters."
#error "Invalid region configuration, update mbed_app.json with correct MBED_CONF_LORA_PHY value"
#endif //MBED_CONF_LORA_PHY == VALUE
#else
#error "Must set LoRa PHY layer parameters."
#endif //MBED_CONF_LORA_PHY
#endif // LORAPHY_TARGET

View File

@ -34,7 +34,7 @@ void LoRaWANTimeHandler::activate_timer_subsystem(events::EventQueue *queue)
_queue = queue;
}
lorawan_time_t LoRaWANTimeHandler::get_current_time( void )
lorawan_time_t LoRaWANTimeHandler::get_current_time(void)
{
const uint32_t current_time = _queue->tick();
return (lorawan_time_t)current_time;

View File

@ -26,8 +26,7 @@ SPDX-License-Identifier: BSD-3-Clause
#include "lorawan_data_structures.h"
class LoRaWANTimeHandler
{
class LoRaWANTimeHandler {
public:
LoRaWANTimeHandler();
~LoRaWANTimeHandler();
@ -62,7 +61,7 @@ public:
* @param [in] obj The structure containing the timer object parameters.
* @param [in] callback The function callback called at the end of the timeout.
*/
void init(timer_event_t &obj, mbed::Callback<void()> callback);
void init(timer_event_t &obj, mbed::Callback<void()> callback);
/** Starts and adds the timer object to the list of timer events.
*

View File

@ -78,8 +78,8 @@ typedef uint32_t lorawan_time_t;
*/
// reject if user tries to set more than MTU
#if MBED_CONF_LORA_TX_MAX_SIZE > 255
#warning "Cannot set TX Max size more than MTU=255"
#define MBED_CONF_LORA_TX_MAX_SIZE 255
#warning "Cannot set TX Max size more than MTU=255"
#define MBED_CONF_LORA_TX_MAX_SIZE 255
#endif
/*!