Skip to content

Commit dc56a06

Browse files
author
Hasnain Virk
committed
Enabling FSB support in AU915 PHY
Just like US915 PHY, user can define a custom FSB mask for AU915 PHY. This helps deployments where base stations do not portray full feature channel sets and choose to stick with sub-bands.
1 parent 207ae2d commit dc56a06

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

features/lorawan/lorastack/phy/LoRaPHYAU915.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ static const uint8_t max_payload_AU915[] = { 51, 51, 51, 115, 242, 242,
220220
static const uint8_t max_payload_with_repeater_AU915[] = { 51, 51, 51, 115,
221221
222, 222, 222, 0, 33, 109, 222, 222, 222, 222, 0, 0 };
222222

223+
static const uint16_t fsb_mask[] = MBED_CONF_LORA_FSB_MASK;
223224

224225
LoRaPHYAU915::LoRaPHYAU915()
225226
{
@@ -244,11 +245,17 @@ LoRaPHYAU915::LoRaPHYAU915()
244245
// All channels are default channels here
245246
// Join request needs to alternate between 125 KHz and 500 KHz channels
246247
// randomly.
247-
default_channel_mask[0] = 0xFFFF;
248-
default_channel_mask[1] = 0xFFFF;
249-
default_channel_mask[2] = 0xFFFF;
250-
default_channel_mask[3] = 0xFFFF;
251-
default_channel_mask[4] = 0x00FF;
248+
// ChannelsMask
249+
for (uint8_t i = 0; i < AU915_MAX_NB_CHANNELS; i++) {
250+
if (i == (AU915_MAX_NB_CHANNELS - 1)) {
251+
// 64 - 71, 500 kHz channels will get enabled
252+
default_channel_mask[i] = 0x00FF & fsb_mask[i];
253+
continue;
254+
}
255+
256+
// 0 - 63 125 kHz channels will get enabled
257+
default_channel_mask[i] = 0xFFFF & fsb_mask[i];
258+
}
252259

253260
memset(channel_mask, 0, sizeof(channel_mask));
254261
memset(current_channel_mask, 0, sizeof(current_channel_mask));
@@ -445,18 +452,18 @@ uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t* params,
445452

446453
if (adr_settings.ch_mask_ctrl == 6) {
447454
// Enable all 125 kHz channels
448-
temp_channel_masks[0] = 0xFFFF;
449-
temp_channel_masks[1] = 0xFFFF;
450-
temp_channel_masks[2] = 0xFFFF;
451-
temp_channel_masks[3] = 0xFFFF;
455+
for (uint8_t i = 0; i < AU915_CHANNEL_MASK_SIZE - 1; i++) {
456+
temp_channel_masks[i] = 0xFFFF;
457+
}
458+
452459
// Apply chMask to channels 64 to 71
453460
temp_channel_masks[4] = adr_settings.channel_mask;
454461
} else if (adr_settings.ch_mask_ctrl == 7) {
455462
// Disable all 125 kHz channels
456-
temp_channel_masks[0] = 0x0000;
457-
temp_channel_masks[1] = 0x0000;
458-
temp_channel_masks[2] = 0x0000;
459-
temp_channel_masks[3] = 0x0000;
463+
for (uint8_t i = 0; i < AU915_CHANNEL_MASK_SIZE - 1; i++) {
464+
temp_channel_masks[i] = 0x0000;
465+
}
466+
460467
// Apply chMask to channels 64 to 71
461468
temp_channel_masks[4] = adr_settings.channel_mask;
462469
} else if (adr_settings.ch_mask_ctrl == 5) {
@@ -493,11 +500,9 @@ uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t* params,
493500
// Copy Mask
494501
copy_channel_mask(channel_mask, temp_channel_masks, AU915_CHANNEL_MASK_SIZE);
495502

496-
current_channel_mask[0] &= channel_mask[0];
497-
current_channel_mask[1] &= channel_mask[1];
498-
current_channel_mask[2] &= channel_mask[2];
499-
current_channel_mask[3] &= channel_mask[3];
500-
current_channel_mask[4] = channel_mask[4];
503+
for (uint8_t i = 0; i < AU915_CHANNEL_MASK_SIZE; i++) {
504+
current_channel_mask[i] &= channel_mask[i];
505+
}
501506
}
502507

503508
// Update status variables
@@ -548,9 +553,6 @@ int8_t LoRaPHYAU915::get_alternate_DR(uint8_t nb_trials)
548553
{
549554
int8_t datarate = 0;
550555

551-
// Re-enable 500 kHz default channels
552-
channel_mask[4] = 0x00FF;
553-
554556
if ((nb_trials & 0x01) == 0x01) {
555557
datarate = DR_6;
556558
} else {
@@ -576,11 +578,10 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next
576578
}
577579

578580
// Check other channels
579-
if (next_chan_params->current_datarate >= DR_6) {
580-
if ((current_channel_mask[4] & 0x00FF) == 0) {
581-
// fall back to 500 kHz default channels
582-
current_channel_mask[4] = channel_mask[4];
583-
}
581+
if ((next_chan_params->current_datarate >= DR_6)
582+
&& (current_channel_mask[4] & 0x00FF) == 0) {
583+
// fall back to 500 kHz default channels
584+
current_channel_mask[4] = channel_mask[4];
584585
}
585586

586587
if (next_chan_params->aggregate_timeoff <= _lora_time->get_elapsed_time(next_chan_params->last_aggregate_tx_time)) {
@@ -605,8 +606,7 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next
605606
// We found a valid channel
606607
*channel = enabled_channels[get_random(0, nb_enabled_channels - 1)];
607608
// Disable the channel in the mask
608-
disable_channel(current_channel_mask, *channel,
609-
AU915_MAX_NB_CHANNELS - 8);
609+
disable_channel(current_channel_mask, *channel, AU915_MAX_NB_CHANNELS);
610610

611611
*time = 0;
612612
return LORAWAN_STATUS_OK;

0 commit comments

Comments
 (0)