mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
wifi: Get possible channels from channels method
This commit is contained in:
parent
379f492041
commit
0826d70838
5 changed files with 60 additions and 13 deletions
|
|
@ -1299,22 +1299,18 @@ static int set_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, voi
|
|||
/*#Device.WiFi.Radio.{i}.PossibleChannels!UBUS:wifi.radio.@Name/status//supp_channels[0].channels*/
|
||||
static int get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res = NULL, *supp_channels = NULL, *arrobj = NULL;
|
||||
char object[UBUS_OBJ_LEN], *cur_opclass = NULL;
|
||||
int i = 0;
|
||||
json_object *res = NULL;
|
||||
char object[UBUS_OBJ_LEN], *bandwidth = NULL;
|
||||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name((((struct wifi_radio_args *)data)->sections)->config_section));
|
||||
dmubus_call(object, "status", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
cur_opclass = dmjson_get_value(res, 1, "opclass");
|
||||
dmjson_foreach_obj_in_array(res, arrobj, supp_channels, i, 1, "supp_channels") {
|
||||
char *opclass = dmjson_get_value(supp_channels, 1, "opclass");
|
||||
if (DM_STRCMP(opclass, cur_opclass) != 0)
|
||||
continue;
|
||||
|
||||
*value = dmjson_get_value_array_all(supp_channels, ",", 1, "channels");
|
||||
break;
|
||||
}
|
||||
bandwidth = dmjson_get_value(res, 1, "bandwidth");
|
||||
dmubus_call(object, "channels", UBUS_ARGS{{"bandwidth", bandwidth, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
|
||||
*value = dmjson_get_value_array_all(res, ",", 1, "channels");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
28
test/files/tmp/wifi.radio.test1.channels.data
Normal file
28
test/files/tmp/wifi.radio.test1.channels.data
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"channels": [
|
||||
36,
|
||||
40,
|
||||
44,
|
||||
48,
|
||||
52,
|
||||
56,
|
||||
60,
|
||||
64,
|
||||
100,
|
||||
104,
|
||||
108,
|
||||
112,
|
||||
116,
|
||||
120,
|
||||
124,
|
||||
128,
|
||||
132,
|
||||
136,
|
||||
140,
|
||||
144,
|
||||
149,
|
||||
153,
|
||||
157,
|
||||
161
|
||||
]
|
||||
}
|
||||
17
test/files/tmp/wifi.radio.test2.channels.data
Normal file
17
test/files/tmp/wifi.radio.test2.channels.data
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"channels": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13
|
||||
]
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
case "$1" in
|
||||
list)
|
||||
echo '{ "status" : {}, "stats": {}, "scanresults": {} }'
|
||||
echo '{ "status" : {}, "stats": {}, "scanresults": {} , "channels": {}}'
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
|
|
@ -17,6 +17,9 @@ case "$1" in
|
|||
scanresults)
|
||||
cat /tmp/wifi.radio.test1.scanresults.data 2>/dev/null
|
||||
;;
|
||||
channels)
|
||||
cat /tmp/wifi.radio.test1.channels.data 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
case "$1" in
|
||||
list)
|
||||
echo '{ "status" : {}, "stats": {}, "scanresults": {} }'
|
||||
echo '{ "status" : {}, "stats": {}, "scanresults": {} , "channels": {}}'
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
|
|
@ -17,6 +17,9 @@ case "$1" in
|
|||
scanresults)
|
||||
cat /tmp/wifi.radio.test2.scanresults.data 2>/dev/null
|
||||
;;
|
||||
channels)
|
||||
cat /tmp/wifi.radio.test2.channels.data 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue