Remove duplicate configuration flags

This commit changes code to use directly mbed os configuration system generated
compilation flags.
pull/6059/head
Kimmo Vaisanen 2018-01-11 11:49:52 +02:00 committed by Hasnain Virk
parent b47c59ce2a
commit 34c034dfff
6 changed files with 47 additions and 215 deletions

View File

@ -61,10 +61,10 @@ lora_mac_status_t LoRaWANInterface::connect()
lorawan_connect_t connection_params;
if (OVER_THE_AIR_ACTIVATION != 0) {
static uint8_t dev_eui[] = LORAWAN_DEVICE_EUI;
static uint8_t app_eui[] = LORAWAN_APPLICATION_EUI;
static uint8_t app_key[] = LORAWAN_APPLICATION_KEY;
if (MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION) {
static uint8_t dev_eui[] = MBED_CONF_LORA_DEVICE_EUI;
static uint8_t app_eui[] = MBED_CONF_LORA_APPLICATION_EUI;
static uint8_t app_key[] = MBED_CONF_LORA_APPLICATION_KEY;
/**
*
* OTAA join
@ -73,14 +73,14 @@ lora_mac_status_t LoRaWANInterface::connect()
connection_params.connection_u.otaa.app_eui = app_eui;
connection_params.connection_u.otaa.dev_eui = dev_eui;
connection_params.connection_u.otaa.app_key = app_key;
connection_params.connection_u.otaa.nb_trials = LORAWAN_NB_TRIALS;
connection_params.connection_u.otaa.nb_trials = MBED_CONF_LORA_NB_TRIALS;
return connect(connection_params);
} else {
static uint8_t nwk_skey[] = LORAWAN_NWKSKEY;
static uint8_t app_skey[] = LORAWAN_APPSKEY;
static uint32_t dev_addr = LORAWAN_DEVICE_ADDRESS;
static uint32_t nwk_id = (LORAWAN_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
static uint8_t nwk_skey[] = MBED_CONF_LORA_NWKSKEY;
static uint8_t app_skey[] = MBED_CONF_LORA_APPSKEY;
static uint32_t dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
static uint32_t nwk_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
/**
*

View File

@ -94,7 +94,7 @@ lora_mac_status_t LoRaWANStack::set_application_port(uint8_t port)
LoRaWANStack::LoRaWANStack()
: _loramac(_lora_time), _lora_phy(_lora_time),
_device_current_state(DEVICE_STATE_NOT_INITIALIZED), _mac_handlers(NULL),
_num_retry(1), _queue(NULL), _duty_cycle_on(LORAWAN_DUTYCYCLE_ON)
_num_retry(1), _queue(NULL), _duty_cycle_on(MBED_CONF_LORA_DUTY_CYCLE_ON)
{
#ifdef MBED_CONF_LORA_APP_PORT
// is_port_valid() is not virtual, so we can call it in constructor
@ -152,7 +152,7 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
static lora_mac_mib_request_confirm_t mib_req;
#if defined(LORAWAN_COMPLIANCE_TEST)
static uint8_t compliance_test_buffer[LORAWAN_TX_MAX_SIZE];
static uint8_t compliance_test_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
#endif
tr_debug("Initializing MAC layer");
@ -174,11 +174,11 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
_loramac.LoRaMacInitialization(&LoRaMacPrimitives, &LoRaMacCallbacks, &_lora_phy, queue);
mib_req.type = LORA_MIB_ADR;
mib_req.param.adr_enable = LORAWAN_ADR_ON;
mib_req.param.adr_enable = MBED_CONF_LORA_ADR_ON;
mib_set_request(&mib_req);
mib_req.type = LORA_MIB_PUBLIC_NETWORK;
mib_req.param.enable_public_network = LORAWAN_PUBLIC_NETWORK;
mib_req.param.enable_public_network = MBED_CONF_LORA_PUBLIC_NETWORK;
mib_set_request(&mib_req);
// Reset counters to zero. Will change in future with 1.1 support.
@ -217,7 +217,7 @@ void LoRaWANStack::prepare_special_tx_frame(uint8_t port)
_tx_msg.f_buffer_size = _compliance_test.app_data_size;
_tx_msg.f_buffer[0] = _compliance_test.app_data_buffer[0];
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, LORAWAN_TX_MAX_SIZE); ++i) {
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
_tx_msg.f_buffer[i] = _compliance_test.app_data_buffer[i];
}
break;
@ -838,13 +838,13 @@ int16_t LoRaWANStack::handle_tx(uint8_t port, const uint8_t* data,
uint16_t max_possible_size = check_possible_tx_size(length);
if (max_possible_size > LORAWAN_TX_MAX_SIZE) {
if (max_possible_size > MBED_CONF_LORA_TX_MAX_SIZE) {
// LORAWAN_APP_DATA_MAX_SIZE should at least be
// either equal to or bigger than maximum possible
// tx size because our tx message buffer takes its
// length from that macro. Force maximum possible tx unit
// to be equal to the buffer size user chose.
max_possible_size = LORAWAN_TX_MAX_SIZE;
max_possible_size = MBED_CONF_LORA_TX_MAX_SIZE;
}
if (max_possible_size < length) {
@ -1118,8 +1118,8 @@ void LoRaWANStack::mcps_confirm_handler(lora_mac_mcps_confirm_t *mcps_confirm)
// or some other error happened. Discard buffer, unset the tx-ongoing
// flag and let the application know
_tx_msg.tx_ongoing = false;
memset(_tx_msg.f_buffer, 0, LORAWAN_TX_MAX_SIZE);
_tx_msg.f_buffer_size = LORAWAN_TX_MAX_SIZE;
memset(_tx_msg.f_buffer, 0, MBED_CONF_LORA_TX_MAX_SIZE);
_tx_msg.f_buffer_size = MBED_CONF_LORA_TX_MAX_SIZE;
tr_error("mcps_confirm_handler: Error code = %d", mcps_confirm->status);
@ -1309,17 +1309,17 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
switch (_compliance_test.state) {
case 0: // Check compliance test disable command (ii)
_compliance_test.is_tx_confirmed = true;
_compliance_test.app_port = LORAWAN_APP_PORT;
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
_compliance_test.app_data_size = LORAWAN_COMPLIANCE_TEST_DATA_SIZE;
_compliance_test.downlink_counter = 0;
_compliance_test.running = false;
lora_mac_mib_request_confirm_t mib_req;
mib_req.type = LORA_MIB_ADR;
mib_req.param.adr_enable = LORAWAN_ADR_ON;
mib_req.param.adr_enable = MBED_CONF_LORA_ADR_ON;
mib_set_request(&mib_req);
#if MBED_CONF_LORA_PHY == 0
_loramac.LoRaMacTestSetDutyCycleOn(LORAWAN_DUTYCYCLE_ON);
_loramac.LoRaMacTestSetDutyCycleOn(MBED_CONF_LORA_DUTY_CYCLE_ON);
#endif
// Go to idle state after compliance test mode.
tr_debug("Compliance test disabled.");
@ -1362,16 +1362,16 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
// Disable TestMode and revert back to normal operation
_compliance_test.is_tx_confirmed = true;
_compliance_test.app_port = LORAWAN_APP_PORT;
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
_compliance_test.app_data_size = LORAWAN_COMPLIANCE_TEST_DATA_SIZE;
_compliance_test.downlink_counter = 0;
_compliance_test.running = false;
mib_request.type = LORA_MIB_ADR;
mib_request.param.adr_enable = LORAWAN_ADR_ON;
mib_request.param.adr_enable = MBED_CONF_LORA_ADR_ON;
mib_set_request(&mib_request);
#if MBED_CONF_LORA_PHY == 0
_loramac.LoRaMacTestSetDutyCycleOn(LORAWAN_DUTYCYCLE_ON);
_loramac.LoRaMacTestSetDutyCycleOn(MBED_CONF_LORA_DUTY_CYCLE_ON);
#endif
mlme_request.type = LORA_MLME_JOIN;
mlme_request.req.join.dev_eui = _lw_session.connection.connection_u.otaa.dev_eui;
@ -1828,7 +1828,7 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
mib_set_request(&mib_req);
// reset buffers to original state
memset(_tx_msg.f_buffer, 0, LORAWAN_TX_MAX_SIZE);
memset(_tx_msg.f_buffer, 0, MBED_CONF_LORA_TX_MAX_SIZE);
_tx_msg.pending_size = 0;
_tx_msg.f_buffer_size = 0;
_tx_msg.tx_ongoing = false;

View File

@ -1243,7 +1243,7 @@ LoRaMacStatus_t LoRaMac::ScheduleTx( void )
nextChan.AggrTimeOff = _params.timers.AggregatedTimeOff;
nextChan.Datarate = _params.sys_params.ChannelsDatarate;
_params.DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
_params.DutyCycleOn = MBED_CONF_LORA_DUTY_CYCLE_ON;
nextChan.DutyCycleEnabled = _params.DutyCycleOn;
nextChan.Joined = _params.IsLoRaMacNetworkJoined;
nextChan.LastAggrTx = _params.timers.AggregatedLastTxDoneTime;
@ -1315,7 +1315,7 @@ void LoRaMac::CalculateBackOff( uint8_t channel )
CalcBackOffParams_t calcBackOff;
calcBackOff.Joined = _params.IsLoRaMacNetworkJoined;
_params.DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
_params.DutyCycleOn = MBED_CONF_LORA_DUTY_CYCLE_ON;
calcBackOff.DutyCycleEnabled = _params.DutyCycleOn;
calcBackOff.Channel = channel;
calcBackOff.ElapsedTime = _lora_time.TimerGetElapsedTime( _params.timers.LoRaMacInitializationTime );
@ -1803,7 +1803,7 @@ LoRaMacStatus_t LoRaMac::LoRaMacInitialization(LoRaMacPrimitives_t *primitives,
// Random seed initialization
srand(lora_phy->get_radio_rng());
_params.PublicNetwork = LORAWAN_PUBLIC_NETWORK;
_params.PublicNetwork = MBED_CONF_LORA_PUBLIC_NETWORK;
lora_phy->setup_public_network_mode(_params.PublicNetwork);
lora_phy->put_radio_to_sleep();

View File

@ -49,10 +49,6 @@
#include "lorastack/mac/LoRaMacMlme.h"
#include "lorastack/mac/LoRaMacMcps.h"
#include "lorastack/mac/LoRaMacMib.h"
/*!
* Maximum PHY layer payload size
*/
#define LORAMAC_PHY_MAXPAYLOAD 255
class LoRaMac

View File

@ -25,10 +25,6 @@
"help": "AES encryption/decryption cipher application key",
"value": "{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}"
},
"network-id": {
"help": "Current network ID",
"value": 0
},
"device-address": {
"help": "Device address on the network",
"value": "0x00000000"
@ -58,12 +54,12 @@
"value": true
},
"duty-cycle-on": {
"help": "Enables/disables duty cycling. NOTE: Disable only for testing. Mandatory in many regions.",
"value": true
"help": "Enables/disables duty cycling. NOTE: Disable only for testing. Mandatory in many regions.",
"value": true
},
"lbt-on": {
"help": "Enables/disables LBT. NOTE: [This feature is not yet integrated].",
"value": false
"help": "Enables/disables LBT. NOTE: [This feature is not yet integrated].",
"value": false
}
}
}

