Skip to content

Commit f7a7315

Browse files
author
Cruz Monrreal
authored
Merge pull request #7816 from kivaisan/option_to_disabled_join_duty_cycle
Lora: Refactor duty-cycle configuration and introduce config for JOIN request
2 parents cb8d09a + 2f15dae commit f7a7315

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,16 @@ lorawan_status_t LoRaMac::schedule_tx()
10701070
_params.timers.aggregated_timeoff = 0;
10711071
}
10721072

1073+
if (MBED_CONF_LORA_DUTY_CYCLE_ON && _lora_phy->verify_duty_cycle(true)) {
1074+
_params.is_dutycycle_on = true;
1075+
} else {
1076+
_params.is_dutycycle_on = false;
1077+
}
1078+
10731079
calculate_backOff(_params.last_channel_idx);
10741080

10751081
next_channel.aggregate_timeoff = _params.timers.aggregated_timeoff;
10761082
next_channel.current_datarate = _params.sys_params.channel_data_rate;
1077-
_params.is_dutycycle_on = MBED_CONF_LORA_DUTY_CYCLE_ON;
10781083
next_channel.dc_enabled = _params.is_dutycycle_on;
10791084
next_channel.joined = _is_nwk_joined;
10801085
next_channel.last_aggregate_tx_time = _params.timers.aggregated_last_tx_time;
@@ -1158,9 +1163,6 @@ lorawan_status_t LoRaMac::schedule_tx()
11581163
void LoRaMac::calculate_backOff(uint8_t channel)
11591164
{
11601165
lorawan_time_t elapsed_time = _lora_time.get_elapsed_time(_params.timers.mac_init_time);
1161-
1162-
_params.is_dutycycle_on = MBED_CONF_LORA_DUTY_CYCLE_ON;
1163-
11641166
_lora_phy->calculate_backoff(_is_nwk_joined, _params.is_last_tx_join_request, _params.is_dutycycle_on,
11651167
channel, elapsed_time, _params.timers.tx_toa);
11661168

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
270270

271271
// Update bands Time OFF
272272
for (uint8_t i = 0; i < nb_bands; i++) {
273-
274-
if (joined == false) {
273+
if (MBED_CONF_LORA_DUTY_CYCLE_ON_JOIN && joined == false) {
275274
uint32_t txDoneTime = MAX(_lora_time->get_elapsed_time(bands[i].last_join_tx_time),
276275
(duty_cycle == true) ?
277276
_lora_time->get_elapsed_time(bands[i].last_tx_time) : 0);
@@ -283,7 +282,6 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
283282
if (bands[i].off_time != 0) {
284283
next_tx_delay = MIN(bands[i].off_time - txDoneTime, next_tx_delay);
285284
}
286-
287285
} else {
288286
// if network has been joined
289287
if (duty_cycle == true) {
@@ -451,7 +449,7 @@ uint8_t LoRaPHY::get_bandwidth(uint8_t dr)
451449
}
452450
}
453451

454-
uint8_t LoRaPHY::enabled_channel_count(bool joined, uint8_t datarate,
452+
uint8_t LoRaPHY::enabled_channel_count(uint8_t datarate,
455453
const uint16_t *channel_mask,
456454
uint8_t *channel_indices,
457455
uint8_t *delayTx)
@@ -1182,7 +1180,7 @@ void LoRaPHY::calculate_backoff(bool joined, bool last_tx_was_join_req, bool dc_
11821180
// Reset time-off to initial value.
11831181
band_table[band_idx].off_time = 0;
11841182

1185-
if (joined == false) {
1183+
if (MBED_CONF_LORA_DUTY_CYCLE_ON_JOIN && joined == false) {
11861184
// Get the join duty cycle
11871185
if (elapsed_time < 3600000) {
11881186
join_duty_cycle = BACKOFF_DC_1_HOUR;
@@ -1245,7 +1243,7 @@ lorawan_status_t LoRaPHY::set_next_channel(channel_selection_params_t *params,
12451243
band_table, phy_params.bands.size);
12461244

12471245
// Search how many channels are enabled
1248-
channel_count = enabled_channel_count(params->joined, params->current_datarate,
1246+
channel_count = enabled_channel_count(params->current_datarate,
12491247
phy_params.channels.mask,
12501248
enabled_channels, &delay_tx);
12511249
} else {

features/lorawan/lorastack/phy/LoRaPHY.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
632632
*/
633633
uint8_t get_bandwidth(uint8_t dr_index);
634634

635-
uint8_t enabled_channel_count(bool joined, uint8_t datarate,
635+
uint8_t enabled_channel_count(uint8_t datarate,
636636
const uint16_t *mask, uint8_t* enabledChannels,
637637
uint8_t* delayTx);
638638

features/lorawan/lorastack/phy/LoRaPHYAS923.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,7 @@ lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next
361361
bands, AS923_MAX_NB_BANDS);
362362

363363
// Search how many channels are enabled
364-
nb_enabled_channels = enabled_channel_count(next_channel_prams->joined,
365-
next_channel_prams->current_datarate,
364+
nb_enabled_channels = enabled_channel_count(next_channel_prams->current_datarate,
366365
channel_mask,
367366
enabled_channels, &delay_tx);
368367
} else {

features/lorawan/lorastack/phy/LoRaPHYAU915.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,9 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next
593593
bands, AU915_MAX_NB_BANDS);
594594

595595
// Search how many channels are enabled
596-
nb_enabled_channels = enabled_channel_count(next_chan_params->joined,
597-
next_chan_params->current_datarate,
598-
current_channel_mask,
599-
enabled_channels, &delay_tx);
596+
nb_enabled_channels = enabled_channel_count(next_chan_params->current_datarate,
597+
current_channel_mask,
598+
enabled_channels, &delay_tx);
600599
} else {
601600
delay_tx++;
602601
next_tx_delay = next_chan_params->aggregate_timeoff - _lora_time->get_elapsed_time(next_chan_params->last_aggregate_tx_time);

features/lorawan/lorastack/phy/LoRaPHYKR920.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
430430
bands, KR920_MAX_NB_BANDS);
431431

432432
// Search how many channels are enabled
433-
nb_enabled_channels = enabled_channel_count(params->joined, params->current_datarate,
434-
channel_mask,
435-
enabled_channels, &delay_tx);
433+
nb_enabled_channels = enabled_channel_count(params->current_datarate,
434+
channel_mask,
435+
enabled_channels, &delay_tx);
436436
} else {
437437
delay_tx++;
438438
nextTxDelay = params->aggregate_timeoff - _lora_time->get_elapsed_time(params->last_aggregate_tx_time);

features/lorawan/lorastack/phy/LoRaPHYUS915.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t* para
631631
next_tx_delay = update_band_timeoff(params->joined, params->dc_enabled, bands, US915_MAX_NB_BANDS);
632632

633633
// Search how many channels are enabled
634-
nb_enabled_channels = enabled_channel_count(params->joined,
635-
params->current_datarate,
634+
nb_enabled_channels = enabled_channel_count(params->current_datarate,
636635
current_channel_mask,
637636
enabled_channels, &delay_tx);
638637
} else {

features/lorawan/lorastack/phy/LoRaPHYUS915Hybrid.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ lorawan_status_t LoRaPHYUS915Hybrid::set_next_channel(channel_selection_params_t
631631
US915_HYBRID_MAX_NB_BANDS);
632632

633633
// Search how many channels are enabled
634-
nb_enabled_channels = enabled_channel_count(params->joined,
635-
params->current_datarate,
634+
nb_enabled_channels = enabled_channel_count(params->current_datarate,
636635
current_channel_mask,
637636
enabled_channels, &delay_tx);
638637
} else {

features/lorawan/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
"help": "Enables/disables duty cycling. NOTE: Disable only for testing. Mandatory in many regions.",
5858
"value": true
5959
},
60+
"duty-cycle-on-join": {
61+
"help": "Enables/disables duty cycling for JOIN requests (disabling requires duty-cycle-on to be disabled). NOTE: Disable only for testing!",
62+
"value": true
63+
},
6064
"lbt-on": {
6165
"help": "Enables/disables LBT. NOTE: [This feature is not yet integrated].",
6266
"value": false

0 commit comments

Comments
 (0)