LoginSignup
2
1

More than 5 years have passed since last update.

PQI Air Cardをインフラストラクチャモードで自動起動する

Posted at

WifiSettings画面で親となるアクセスポイントのSSIDが3つまで指定できて、
autorun.shで/usr/bin/w2を叩くと起動時にインフラストラクチャモードで起動できる、というのはちょっと検索すれば出てくる話。

けれど、アクセスポイントが見つからなかったときに、Eye-FiみたいにAPモードに切り替わって欲しい。
そのためのautorun.shが、以下。

autorun.sh
#!/bin/sh
a1
sleep 1
iwconfig
ifconfig mlan0 192.168.1.1 netmask 255.255.255.0 up
iwconfig mlan0 txpower 15
iwlist mlan0 scan
sleep 2
iwlist mlan0 scan 2>&1 > /tmp/wifilist.txt
connect_hotspot=0
for ssid in `cat /mnt/mtd/config/wsd.conf | egrep "AP_SSID : ." | perl -anle
do
    grep ESSID:\"$ssid\" /tmp/wifilist.txt
    if [ $? -eq 0 ]; then connect_hotspot=1; fi
done

if [ $connect_hotspot -eq 1 ];
then
    /usr/bin/w2 >> $statelog
else
    echo "fallback to AP mode" >> $statelog
    /usr/bin/w3
fi

/usr/bin/a1は、無線ハードウェアの初期設定用。
iwlist mlan0 scanで周囲のアクセスポイントがスキャンできるが、1度で全部出てこないことが多いので、2秒待ってもう一度スキャンし、2度目の結果をリストに保存している。
ブラウザから設定したSSIDなどは/mnt/mtd/config/wsd.confに保存されているので、ここからAP_SSIDの設定だけを読み出し、スキャン結果に存在するかを確認している。
周囲に指定したアクセスポイントがあれば、w2を実行してインフラストラクチャモードに。
無ければ、w3を実行してAPモードで起動するようにしている。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1