Implement get Wifi status.

This commit is contained in:
Valverde Antonio
2014-06-30 19:13:28 +09:00
parent 98148cdc7f
commit d9281bb30a
8 changed files with 64 additions and 4 deletions

View File

@@ -13,9 +13,7 @@ module.exports = syrup.serial()
router.on(wire.WifiSetEnabledMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
log.info('Setting Wifi "%s"', message.enabled)
service.setWifiEnabled(message.enabled)
.timeout(30000)
.then(function() {
@@ -25,7 +23,27 @@ module.exports = syrup.serial()
])
})
.error(function(err) {
log.error('Setting wifi enabled failed', err.stack)
log.error('Setting Wifi enabled failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
router.on(wire.WifiGetStatusMessage, function(channel){
var reply = wireutil.reply(options.serial)
log.info('Getting Wifi status')
service.getWifiStatus()
.timeout(30000)
.then(function(enabled) {
push.send([
channel
, reply.okay(enabled ? 'wifi_enabled' : 'wifi_disabled')
])
})
.error(function(err) {
log.error('Getting Wifi status failed', err.stack)
push.send([
channel
, reply.fail(err.message)