Skip to content

Commit

Permalink
Add WiFi mode "apname":
Browse files Browse the repository at this point in the history
Adds the possibility of having a second AP interface per device with
another SSID (Hostname by default). So user can choose between WiFi
roaming or WiFi static by choosing the right SSID.

Signed-off-by: Pau Escrich <p4u@dabax.net>
  • Loading branch information
p4u committed Aug 6, 2016
1 parent 0969991 commit a17e617
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/lime-system/files/etc/config/lime-defaults
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ config lime wifi
option channel_2ghz '11'
option channel_5ghz '157'
list modes 'ap'
list modes 'apname'
list modes 'adhoc'
option ap_ssid 'Libre-Mesh.org'
option apname_ssid '%H'
option adhoc_ssid '%H'
option adhoc_bssid 'ca:fe:00:c0:ff:ee'
option adhoc_mcast_rate_2ghz '24000'
Expand Down
2 changes: 2 additions & 0 deletions packages/lime-system/files/etc/config/lime.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ config lime wifi
# option htmode_2ghz 'HT20'
# option htmode_5ghz 'HT40'
# list modes 'ap'
# list modes 'apname'
# list modes 'adhoc'
option ap_ssid 'libre-mesh.org'
option apname_ssid '%H'
# option adhoc_ssid '%H' # Parametrizable with %M, %H
# option adhoc_bssid 'ca:fe:00:c0:ff:ee'
# option adhoc_mcast_rate_2ghz '24000'
Expand Down
2 changes: 1 addition & 1 deletion packages/lime-system/files/usr/lib/lua/lime/mode/adhoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ adhoc.wifi_mode="adhoc"
function adhoc.setup_radio(radio, args)
--! checks("table", "?table")

return wireless.createBaseWirelessIface(radio, adhoc.wifi_mode, nil)
return wireless.createBaseWirelessIface(radio, adhoc.wifi_mode, nil, nil)
end

return adhoc
2 changes: 1 addition & 1 deletion packages/lime-system/files/usr/lib/lua/lime/mode/ap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ap.wifi_mode="ap"
function ap.setup_radio(radio, args)
--! checks("table", "?table")

return wireless.createBaseWirelessIface(radio, ap.wifi_mode, { network = "lan" })
return wireless.createBaseWirelessIface(radio, ap.wifi_mode, nil, { network = "lan" })
end

return ap
13 changes: 13 additions & 0 deletions packages/lime-system/files/usr/lib/lua/lime/mode/apname.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/lua

local ap = {}

ap.wifi_mode="ap"

function ap.setup_radio(radio, args)
--! checks("table", "?table")

return wireless.createBaseWirelessIface(radio, ap.wifi_mode, "name", { network = "lan" })
end

return ap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ieee80211s.wifi_mode="mesh"
function ieee80211s.setup_radio(radio, args)
--! checks("table", "?table")

return wireless.createBaseWirelessIface(radio, ieee80211s.wifi_mode, nil)
return wireless.createBaseWirelessIface(radio, ieee80211s.wifi_mode, nil, nil)
end

return ieee80211s
10 changes: 5 additions & 5 deletions packages/lime-system/files/usr/lib/lua/lime/wireless.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ function wireless.is5Ghz(radio)
return false
end

wireless.availableModes = { adhoc=true, ap=true }
wireless.availableModes = { adhoc=true, ap=true, apname=true }
function wireless.isMode(m)
return wireless.availableModes[m]
end

function wireless.createBaseWirelessIface(radio, mode, extras)
--! checks("table", "string", "?table")
function wireless.createBaseWirelessIface(radio, mode, nameSuffix, extras)
--! checks("table", "string", "?string", "?table")
--! checks(...) come from http://lua-users.org/wiki/LuaTypeChecking -> https://github.com/fab13n/checks

nameSuffix = nameSuffix or ""
local radioName = radio[".name"]
local phyIndex = radioName:match("%d+")
local ifname = "wlan"..phyIndex..wireless.wifiModeSeparator..mode
local ifname = "wlan"..phyIndex..wireless.wifiModeSeparator..mode..nameSuffix
--! sanitize generated ifname for constructing uci section name
--! because only alphanumeric and underscores are allowed
local wirelessInterfaceName = wireless.limeIfNamePrefix..ifname:gsub("[^%w_]", "_").."_"..radioName
Expand Down

0 comments on commit a17e617

Please sign in to comment.