-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change directory structure (not verified yet) - arn/ - arn/device/ - arn/device/mngr.lua - arn/device/uhf.lua - arn/device/hal/ - arn/device/hal/hal_raw.lua - arn/utils/ - arn/utils/cache.lua - arn/utils/ccff.lua - arn/utils/debug.lua - arn/utils/rarp.lua - arn/utils/serialize.lua * Update ARN-Mngr * Upgrade for "ARN OMC Agent", add function ccff.file.exists() * Try Makefile * 2017.10.19 Continue ARN-Scripts (v2.0) - Add "radio query lock"; - Handle "dead-lock"; - Add "banner"; - No error on GWS5Kv2, need more tests. * Co-work with ARN-Proto (+arn-agent-omc) * Import "JSON.Encode()" * Assign default region value, and check its type before compare * "rarp": return ip only; let cache valid in next hour
- Loading branch information
Showing
20 changed files
with
432 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 6Harmonics Inc | ||
# maintainer: Qige Zhao <[email protected]> | ||
# updated on: 2017.10.19 | ||
|
||
all: | ||
|
||
clean: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
-- Provide unified commands | ||
-- by Qige <[email protected]> | ||
|
||
local gws_hal = require 'arn.hal_raw' | ||
local gws_hal = require 'arn.device.hal.hal_raw' | ||
local sfmt = string.format | ||
|
||
local arg_key = tostring(arg[1]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,28 @@ Tasks: | |
2. read limits from "/etc/config/arn-spec" | ||
3. finally, set via "arn.hal_raw" | ||
4. "arn.mngr" provide CACHE | ||
5. "qutil.rarp" provide RARP | ||
5. "qutil.rarp" provide RARP (+rarp-client +rarp-server) | ||
Maintainer: | ||
by Qige <[email protected]> | ||
2017.08.18|2017.08.22 | ||
2017.08.18|2017.08.22 v1.0 | ||
2017.08.29 v1.1 | ||
2017.10.19 v2.0 continue ARN-Scripts; plan to add ARN-iOMC3-Agent | ||
]]-- | ||
|
||
--local DBG = print | ||
local function DBG(msg) end | ||
|
||
local mngr = require 'arn.mngr' | ||
local rarp = require 'qutil.rarp' | ||
local ccff = require 'qutil.ccff' | ||
local mngr = require 'arn.device.mngr' | ||
local rarp = require 'arn.utils.rarp' | ||
local ccff = require 'arn.utils.ccff' | ||
local is_array = ccff.val.is_array | ||
local sfmt = string.format | ||
local ssub = string.sub | ||
local slen = string.len | ||
local exec = ccff.execute | ||
|
||
local VERSION = 'ARN-Scripts (+HAL +Cache +5K/+4K) v2017.08.18 ' | ||
local VERSION = 'ARN-Scripts (+HAL +Cache +5Kv2) v2.0-191017Q' | ||
|
||
local arg_key = tostring(arg[1]) -- nil > 'nil' | ||
local arg_val = tostring(arg[2]) -- nil > 'nil' | ||
|
@@ -121,9 +123,22 @@ local function format_radio(key, obj) | |
return result .. '\n' | ||
end | ||
|
||
local function format_thrpt(val) | ||
local thrpt = '0.00 Kbps' | ||
if (val) then | ||
local bps = tonumber(val) | ||
if (bps > 1024 * 1024) then | ||
thrpt = sfmt("%.2f Mbps", (bps / 1024 / 1024)) | ||
else | ||
thrpt = sfmt("%.2f Kbps", (bps / 1024)) | ||
end | ||
end | ||
return thrpt | ||
end | ||
|
||
local function format_nw(key, obj) | ||
local result = sfmt(' thrpt: Rx %s, Tx %s ("arn -m" ONLY, not accurate)', | ||
obj.rx or '0.00 Kbps', obj.tx or '0.00 Kbps') | ||
format_thrpt(obj.rx), format_thrpt(obj.tx)) | ||
return result | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
================= FAILSAFE MODE active =================== | ||
Thank you for choosing | ||
__ _ _ _ | ||
/ /_ | | | | __ _ _ __ _ __ ___ ___ _ __ (_) ___ ___ | ||
| '_ \| |_| |/ _` | '__| '_ ` _ \ / _ \| '_ \| |/ __/ __| | ||
| (_) | _ | (_| | | | | | | | | (_) | | | | | (__\__ \ | ||
\___/|_| |_|\__,_|_| |_| |_| |_|\___/|_| |_|_|\___|___/ | ||
|
||
--------------------------------------------------------- | ||
ARN Beijing Firmware | ||
--------------------------------------------------------- | ||
* Kernel Dawen Zhang, Yaoyang Wang | ||
* Application Yu Zhou, Qige Zhao | ||
--------------------------------------------------------- | ||
========================================================== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Thank you for choosing | ||
__ _ _ _ | ||
/ /_ | | | | __ _ _ __ _ __ ___ ___ _ __ (_) ___ ___ | ||
| '_ \| |_| |/ _` | '__| '_ ` _ \ / _ \| '_ \| |/ __/ __| | ||
| (_) | _ | (_| | | | | | | | | (_) | | | | | (__\__ \ | ||
\___/|_| |_|\__,_|_| |_| |_| |_|\___/|_| |_|_|\___|___/ | ||
|
||
--------------------------------------------------------- | ||
ARN Beijing Firmware | ||
--------------------------------------------------------- | ||
* Kernel Dawen Zhang, Yaoyang Wang | ||
* Application Yu Zhou, Qige Zhao | ||
--------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
--[[ | ||
Note: | ||
Although GWS4K share the same methods and functions, | ||
Although GWS3K share the same methods and functions, | ||
this copy will let maintainer handle 2 types of hardware. | ||
by Qige <[email protected]> | ||
2017.08.16 update_rt | ||
2017.08.16 update_rt, copied from gws_4k.lua | ||
2017.10.19 dismiss error, function and data not verified | ||
]]-- | ||
|
||
local DBG = print | ||
--local function DBG(msg) end | ||
|
||
local ccff = require 'qutil.ccff' | ||
local uhf = require 'arn.uhf' | ||
local ccff = require 'arn.utils.ccff' | ||
local uhf = require 'arn.device.uhf' | ||
|
||
local exec = ccff.execute | ||
local vint = ccff.val.n | ||
|
@@ -25,11 +26,11 @@ gws_radio.conf = {} | |
gws_radio.conf.val_length_max = 8 | ||
|
||
gws_radio.cmd = {} | ||
gws_radio.cmd.rfinfo_clean = 'echo > /tmp/.GWS4K.tmp' | ||
gws_radio.cmd.rfinfo = 'rfinfo 2>/dev/null > /tmp/.GWS4K.tmp' | ||
gws_radio.cmd.region = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep Region -A1 | grep [01]* -o' | ||
gws_radio.cmd.channel = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep Channel -A1 | grep [0-9]* -o' | ||
gws_radio.cmd.txpower = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep ^Tx | grep Power | grep [0-9\.]* -o' | ||
gws_radio.cmd.rfinfo_clean = 'echo > /tmp/.GWS3K.tmp' | ||
gws_radio.cmd.rfinfo = 'rfinfo 2>/dev/null > /tmp/.GWS3K.tmp' | ||
gws_radio.cmd.region = 'cat /tmp/.GWS3K.tmp 2> /dev/null | grep Region -A1 | grep [01]* -o' | ||
gws_radio.cmd.channel = 'cat /tmp/.GWS3K.tmp 2> /dev/null | grep Channel -A1 | grep [0-9]* -o' | ||
gws_radio.cmd.txpower = 'cat /tmp/.GWS3K.tmp 2> /dev/null | grep ^Tx | grep Power | grep [0-9\.]* -o' | ||
gws_radio.cmd.chanbw = 'uci get wireless.radio0.chanbw' | ||
|
||
gws_radio.cmd.region_set = 'setregion %s 2> /dev/null ' | ||
|
@@ -39,10 +40,14 @@ gws_radio.cmd.chanbw_set = 'setchanbw %s 2> /dev/null ' | |
gws_radio.cmd.rxgain_set = 'setrxgain %s 2> /dev/null ' | ||
|
||
function gws_radio.update_init() | ||
DBG(sfmt("GWS4K----> update_init()")) | ||
DBG(sfmt("GWS3K----> update_init()")) | ||
exec(gws_radio.cmd.rfinfo) | ||
end | ||
|
||
function gws_radio.rfinfo_clean() | ||
exec(gws_radio.cmd.rfinfo_clean) | ||
end | ||
|
||
--[[ | ||
Tasks: | ||
1. Return each value by key; | ||
|
@@ -73,40 +78,46 @@ Tasks: | |
2. Fetch each parameters from tmp file. | ||
]]-- | ||
function gws_radio.UPDATE_RT() | ||
DBG(sfmt("GWS4K> update_rt (@%d)", os.time())) | ||
DBG(sfmt("GWS3K> update_rt (@%d)", os.time())) | ||
local result = {} | ||
|
||
gws_radio.update_init() | ||
|
||
DBG(sfmt("GWS4K----> update_item() region")) | ||
DBG(sfmt("GWS3K----> update_item() region")) | ||
result.region = gws_radio.update_item('region') | ||
|
||
DBG(sfmt("GWS4K----> update_item() channel")) | ||
DBG(sfmt("GWS3K----> update_item() channel")) | ||
result.channo = gws_radio.update_item('channel') | ||
result.freq = uhf.channel_to_freq(result.region, result.channo) | ||
|
||
DBG(sfmt("GWS4K----> update_item() txpower")) | ||
DBG(sfmt("GWS3K----> update_item() txpower")) | ||
result.txpwr = gws_radio.update_item('txpower') | ||
|
||
DBG(sfmt("GWS4K----> update_item() chanbw")) | ||
DBG(sfmt("GWS3K----> update_item() chanbw")) | ||
result.chanbw = gws_radio.update_item('chanbw') | ||
|
||
--result.ts = os.time() | ||
return result | ||
end | ||
|
||
function gws_radio.SET_RT(key, value) | ||
DBG(sfmt("GWS4K> set_rt k=%s,value=%s (@%d)", key or '-', value or '-', os.time())) | ||
local result = true | ||
DBG(sfmt("GWS3K> set_rt k=%s,value=%s (@%d)", key or '-', value or '-', os.time())) | ||
if (key == 'region') then | ||
exec(sfmt(gws_radio.cmd.region_set, value)) | ||
result = false | ||
elseif (key == 'channel' or key == 'channo') then | ||
exec(sfmt(gws_radio.cmd.channel_set, value)) | ||
result = false | ||
elseif (key == 'txpower' or key == 'txpwr') then | ||
exec(sfmt(gws_radio.cmd.txpower_set, value)) | ||
result = false | ||
elseif (key == 'rxgain') then | ||
exec(sfmt(gws_radio.cmd.rxgain_set, value)) | ||
result = false | ||
end | ||
exec(gws_radio.cmd.rfinfo_clean) | ||
gws_radio.rfinfo_clean() | ||
return result | ||
end | ||
|
||
return gws_radio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
--[[ | ||
Note: | ||
Although GWS4K share the same methods and functions, | ||
this copy will let maintainer handle 2 types of hardware. | ||
by Qige <[email protected]> | ||
2017.08.16 update_rt | ||
]]-- | ||
|
||
local DBG = print | ||
--local function DBG(msg) end | ||
|
||
local ccff = require 'arn.utils.ccff' | ||
local uhf = require 'arn.device.uhf' | ||
|
||
local exec = ccff.execute | ||
local vint = ccff.val.n | ||
local sfmt = string.format | ||
local ssub = string.sub | ||
local slen = string.len | ||
|
||
local gws_radio = {} | ||
|
||
gws_radio.conf = {} | ||
gws_radio.conf.val_length_max = 8 | ||
|
||
gws_radio.cmd = {} | ||
gws_radio.cmd.rfinfo_clean = 'echo > /tmp/.GWS4Kv2.tmp' | ||
gws_radio.cmd.rfinfo_lock = '/tmp/.GWS4Kv2.lock' | ||
gws_radio.cmd.rfinfo_wait = 'sleep 2' | ||
gws_radio.cmd.rfinfo = 'rfinfo 2>/dev/null > /tmp/.GWS4K.tmp' | ||
gws_radio.cmd.region = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep Region -A1 | grep [01]* -o' | ||
gws_radio.cmd.channel = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep Channel -A1 | grep [0-9]* -o' | ||
gws_radio.cmd.txpower = 'cat /tmp/.GWS4K.tmp 2> /dev/null | grep ^Tx | grep Power | grep [0-9\.]* -o' | ||
gws_radio.cmd.chanbw = 'uci get wireless.radio0.chanbw' | ||
|
||
gws_radio.cmd.region_set = 'setregion %s 2> /dev/null ' | ||
gws_radio.cmd.channel_set = 'setchan %s 2> /dev/null ' | ||
gws_radio.cmd.txpower_set = 'settxpwr %s 2> /dev/null ' | ||
gws_radio.cmd.chanbw_set = 'setchanbw %s 2> /dev/null ' | ||
gws_radio.cmd.rxgain_set = 'setrxgain %s 2> /dev/null ' | ||
|
||
function gws_radio.update_init() | ||
DBG(sfmt("GWS4K----> update_init()")) | ||
-- v2.0 2017.10.19 enable read lock | ||
rfinfo_lock = fread(gws_radio.cmd.rfinfo_lock) | ||
if (rfinfo_lock ~= 'lock' and rfinfo_lock ~= 'lock\n') then | ||
print(sfmt('%80s', '> updating radio <')) | ||
DBG('note> updating device < lock:', rfinfo_lock) | ||
fwrite(gws_radio.cmd.rfinfo_lock, 'lock') | ||
exec(gws_radio.cmd.rfinfo) | ||
fwrite(gws_radio.cmd.rfinfo_lock, 'unlock') | ||
DBG('note> updated') | ||
else | ||
print(sfmt('%80s', '> device busy <')) | ||
lock_counts = 3 | ||
while(rfinfo_lock == 'lock' or rfinfo_lock == 'lock\n') do | ||
exec(gws_radio.cmd.rfinfo_wait) | ||
rfinfo_lock = fread(gws_radio.cmd.rfinfo_lock) | ||
lock_counts = lock_counts - 1 | ||
if (lock_counts < 0) then | ||
print(sfmt('%80s', 'solving dead-lock')) | ||
break | ||
end | ||
end | ||
fwrite(gws_radio.cmd.rfinfo_lock, 'unlock') -- FIXME | ||
end | ||
--print(exec(gws_radio.cmd.rfinfo_all)) | ||
end | ||
|
||
function gws_radio.rfinfo_clean() | ||
exec(gws_radio.cmd.rfinfo_clean) | ||
end | ||
|
||
--[[ | ||
Tasks: | ||
1. Return each value by key; | ||
2. If result is too long, return first 8 chars. | ||
]]-- | ||
function gws_radio.update_item(key) | ||
local result | ||
if (key == 'region') then | ||
result = exec(gws_radio.cmd.region) | ||
elseif (key == 'channel' or key == 'channo') then | ||
result = exec(gws_radio.cmd.channel) | ||
elseif (key == 'txpower' or key == 'txpwr') then | ||
result = exec(gws_radio.cmd.txpower) | ||
elseif (key == 'chanbw') then | ||
result = exec(gws_radio.cmd.chanbw) | ||
end | ||
-- limit return length | ||
local lmax = gws_radio.conf.val_length_max | ||
if (result and slen(result) > lmax) then | ||
result = ssub(result, 1, lmax) | ||
end | ||
return vint(result) | ||
end | ||
|
||
--[[ | ||
Tasks: | ||
1. Do cli call; | ||
2. Fetch each parameters from tmp file. | ||
]]-- | ||
function gws_radio.UPDATE_RT() | ||
DBG(sfmt("GWS4K> update_rt (@%d)", os.time())) | ||
local result = {} | ||
|
||
gws_radio.update_init() | ||
|
||
DBG(sfmt("GWS4K----> update_item() region")) | ||
result.region = gws_radio.update_item('region') | ||
|
||
DBG(sfmt("GWS4K----> update_item() channel")) | ||
result.channo = gws_radio.update_item('channel') | ||
result.freq = uhf.channel_to_freq(result.region, result.channo) | ||
|
||
DBG(sfmt("GWS4K----> update_item() txpower")) | ||
result.txpwr = gws_radio.update_item('txpower') | ||
|
||
DBG(sfmt("GWS4K----> update_item() chanbw")) | ||
result.chanbw = gws_radio.update_item('chanbw') | ||
|
||
--result.ts = os.time() | ||
return result | ||
end | ||
|
||
function gws_radio.SET_RT(key, value) | ||
local result = true | ||
DBG(sfmt("GWS4K> set_rt k=%s,value=%s (@%d)", key or '-', value or '-', os.time())) | ||
if (key == 'region') then | ||
exec(sfmt(gws_radio.cmd.region_set, value)) | ||
result = false | ||
elseif (key == 'channel' or key == 'channo') then | ||
exec(sfmt(gws_radio.cmd.channel_set, value)) | ||
result = false | ||
elseif (key == 'txpower' or key == 'txpwr') then | ||
exec(sfmt(gws_radio.cmd.txpower_set, value)) | ||
result = false | ||
elseif (key == 'rxgain') then | ||
exec(sfmt(gws_radio.cmd.rxgain_set, value)) | ||
result = false | ||
end | ||
gws_radio.rfinfo_clean() | ||
return result | ||
end | ||
|
||
return gws_radio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--[[ | ||
Note: | ||
Although GWS5Kv1 & GWS5Kv2 share the same methods and functions, | ||
this copy will let maintainer handle 2 types of hardware. | ||
by Qige <[email protected]> | ||
almost same as GWS5Kv2, it's a wrapper | ||
]]-- | ||
|
||
--local DBG = print | ||
local function DBG(msg) end | ||
|
||
local gws_radio = require 'arn.device.hal.gws_5kv2' | ||
return gws_radio |
Oops, something went wrong.