@@ -1869,6 +1869,44 @@ int ws_bootstrap_restart_delayed(int8_t interface_id)
1869
1869
return 0 ;
1870
1870
}
1871
1871
1872
+ 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
+ {
1874
+ rf_config -> modulation = ws_get_modulation_using_phy_mode_id (phy_mode_id );
1875
+ if (rf_config -> modulation == M_UNDEFINED ) {
1876
+ return -1 ;
1877
+ }
1878
+ protocol_interface_info_entry_t * interface = protocol_stack_interface_info_get_by_id (api -> parent_id );
1879
+ if (!interface ) {
1880
+ return -1 ;
1881
+ }
1882
+ uint8_t regulatory_domain = interface -> ws_info -> hopping_schdule .regulatory_domain ;
1883
+ uint8_t base_channel_plan_id = interface -> ws_info -> hopping_schdule .channel_plan_id ;
1884
+ 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 );
1886
+ }
1887
+ if (!base_channel_plan_id ) {
1888
+ return -1 ;
1889
+ }
1890
+ // 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 );
1892
+ if (!channel_plan_id ) {
1893
+ return -1 ;
1894
+ }
1895
+
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 );
1900
+ if (!rf_config -> channel_0_center_frequency || !rf_config -> channel_spacing || !rf_config -> number_of_channels || !rf_config -> datarate ) {
1901
+ return -1 ;
1902
+ }
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 );
1907
+ return 0 ;
1908
+ }
1909
+
1872
1910
static int ws_bootstrap_set_rf_config (protocol_interface_info_entry_t * cur , phy_rf_channel_configuration_s rf_configs )
1873
1911
{
1874
1912
mlme_set_t set_request ;
@@ -1901,6 +1939,16 @@ static int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_
1901
1939
cur -> mac_api -> mlme_req (cur -> mac_api , MLME_SET , & set_request );
1902
1940
// Start automatic CCA threshold
1903
1941
mac_helper_start_auto_cca_threshold (cur -> id , cur -> ws_info -> hopping_schdule .number_of_channels , CCA_DEFAULT_DBM , CCA_HIGH_LIMIT , CCA_LOW_LIMIT );
1942
+ // Enable MAC mode switch when base PHY mode ID could be found, otherwise disable the feature
1943
+ uint8_t phy_mode_id = cur -> ws_info -> hopping_schdule .phy_mode_id ;
1944
+ if (phy_mode_id == 255 ) {
1945
+ phy_mode_id = ws_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1946
+ }
1947
+ if (!phy_mode_id ) {
1948
+ cur -> mac_api -> mac_mode_switch_resolver_set (cur -> mac_api , NULL , phy_mode_id );
1949
+ } else {
1950
+ cur -> mac_api -> mac_mode_switch_resolver_set (cur -> mac_api , & ws_bootstrap_phy_mode_resolver , phy_mode_id );
1951
+ }
1904
1952
return 0 ;
1905
1953
}
1906
1954
@@ -1921,35 +1969,35 @@ int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t
1921
1969
return 0 ;
1922
1970
}
1923
1971
1972
+ static int ws_bootstrap_operating_mode_resolver (protocol_interface_info_entry_t * cur , phy_rf_channel_configuration_s * rf_config )
1973
+ {
1974
+ memset (rf_config , 0 , sizeof (phy_rf_channel_configuration_s ));
1975
+ rf_config -> fec = false;
1976
+ 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 );
1979
+ 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 );
1981
+ rf_config -> number_of_channels = cur -> ws_info -> hopping_schdule .number_of_channels ;
1982
+ return 0 ;
1983
+ }
1984
+
1924
1985
int ws_bootstrap_set_domain_rf_config (protocol_interface_info_entry_t * cur )
1925
1986
{
1926
- phy_rf_channel_configuration_s rf_configs ;
1927
- memset (& rf_configs , 0 , sizeof (phy_rf_channel_configuration_s ));
1987
+ phy_rf_channel_configuration_s rf_config ;
1988
+ memset (& rf_config , 0 , sizeof (phy_rf_channel_configuration_s ));
1928
1989
1929
1990
uint8_t phy_mode_id = cur -> ws_info -> hopping_schdule .phy_mode_id ;
1930
- if (((phy_mode_id >= 34 ) && (phy_mode_id <= 38 )) ||
1931
- ((phy_mode_id >= 51 ) && (phy_mode_id <= 54 )) ||
1932
- ((phy_mode_id >= 68 ) && (phy_mode_id <= 70 )) ||
1933
- ((phy_mode_id >= 84 ) && (phy_mode_id <= 86 ))) {
1934
- rf_configs .modulation = M_OFDM ;
1935
- rf_configs .datarate = ws_get_datarate_using_phy_mode_id (cur -> ws_info -> hopping_schdule .phy_mode_id );
1936
- rf_configs .ofdm_option = ws_get_ofdm_option_using_phy_mode_id (cur -> ws_info -> hopping_schdule .phy_mode_id );
1937
- rf_configs .ofdm_mcs = ws_get_ofdm_mcs_using_phy_mode_id (cur -> ws_info -> hopping_schdule .phy_mode_id );
1938
- } else {
1939
- if ((phy_mode_id >= 17 ) && (phy_mode_id <= 24 )) {
1940
- rf_configs .fec = true;
1941
- } else {
1942
- rf_configs .fec = false;
1943
- }
1944
- rf_configs .modulation = M_2FSK ;
1945
- rf_configs .datarate = ws_get_datarate_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1946
- rf_configs .modulation_index = ws_get_modulation_index_using_operating_mode (cur -> ws_info -> hopping_schdule .operating_mode );
1991
+ if (phy_mode_id == 255 ) {
1992
+ phy_mode_id = ws_convert_operating_mode_to_phy_mode_id (cur -> ws_info -> hopping_schdule .operating_mode );
1993
+ }
1994
+
1995
+ if (!phy_mode_id || ws_bootstrap_phy_mode_resolver (cur -> mac_api , phy_mode_id , & rf_config )) {
1996
+ // Cannot resolve RF configuration using PHY mode ID, try with operating mode
1997
+ ws_bootstrap_operating_mode_resolver (cur , & rf_config );
1947
1998
}
1948
1999
1949
- rf_configs .channel_0_center_frequency = (uint32_t )cur -> ws_info -> hopping_schdule .ch0_freq * 100000 ;
1950
- rf_configs .channel_spacing = ws_decode_channel_spacing (cur -> ws_info -> hopping_schdule .channel_spacing );
1951
- rf_configs .number_of_channels = cur -> ws_info -> hopping_schdule .number_of_channels ;
1952
- ws_bootstrap_set_rf_config (cur , rf_configs );
2000
+ ws_bootstrap_set_rf_config (cur , rf_config );
1953
2001
return 0 ;
1954
2002
}
1955
2003
0 commit comments