Openwrt Buffalo WZR-HP-G300NH2 建立自訂鍵

想用Buffalo 前面那個鍵做其他功能
不過只找到下方那個鍵,找不到AOSS那個鍵的代號。(可能已經壞掉了?)
參考資料:
1. OpenWRT、dd-wrt自設定路由按鈕功能
First, Find out the button
http://wiki.openwrt.org/doc/howto/hardware.button

preliminary.steps

root@OpenWrt:~# mkdir -p /etc/hotplug.d/button
root@OpenWrt:~# vi /etc/hotplug.d/button/button
#!/bin/sh
logger the button was $BUTTON and the action was $ACTION
root@OpenWrt:~# logread
[...]
Feb 14 23:43:12 OpenWrt user.notice root: the button was BTN_3 and the action was pressed 上
Feb 14 23:43:13 OpenWrt user.notice root: the button was BTN_3 and the action was released 下
Feb 14 23:43:14 OpenWrt user.notice root: the button was BTN_3 and the action was pressed
Feb 14 23:43:14 OpenWrt user.notice root: the button was BTN_3 and the action was released
root@OpenWrt:/etc# wget --no-check-certificate -O /etc/hotplug.d/button/00-button https://dev.openwrt.org/export/3633
2/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button
--2015-02-14 23:45:56-- https://dev.openwrt.org/export/36332/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button
Resolving dev.openwrt.org... 2a00:1328:e000:452::26, 217.115.15.26
Connecting to dev.openwrt.org|2a00:1328:e000:452::26|:443... failed: Address family not supported by protocol.
Connecting to dev.openwrt.org|217.115.15.26|:443... connected.
WARNING: cannot verify dev.openwrt.org's certificate, issued by `/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA':
Self-signed certificate encountered.
HTTP request sent, awaiting response... 200 Ok
Length: 512 [text/plain]
Saving to: `/etc/hotplug.d/button/00-button'
2015-02-14 23:45:58 (14.9 MB/s) - `/etc/hotplug.d/button/00-button' saved [512/512]
這時你可以加添你想要的功能了。
我主要功能是用這個router BT download 到usb 內。當我推上這個鍵時會自動mount usb 及 start transmission. 而當我推下這個鍵時會自動停transmission 及umount usb.
root@OpenWrt:~# uci add system button
root@OpenWrt:~# uci set system.@button[-1].button=BTN_3
root@OpenWrt:~# uci set system.@button[-1].action=pressed
root@OpenWrt:~# uci set system.@button[-1].handler='mount /dev/sda1 /mnt/usb;sleep 5; /etc/init.d/transmission start'
root@OpenWrt:~# uci add system button
root@OpenWrt:~# uci set system.@button[-1].button=BTN_3
root@OpenWrt:~# uci set system.@button[-1].action=released
root@OpenWrt:~# uci set system.@button[-1].handler='/etc/init.d/transmission stop;sleep 5; umount /dev/sda1
'

另一方面transmission 的startup script 都要改少少野,因為要check 下是否mount 好個usb 先BT,若果mount 唔好,應該要fail 左個startup script 先啱。

Comments

Popular Posts