View File

@ -90,6 +90,20 @@ typedef uint32_t TimerTime_t;
*/
#define LORA_MAX_NB_CHANNELS 16
/**
* Maximum PHY layer payload size for reception.
*/
#define LORAMAC_PHY_MAXPAYLOAD 255
/**
*
* Default user application maximum data size for transmission
*/
// 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"
#endif
/*!
* LoRaWAN device classes definition.
*
@ -1706,180 +1720,6 @@ typedef struct sLoRaMacCallback
}LoRaMacCallback_t;
/**
* The AES encryption/decryption cipher application session key.
*/
#ifdef MBED_CONF_LORA_APPSKEY
#define LORAWAN_APPSKEY MBED_CONF_LORA_APPSKEY
#else
#define LORAWAN_APPSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
/**
* The AES encryption/decryption cipher network session key.
*/
#ifdef MBED_CONF_LORA_NWKSKEY
#define LORAWAN_NWKSKEY MBED_CONF_LORA_NWKSKEY
#else
#define LORAWAN_NWKSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
/**
* The device address on the network (big endian).
*/
#ifdef MBED_CONF_LORA_DEVICE_ADDRESS
#define LORAWAN_DEVICE_ADDRESS MBED_CONF_LORA_DEVICE_ADDRESS
#else
#define LORAWAN_DEVICE_ADDRESS 0
#endif
/**
* The current network ID.
*/
#ifdef MBED_CONF_LORA_NETWORK_ID
#define LORAWAN_NETWORK_ID MBED_CONF_LORA_NETWORK_ID
#else
#define LORAWAN_NETWORK_ID 0
#endif
/**
* The AES encryption/decryption cipher application key.
*/
#ifdef MBED_CONF_LORA_APPLICATION_KEY
#define LORAWAN_APPLICATION_KEY MBED_CONF_LORA_APPLICATION_KEY
#else
#define LORAWAN_APPLICATION_KEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
/**
* The application IEEE EUI.
*/
#ifdef MBED_CONF_LORA_APPLICATION_EUI
#define LORAWAN_APPLICATION_EUI MBED_CONF_LORA_APPLICATION_EUI
#else
#define LORAWAN_APPLICATION_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
/**
* The mote device IEEE EUI.
*/
#ifdef MBED_CONF_LORA_DEVICE_EUI
#define LORAWAN_DEVICE_EUI MBED_CONF_LORA_DEVICE_EUI
#else
#define LORAWAN_DEVICE_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
/**
* Indicates how many times join can be tried.
*/
#ifdef MBED_CONF_LORA_NB_TRIALS
#define LORAWAN_NB_TRIALS MBED_CONF_LORA_NB_TRIALS
#else
#define LORAWAN_NB_TRIALS 8
#endif
/**
* When set to true, the application uses the Over-the-Air activation procedure.
*/
#if defined(MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION) == 1
#define OVER_THE_AIR_ACTIVATION MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION
#else
#define OVER_THE_AIR_ACTIVATION false
#endif
/**
* LoRaWAN connects to a public network or private network, true = public network.
*/
#if defined(MBED_CONF_LORA_PUBLIC_NETWORK) == 1
#define LORAWAN_PUBLIC_NETWORK MBED_CONF_LORA_PUBLIC_NETWORK
#else
#define LORAWAN_PUBLIC_NETWORK false
#endif
/**
* Maximum PHY layer payload size for reception.
* This is not user configurable. Its hard coded in LoRaMac.cpp
* and we don't want to change that file too much
*/
#define LORAMAC_PHY_MAXPAYLOAD 255
/**
*
* Default user application maximum data size for trasnmission
*/
// reject if user tries to set more than MTU
#if defined MBED_CONF_LORA_TX_MAX_SIZE && MBED_CONF_LORA_TX_MAX_SIZE > 255
#warning "Cannot set TX Max size more than MTU=255"
#define LORAWAN_TX_MAX_SIZE 255
#elif defined MBED_CONF_LORA_TX_MAX_SIZE && MBED_CONF_LORA_TX_MAX_SIZE < 255
#define LORAWAN_TX_MAX_SIZE MBED_CONF_LORA_TX_MAX_SIZE
#else
#define LORAWAN_TX_MAX_SIZE 64
#endif
/**
*
* Defines the application data transmission timer cycle, value in [ms]
* Used only when automatic duty cycling is off
*/
#ifdef MBED_CONF_APP_TX_TIMER
#define TX_TIMER MBED_CONF_APP_TX_TIMER
#else
#define TX_TIMER 5000
#endif
/**
*
* Defines a random delay for application data transmission cycle, value in [ms]
* Used only when automatic duty cycling is off
*/
#ifdef MBED_CONF_APP_TX_TIMER_RND
#define TX_TIMER_RND MBED_CONF_APP_TX_TIMER_RND
#else
#define TX_TIMER_RND 1000
#endif
/**
*
* LoRaWAN Adaptive Data Rate
*
* \remark Please note that when ADR is enabled, the end-device should be static.
*/
#if defined(MBED_CONF_LORA_ADR_ON) == 1
#define LORAWAN_ADR_ON MBED_CONF_LORA_ADR_ON
#else
#define LORAWAN_ADR_ON false
#endif
/**
*
* The default application port.
*/
#ifdef MBED_CONF_LORA_APP_PORT
#define LORAWAN_APP_PORT MBED_CONF_LORA_APP_PORT
#else
#define LORAWAN_APP_PORT 0x15
#endif
/**
* Default duty cycling setting
*/
#if defined(MBED_CONF_LORA_DUTY_CYCLE_ON) == 1
#define LORAWAN_DUTYCYCLE_ON MBED_CONF_LORA_DUTY_CYCLE_ON
#else
#define LORAWAN_DUTYCYCLE_ON false
#endif
/**
* Listen-before-talk setting
*/
#if defined(MBED_CONF_LORA_LBT_ON) == 1
#define LORAWAN_LBT_ON MBED_CONF_LORA_LBT_ON
#else
#define LORAWAN_LBT_ON false
#endif
/** End-device states.
*
*/
@ -2100,7 +1940,7 @@ typedef struct lora_mac_tx_message {
*
* Base pointer to the buffer
*/
uint8_t f_buffer[LORAWAN_TX_MAX_SIZE];
uint8_t f_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
/** Payload size.
*