Date:2012-07-04 04:18:12 (11 years 8 months ago)
Author:Xiangfu
Commit:a9bac6cda9bec9c36158234ad04b92b088c07bb8
Message:milkymist-files: files for configure m1 wireless gadget

Files: milkymist-files/files/m1-wireless.lua (1 diff)
milkymist-files/files/m1-wireless.sh (1 diff)
nanonote-files/data/qi_lb60/scripts/compile-openwrt-xburst.sh (1 diff)
xburst-tools/Makefile (1 diff)

Change Details

milkymist-files/files/m1-wireless.lua
1#!/usr/bin/env lua
2
3local io = require "io"
4local os = require "os"
5local table = require "table"
6
7function trim (s)
8    return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
9end
10
11function split(delim, text)
12    local list = {}
13    if string.len(text) <= 0 then
14       return list
15    end
16    delim = delim or ""
17    local pos = 1
18    -- if delim matches empty string then it would give an endless loop
19    if string.find("", delim, 1) and delim ~= "" then
20       error("delim matches empty string!")
21    end
22    local first, last
23    while 1 do
24       if delim ~= "" then
25          first, last = string.find(text, delim, pos)
26       else
27          first, last = string.find(text, "%s+", pos)
28          if first == 1 then
29         pos = last+1
30         first, last = string.find(text, "%s+", pos)
31          end
32       end
33       if first then -- found?
34          table.insert(list, string.sub(text, pos, first-1))
35          pos = last+1
36       else
37          table.insert(list, string.sub(text, pos))
38          break
39       end
40    end
41    return list
42end
43
44function exec(command)
45        local pp = io.popen(command)
46        local data = pp:read("*a")
47    pp:close()
48
49        return data
50end
51
52function iwscan(iface)
53    local siface = iface or ""
54    local cnt = exec("iwlist "..siface.." scan 2>/dev/null")
55    local iws = {}
56
57    cnt = trim(cnt)
58    for i, l in pairs(split("\n Cell", cnt)) do
59       local ESSID = l:match("ESSID:\"(.-)\"")
60       if ESSID then
61          local Q = l:match("Quality[:=](.-)[ ]")
62          local A = l:match("Authentication Suites.- : (.-)\n")
63          local P = l:match("Pairwise Ciphers.- : (.-)\n")
64
65          local enc
66          if not l:find("Encryption key:on") then
67         enc = "none"
68          else
69         local wpa = l:find("WPA Version 1")
70         local rsn = l:find("WPA2 Version 1")
71         if wpa and rsn then enc = "psk+psk2"
72         elseif rsn then enc = "psk2"
73         elseif wpa then enc = "psk"
74         else enc = "wep" end
75          end
76
77          local r = Q .. "\t" .. ESSID .. "\t" .. enc
78
79          table.insert(iws, r)
80       end
81    end
82
83    return iws
84end
85
86local t = iwscan("wlan0")
87for k,v in pairs(t) do print(v) end
milkymist-files/files/m1-wireless.sh
1#!/bin/sh
2
3if [ "$1" == "set" ] && [ "$#" == "4" ]; then
4  uci delete network.wwan
5  uci commit wireless
6
7  uci set network.wwan=interface
8  uci set network.wwan.proto=dhcp
9  uci commit wireless
10
11  uci delete wireless.@wifi-iface[0]
12  uci commit wireless
13
14  uci set wireless.@wifi-device[0].disabled=0
15  uci add wireless wifi-iface > /dev/null 2>&1
16  uci set wireless.@wifi-iface[0].device='radio0'
17  uci set wireless.@wifi-iface[0].network='wwan'
18  uci set wireless.@wifi-iface[0].mode='sta'
19
20  #none for an open network,
21  #wep for WEP,
22  #psk for WPA-PSK, or
23  #psk2
24
25  uci set wireless.@wifi-iface[0].ssid=$2
26  uci set wireless.@wifi-iface[0].key=$3
27  uci set wireless.@wifi-iface[0].encryption=$4
28
29  uci commit wireless
30  wifi up > /dev/null 2>&1
31  udhcpc -i wlan0 -b > /dev/null 2>&1
32
33  ifconfig wlan0 | grep "inet addr"
34
35  exit 0
36fi
37
38
39if [ "$1" == "get" ]; then
40  ifconfig -a | grep wlan0 > /dev/null 2>&1
41
42  if [ "$?" != "0" ]; then
43    iw phy phy0 interface add wlan0 type station
44    ifconfig wlan0 up
45    sleep 1
46  fi
47
48  /opt/m1-wireless.lua
49
50  exit 0
51fi
52
53if [ "$1" == "status" ]; then
54  ifconfig wlan0
55
56  exit 0
57fi
58
59echo "Usage: $0 [get/set/status] PARAMS..."
nanonote-files/data/qi_lb60/scripts/compile-openwrt-xburst.sh
9595(cd ${IMAGES_DIR} && \
9696    grep -E "ERROR:\ package.*failed to build" BUILD_LOG | \
9797    grep -v "package/kernel" > failed_packages.txt; \
98
99    if [ "$1" == "minimal" ]; then
100    cp failed_packages.txt /home/xiangfu/building/Nanonote/Ben/
101    fi
98102)
99103
100104if [ "${MAKE_RET}" == "0" ]; then
xburst-tools/Makefile
2929  CATEGORY:=Utilities
3030  TITLE:=Xburst-Tools
3131  URL:=http://projects.qi-hardware.com/p/xburst-tools/
32  DEPENDS:=+libusb +libusb-1.0 +confuse +libreadline
32  DEPENDS:=+libusb +libusb-1.0 +confuse +libreadline +libncurses
3333endef
3434
3535define Package/xburst-tools/description

Archive Download the corresponding diff file



interactive