milkymist-files: files for configure m1 wireless gadget

This commit is contained in:
Xiangfu 2012-07-04 10:18:12 +08:00
parent 3f051415c4
commit a9bac6cda9
4 changed files with 151 additions and 1 deletions

View File

@ -0,0 +1,87 @@
#!/usr/bin/env lua
local io = require "io"
local os = require "os"
local table = require "table"
function trim (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
function split(delim, text)
local list = {}
if string.len(text) <= 0 then
return list
end
delim = delim or ""
local pos = 1
-- if delim matches empty string then it would give an endless loop
if string.find("", delim, 1) and delim ~= "" then
error("delim matches empty string!")
end
local first, last
while 1 do
if delim ~= "" then
first, last = string.find(text, delim, pos)
else
first, last = string.find(text, "%s+", pos)
if first == 1 then
pos = last+1
first, last = string.find(text, "%s+", pos)
end
end
if first then -- found?
table.insert(list, string.sub(text, pos, first-1))
pos = last+1
else
table.insert(list, string.sub(text, pos))
break
end
end
return list
end
function exec(command)
local pp = io.popen(command)
local data = pp:read("*a")
pp:close()
return data
end
function iwscan(iface)
local siface = iface or ""
local cnt = exec("iwlist "..siface.." scan 2>/dev/null")
local iws = {}
cnt = trim(cnt)
for i, l in pairs(split("\n Cell", cnt)) do
local ESSID = l:match("ESSID:\"(.-)\"")
if ESSID then
local Q = l:match("Quality[:=](.-)[ ]")
local A = l:match("Authentication Suites.- : (.-)\n")
local P = l:match("Pairwise Ciphers.- : (.-)\n")
local enc
if not l:find("Encryption key:on") then
enc = "none"
else
local wpa = l:find("WPA Version 1")
local rsn = l:find("WPA2 Version 1")
if wpa and rsn then enc = "psk+psk2"
elseif rsn then enc = "psk2"
elseif wpa then enc = "psk"
else enc = "wep" end
end
local r = Q .. "\t" .. ESSID .. "\t" .. enc
table.insert(iws, r)
end
end
return iws
end
local t = iwscan("wlan0")
for k,v in pairs(t) do print(v) end

View File

@ -0,0 +1,59 @@
#!/bin/sh
if [ "$1" == "set" ] && [ "$#" == "4" ]; then
uci delete network.wwan
uci commit wireless
uci set network.wwan=interface
uci set network.wwan.proto=dhcp
uci commit wireless
uci delete wireless.@wifi-iface[0]
uci commit wireless
uci set wireless.@wifi-device[0].disabled=0
uci add wireless wifi-iface > /dev/null 2>&1
uci set wireless.@wifi-iface[0].device='radio0'
uci set wireless.@wifi-iface[0].network='wwan'
uci set wireless.@wifi-iface[0].mode='sta'
#none for an open network,
#wep for WEP,
#psk for WPA-PSK, or
#psk2
uci set wireless.@wifi-iface[0].ssid=$2
uci set wireless.@wifi-iface[0].key=$3
uci set wireless.@wifi-iface[0].encryption=$4
uci commit wireless
wifi up > /dev/null 2>&1
udhcpc -i wlan0 -b > /dev/null 2>&1
ifconfig wlan0 | grep "inet addr"
exit 0
fi
if [ "$1" == "get" ]; then
ifconfig -a | grep wlan0 > /dev/null 2>&1
if [ "$?" != "0" ]; then
iw phy phy0 interface add wlan0 type station
ifconfig wlan0 up
sleep 1
fi
/opt/m1-wireless.lua
exit 0
fi
if [ "$1" == "status" ]; then
ifconfig wlan0
exit 0
fi
echo "Usage: $0 [get/set/status] PARAMS..."

View File

@ -95,6 +95,10 @@ cp -a files/* ${IMAGES_DIR}/files/
(cd ${IMAGES_DIR} && \
grep -E "ERROR:\ package.*failed to build" BUILD_LOG | \
grep -v "package/kernel" > failed_packages.txt; \
if [ "$1" == "minimal" ]; then
cp failed_packages.txt /home/xiangfu/building/Nanonote/Ben/
fi
)
if [ "${MAKE_RET}" == "0" ]; then

View File

@ -29,7 +29,7 @@ define Package/xburst-tools
CATEGORY:=Utilities
TITLE:=Xburst-Tools
URL:=http://projects.qi-hardware.com/p/xburst-tools/
DEPENDS:=+libusb +libusb-1.0 +confuse +libreadline
DEPENDS:=+libusb +libusb-1.0 +confuse +libreadline +libncurses
endef
define Package/xburst-tools/description