amazon dash button の検知までをtest
前準備 node.js npm
予めraspiにnode.jsがinstallされていますが、古いようですので、 nodejs.orgのdocumentに従いinstall.
Installing Node.js via package manager | Node.js
Installing Dasher on a Raspberry Pi · maddox/dasher Wiki · GitHub
$ sudo apt-get update # パッケージ・リストを入手 $ sudo apt-get upgrade $ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - $ sudo apt-get install -y nodejs $ node -v v8.3.0 $ nodejs -v v8.3.0 $ npm -v 5.3.0
試しに install node-dash-button
dasherはnode-dash-buttonをwrapして、 http等でrequestするものですが、試しにnode-dash-buttonもinstall
手順は、ほぼ node-dash-button の github.com に記載の通りです。
前準備 libpcap
tcpdumpと同じsiteでも配布されています sudo apt-get install libpcap-dev
install node-dash-button
$ cd /home/endo/local $ mkdir dash-button $ cd dash-button $ /usr/bin/npm init #対話形式によるprojectの書式化 $ /usr/bin/npm install node-dash-button --save
dash buttonのmac address検知
手元にあるdash buttonのmacは 18:74:2e:04:f6:e2 のようです。
$ sudo node ~/dev/dash-button/node_modules/node-dash-button/bin/findbutton Watching for arp & udp requests on your local network, please try to press your dash now Dash buttons should appear as manufactured by 'Amazon Technologies Inc.' Possible dash hardware address detected: 18:74:2e:04:f6:e2 Manufacturer: unknown Protocol: udp
root権限やsudoなしで、動作させる方法ないかな?
dasher
install dasher
$ cd dev $ git clone https://github.com/maddox/dasher.git $ cd dasher $ npm install $ ls node_modules/ ajv core-util-is har-validator jsprim safe-buffer asn1 cryptiles hawk mime-db sntp assert-plus dashdash hoek mime-types socketwatcher asynckit delayed-stream http-signature nan sshpk aws4 ecc-jsbn isstream node-dash-button stringstream aws-sign2 extend is-typedarray oauth-sign tough-cookie bcrypt-pbkdf extsprintf jsbn pcap tunnel-agent boom forever-agent jsonify performance-now tweetnacl caseless form-data json-schema punycode underscore co getpass json-stable-stringify qs uuid combined-stream har-schema json-stringify-safe request verror ## dash buttonのmac address検知 当然、macは 18:74:2e:04:f6:e2
$ $ ~/dev/dasher/script/find_button Watching for arp & udp requests on your local network, please try to press your dash now Dash buttons should appear as manufactured by ‘Amazon Technologies Inc.’ Possible dash hardware address detected: 18:74:2e:04:f6:e2 Manufacturer: unknown Protocol: udp
## config dasher config.example.json には、様々なサンプルがあるので、これをベースにするとよさそうです。
cp config.example.json config/config.json vi config/config.json {“buttons”:[ { “name”: “Debug Dash Button 1”, “address”: “18:74:2e:04:f6:e2”, “debug”: true }, { “name”: “Debug Dash Button 2”, “address”: “18:74:2e:04:f6:e2”, “url”: “http://192.168.0.12/”, “method”: “GET”, “debug”: true }, { “name”: “Debug Dash Button 3”, “address”: “18:74:2e:04:f6:e2”, “cmd”: “echo ‘ HOGE ’ > /home/endo/tmp/foo.log” } ]}
# test dasher
$ cd ~/dev/dasher $ sudo npm run start
dasher@1.4.1 start /home/endo/dev/dasher node app.js
[2017-08-16T00:30:01.177Z] TEST DASHER added. : :
あれ?、buttonを検知しないし、errorも吐かない...? raspi or nodejsのinstallがおかしいのかな? また、今度ですね。 # その他 - dasherの自動起動もdocumentに記載 試していませんが [https://github.com/maddox/dasher/wiki:title]