Raspberry PiでIoTなシステム開発:nodeからwifi接続をコントロールする

nodeからRaspberry Piのwifi接続をコントロールしたいなぁ、でもexecをいちいち叩いていくのは面倒だし、と思っていたら、moduleを作ってくれている人がいました。ネットには神が沢山います。wifi-controlこのmoduleは実際にはnmcliのフロントエンドに過ぎないので、使用するためにはまずnmcliをインストールします。

Setting up policykit-1 (0.105-8) ...Setting up network-manager (0.9.10.0-7) ...The following network interfaces were found in /etc/network/interfaceswhich means they are currently configured by ifupdown:- eth0- wlan0- wlan1If you want to manage those interfaces with NetworkManager insteadremove their configuration from /etc/network/interfaces.Setting up ppp (2.4.6-3.1) ...Setting up iputils-arping (3:20121221-5) ...

ご丁寧にもinterfacesに書いてあったらダメよと指摘してくれましたので、interfacesからwlan1の設定を削除しておきました。

WiFiControl: Debug mode set to: trueWiFiControl: Determining system wireless interface...WiFiControl: Host machine is Linux.WiFiControl: Executing: nmcli -m multiline device status | grep wlanWiFiControl: Automatically located wireless interface wlan1.WiFiControl: Debug mode set to: trueWiFiControl: AP connection attempt timeout set to: 10000msWiFiControl: Wireless interface manually set to wlan1.WiFiControl: Scanning for nearby WiFi Access Points...WiFiControl: Nearby WiFi APs successfully scanned (11 found).{ success: true,  msg: 'Nearby WiFi APs successfully scanned (11 found).',  networks:   [ { ssid: 'aterm-d014ce-g',       channel: '6',       signal_level: '70',       security: 'WPA1 WPA2' },     { ssid: 'AP-2F-YA-2.4GHz',       channel: '13',       signal_level: '47',       security: 'WPA1 WPA2' },     { ssid: 'AP-2F-YU-2.4GHz',

“””