65
65
#include "6LoWPAN/ws/ws_bootstrap_6lbr.h"
66
66
#include "6LoWPAN/ws/ws_bootstrap_ffn.h"
67
67
#include "6LoWPAN/ws/ws_bootstrap_lfn.h"
68
+ #include "6LoWPAN/ws/ws_phy.h"
68
69
#include "6LoWPAN/lowpan_adaptation_interface.h"
69
70
#include "Service_Libs/etx/etx.h"
70
71
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
@@ -582,8 +583,8 @@ static uint8_t ws_generate_exluded_channel_list_from_active_channels(ws_excluded
582
583
void ws_fhss_configure_channel_masks (protocol_interface_info_entry_t * cur , fhss_ws_configuration_t * fhss_configuration )
583
584
{
584
585
fhss_configuration -> channel_mask_size = cur -> ws_info -> hopping_schdule .number_of_channels ;
585
- 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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
586
- 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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
586
+ ws_common_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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
587
+ ws_common_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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
587
588
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
588
589
for (uint8_t n = 0 ; n < 8 ; n ++ ) {
589
590
fhss_configuration -> unicast_channel_mask [n ] &= cur -> ws_info -> cfg -> fhss .fhss_channel_mask [n ];
@@ -600,12 +601,7 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
600
601
if (!fhss_api ) {
601
602
// When FHSS doesn't exist yet, create one
602
603
ws_fhss_configure_channel_masks (cur , & fhss_configuration );
603
-
604
- fhss_configuration .fhss_uc_dwell_interval = cur -> ws_info -> cfg -> fhss .fhss_uc_dwell_interval ;
605
- fhss_configuration .ws_uc_channel_function = (fhss_ws_channel_functions )cur -> ws_info -> cfg -> fhss .fhss_uc_channel_function ;
606
- fhss_configuration .ws_bc_channel_function = (fhss_ws_channel_functions )cur -> ws_info -> cfg -> fhss .fhss_bc_channel_function ;
607
- fhss_configuration .fhss_bc_dwell_interval = cur -> ws_info -> cfg -> fhss .fhss_bc_dwell_interval ;
608
- fhss_configuration .fhss_broadcast_interval = cur -> ws_info -> cfg -> fhss .fhss_bc_interval ;
604
+ ws_fhss_set_defaults (cur , & fhss_configuration );
609
605
fhss_api = ns_fhss_ws_create (& fhss_configuration , cur -> ws_info -> fhss_timer_ptr );
610
606
611
607
if (!fhss_api ) {
@@ -615,26 +611,7 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
615
611
// Allow transmitting unicast frames only on TX slots in normal and expedited forwarding mode
616
612
ns_fhss_ws_set_tx_allowance_level (fhss_api , WS_TX_SLOT , WS_TX_SLOT );
617
613
} else {
618
- // Read defaults from the configuration to help FHSS testing
619
- const fhss_ws_configuration_t * fhss_configuration_copy = ns_fhss_ws_configuration_get (fhss_api );
620
- if (!fhss_configuration_copy ) {
621
- // no configuration set yet
622
- return 0 ;
623
- }
624
- fhss_configuration = * fhss_configuration_copy ;
625
- //Overwrite domain channel setup this will over write a default 35 channel
626
- int num_of_channels = channel_list_count_channels (fhss_configuration_copy -> unicast_channel_mask );
627
- cur -> ws_info -> hopping_schdule .number_of_channels = (uint8_t ) num_of_channels ;
628
- memcpy (cur -> ws_info -> cfg -> fhss .fhss_channel_mask , fhss_configuration_copy -> unicast_channel_mask , sizeof (uint32_t ) * 8 );
629
- cur -> ws_info -> cfg -> fhss .fhss_uc_channel_function = fhss_configuration_copy -> ws_uc_channel_function ;
630
- cur -> ws_info -> cfg -> fhss .fhss_bc_channel_function = fhss_configuration_copy -> ws_bc_channel_function ;
631
- cur -> ws_info -> cfg -> fhss .fhss_bc_dwell_interval = fhss_configuration_copy -> fhss_bc_dwell_interval ;
632
- cur -> ws_info -> cfg -> fhss .fhss_bc_interval = fhss_configuration_copy -> fhss_broadcast_interval ;
633
- cur -> ws_info -> cfg -> fhss .fhss_uc_dwell_interval = fhss_configuration_copy -> fhss_uc_dwell_interval ;
634
- cur -> ws_info -> cfg -> fhss .fhss_bc_fixed_channel = fhss_configuration_copy -> broadcast_fixed_channel ;
635
- cur -> ws_info -> cfg -> fhss .fhss_uc_fixed_channel = fhss_configuration_copy -> unicast_fixed_channel ;
636
- ws_fhss_configure_channel_masks (cur , & fhss_configuration );
637
- ns_fhss_ws_configuration_set (fhss_api , & fhss_configuration );
614
+ return -1 ;
638
615
}
639
616
640
617
return 0 ;
@@ -677,14 +654,10 @@ uint16_t ws_randomize_fixed_channel(uint16_t configured_fixed_channel, uint8_t n
677
654
int8_t ws_fhss_configure (protocol_interface_info_entry_t * cur , bool discovery )
678
655
{
679
656
// Read configuration of existing FHSS and start using the default values for any network
680
- fhss_ws_configuration_t fhss_configuration ;
681
- memset (& fhss_configuration , 0 , sizeof (fhss_ws_configuration_t ));
657
+ fhss_ws_configuration_t fhss_configuration = ws_common_get_current_fhss_configuration (cur );
658
+ ws_fhss_set_defaults (cur , & fhss_configuration );
659
+ ws_fhss_configure_channel_masks (cur , & fhss_configuration );
682
660
683
- if (ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api )) {
684
- memcpy (& fhss_configuration , ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api ), sizeof (fhss_ws_configuration_t ));
685
- ws_fhss_set_defaults (cur , & fhss_configuration );
686
- ws_fhss_configure_channel_masks (cur , & fhss_configuration );
687
- }
688
661
// Discovery is done using fixed channel
689
662
if (discovery ) {
690
663
fhss_configuration .ws_uc_channel_function = WS_FIXED_CHANNEL ;
@@ -706,13 +679,10 @@ int8_t ws_fhss_configure(protocol_interface_info_entry_t *cur, bool discovery)
706
679
707
680
static int8_t ws_fhss_enable (protocol_interface_info_entry_t * cur )
708
681
{
709
- const fhss_ws_configuration_t * fhss_configuration = ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api );
682
+ fhss_ws_configuration_t fhss_configuration = ws_common_get_current_fhss_configuration (cur );
710
683
711
- if (!cur -> ws_info -> fhss_api || !fhss_configuration ) {
712
- return -1 ;
713
- }
714
684
// Set the LLC information to follow the actual fhss settings
715
- ws_bootstrap_llc_hopping_update (cur , fhss_configuration );
685
+ ws_bootstrap_llc_hopping_update (cur , & fhss_configuration );
716
686
717
687
// Set neighbor info callback
718
688
if (ns_fhss_set_neighbor_info_fp (cur -> ws_info -> fhss_api , & ws_get_neighbor_info )) {
@@ -729,14 +699,12 @@ static int8_t ws_fhss_enable(protocol_interface_info_entry_t *cur)
729
699
*/
730
700
void ws_bootstrap_primary_parent_set (struct protocol_interface_info_entry * cur , llc_neighbour_req_t * neighbor_info , ws_parent_synch_e synch_req )
731
701
{
732
-
733
- fhss_ws_configuration_t fhss_configuration ;
734
702
if (!neighbor_info -> ws_neighbor -> broadcast_timing_info_stored ) {
735
703
tr_error ("No BC timing info for set new parent" );
736
704
return ;
737
705
}
738
706
739
- memcpy ( & fhss_configuration , ns_fhss_ws_configuration_get ( cur -> ws_info -> fhss_api ), sizeof ( fhss_ws_configuration_t ) );
707
+ fhss_ws_configuration_t fhss_configuration = ws_common_get_current_fhss_configuration ( cur );
740
708
741
709
// Learning broadcast network configuration
742
710
if (neighbor_info -> ws_neighbor -> broadcast_shedule_info_stored ) {
@@ -1871,7 +1839,7 @@ int ws_bootstrap_restart_delayed(int8_t interface_id)
1871
1839
1872
1840
static int8_t ws_bootstrap_phy_mode_resolver (const mac_api_t * api , uint8_t phy_mode_id , phy_rf_channel_configuration_s * rf_config )
1873
1841
{
1874
- rf_config -> modulation = ws_get_modulation_using_phy_mode_id (phy_mode_id );
1842
+ rf_config -> modulation = ws_phy_get_modulation_using_phy_mode_id (phy_mode_id );
1875
1843
if (rf_config -> modulation == M_UNDEFINED ) {
1876
1844
return -1 ;
1877
1845
}
@@ -1882,28 +1850,28 @@ static int8_t ws_bootstrap_phy_mode_resolver(const mac_api_t *api, uint8_t phy_m
1882
1850
uint8_t regulatory_domain = interface -> ws_info -> hopping_schdule .regulatory_domain ;
1883
1851
uint8_t base_channel_plan_id = interface -> ws_info -> hopping_schdule .channel_plan_id ;
1884
1852
if (base_channel_plan_id == 255 ) {
1885
- base_channel_plan_id = ws_convert_operating_class_to_channel_plan_id (interface -> ws_info -> hopping_schdule .operating_class , regulatory_domain );
1853
+ base_channel_plan_id = ws_phy_convert_operating_class_to_channel_plan_id (interface -> ws_info -> hopping_schdule .operating_class , regulatory_domain );
1886
1854
}
1887
1855
if (!base_channel_plan_id ) {
1888
1856
return -1 ;
1889
1857
}
1890
1858
// Function returns base channel plan ID, if it matches the PHY mode ID. Otherwise, nearest matching channel plan ID where PHY mode ID is allowed will be returned.
1891
- uint8_t channel_plan_id = ws_get_channel_plan_id_using_phy_mode_id (phy_mode_id , regulatory_domain , base_channel_plan_id );
1859
+ uint8_t channel_plan_id = ws_phy_get_channel_plan_id_using_phy_mode_id (phy_mode_id , regulatory_domain , base_channel_plan_id );
1892
1860
if (!channel_plan_id ) {
1893
1861
return -1 ;
1894
1862
}
1895
1863
1896
- rf_config -> channel_0_center_frequency = ws_get_channel_0_frequency_using_channel_plan_id (channel_plan_id );
1897
- rf_config -> channel_spacing = ws_get_channel_spacing_using_channel_plan_id (channel_plan_id );
1898
- rf_config -> number_of_channels = ws_get_number_of_channels_using_channel_plan_id (channel_plan_id );
1899
- rf_config -> datarate = ws_get_datarate_using_phy_mode_id (phy_mode_id );
1864
+ rf_config -> channel_0_center_frequency = ws_phy_get_channel_0_frequency_using_channel_plan_id (channel_plan_id );
1865
+ rf_config -> channel_spacing = ws_phy_get_channel_spacing_using_channel_plan_id (channel_plan_id );
1866
+ rf_config -> number_of_channels = ws_phy_get_number_of_channels_using_channel_plan_id (channel_plan_id );
1867
+ rf_config -> datarate = ws_phy_get_datarate_using_phy_mode_id (phy_mode_id );
1900
1868
if (!rf_config -> channel_0_center_frequency || !rf_config -> channel_spacing || !rf_config -> number_of_channels || !rf_config -> datarate ) {
1901
1869
return -1 ;
1902
1870
}
1903
- rf_config -> ofdm_option = ws_get_ofdm_option_using_phy_mode_id (phy_mode_id );
1904
- rf_config -> ofdm_mcs = ws_get_ofdm_mcs_using_phy_mode_id (phy_mode_id );
1905
- rf_config -> fec = ws_get_fsk_fec_enabled_using_phy_mode_id (phy_mode_id );
1906
- rf_config -> modulation_index = ws_get_modulation_index_using_phy_mode_id (phy_mode_id );
1871
+ rf_config -> ofdm_option = ws_phy_get_ofdm_option_using_phy_mode_id (phy_mode_id );
1872
+ rf_config -> ofdm_mcs = ws_phy_get_ofdm_mcs_using_phy_mode_id (phy_mode_id );
1873
+ rf_config -> fec = ws_phy_get_fsk_fec_enabled_using_phy_mode_id (phy_mode_id );
1874
+ rf_config -> modulation_index = ws_phy_get_modulation_index_using_phy_mode_id (phy_mode_id );
1907
1875
return 0 ;
1908
1876
}
1909
1877
@@ -1942,7 +1910,7 @@ static int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_
1942
1910
// Enable MAC mode switch when base PHY mode ID could be found, otherwise disable the feature
1943
1911
uint8_t phy_mode_id = cur -> ws_info -> hopping_schdule .phy_mode_id ;
1944
1912
if (phy_mode_id == 255 ) {
1945
- phy_mode_id = ws_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1913
+ phy_mode_id = ws_phy_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1946
1914
}
1947
1915
if (!phy_mode_id ) {
1948
1916
cur -> mac_api -> mac_mode_switch_resolver_set (cur -> mac_api , NULL , phy_mode_id );
@@ -1974,10 +1942,10 @@ static int ws_bootstrap_operating_mode_resolver(protocol_interface_info_entry_t
1974
1942
memset (rf_config , 0 , sizeof (phy_rf_channel_configuration_s ));
1975
1943
rf_config -> fec = false;
1976
1944
rf_config -> modulation = M_2FSK ;
1977
- rf_config -> datarate = ws_get_datarate_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1978
- rf_config -> modulation_index = ws_get_modulation_index_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1945
+ rf_config -> datarate = ws_phy_get_datarate_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1946
+ rf_config -> modulation_index = ws_phy_get_modulation_index_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1979
1947
rf_config -> channel_0_center_frequency = (uint32_t )cur -> ws_info -> hopping_schdule .ch0_freq * 100000 ;
1980
- rf_config -> channel_spacing = ws_decode_channel_spacing (cur -> ws_info -> hopping_schdule .channel_spacing );
1948
+ rf_config -> channel_spacing = ws_phy_decode_channel_spacing (cur -> ws_info -> hopping_schdule .channel_spacing );
1981
1949
rf_config -> number_of_channels = cur -> ws_info -> hopping_schdule .number_of_channels ;
1982
1950
return 0 ;
1983
1951
}
@@ -1989,7 +1957,7 @@ int ws_bootstrap_set_domain_rf_config(protocol_interface_info_entry_t *cur)
1989
1957
1990
1958
uint8_t phy_mode_id = cur -> ws_info -> hopping_schdule .phy_mode_id ;
1991
1959
if (phy_mode_id == 255 ) {
1992
- phy_mode_id = ws_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1960
+ phy_mode_id = ws_phy_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1993
1961
}
1994
1962
1995
1963
if (!phy_mode_id || ws_bootstrap_phy_mode_resolver (cur -> mac_api , phy_mode_id , & rf_config )) {
@@ -2963,7 +2931,7 @@ static void ws_set_asynch_channel_list(protocol_interface_info_entry_t *cur, asy
2963
2931
uint16_t channel_number = cur -> ws_info -> cfg -> fhss .fhss_uc_fixed_channel ;
2964
2932
async_req -> channel_list .channel_mask [channel_number / 32 ] = 1U << (channel_number % 32 );
2965
2933
} else {
2966
- 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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
2934
+ ws_common_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 , cur -> ws_info -> hopping_schdule .channel_plan_id );
2967
2935
}
2968
2936
2969
2937
async_req -> channel_list .channel_page = CHANNEL_PAGE_10 ;
0 commit comments