Skip to content

Commit 296961d

Browse files
authored
Merge pull request #12836 from felipeLeast/wisun_bz
Wi-SUN added regulatory domain Brazil
2 parents 0b4b2af + b0ab860 commit 296961d

File tree

3 files changed

+53
-9
lines changed

3 files changed

+53
-9
lines changed

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ static uint8_t ws_generate_exluded_channel_list_from_active_channels(ws_excluded
486486

487487
static void ws_fhss_configure_channel_masks(protocol_interface_info_entry_t *cur, fhss_ws_configuration_t *fhss_configuration)
488488
{
489-
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
490-
ws_generate_channel_list(fhss_configuration->unicast_channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
489+
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class);
490+
ws_generate_channel_list(fhss_configuration->unicast_channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class);
491491
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
492492
for (uint8_t n = 0; n < 8; n++) {
493493
fhss_configuration->unicast_channel_mask[n] &= cur->ws_info->cfg->fhss.fhss_channel_mask[n];
@@ -2731,7 +2731,7 @@ static void ws_set_asynch_channel_list(protocol_interface_info_entry_t *cur, asy
27312731
uint16_t channel_number = cur->ws_info->cfg->fhss.fhss_uc_fixed_channel;
27322732
async_req->channel_list.channel_mask[0 + (channel_number / 32)] = (1 << (channel_number % 32));
27332733
} else {
2734-
ws_generate_channel_list(async_req->channel_list.channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
2734+
ws_generate_channel_list(async_req->channel_list.channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class);
27352735
}
27362736

27372737
async_req->channel_list.channel_page = CHANNEL_PAGE_10;

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.c

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,34 @@ uint8_t DEVICE_MIN_SENS = 174 - 93;
4949

5050
uint16_t test_max_child_count_override = 0xffff;
5151

52-
53-
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain)
52+
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain, uint8_t operating_class)
5453
{
55-
(void)regulatory_domain;
56-
for (uint8_t i = 0; i < number_of_channels; i++) {
57-
channel_mask[0 + (i / 32)] |= (1 << (i % 32));
54+
uint32_t excluded_start_channel = 0xFFFFFFFF;
55+
uint32_t excluded_end_channel = 0xFFFFFFFF;
56+
57+
if (regulatory_domain == REG_DOMAIN_BZ) {
58+
if (operating_class == 1) {
59+
excluded_start_channel = 26;
60+
excluded_end_channel = 64;
61+
} else if (operating_class == 2) {
62+
excluded_start_channel = 12;
63+
excluded_end_channel = 32;
64+
} else if (operating_class == 3) {
65+
excluded_start_channel = 7;
66+
excluded_end_channel = 21;
67+
}
68+
}
69+
70+
// Clear channel mask
71+
for (uint8_t i = 0; i < 8; i++) {
72+
channel_mask[i] = 0;
73+
}
74+
75+
// Set channel maks outside excluded channels
76+
for (uint16_t i = 0; i < number_of_channels; i++) {
77+
if (i < excluded_start_channel || i > excluded_end_channel) {
78+
channel_mask[0 + (i / 32)] |= (1 << (i % 32));
79+
}
5880
}
5981
return 0;
6082
}
@@ -159,6 +181,19 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur,
159181
} else {
160182
return -1;
161183
}
184+
} else if (hopping_schdule->regulatory_domain == REG_DOMAIN_BZ) {
185+
if (hopping_schdule->operating_class == 1) {
186+
hopping_schdule->ch0_freq = 9022;
187+
hopping_schdule->channel_spacing = CHANNEL_SPACING_200;
188+
} else if (hopping_schdule->operating_class == 2) {
189+
hopping_schdule->ch0_freq = 9024;
190+
hopping_schdule->channel_spacing = CHANNEL_SPACING_400;
191+
} else if (hopping_schdule->operating_class == 3) {
192+
hopping_schdule->ch0_freq = 9026;
193+
hopping_schdule->channel_spacing = CHANNEL_SPACING_600;
194+
} else {
195+
return -1;
196+
}
162197
} else if (hopping_schdule->regulatory_domain == REG_DOMAIN_JP) {
163198
if (hopping_schdule->operating_class == 1) {
164199
hopping_schdule->ch0_freq = 9206;
@@ -189,6 +224,7 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur,
189224
if (!hopping_schdule->number_of_channels) {
190225
return -1;
191226
}
227+
192228
return 0;
193229
}
194230

@@ -232,6 +268,14 @@ uint16_t ws_common_channel_number_calc(uint8_t regulatory_domain, uint8_t operat
232268
} else if (operating_class == 3) {
233269
return 12;
234270
}
271+
} else if (regulatory_domain == REG_DOMAIN_BZ) {
272+
if (operating_class == 1) {
273+
return 129;
274+
} else if (operating_class == 2) {
275+
return 64;
276+
} else if (operating_class == 3) {
277+
return 42;
278+
}
235279
} else if (regulatory_domain == REG_DOMAIN_WW) {
236280
if (operating_class == 1) {
237281
// TODO we dont support this yet, but it is used as test value

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ typedef struct ws_info_s {
112112

113113
#ifdef HAVE_WS
114114

115-
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain);
115+
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain, uint8_t operating_class);
116116

117117
uint32_t ws_decode_channel_spacing(uint8_t channel_spacing);
118118

0 commit comments

Comments
 (0)