Fri 05/30, 2008

Fon-MP3 (2) [Computer and Networking , Electronics ]

MP3 プレーヤーに仕立てた La Fonera をクライアントブリッジモードに設定してみる。Ether 無しのスタンドアローンで使うための一歩。次はシリアル端末に代わる適当な操作ガジェットを用意したい。

家庭内 LAN で 192.168.1.1 のルータがゲートウェイ兼 DNS プロクシになっていて、無線 LAN アクセスポイントがあり、WEP で暗号化されているという前提での設定。

root@OpenWrt:/etc/config# cat /etc/config/network
# Copyright (C) 2006 OpenWrt.org

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname eth0
        option type     bridge
        option proto    'static'
        option ipaddr   192.168.2.1 - LAN port アドレス (LaFonera)
        option netmask  255.255.255.0
       # option gateway  192.168.1.1 - ゲートウェイ
       # option dns      192.168.1.1 - DNS


config "interface" "wan"
        option ifname   'ath0'
        option proto    'dhcp'

root@OpenWrt:/etc/config# cat /etc/config/wireless
config wifi-device  wifi0
        option type     atheros
        option channel  11
        option disabled 0

config wifi-iface
        option device   wifi0
        option network  lan
        option mode     sta
        option ssid     YOUR_SSID - SSID
        option encryption wep
        option key      1
        option key1     '1234567890' - WEP キー
        option wds      1 - これがないと動かない。
root@OpenWrt:/etc/config# ifconfig -a
ath0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6146 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6365 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:7152316 (6.8 MiB)  TX bytes:636899 (621.9 KiB)

br-lan    Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.216  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6145 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5907 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:7065944 (6.7 MiB)  TX bytes:488049 (476.6 KiB)

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1043 (1.0 KiB)
          Interrupt:4 Base address:0x1000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wifi0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31290 errors:0 dropped:6782 overruns:0 frame:4512
          TX packets:6790 errors:3 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:199
          RX bytes:9268561 (8.8 MiB)  TX bytes:907410 (886.1 KiB)
          Interrupt:3 Memory:b0000000-b00ffffc
root@OpenWrt:/etc/config#
で、電源をいれて起動したら勝手に再生が始まるようにしてみた。次のようなスクリプトを cron で毎分毎に実行すると mp3d が動いていてアイドル状態にあれば指定のストリームに接続して再生を始める。電源オンから openwrt 自体の起動までに結構時間がかかるのは、まぁ仕方ない。
#!/bin/sh
pls="http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=3540&file=filename.pls" .. 適当な playlist の URL
foo=`mplay STATE | grep IDLE`
if [ $foo="STATE MP3_STATE_IDLE" ]; then
  mplay VOLUME 10 .. 適当なボリューム値
  mplay STREAM pls $pls .. 直接の mp3 ストリームならば pls の代わりに url 
fi

Posted by masato at 09:52 PM
このエントリーのトラックバックURL: http://bird.dip.jp/cgi-bin/mt/mt-tb.cgi/1585
コメントする

おそらく携帯電話等からは投稿できません。日本語文字列を含まないコメントやトラックバック、および当サイトへの言及を含まないトラックバックは御遠慮いただいております。また、90日以上経過した記事へのコメントはできません。










名前、アドレスを登録しますか?