Skip to content

Commit

Permalink
ucentral-event: add channel switch handler
Browse files Browse the repository at this point in the history
Add channel switch handler to update hapd object
with new frequency and channel info.

Fixes: WIFI-14336

Signed-off-by: Marek Kwaczynski <[email protected]>
  • Loading branch information
mkwacz authored and blogic committed Jan 6, 2025
1 parent 1cf48ae commit 7477963
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions feeds/ucentral/ucentral-event/files/ucentral-event
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -177,6 +211,10 @@ handlers = {
}
},

'channel-switch' : function(notify, hapd) {
handle_channel_switch(hapd, notify);
},

disassoc: function(notify, hapd) {
if (ratelimit) {
let msg = {
Expand Down

0 comments on commit 7477963

Please sign in to comment.