|
22 | 22 | #include "randLIB.h"
|
23 | 23 | #include <ns_list.h>
|
24 | 24 | #include <nsdynmemLIB.h>
|
25 |
| -#include "NWK_INTERFACE/Include/protocol.h" |
26 | 25 | #include "6LoWPAN/ws/ws_config.h"
|
27 | 26 | #include "6LoWPAN/ws/ws_common_defines.h"
|
28 | 27 | #include "6LoWPAN/ws/ws_common.h"
|
@@ -137,87 +136,122 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
|
137 | 136 | if (cur->ws_info->hopping_schdule.operating_class == 1) {
|
138 | 137 | cur->ws_info->hopping_schdule.ch0_freq = 9171;
|
139 | 138 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
|
140 |
| - cur->ws_info->hopping_schdule.number_of_channels = 32; |
141 | 139 | } else if (cur->ws_info->hopping_schdule.operating_class == 2) {
|
142 | 140 | cur->ws_info->hopping_schdule.ch0_freq = 9173;
|
143 | 141 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
|
144 |
| - cur->ws_info->hopping_schdule.number_of_channels = 16; |
145 | 142 | } else {
|
146 | 143 | return -1;
|
147 | 144 | }
|
148 | 145 | } else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_EU) {
|
149 | 146 | if (cur->ws_info->hopping_schdule.operating_class == 1) {
|
150 | 147 | cur->ws_info->hopping_schdule.ch0_freq = 8631;
|
151 | 148 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_100;
|
152 |
| - cur->ws_info->hopping_schdule.number_of_channels = 69; |
153 | 149 | } else if (cur->ws_info->hopping_schdule.operating_class == 2) {
|
154 | 150 | cur->ws_info->hopping_schdule.ch0_freq = 8631;
|
155 | 151 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
|
156 |
| - cur->ws_info->hopping_schdule.number_of_channels = 35; |
157 | 152 | } else if (cur->ws_info->hopping_schdule.operating_class == 3) {
|
158 | 153 | cur->ws_info->hopping_schdule.ch0_freq = 8701;
|
159 | 154 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_100;
|
160 |
| - cur->ws_info->hopping_schdule.number_of_channels = 55; |
161 | 155 | } else if (cur->ws_info->hopping_schdule.operating_class == 4) {
|
162 | 156 | cur->ws_info->hopping_schdule.ch0_freq = 8702;
|
163 | 157 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
|
164 |
| - cur->ws_info->hopping_schdule.number_of_channels = 27; |
165 | 158 | } else {
|
166 | 159 | return -1;
|
167 | 160 | }
|
168 | 161 | } else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_NA) {
|
169 | 162 | if (cur->ws_info->hopping_schdule.operating_class == 1) {
|
170 | 163 | cur->ws_info->hopping_schdule.ch0_freq = 9022;
|
171 | 164 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
|
172 |
| - cur->ws_info->hopping_schdule.number_of_channels = 129; |
173 | 165 | } else if (cur->ws_info->hopping_schdule.operating_class == 2) {
|
174 | 166 | cur->ws_info->hopping_schdule.ch0_freq = 9024;
|
175 | 167 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
|
176 |
| - cur->ws_info->hopping_schdule.number_of_channels = 64; |
177 | 168 | } else if (cur->ws_info->hopping_schdule.operating_class == 3) {
|
178 | 169 | cur->ws_info->hopping_schdule.ch0_freq = 9026;
|
179 | 170 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_600;
|
180 |
| - cur->ws_info->hopping_schdule.number_of_channels = 42; |
181 | 171 | } else {
|
182 | 172 | return -1;
|
183 | 173 | }
|
184 | 174 | } else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_JP) {
|
185 | 175 | if (cur->ws_info->hopping_schdule.operating_class == 1) {
|
186 | 176 | cur->ws_info->hopping_schdule.ch0_freq = 9206;
|
187 | 177 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
|
188 |
| - cur->ws_info->hopping_schdule.number_of_channels = 38; |
189 | 178 | } else if (cur->ws_info->hopping_schdule.operating_class == 2) {
|
190 | 179 | cur->ws_info->hopping_schdule.ch0_freq = 9209;
|
191 | 180 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
|
192 |
| - cur->ws_info->hopping_schdule.number_of_channels = 18; |
193 | 181 | } else if (cur->ws_info->hopping_schdule.operating_class == 3) {
|
194 | 182 | cur->ws_info->hopping_schdule.ch0_freq = 9208;
|
195 | 183 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_600;
|
196 |
| - cur->ws_info->hopping_schdule.number_of_channels = 12; |
197 | 184 | } else {
|
198 | 185 | return -1;
|
199 | 186 | }
|
200 | 187 | } else if (cur->ws_info->hopping_schdule.regulatory_domain == REG_DOMAIN_WW) {
|
201 | 188 | if (cur->ws_info->hopping_schdule.operating_class == 1) {
|
202 | 189 | cur->ws_info->hopping_schdule.ch0_freq = 24002;
|
203 | 190 | 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 |
205 | 191 | } else if (cur->ws_info->hopping_schdule.operating_class == 2) {
|
206 | 192 | cur->ws_info->hopping_schdule.ch0_freq = 24004;
|
207 | 193 | cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_400;
|
208 |
| - cur->ws_info->hopping_schdule.number_of_channels = 207; |
209 | 194 | } else {
|
210 | 195 | return -1;
|
211 | 196 | }
|
212 | 197 | } else {
|
213 | 198 | return -1;
|
214 | 199 | }
|
| 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 | + } |
215 | 204 | // Note: doesn't work for Brazil region
|
216 | 205 | 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);
|
217 | 206 | ws_set_domain_rf_config(cur);
|
218 | 207 | return 0;
|
219 | 208 | }
|
220 | 209 |
|
| 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 | + |
221 | 255 | int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
|
222 | 256 | {
|
223 | 257 |
|
|
0 commit comments