Skip to content

Commit b68f394

Browse files
author
Jarkko Paso
committed
WS bootstrap: Updated channel function set apis
1 parent 42b2e7c commit b68f394

File tree

5 files changed

+57
-21
lines changed

5 files changed

+57
-21
lines changed

nanostack/ws_management_api.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
#include "net_interface.h" /* Declaration for channel_list_s. */
3333

3434
// TODO: Remove when application updated
35-
#define ws_management_fhss_channel_function_configure ws_management_fhss_unicast_channel_function_configure
35+
#define DEFAULT_FIXED_CHANNEL 11
36+
#define DEFAULT_DWELL_TIME 250
37+
#define ws_management_fhss_channel_function_configure(x,y) ws_management_fhss_unicast_channel_function_configure(x,y,DEFAULT_FIXED_CHANNEL,DEFAULT_DWELL_TIME)
3638

3739
#ifdef __cplusplus
3840
extern "C" {
@@ -188,14 +190,18 @@ int ws_management_fhss_timing_configure(
188190
* if application defined is used the behaviour is undefined
189191
*
190192
* \param interface_id Network interface ID.
191-
* \param channel_function Unicast channel function
193+
* \param channel_function Unicast channel function.
194+
* \param fixed_channel Used channel when channel function is fixed channel.
195+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1.
192196
*
193197
* \return 0, Init OK.
194198
* \return <0 Init fail.
195199
*/
196200
int ws_management_fhss_unicast_channel_function_configure(
197201
int8_t interface_id,
198-
uint8_t channel_function);
202+
uint8_t channel_function,
203+
uint8_t fixed_channel,
204+
uint8_t dwell_interval);
199205

200206
/**
201207
* Configure broadcast channel function.
@@ -205,13 +211,19 @@ int ws_management_fhss_unicast_channel_function_configure(
205211
* if application defined is used the behaviour is undefined
206212
*
207213
* \param interface_id Network interface ID.
208-
* \param channel_function Broadcast channel function
214+
* \param channel_function Broadcast channel function.
215+
* \param fixed_channel Used channel when channel function is fixed channel.
216+
* \param dwell_interval Broadcast channel dwell interval.
217+
* \param broadcast_interval Broadcast interval.
209218
*
210219
* \return 0, Init OK.
211220
* \return <0 Init fail.
212221
*/
213222
int ws_management_fhss_broadcast_channel_function_configure(
214223
int8_t interface_id,
215-
uint8_t channel_function);
224+
uint8_t channel_function,
225+
uint8_t fixed_channel,
226+
uint8_t dwell_interval,
227+
uint32_t broadcast_interval);
216228

217229
#endif /* WS_MANAGEMENT_API_H_ */

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ static fhss_ws_neighbor_timing_info_t *ws_get_neighbor_info(const fhss_api_t *ap
182182
static void ws_bootstrap_llc_hopping_update(struct protocol_interface_info_entry *cur, const fhss_ws_configuration_t *fhss_configuration)
183183
{
184184
memcpy(cur->ws_info->hopping_schdule.channel_mask, fhss_configuration->channel_mask, sizeof(uint32_t) * 8);
185+
cur->ws_info->hopping_schdule.uc_fixed_channel = fhss_configuration->unicast_fixed_channel;
186+
cur->ws_info->hopping_schdule.bc_fixed_channel = fhss_configuration->broadcast_fixed_channel;
185187
cur->ws_info->hopping_schdule.uc_channel_function = fhss_configuration->ws_uc_channel_function;
186188
cur->ws_info->hopping_schdule.bc_channel_function = fhss_configuration->ws_bc_channel_function;
187189
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = fhss_configuration->fhss_bc_dwell_interval;
@@ -240,8 +242,8 @@ static int8_t ws_fhss_set_defaults(protocol_interface_info_entry_t *cur, fhss_ws
240242
fhss_configuration->ws_bc_channel_function = cur->ws_info->fhss_bc_channel_function;
241243
fhss_configuration->fhss_bc_dwell_interval = cur->ws_info->fhss_bc_dwell_interval;
242244
fhss_configuration->fhss_broadcast_interval = cur->ws_info->fhss_bc_interval;
243-
fhss_configuration->unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel;
244-
fhss_configuration->broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel;
245+
fhss_configuration->unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;
246+
fhss_configuration->broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel;
245247
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
246248

247249
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
@@ -277,12 +279,12 @@ static int8_t ws_fhss_discovery_configure(protocol_interface_info_entry_t *cur)
277279
fhss_configuration.ws_bc_channel_function = WS_FIXED_CHANNEL;
278280
fhss_configuration.fhss_bc_dwell_interval = 0;
279281
fhss_configuration.fhss_broadcast_interval = 0;
280-
cur->ws_info->hopping_schdule.uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
281-
cur->ws_info->hopping_schdule.bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
282+
cur->ws_info->fhss_uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
283+
cur->ws_info->fhss_bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
282284
memset(fhss_configuration.channel_mask, 0, sizeof(uint32_t) * 8);
283-
channel_list_set_channel(fhss_configuration.channel_mask, cur->ws_info->hopping_schdule.uc_fixed_channel, true);
284-
fhss_configuration.unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel;
285-
fhss_configuration.broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel;
285+
channel_list_set_channel(fhss_configuration.channel_mask, cur->ws_info->fhss_uc_fixed_channel, true);
286+
fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;
287+
fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel;
286288
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api,&fhss_configuration);
287289
ws_bootstrap_llc_hopping_update(cur,&fhss_configuration);
288290

@@ -328,8 +330,8 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
328330
fhss_configuration.bsi = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id;
329331
fhss_configuration.fhss_bc_dwell_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval;
330332
fhss_configuration.fhss_broadcast_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_interval;
331-
fhss_configuration.unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel;
332-
fhss_configuration.broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel;
333+
fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;
334+
fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel;
333335
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration);
334336

335337
if (fhss_configuration.fhss_bc_dwell_interval && fhss_configuration.fhss_broadcast_interval) {
@@ -1158,7 +1160,7 @@ static void ws_bootstrap_fhss_activate(protocol_interface_info_entry_t *cur)
11581160
tr_debug("MAC init");
11591161
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, true);
11601162
cur->lowpan_info &= ~INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE;
1161-
ws_bootstrap_mac_activate(cur, cur->ws_info->hopping_schdule.uc_fixed_channel, cur->ws_info->network_pan_id, true);
1163+
ws_bootstrap_mac_activate(cur, cur->ws_info->fhss_uc_fixed_channel, cur->ws_info->network_pan_id, true);
11621164
return;
11631165
}
11641166

