Skip to content

Commit 98af118

Browse files
author
Jarkko Paso
authored
Merge pull request #1965 from ARMmbed/IOTTHD-3193
Iotthd 3193
2 parents fc76d1e + bdfea40 commit 98af118

File tree

3 files changed

+53
-70
lines changed

3 files changed

+53
-70
lines changed

source/6LoWPAN/ws/ws_common.c

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "randLIB.h"
2323
#include <ns_list.h>
2424
#include <nsdynmemLIB.h>
25-
#include "NWK_INTERFACE/Include/protocol.h"
2625
#include "6LoWPAN/ws/ws_config.h"
2726
#include "6LoWPAN/ws/ws_common_defines.h"
2827
#include "6LoWPAN/ws/ws_common.h"
@@ -137,87 +136,122 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
137136
if (cur->ws_info->hopping_schdule.operating_class == 1) {
138137
cur->ws_info->hopping_schdule.ch0_freq = 9171;
139138
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
140-
cur->ws_info->hopping_schdule.number_of_channels = 32;
141139
} else if (cur->ws_info->hopping_schdule.operating_class == 2) {
142140
cur->ws_info->hopping_schdule.ch0_freq = 9173;
143141
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
144-
cur->ws_info->hopping_schdule.number_of_channels = 16;
145142
} else {
146143
return -1;
147144
}
148145
} else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_EU) {
149146
if (cur->ws_info->hopping_schdule.operating_class == 1) {
150147
cur->ws_info->hopping_schdule.ch0_freq = 8631;
151148
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_100;
152-
cur->ws_info->hopping_schdule.number_of_channels = 69;
153149
} else if (cur->ws_info->hopping_schdule.operating_class == 2) {
154150
cur->ws_info->hopping_schdule.ch0_freq = 8631;
155151
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
156-
cur->ws_info->hopping_schdule.number_of_channels = 35;
157152
} else if (cur->ws_info->hopping_schdule.operating_class == 3) {
158153
cur->ws_info->hopping_schdule.ch0_freq = 8701;
159154
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_100;
160-
cur->ws_info->hopping_schdule.number_of_channels = 55;
161155
} else if (cur->ws_info->hopping_schdule.operating_class == 4) {
162156
cur->ws_info->hopping_schdule.ch0_freq = 8702;
163157
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
164-
cur->ws_info->hopping_schdule.number_of_channels = 27;
165158
} else {
166159
return -1;
167160
}
168161
} else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_NA) {
169162
if (cur->ws_info->hopping_schdule.operating_class == 1) {
170163
cur->ws_info->hopping_schdule.ch0_freq = 9022;
171164
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
172-
cur->ws_info->hopping_schdule.number_of_channels = 129;
173165
} else if (cur->ws_info->hopping_schdule.operating_class == 2) {
174166
cur->ws_info->hopping_schdule.ch0_freq = 9024;
175167
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
176-
cur->ws_info->hopping_schdule.number_of_channels = 64;
177168
} else if (cur->ws_info->hopping_schdule.operating_class == 3) {
178169
cur->ws_info->hopping_schdule.ch0_freq = 9026;
179170
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_600;
180-
cur->ws_info->hopping_schdule.number_of_channels = 42;
181171
} else {
182172
return -1;
183173
}
184174
} else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_JP) {
185175
if (cur->ws_info->hopping_schdule.operating_class == 1) {
186176
cur->ws_info->hopping_schdule.ch0_freq = 9206;
187177
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
188-
cur->ws_info->hopping_schdule.number_of_channels = 38;
189178
} else if (cur->ws_info->hopping_schdule.operating_class == 2) {
190179
cur->ws_info->hopping_schdule.ch0_freq = 9209;
191180
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
192-
cur->ws_info->hopping_schdule.number_of_channels = 18;
193181
} else if (cur->ws_info->hopping_schdule.operating_class == 3) {
194182
cur->ws_info->hopping_schdule.ch0_freq = 9208;
195183
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_600;
196-
cur->ws_info->hopping_schdule.number_of_channels = 12;
197184
} else {
198185
return -1;
199186
}
200187
} else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_WW) {
201188
if (cur->ws_info->hopping_schdule.operating_class == 1) {
202189
cur->ws_info->hopping_schdule.ch0_freq = 24002;
203190
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
204-
cur->ws_info->hopping_schdule.number_of_channels = (uint8_t)416; // TODO we dont support this yet, but it is used as test value
205191
} else if (cur->ws_info->hopping_schdule.operating_class == 2) {
206192
cur->ws_info->hopping_schdule.ch0_freq = 24004;
207193
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
208-
cur->ws_info->hopping_schdule.number_of_channels = 207;
209194
} else {
210195
return -1;
211196
}
212197
} else {
213198
return -1;
214199
}
200+
cur->ws_info->hopping_schdule.number_of_channels = (uint8_t)ws_common_channel_number_calc(cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class);
201+
if (!cur->ws_info->hopping_schdule.number_of_channels) {
202+
return -1;
203+
}
215204
// Note: doesn't work for Brazil region
216205
ws_generate_channel_list(cur->ws_info->hopping_schdule.channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
217206
ws_set_domain_rf_config(cur);
218207
return 0;
219208
}
220209

