diff --git a/dmtree/tr181/os.h b/dmtree/tr181/os.h index e0998c8b35ab9f92fa70739c20d9e067e5ba6822..2099bdae6a849088127caf1c44e9f36866147e1c 100644 --- a/dmtree/tr181/os.h +++ b/dmtree/tr181/os.h @@ -106,6 +106,7 @@ int os__get_access_point_associative_device_statistics_retry_count(char *refpara int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); +int os__get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int os__get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int os__get_neighboring_wifi_diagnostics_result_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); diff --git a/dmtree/tr181/wifi-iopsyswrt.c b/dmtree/tr181/wifi-iopsyswrt.c index da476429f36c2afc0a3a34c199eeadccf0632cd3..c4cdc4d22f8a6ca2b458ee0d9d99416d241c88f9 100644 --- a/dmtree/tr181/wifi-iopsyswrt.c +++ b/dmtree/tr181/wifi-iopsyswrt.c @@ -311,6 +311,19 @@ int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char return 0; } +/*#Device.WiFi.Radio.{i}.SupportedFrequencyBands!UBUS:wifi.radio.@Name/status//supp_bands*/ +int os__get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + json_object *res = NULL; + char object[32]; + + snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec)); + dmubus_call(object, "status", UBUS_ARGS{}, 0, &res); + DM_ASSERT(res, *value = ""); + *value = dmjson_get_value_array_all(res, DELIMITOR, 1, "supp_bands"); + return 0; +} + /*#Device.WiFi.Radio.{i}.ChannelsInUse!UCI:wireless/wifi-device,@i-1/channel*/ int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { diff --git a/dmtree/tr181/wifi-openwrt.c b/dmtree/tr181/wifi-openwrt.c index e96141da1a69083c799b3557496861ddc82b58e0..501f523299bdfc842ab71d1a471fd73592cee036 100644 --- a/dmtree/tr181/wifi-openwrt.c +++ b/dmtree/tr181/wifi-openwrt.c @@ -221,6 +221,11 @@ int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char return not_implemented(value); } +int os__get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + return not_implemented(value); +} + int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index 75056aa08390b0a9a479d0f9eff1d1dcfa30ebb7..9320db0f79bb2b423a23768288cd2632d83cb3fd 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -1341,9 +1341,17 @@ static int set_WiFiAccessPointAccounting_Secret(char *refparam, struct dmctx *ct return 0; } -static int get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +static int set_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { - *value = "2.4GHz,5GHz"; + switch (action) { + case VALUECHECK: + if (dm_validate_string(value, -1, -1, SupportedFrequencyBands, 2, NULL, 0)) + return FAULT_9007; + break; + case VALUESET: + dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "hwmode", (!strcmp(value, "5GHz") ? "11a" :"11g")); + break; + } return 0; } @@ -2275,8 +2283,8 @@ DMLEAF tWiFiRadioParams[] = { {"LowerLayers", &DMWRITE, DMT_STRING, get_WiFiRadio_LowerLayers, set_WiFiRadio_LowerLayers, NULL, NULL, BBFDM_BOTH}, {"Name", &DMREAD, DMT_STRING, get_WiFiRadio_Name, NULL, NULL, NULL, BBFDM_BOTH}, {"MaxBitRate", &DMREAD, DMT_UNINT, os__get_radio_max_bit_rate, NULL, NULL, NULL, BBFDM_BOTH}, -{"OperatingFrequencyBand", &DMREAD, DMT_STRING, os__get_radio_frequency, NULL, NULL, NULL, BBFDM_BOTH}, -{"SupportedFrequencyBands", &DMREAD, DMT_STRING, get_radio_supported_frequency_bands, NULL, NULL, NULL, BBFDM_BOTH}, +{"OperatingFrequencyBand", &DMWRITE, DMT_STRING, os__get_radio_frequency, set_radio_frequency, NULL, NULL, BBFDM_BOTH}, +{"SupportedFrequencyBands", &DMREAD, DMT_STRING, os__get_radio_supported_frequency_bands, NULL, NULL, NULL, BBFDM_BOTH}, {"SupportedStandards", &DMREAD, DMT_STRING, os__get_radio_supported_standard, NULL, NULL, NULL, BBFDM_BOTH}, {"OperatingStandards", &DMWRITE, DMT_STRING, os_get_radio_operating_standard, set_radio_operating_standard, NULL, NULL, BBFDM_BOTH}, {"ChannelsInUse", &DMREAD, DMT_STRING, os__get_radio_channel, NULL, NULL, NULL, BBFDM_BOTH}, diff --git a/json/tr181.json b/json/tr181.json index 9df56279ac99839d017a25585702ad9659cb3675..783d75bc198dae91cc6b25c92d6d22dd9aa92526 100644 --- a/json/tr181.json +++ b/json/tr181.json @@ -29232,7 +29232,18 @@ "2.4GHz", "5GHz" ] - } + }, + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "wifi.radio.@Name", + "method": "status", + "args": {}, + "key": "supp_bands" + } + } + ] }, "OperatingFrequencyBand": { "type": "string", diff --git a/libbbf_api/dmcommon.c b/libbbf_api/dmcommon.c index 110b15e3733e923cabe1768b581e89fe71511b8b..fa1d1f802b8953a5f037563832fc80b1e6fd1c54 100644 --- a/libbbf_api/dmcommon.c +++ b/libbbf_api/dmcommon.c @@ -57,6 +57,7 @@ char *DTMFMethod[] = {"InBand", "RFC2833", "SIPInfo"}; char *ProfileEnable[] = {"Disabled", "Quiescent", "Enabled"}; char *SupportedOperatingChannelBandwidth[] = {"20MHz", "40MHz", "80MHz", "160MHZ", "80+80MHz", "Auto"}; char *SupportedStandards[] = {"a", "b", "g", "n", "ac", "ax"}; +char *SupportedFrequencyBands[] = {"2.4GHz", "5GHz"}; char *PIN[] = {"^\\d{4}|\\d{8}$"}; char *DestinationAddress[] = {"^\\d+/\\d+$"}; diff --git a/libbbf_api/dmcommon.h b/libbbf_api/dmcommon.h index 7633add233ba23a64fdaa3f63d23b1f67557d49b..2bb394325ec4c739982f216cc0de05d8ccf0ae4c 100644 --- a/libbbf_api/dmcommon.h +++ b/libbbf_api/dmcommon.h @@ -103,6 +103,7 @@ extern char *IPv4Prefix[]; extern char *IPv6Prefix[]; extern char *SupportedOperatingChannelBandwidth[]; extern char *SupportedStandards[]; +extern char *SupportedFrequencyBands[]; #define UPTIME "/proc/uptime" #define DEFAULT_CONFIG_DIR "/etc/config/"