$ tessel wifi -n 'Alan 的 AirPort Time Capsule' -p 'PASSWORD'
TESSEL! Connected to TM-00-04-f000da30-00544741-1ca82586.
INFO Connecting to "Alan 的 AirPort Time Capsule" with wpa2 security...
INFO Acquiring IP address.
..
INFO Connected!
IP 192.168.1.46
DNS 168.95.192.1
DHCP 192.168.1.1
Gateway 192.168.1.1
var https = require('https');
wifi.on('connect', function(data) {
console.log("connect emitted", data);
var json = JSON.parse('{"text":"This is a line of text in a channel.\nAnd this is another line of text."}');
var postData = 'payload=' + JSON.stringify(json);
var options = {
hostname: 'hooks.slack.com',
port: 443,
path: '/services/T030MA704/B04MARY2F/clicTENx48f4h5v9OePzePkH',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length
}
};
// Setup the request. The options parameter is
// the object we defined above.
var req = https.request(options, function(res) {
res.setEncoding('utf-8');
var responseString = '';
res.on('data', function(data) {
responseString += data;
});
res.on('end', function() {
console.log(responseString);
});
});
req.on('error', function(e) {
console.log('something error.');
});
req.write(postData);
req.end();
}
$ tessel run wifi-control.js
TESSEL! Connected to TM-00-04-f000da30-00544741-1ca82586.
INFO Bundling directory /Users/alan/Documents/tessel-code
INFO Deploying bundle (8.87 MB)...
INFO Running script...
connect emitted {
dns : 168.95.192.1,
ip : 192.168.1.46,
event : status,
connected : 1,
dhcp : 192.168.1.1,
ssid : Alan 的 AirPort Time Capsule,
gateway : 192.168.1.1
}
ok