210+
uint16_t ws_common_channel_number_calc(uint8_t regulatory_domain, uint8_t operating_class)
211+
{
212+
if (regulatory_domain == REG_DOMAIN_KR) {
213+
if (operating_class == 1) {
214+
return 32;
215+
} else if (operating_class == 2) {
216+
return 16;
217+
}
218+
} else if (regulatory_domain == REG_DOMAIN_EU) {
219+
if (operating_class == 1) {
220+
return 69;
221+
} else if (operating_class == 2) {
222+
return 35;
223+
} else if (operating_class == 3) {
224+
return 55;
225+
} else if (operating_class == 4) {
226+
return 27;
227+
}
228+
} else if (regulatory_domain == REG_DOMAIN_NA) {
229+
if (operating_class == 1) {
230+
return 129;
231+
} else if (operating_class == 2) {
232+
return 64;
233+
} else if (operating_class == 3) {
234+
return 42;
235+
}
236+
} else if (regulatory_domain == REG_DOMAIN_JP) {
237+
if (operating_class == 1) {
238+
return 38;
239+
} else if (operating_class == 2) {
240+
return 18;
241+
} else if (operating_class == 3) {
242+
return 12;
243+
}
244+
} else if (regulatory_domain == REG_DOMAIN_WW) {
245+
if (operating_class == 1) {
246+
// TODO we dont support this yet, but it is used as test value
247+
return 416;
248+
} else if (operating_class == 2) {
249+
return 207;
250+
}
251+
}
252+
return 0;
253+
}
254+
221255
int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
222256
{
223257

source/6LoWPAN/ws/ws_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "fhss_api.h"
2525
#include "fhss_config.h"
2626
#include "net_fhss.h"
27+
#include "NWK_INTERFACE/Include/protocol.h"
2728
#include "6LoWPAN/ws/ws_common_defines.h"
2829
#include "6LoWPAN/ws/ws_neighbor_class.h"
2930
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
@@ -103,6 +104,8 @@ int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_chann
103104

104105
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur);
105106

107+
uint16_t ws_common_channel_number_calc(uint8_t regulatory_domain, uint8_t operating_class);
108+
106109
int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur);
107110

108111
void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size);

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "fhss_config.h"
2525
#include "6LoWPAN/ws/ws_config.h"
2626
#include "6LoWPAN/ws/ws_neighbor_class.h"
27+
#include "6LoWPAN/ws/ws_common.h"
2728
#include "ws_management_api.h"
2829

2930
#ifdef HAVE_WS
@@ -93,61 +94,6 @@ void ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor_class_entry
9394
ws_neighbor->fhss_data.uc_timing_info.ufsi = ws_utt->ufsi;
9495
}
9596

96-
static uint16_t ws_common_channel_number_calc(uint8_t regulatory_domain, uint8_t operating_class)
97-
{
98-
if (regulatory_domain == REG_DOMAIN_KR) {
99-
if (operating_class == 1) {
100-
return 32;
101-
} else if (operating_class == 2) {
102-
return 16;
103-
} else {
104-
return 0;
105-
}
106-
} else if (regulatory_domain == REG_DOMAIN_EU) {
107-
if (operating_class == 1) {
108-
return 69;
109-
} else if (operating_class == 2) {
110-
return 35;
111-
} else if (operating_class == 3) {
112-
return 59;
113-
} else if (operating_class == 4) {
114-
return 30;
115-
} else {
116-
return 0;
117-
}
118-
} else if (regulatory_domain == REG_DOMAIN_NA) {
119-
if (operating_class == 1) {
120-
return 129;
121-
} else if (operating_class == 2) {
122-
return 64;
123-
} else if (operating_class == 3) {
124-
return 42;
125-
} else {
126-
return 0;
127-
}
128-
} else if (regulatory_domain == REG_DOMAIN_JP) {
129-
if (operating_class == 1) {
130-
return 38;
131-
} else if (operating_class == 2) {
132-
return 18;
133-
} else if (operating_class == 3) {
134-
return 12;
135-
} else {
136-
return 0;
137-
}
138-
} else if (regulatory_domain == REG_DOMAIN_WW) {
139-
if (operating_class == 1) {
140-
return 416;
141-
} else if (operating_class == 2) {
142-
return 207;
143-
} else {
144-
return 0;
145-
}
146-
} else {
147-
return 0;
148-
}
149-
}
150-
15197
void ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_us_ie_t *ws_us)
15298
{
15399
ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function = ws_us->channel_function;

0 commit comments

Comments
 (0)