Skip to content
Snippets Groups Projects
Commit 7c093075 authored by Michael Schwarz's avatar Michael Schwarz
Browse files

First version of txpower-fix to get full txpower back

parent abff907b
No related branches found
No related tags found
No related merge requests found
include $(TOPDIR)/rules.mk
PKG_NAME:=ffho-txpower-fix
PKG_VERSION:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(GLUONDIR)/include/package.mk
define Package/ffho-txpower-fix
SECTION:=admin
CATEGORY:=Workaround
DEPENDS:=+wireless-tools
TITLE:=Fixes txpower on some wifi nodes under chaos calmer (gluon 2015.2)
endef
define Package/ffho-txpower-fix/description
With chaoscalmer, wifi nodes seemed to be locked to less txpower than they could do.
First suggestions are, that this is a mistake in the upstream OpenWrt-Code. Even the
bugtrackers of OpenWrt are full of this.
The idea of this workaround is, to check if the txpower could be increased iff it isn't
already set to a special value. Unfortunately this can only be done by setting the
country code to 00.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/ffho-txpower-fix/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,ffho-txpower-fix))
#!/usr/bin/lua
site = require("gluon.site_config")
uci = require('luci.model.uci').cursor()
--- wrapper for calling systemcommands
function cmd(_command)
local f = io.popen(_command)
local l = f:read("*a")
f:close()
return l
end
--- first of all, get 2.4GHz wifi interface
local interface24 = false
if uci:get('wireless', 'radio0', 'hwmode') then
hwmode = uci:get('wireless', 'radio0', 'hwmode')
if hwmode == '11g' then
interface24 = 'radio0'
end
end
--- try with radio1 if radio0 seems not the correct interface
if not interface24 and uci:get('wireless', 'radio1', 'hwmode') then
hwmode = uci:get('wireless', 'radio1', 'hwmode')
if hwmode == '11g' then
interface24 = 'radio1'
end
end
--- check if txpower is already set. if so, we have nothing to do
if uci:get('wireless', interface24, 'txpower') then
os.exit(0)
end
--- get corresponding wifi interface
configuredInterface = ''
interfaceList = uci:get_all('wireless')
for interface, value in pairs(interfaceList) do
if uci:get('wireless', interface, 'device') == interface24 and
uci:get('wireless', interface, 'disabled') == '0' then
configuredInterface = uci:get('wireless', interface, 'ifname')
break
end
end
if configuredInterface == '' then
exit(0) -- we didn't find an active wifi interface
end
--- get current txpower
t = cmd('iwinfo ' .. configuredInterface .. ' info | grep Tx-Power | awk \'{print $2}\'')
currentTxPower = string.gsub(t, "\n", "")
currentTxPower = tonumber(currentTxPower)
--- get maximum possible Tx-Power
t = cmd('iwinfo ' .. configuredInterface .. ' txpowerlist | tail -n 1 | sed -e \'s/\\\*//\' | awk \'{print $1}\'')
maximumTxPower = string.gsub(t, "\n", "")
maximumTxPower = tonumber(maximumTxPower)
--- if current and maximum power differs, apply workaround
if maximumTxPower > 20 then
maximumTxPower = 20 -- we are in Germany!
end
if currentTxPower < maximumTxPower then
uci:set('wireless', interface24, 'country', '00')
uci:set('wireless', interface24, 'txpower', maximumTxPower)
uci:save('wireless')
uci:commit('wireless')
cmd('wifi')
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment