AP Roaming with OpenWrt finally became easier!

Hi everyone,
I found this script:
https://github.com/barbieri/barbieri-playground/tree/master/openwrt/wifi-disconnect-low-signal
Made by barbieri.

I edited the script that way:

function Device:disconnect_sta(sta)
   local endpoint = "hostapd." .. self.ifname
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                abridged = 1,
   })
   inf("%s: disconnected %s", self.ifname, tostring(sta))
end

And its working flawlessly with my OnePlus 9 Pro.
But,
with Redmi Note 7 for example, must add "neighbors" to the bss_transition_request .
if someone can make a code in lua to extract the

ubus call hostapd.wlan0 rrm_nr_list

and add it as array to the code, we could make PERFECT roaming solution for the openWRT community!

I dont know how to programming with lua, but it seems it should be an easy code..

Should be something like:

function Device:disconnect_sta(sta)
   local endpoint = "hostapd." .. self.ifname
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                validity_period = 30,
                abridged = 1,
                neighbors = 'Array',
   })
   inf("%s: disconnected %s", self.ifname, tostring(sta))
end

Update-
added manually neighbors list from:

ubus call hostapd.wlan rrm_nr_get_own

Not tested yet, anyone can tell if the syntax is correct?

function Device:disconnect_sta(sta)
if self.ifname == "wlan0" then
   local endpoint = "hostapd." .. self.ifname
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                neighbors = "[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]",
                abridged = 1,
   })
elseif self.ifname == "wlan1" then
   local endpoint = "hostapd." .. self.ifname
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                neighbors = "[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]",
                abridged = 1,
   })
end
   inf("%s: disconnected %s", self.ifname, tostring(sta))
end

Update-
Finally succeded, should have sent the neighbors parameter as array that way.

function Device:disconnect_sta(sta)

local two_arr = {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
local five_arr = {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}

local endpoint = "hostapd." .. self.ifname

if self.ifname == "wlan0" then
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                validity_period = 30,
                neighbors = two_arr,
                abridged = 1,
   })

elseif self.ifname == "wlan1" then
   conn:call(endpoint, "bss_transition_request", {
                addr = sta.addr,
                disassociation_imminent = false,
                disassociation_timer = 0,
                validity_period = 30,
                neighbors = five_arr,
                abridged = 1,
   })
end

   inf("%s: disconnected %s", self.ifname, tostring(sta))
end
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.