Skip to content

Commit

Permalink
ap_up: fix wait for hostapd
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrk committed Dec 26, 2024
1 parent 942c769 commit 0a580b9
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/lime-system/files/usr/bin/limed
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--! SPDX-License-Identifier: AGPL-3.0-only

local config = require("lime.config")
local utils = require("lime.utils")

local limed = {};

Expand Down Expand Up @@ -62,7 +63,7 @@ local peerSubscriber = {
notify = function(nData, nType)
if nType ~= "apup-newpeer" then return end

print("peerSubscriber:", nType, nData.ifname)
utils.log("peerSubscriber:", nType, nData.ifname)
network.createStatic(nData.ifname)
network.runProtocols(nData.ifname)
end
Expand All @@ -77,11 +78,29 @@ local apupSubscriber = {

local evPath = "hostapd." .. apupDev

print("Subscribing:", evPath)
utils.log("Subscribing:", evPath)
ubus:subscribe(evPath, peerSubscriber)
end
}

function limed.waitForHostapd()
local found = false
while not found do
local namespaces = ubus:objects()
for _, namespace in ipairs(namespaces) do
if namespace == "hostapd" then
found = true
break
end
end
if not found then
utils.log("Waiting for 'hostapd' namespace...")
os.execute("sleep 1") -- Wait for 1 second before retrying
else
utils.log(" 'hostapd' namespace exists...")
end
end
end
limed.waitForHostapd()
uloop.init();
ubus:subscribe("hostapd", apupSubscriber)
uloop.run();

0 comments on commit 0a580b9

Please sign in to comment.