mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 01:22:25 +00:00
ucentral-event: add channel switch handler
Add channel switch handler to update hapd object with new frequency and channel info. Fixes: WIFI-14336 Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
This commit is contained in:
committed by
John Crispin
parent
1cf48ae6d9
commit
7477963b1f
@@ -119,6 +119,40 @@ function event(object, verb, payload) {
|
||||
});
|
||||
}
|
||||
|
||||
function freq2chan(freq) {
|
||||
if (freq == 2484)
|
||||
return 14;
|
||||
else if (freq < 2484)
|
||||
return (freq - 2407) / 5;
|
||||
else if (freq >= 4910 && freq <= 4980)
|
||||
return (freq - 4000) / 5;
|
||||
else if(freq >= 56160 + 2160 * 1 && freq <= 56160 + 2160 * 6)
|
||||
return (freq - 56160) / 2160;
|
||||
else if (freq == 5935)
|
||||
return (freq - 5925) / 5;
|
||||
else if (freq > 5950 && freq <= 7115)
|
||||
return (freq - 5950) / 5;
|
||||
else if (freq >= 5000 && freq < 5900)
|
||||
return (freq - 5000) / 5;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* notify data expected format:
|
||||
* { "ifname": "wlan1", "freq": 5180, "bssid": "XX:XX:XX:XX:XX:XX"
|
||||
*/
|
||||
function handle_channel_switch(hapd, notify) {
|
||||
if (!notify && !notify?.data && !notify.data?.freq)
|
||||
return;
|
||||
|
||||
let ch = freq2chan(notify.data.freq);
|
||||
if (ch < 0)
|
||||
return;
|
||||
|
||||
hapd.freq = notify.data.freq;
|
||||
hapd.channel = ch;
|
||||
}
|
||||
|
||||
let handlers;
|
||||
handlers = {
|
||||
'sta-authorized': function(notify, hapd) {
|
||||
@@ -177,6 +211,10 @@ handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
'channel-switch' : function(notify, hapd) {
|
||||
handle_channel_switch(hapd, notify);
|
||||
},
|
||||
|
||||
disassoc: function(notify, hapd) {
|
||||
if (ratelimit) {
|
||||
let msg = {
|
||||
|
||||
Reference in New Issue
Block a user