@@ -1561,8 +1563,8 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
15611563
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
15621564
tr_debug("Border router start network");
15631565
// Randomize fixed channel. Only used if channel plan is fixed
1564-
cur->ws_info->hopping_schdule.uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
1565-
cur->ws_info->hopping_schdule.bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
1566+
cur->ws_info->fhss_uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
1567+
cur->ws_info->fhss_bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1);
15661568
cur->ws_info->network_pan_id = randLIB_get_random_in_range(0,0xfffd);
15671569
cur->ws_info->pan_information.pan_size = 0;
15681570
cur->ws_info->pan_information.pan_version = randLIB_get_random_in_range(0,0xffff);

source/6LoWPAN/ws/ws_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ typedef struct ws_info_s {
6161
uint32_t fhss_bc_interval;
6262
uint8_t fhss_uc_channel_function;
6363
uint8_t fhss_bc_channel_function;
64+
uint8_t fhss_uc_fixed_channel;
65+
uint8_t fhss_bc_fixed_channel;
6466
uint32_t fhss_channel_mask[8];
6567

6668
struct ws_pan_information_s pan_information;

source/6LoWPAN/ws/ws_empty_functions.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,29 @@ int ws_management_fhss_timing_configure(
9494

9595
int ws_management_fhss_unicast_channel_function_configure(
9696
int8_t interface_id,
97-
uint8_t channel_function)
97+
uint8_t channel_function,
98+
uint8_t fixed_channel,
99+
uint8_t dwell_interval)
98100
{
99101
(void)interface_id;
100102
(void)channel_function;
103+
(void)fixed_channel;
104+
(void)dwell_interval;
101105
return -1;
102106
}
103107

104108
int ws_management_fhss_broadcast_channel_function_configure(
105109
int8_t interface_id,
106-
uint8_t channel_function)
110+
uint8_t channel_function,
111+
uint8_t fixed_channel,
112+
uint8_t dwell_interval,
113+
uint32_t broadcast_interval)
107114
{
108115
(void)interface_id;
109116
(void)channel_function;
117+
(void)fixed_channel;
118+
(void)dwell_interval;
119+
(void)broadcast_interval;
110120
return -1;
111121
}
112122

source/6LoWPAN/ws/ws_management_api.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ int ws_management_fhss_timing_configure(
163163

164164
int ws_management_fhss_unicast_channel_function_configure(
165165
int8_t interface_id,
166-
uint8_t channel_function)
166+
uint8_t channel_function,
167+
uint8_t fixed_channel,
168+
uint8_t dwell_interval)
167169
{
168170
protocol_interface_info_entry_t *cur;
169171

@@ -178,6 +180,8 @@ int ws_management_fhss_unicast_channel_function_configure(
178180
return -2;
179181
}
180182
cur->ws_info->fhss_uc_channel_function = channel_function;
183+
cur->ws_info->fhss_uc_fixed_channel = fixed_channel;
184+
cur->ws_info->fhss_uc_dwell_interval = dwell_interval;
181185

182186
// if settings change reset_restart for the settings needed
183187
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
@@ -190,7 +194,10 @@ int ws_management_fhss_unicast_channel_function_configure(
190194

191195
int ws_management_fhss_broadcast_channel_function_configure(
192196
int8_t interface_id,
193-
uint8_t channel_function)
197+
uint8_t channel_function,
198+
uint8_t fixed_channel,
199+
uint8_t dwell_interval,
200+
uint32_t broadcast_interval)
194201
{
195202
protocol_interface_info_entry_t *cur;
196203

@@ -205,6 +212,9 @@ int ws_management_fhss_broadcast_channel_function_configure(
205212
return -2;
206213
}
207214
cur->ws_info->fhss_bc_channel_function = channel_function;
215+
cur->ws_info->fhss_bc_fixed_channel = fixed_channel;
216+
cur->ws_info->fhss_bc_dwell_interval = dwell_interval;
217+
cur->ws_info->fhss_bc_interval = broadcast_interval;
208218

209219
// if settings change reset_restart for the settings needed
210220
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {

0 commit comments

Comments
 (0)