gluon-geolocator: update to master package configuration
* drop bssid blacklist * only allow Master mode scanned wifis for osition request.
This commit is contained in:
parent
f6a533327a
commit
5ffb482705
@ -4,33 +4,11 @@ PKG_NAME:=gluon-geolocator
|
|||||||
PKG_VERSION:=1
|
PKG_VERSION:=1
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
|
||||||
|
|
||||||
include ../gluon.mk
|
include ../gluon.mk
|
||||||
|
|
||||||
define Package/gluon-geolocator
|
define Package/gluon-geolocator
|
||||||
SECTION:=gluon
|
|
||||||
CATEGORY:=Gluon
|
|
||||||
TITLE:=Provide the geolocator to receive positions over wifi
|
TITLE:=Provide the geolocator to receive positions over wifi
|
||||||
DEPENDS:=+gluon-node-info +micrond
|
DEPENDS:=+gluon-node-info +micrond
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
|
||||||
mkdir -p $(PKG_BUILD_DIR)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/gluon-geolocator/install
|
|
||||||
$(CP) ./files/* $(1)/
|
|
||||||
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/gluon-geolocator/postinst
|
|
||||||
#!/bin/sh
|
|
||||||
$(call GluonCheckSite,check_site.lua)
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,gluon-geolocator))
|
$(eval $(call BuildPackage,gluon-geolocator))
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
need_boolean(in_site({'geolocator', 'autolocation'}), false)
|
need_boolean(in_site({'geolocator', 'autolocation'}), false)
|
||||||
need_number(in_site({'geolocator', 'interval'}), false)
|
need_number(in_site({'geolocator', 'interval'}), false)
|
||||||
need_string_array_match(in_site({'geolocator', 'blacklist'}), '^%w+:%w+:%w+:%w+:%w+:%w+$')
|
|
||||||
|
@ -2,4 +2,3 @@ config geolocator 'settings'
|
|||||||
option static_location '0'
|
option static_location '0'
|
||||||
option auto_location '1'
|
option auto_location '1'
|
||||||
option refresh_interval '1000'
|
option refresh_interval '1000'
|
||||||
|
|
||||||
|
@ -36,15 +36,6 @@ local function exit(exc)
|
|||||||
os.exit(exc)
|
os.exit(exc)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function table_contains(tbl, prefix)
|
|
||||||
for _, entry in ipairs(tbl) do
|
|
||||||
if entry:match(prefix) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getWifiifnames()
|
local function getWifiifnames()
|
||||||
local ifnames = {}
|
local ifnames = {}
|
||||||
uci:foreach('wireless', 'wifi-iface',
|
uci:foreach('wireless', 'wifi-iface',
|
||||||
@ -61,13 +52,6 @@ end
|
|||||||
-- Get position
|
-- Get position
|
||||||
local function Get_geolocation_info()
|
local function Get_geolocation_info()
|
||||||
|
|
||||||
-- Get list of BSSID there should ignored
|
|
||||||
local blacklist_bssid = { }
|
|
||||||
for _, bl_bssid in ipairs(uci:get(GLC, "settings", "blacklist")) do
|
|
||||||
-- Ensure rm colons and uppercase
|
|
||||||
table.insert(blacklist_bssid,(string.upper(bl_bssid):gsub(":", "")))
|
|
||||||
end
|
|
||||||
|
|
||||||
local scaned_bssid = ""
|
local scaned_bssid = ""
|
||||||
local uniq = { }
|
local uniq = { }
|
||||||
for _, ifname in ipairs(getWifiifnames()) do
|
for _, ifname in ipairs(getWifiifnames()) do
|
||||||
@ -75,16 +59,19 @@ local function Get_geolocation_info()
|
|||||||
if api then
|
if api then
|
||||||
local iw = iwinfo[api]
|
local iw = iwinfo[api]
|
||||||
|
|
||||||
-- Get list of BSSID without blacklisted and redundancy entrys.
|
-- Get list of BSSID without redundancy entrys.
|
||||||
for _, net in ipairs(iw.scanlist(ifname) or { }) do
|
for _, net in ipairs(iw.scanlist(ifname) or { }) do
|
||||||
|
--only alowe Master mode driven wifis
|
||||||
|
if net.mode:match("Master") then
|
||||||
-- Ensure rm colons and uppercase
|
-- Ensure rm colons and uppercase
|
||||||
net.bssid = string.upper(net.bssid:gsub(":", ""))
|
net.bssid = string.upper(net.bssid:gsub(":", ""))
|
||||||
if not uniq[net.bssid] and not table_contains(blacklist_bssid, net.bssid) then
|
if not uniq[net.bssid] then
|
||||||
scaned_bssid = scaned_bssid .. "," .. net.bssid
|
scaned_bssid = scaned_bssid .. "," .. net.bssid
|
||||||
uniq[net.bssid] = true
|
uniq[net.bssid] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #scaned_bssid < 12 then
|
end
|
||||||
|
if #scaned_bssid < 12 then -- because one BSSID contains 12 characters
|
||||||
io.stdout:write("No surrounded BSSIDs found.\n")
|
io.stdout:write("No surrounded BSSIDs found.\n")
|
||||||
return { }
|
return { }
|
||||||
end
|
end
|
||||||
|
@ -22,6 +22,5 @@ uci:section(config, config, 'settings', {
|
|||||||
static_location = static_location,
|
static_location = static_location,
|
||||||
refresh_interval = refresh_interval,
|
refresh_interval = refresh_interval,
|
||||||
auto_location = auto_location,
|
auto_location = auto_location,
|
||||||
blacklist = site.geolocator.blacklist({}),
|
|
||||||
})
|
})
|
||||||
uci:save(config)
|
uci:save(config)
|
||||||
|
Loading…
Reference in New Issue
Block a user