diff --git a/nanostack/ws_management_api.h b/nanostack/ws_management_api.h index ef31c56fbe0..6e502cc0c74 100644 --- a/nanostack/ws_management_api.h +++ b/nanostack/ws_management_api.h @@ -32,7 +32,9 @@ #include "net_interface.h" /* Declaration for channel_list_s. */ // TODO: Remove when application updated -#define ws_management_fhss_channel_function_configure ws_management_fhss_unicast_channel_function_configure +#define DEFAULT_FIXED_CHANNEL 11 +#define DEFAULT_DWELL_TIME 250 +#define ws_management_fhss_channel_function_configure(x,y) ws_management_fhss_unicast_channel_function_configure(x,y,DEFAULT_FIXED_CHANNEL,DEFAULT_DWELL_TIME) #ifdef __cplusplus extern "C" { @@ -188,14 +190,18 @@ int ws_management_fhss_timing_configure( * if application defined is used the behaviour is undefined * * \param interface_id Network interface ID. - * \param channel_function Unicast channel function + * \param channel_function Unicast channel function. + * \param fixed_channel Used channel when channel function is fixed channel. + * \param dwell_interval Used dwell interval when channel function is TR51 or DH1. * * \return 0, Init OK. * \return <0 Init fail. */ int ws_management_fhss_unicast_channel_function_configure( int8_t interface_id, - uint8_t channel_function); + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval); /** * Configure broadcast channel function. @@ -205,13 +211,19 @@ int ws_management_fhss_unicast_channel_function_configure( * if application defined is used the behaviour is undefined * * \param interface_id Network interface ID. - * \param channel_function Broadcast channel function + * \param channel_function Broadcast channel function. + * \param fixed_channel Used channel when channel function is fixed channel. + * \param dwell_interval Broadcast channel dwell interval. + * \param broadcast_interval Broadcast interval. * * \return 0, Init OK. * \return <0 Init fail. */ int ws_management_fhss_broadcast_channel_function_configure( int8_t interface_id, - uint8_t channel_function); + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval, + uint32_t broadcast_interval); #endif /* WS_MANAGEMENT_API_H_ */ diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index 7ac91a89ef6..c169347ade5 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -182,6 +182,8 @@ static fhss_ws_neighbor_timing_info_t *ws_get_neighbor_info(const fhss_api_t *ap static void ws_bootstrap_llc_hopping_update(struct protocol_interface_info_entry *cur, const fhss_ws_configuration_t *fhss_configuration) { memcpy(cur->ws_info->hopping_schdule.channel_mask, fhss_configuration->channel_mask, sizeof(uint32_t) * 8); + cur->ws_info->hopping_schdule.uc_fixed_channel = fhss_configuration->unicast_fixed_channel; + cur->ws_info->hopping_schdule.bc_fixed_channel = fhss_configuration->broadcast_fixed_channel; cur->ws_info->hopping_schdule.uc_channel_function = fhss_configuration->ws_uc_channel_function; cur->ws_info->hopping_schdule.bc_channel_function = fhss_configuration->ws_bc_channel_function; 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 fhss_configuration->ws_bc_channel_function = cur->ws_info->fhss_bc_channel_function; fhss_configuration->fhss_bc_dwell_interval = cur->ws_info->fhss_bc_dwell_interval; fhss_configuration->fhss_broadcast_interval = cur->ws_info->fhss_bc_interval; - fhss_configuration->unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel; - fhss_configuration->broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel; + fhss_configuration->unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel; + fhss_configuration->broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel; ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain); // 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) fhss_configuration.ws_bc_channel_function = WS_FIXED_CHANNEL; fhss_configuration.fhss_bc_dwell_interval = 0; fhss_configuration.fhss_broadcast_interval = 0; - cur->ws_info->hopping_schdule.uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); - cur->ws_info->hopping_schdule.bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); + cur->ws_info->fhss_uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); + cur->ws_info->fhss_bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); memset(fhss_configuration.channel_mask, 0, sizeof(uint32_t) * 8); - channel_list_set_channel(fhss_configuration.channel_mask, cur->ws_info->hopping_schdule.uc_fixed_channel, true); - fhss_configuration.unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel; - fhss_configuration.broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel; + channel_list_set_channel(fhss_configuration.channel_mask, cur->ws_info->fhss_uc_fixed_channel, true); + fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel; + fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel; ns_fhss_ws_configuration_set(cur->ws_info->fhss_api,&fhss_configuration); ws_bootstrap_llc_hopping_update(cur,&fhss_configuration); @@ -328,8 +330,8 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry fhss_configuration.bsi = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id; fhss_configuration.fhss_bc_dwell_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval; fhss_configuration.fhss_broadcast_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_interval; - fhss_configuration.unicast_fixed_channel = cur->ws_info->hopping_schdule.uc_fixed_channel; - fhss_configuration.broadcast_fixed_channel = cur->ws_info->hopping_schdule.bc_fixed_channel; + fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel; + fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel; ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration); 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) tr_debug("MAC init"); mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, true); cur->lowpan_info &= ~INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE; - ws_bootstrap_mac_activate(cur, cur->ws_info->hopping_schdule.uc_fixed_channel, cur->ws_info->network_pan_id, true); + ws_bootstrap_mac_activate(cur, cur->ws_info->fhss_uc_fixed_channel, cur->ws_info->network_pan_id, true); return; } @@ -1561,8 +1563,8 @@ static void ws_bootstrap_event_handler(arm_event_s *event) if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) { tr_debug("Border router start network"); // Randomize fixed channel. Only used if channel plan is fixed - cur->ws_info->hopping_schdule.uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); - cur->ws_info->hopping_schdule.bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); + cur->ws_info->fhss_uc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); + cur->ws_info->fhss_bc_fixed_channel = randLIB_get_random_in_range(0,cur->ws_info->hopping_schdule.number_of_channels - 1); cur->ws_info->network_pan_id = randLIB_get_random_in_range(0,0xfffd); cur->ws_info->pan_information.pan_size = 0; cur->ws_info->pan_information.pan_version = randLIB_get_random_in_range(0,0xffff); diff --git a/source/6LoWPAN/ws/ws_common.h b/source/6LoWPAN/ws/ws_common.h index 387d74bc324..02ed1a10e51 100644 --- a/source/6LoWPAN/ws/ws_common.h +++ b/source/6LoWPAN/ws/ws_common.h @@ -61,6 +61,8 @@ typedef struct ws_info_s { uint32_t fhss_bc_interval; uint8_t fhss_uc_channel_function; uint8_t fhss_bc_channel_function; + uint8_t fhss_uc_fixed_channel; + uint8_t fhss_bc_fixed_channel; uint32_t fhss_channel_mask[8]; struct ws_pan_information_s pan_information; diff --git a/source/6LoWPAN/ws/ws_empty_functions.c b/source/6LoWPAN/ws/ws_empty_functions.c index 7adce713464..2a956f66661 100644 --- a/source/6LoWPAN/ws/ws_empty_functions.c +++ b/source/6LoWPAN/ws/ws_empty_functions.c @@ -94,19 +94,29 @@ int ws_management_fhss_timing_configure( int ws_management_fhss_unicast_channel_function_configure( int8_t interface_id, - uint8_t channel_function) + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval) { (void)interface_id; (void)channel_function; + (void)fixed_channel; + (void)dwell_interval; return -1; } int ws_management_fhss_broadcast_channel_function_configure( int8_t interface_id, - uint8_t channel_function) + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval, + uint32_t broadcast_interval) { (void)interface_id; (void)channel_function; + (void)fixed_channel; + (void)dwell_interval; + (void)broadcast_interval; return -1; } diff --git a/source/6LoWPAN/ws/ws_management_api.c b/source/6LoWPAN/ws/ws_management_api.c index 3feef1fd5c5..abee57fcdec 100644 --- a/source/6LoWPAN/ws/ws_management_api.c +++ b/source/6LoWPAN/ws/ws_management_api.c @@ -163,7 +163,9 @@ int ws_management_fhss_timing_configure( int ws_management_fhss_unicast_channel_function_configure( int8_t interface_id, - uint8_t channel_function) + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval) { protocol_interface_info_entry_t *cur; @@ -178,6 +180,8 @@ int ws_management_fhss_unicast_channel_function_configure( return -2; } cur->ws_info->fhss_uc_channel_function = channel_function; + cur->ws_info->fhss_uc_fixed_channel = fixed_channel; + cur->ws_info->fhss_uc_dwell_interval = dwell_interval; // if settings change reset_restart for the settings needed if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) { @@ -190,7 +194,10 @@ int ws_management_fhss_unicast_channel_function_configure( int ws_management_fhss_broadcast_channel_function_configure( int8_t interface_id, - uint8_t channel_function) + uint8_t channel_function, + uint8_t fixed_channel, + uint8_t dwell_interval, + uint32_t broadcast_interval) { protocol_interface_info_entry_t *cur; @@ -205,6 +212,9 @@ int ws_management_fhss_broadcast_channel_function_configure( return -2; } cur->ws_info->fhss_bc_channel_function = channel_function; + cur->ws_info->fhss_bc_fixed_channel = fixed_channel; + cur->ws_info->fhss_bc_dwell_interval = dwell_interval; + cur->ws_info->fhss_bc_interval = broadcast_interval; // if settings change reset_restart for the settings needed if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {