WiFi: Update get/set of PreambleType param

Short preamble is handled in tr181 as radio parameter
with three possible values: long, short, auto.
Openwrt option short_preamble to store that information is
set per interface and has only two values 0,1.
Because of this difference we loose auto value.

Set PreambleType param for radio will cause setting
that value to all interfaces created on that radio.
Get PreambleType will return "short" when at least
one interface has it set to short, "long" will be returned
when all interfaces have preamble set to long.

Signed-off-by: Marek Puzyniak <marek.puzyniak@iopsys.eu>
This commit is contained in:
Marek Puzyniak 2022-07-22 11:33:28 +00:00
parent 7ca14a3fcd
commit 7ef033aece

View file

@ -1459,20 +1459,33 @@ static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
/*#Device.WiFi.Radio.{i}.PreambleType!UCI:wireless/wifi-device,@i-1/short_preamble*/
static int get_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_radio_args *)data)->sections)->config_section, "short_preamble", value);
*value = ((*value)[0] == '1') ? "short" : "long";
struct uci_section *s = NULL;
*value = "long";
uci_foreach_option_eq("wireless", "wifi-iface", "device", section_name((((struct wifi_radio_args *)data)->sections)->config_section), s) {
char *iface_short_preamble = NULL;
dmuci_get_value_by_section_string(s, "short_preamble", &iface_short_preamble);
if (iface_short_preamble && iface_short_preamble[0] == '1') {
*value = "short";
break;
}
}
return 0;
}
static int set_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *s = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, -1, PreambleType, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((((struct wifi_radio_args *)data)->sections)->config_section, "short_preamble", (DM_LSTRCMP(value, "short") == 0) ? "1" : "0");
uci_foreach_option_eq("wireless", "wifi-iface", "device", section_name((((struct wifi_radio_args *)data)->sections)->config_section), s) {
dmuci_set_value_by_section(s, "short_preamble", (DM_LSTRCMP(value, "short") == 0) ? "1" : "0");
}
break;
}
return 0;