Skip to content

Commit 34c034d

Browse files
Kimmo VaisanenHasnain Virk
authored andcommitted
Remove duplicate configuration flags
This commit changes code to use directly mbed os configuration system generated compilation flags.
1 parent b47c59c commit 34c034d

File tree

6 files changed

+47
-215
lines changed

6 files changed

+47
-215
lines changed

features/lorawan/LoRaWANInterface.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ lora_mac_status_t LoRaWANInterface::connect()
6161

6262
lorawan_connect_t connection_params;
6363

64-
if (OVER_THE_AIR_ACTIVATION != 0) {
65-
static uint8_t dev_eui[] = LORAWAN_DEVICE_EUI;
66-
static uint8_t app_eui[] = LORAWAN_APPLICATION_EUI;
67-
static uint8_t app_key[] = LORAWAN_APPLICATION_KEY;
64+
if (MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION) {
65+
static uint8_t dev_eui[] = MBED_CONF_LORA_DEVICE_EUI;
66+
static uint8_t app_eui[] = MBED_CONF_LORA_APPLICATION_EUI;
67+
static uint8_t app_key[] = MBED_CONF_LORA_APPLICATION_KEY;
6868
/**
6969
*
7070
* OTAA join
@@ -73,14 +73,14 @@ lora_mac_status_t LoRaWANInterface::connect()
7373
connection_params.connection_u.otaa.app_eui = app_eui;
7474
connection_params.connection_u.otaa.dev_eui = dev_eui;
7575
connection_params.connection_u.otaa.app_key = app_key;
76-
connection_params.connection_u.otaa.nb_trials = LORAWAN_NB_TRIALS;
76+
connection_params.connection_u.otaa.nb_trials = MBED_CONF_LORA_NB_TRIALS;
7777

7878
return connect(connection_params);
7979
} else {
80-
static uint8_t nwk_skey[] = LORAWAN_NWKSKEY;
81-
static uint8_t app_skey[] = LORAWAN_APPSKEY;
82-
static uint32_t dev_addr = LORAWAN_DEVICE_ADDRESS;
83-
static uint32_t nwk_id = (LORAWAN_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
80+
static uint8_t nwk_skey[] = MBED_CONF_LORA_NWKSKEY;
81+
static uint8_t app_skey[] = MBED_CONF_LORA_APPSKEY;
82+
static uint32_t dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
83+
static uint32_t nwk_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
8484

8585
/**
8686
*

features/lorawan/LoRaWANStack.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ lora_mac_status_t LoRaWANStack::set_application_port(uint8_t port)
9494
LoRaWANStack::LoRaWANStack()
9595
: _loramac(_lora_time), _lora_phy(_lora_time),
9696
_device_current_state(DEVICE_STATE_NOT_INITIALIZED), _mac_handlers(NULL),
97-
_num_retry(1), _queue(NULL), _duty_cycle_on(LORAWAN_DUTYCYCLE_ON)
97+
_num_retry(1), _queue(NULL), _duty_cycle_on(MBED_CONF_LORA_DUTY_CYCLE_ON)
9898
{
9999
#ifdef MBED_CONF_LORA_APP_PORT
100100
// 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)
152152
static lora_mac_mib_request_confirm_t mib_req;
153153

154154
#if defined(LORAWAN_COMPLIANCE_TEST)
155-
static uint8_t compliance_test_buffer[LORAWAN_TX_MAX_SIZE];
155+
static uint8_t compliance_test_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
156156
#endif
157157

158158
tr_debug("Initializing MAC layer");
@@ -174,11 +174,11 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
174174
_loramac.LoRaMacInitialization(&LoRaMacPrimitives, &LoRaMacCallbacks, &_lora_phy, queue);
175175

176176
mib_req.type = LORA_MIB_ADR;
177-
mib_req.param.adr_enable = LORAWAN_ADR_ON;
177+
mib_req.param.adr_enable = MBED_CONF_LORA_ADR_ON;
178178
mib_set_request(&mib_req);
179179

180180
mib_req.type = LORA_MIB_PUBLIC_NETWORK;
181-
mib_req.param.enable_public_network = LORAWAN_PUBLIC_NETWORK;
181+
mib_req.param.enable_public_network = MBED_CONF_LORA_PUBLIC_NETWORK;
182182
mib_set_request(&mib_req);
183183

184184
// 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)
217217
_tx_msg.f_buffer_size = _compliance_test.app_data_size;
218218

219219
_tx_msg.f_buffer[0] = _compliance_test.app_data_buffer[0];
220-
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, LORAWAN_TX_MAX_SIZE); ++i) {
220+
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
221221
_tx_msg.f_buffer[i] = _compliance_test.app_data_buffer[i];
222222
}
223223
break;
@@ -838,13 +838,13 @@ int16_t LoRaWANStack::handle_tx(uint8_t port, const uint8_t* data,
838838

839839
uint16_t max_possible_size = check_possible_tx_size(length);
840840

841-
if (max_possible_size > LORAWAN_TX_MAX_SIZE) {
841+
if (max_possible_size > MBED_CONF_LORA_TX_MAX_SIZE) {
842842
// LORAWAN_APP_DATA_MAX_SIZE should at least be
843843
// either equal to or bigger than maximum possible
844844
// tx size because our tx message buffer takes its
845845
// length from that macro. Force maximum possible tx unit
846846
// to be equal to the buffer size user chose.
847-
max_possible_size = LORAWAN_TX_MAX_SIZE;
847+
max_possible_size = MBED_CONF_LORA_TX_MAX_SIZE;
848848
}
849849

850850
if (max_possible_size < length) {
@@ -1118,8 +1118,8 @@ void LoRaWANStack::mcps_confirm_handler(lora_mac_mcps_confirm_t *mcps_confirm)
11181118
// or some other error happened. Discard buffer, unset the tx-ongoing
11191119
// flag and let the application know
11201120
_tx_msg.tx_ongoing = false;
1121-
memset(_tx_msg.f_buffer, 0, LORAWAN_TX_MAX_SIZE);
1122-
_tx_msg.f_buffer_size = LORAWAN_TX_MAX_SIZE;
1121+
memset(_tx_msg.f_buffer, 0, MBED_CONF_LORA_TX_MAX_SIZE);
1122+
_tx_msg.f_buffer_size = MBED_CONF_LORA_TX_MAX_SIZE;
11231123

11241124
tr_error("mcps_confirm_handler: Error code = %d", mcps_confirm->status);
11251125

@@ -1309,17 +1309,17 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
13091309
switch (_compliance_test.state) {
13101310
case 0: // Check compliance test disable command (ii)
13111311
_compliance_test.is_tx_confirmed = true;
1312-
_compliance_test.app_port = LORAWAN_APP_PORT;
1312+
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
13131313
_compliance_test.app_data_size = LORAWAN_COMPLIANCE_TEST_DATA_SIZE;
13141314
_compliance_test.downlink_counter = 0;
13151315
_compliance_test.running = false;
13161316

13171317
lora_mac_mib_request_confirm_t mib_req;
13181318
mib_req.type = LORA_MIB_ADR;
1319-
mib_req.param.adr_enable = LORAWAN_ADR_ON;
1319+
mib_req.param.adr_enable = MBED_CONF_LORA_ADR_ON;
13201320
mib_set_request(&mib_req);
13211321
#if MBED_CONF_LORA_PHY == 0
1322-
_loramac.LoRaMacTestSetDutyCycleOn(LORAWAN_DUTYCYCLE_ON);
1322+
_loramac.LoRaMacTestSetDutyCycleOn(MBED_CONF_LORA_DUTY_CYCLE_ON);
13231323
#endif
13241324
// Go to idle state after compliance test mode.
13251325
tr_debug("Compliance test disabled.");
@@ -1362,16 +1362,16 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
13621362

13631363
// Disable TestMode and revert back to normal operation
13641364
_compliance_test.is_tx_confirmed = true;
1365-
_compliance_test.app_port = LORAWAN_APP_PORT;
1365+
_compliance_test.app_port = MBED_CONF_LORA_APP_PORT;
13661366
_compliance_test.app_data_size = LORAWAN_COMPLIANCE_TEST_DATA_SIZE;
13671367
_compliance_test.downlink_counter = 0;
13681368
_compliance_test.running = false;
13691369

13701370
mib_request.type = LORA_MIB_ADR;
1371-
mib_request.param.adr_enable = LORAWAN_ADR_ON;
1371+
mib_request.param.adr_enable = MBED_CONF_LORA_ADR_ON;
13721372
mib_set_request(&mib_request);
13731373
#if MBED_CONF_LORA_PHY == 0
1374-
_loramac.LoRaMacTestSetDutyCycleOn(LORAWAN_DUTYCYCLE_ON);
1374+
_loramac.LoRaMacTestSetDutyCycleOn(MBED_CONF_LORA_DUTY_CYCLE_ON);
13751375
#endif
13761376
mlme_request.type = LORA_MLME_JOIN;
13771377
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()
18281828
mib_set_request(&mib_req);
18291829

18301830
// reset buffers to original state
1831-
memset(_tx_msg.f_buffer, 0, LORAWAN_TX_MAX_SIZE);
1831+
memset(_tx_msg.f_buffer, 0, MBED_CONF_LORA_TX_MAX_SIZE);
18321832
_tx_msg.pending_size = 0;
18331833
_tx_msg.f_buffer_size = 0;
18341834
_tx_msg.tx_ongoing = false;

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ LoRaMacStatus_t LoRaMac::ScheduleTx( void )
12431243

12441244
nextChan.AggrTimeOff = _params.timers.AggregatedTimeOff;
12451245
nextChan.Datarate = _params.sys_params.ChannelsDatarate;
1246-
_params.DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
1246+
_params.DutyCycleOn = MBED_CONF_LORA_DUTY_CYCLE_ON;
12471247
nextChan.DutyCycleEnabled = _params.DutyCycleOn;
12481248
nextChan.Joined = _params.IsLoRaMacNetworkJoined;
12491249
nextChan.LastAggrTx = _params.timers.AggregatedLastTxDoneTime;
@@ -1315,7 +1315,7 @@ void LoRaMac::CalculateBackOff( uint8_t channel )
13151315
CalcBackOffParams_t calcBackOff;
13161316

13171317
calcBackOff.Joined = _params.IsLoRaMacNetworkJoined;
1318-
_params.DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
1318+
_params.DutyCycleOn = MBED_CONF_LORA_DUTY_CYCLE_ON;
13191319
calcBackOff.DutyCycleEnabled = _params.DutyCycleOn;
13201320
calcBackOff.Channel = channel;
13211321
calcBackOff.ElapsedTime = _lora_time.TimerGetElapsedTime( _params.timers.LoRaMacInitializationTime );
@@ -1803,7 +1803,7 @@ LoRaMacStatus_t LoRaMac::LoRaMacInitialization(LoRaMacPrimitives_t *primitives,
18031803
// Random seed initialization
18041804
srand(lora_phy->get_radio_rng());
18051805

1806-
_params.PublicNetwork = LORAWAN_PUBLIC_NETWORK;
1806+
_params.PublicNetwork = MBED_CONF_LORA_PUBLIC_NETWORK;
18071807
lora_phy->setup_public_network_mode(_params.PublicNetwork);
18081808
lora_phy->put_radio_to_sleep();
18091809

features/lorawan/lorastack/mac/LoRaMac.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
#include "lorastack/mac/LoRaMacMlme.h"
5050
#include "lorastack/mac/LoRaMacMcps.h"
5151
#include "lorastack/mac/LoRaMacMib.h"
52-
/*!
53-
* Maximum PHY layer payload size
54-
*/
55-
#define LORAMAC_PHY_MAXPAYLOAD 255
5652

5753

5854
class LoRaMac

features/lorawan/mbed_lib.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
"help": "AES encryption/decryption cipher application key",
2626
"value": "{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}"
2727
},
28-
"network-id": {
29-
"help": "Current network ID",
30-
"value": 0
31-
},
3228
"device-address": {
3329
"help": "Device address on the network",
3430
"value": "0x00000000"
@@ -58,12 +54,12 @@
5854
"value": true
5955
},
6056
"duty-cycle-on": {
61-
"help": "Enables/disables duty cycling. NOTE: Disable only for testing. Mandatory in many regions.",
62-
"value": true
57+
"help": "Enables/disables duty cycling. NOTE: Disable only for testing. Mandatory in many regions.",
58+
"value": true
6359
},
6460
"lbt-on": {
65-
"help": "Enables/disables LBT. NOTE: [This feature is not yet integrated].",
66-
"value": false
61+
"help": "Enables/disables LBT. NOTE: [This feature is not yet integrated].",
62+
"value": false
6763
}
6864
}
6965
}

0 commit comments

Comments
 (0)