Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
3 changed files with 39 additions and 39 deletions
Showing only changes of commit 9302cf1b21 - Show all commits

View File

@ -120,8 +120,9 @@ function rDelay (req, res, next) {
}
function rFrame (req, res, next) {
intval.frame(cb=()=>{
log.info('happened')
log.info('/frame', { method : req.method })
intval.frame(true, 0, () => {
log.info('frame stopped')
})
res.send({})
return next()

View File

@ -11,31 +11,28 @@ function capitalize (s) {
class Blootstrap {
constructor () {
this._onData = () => {}
try {
ipc.connectTo('blootstrap_ble', () => {
ipc.of.blootstrap_ble.on('connect', () => {
log.info('connect', `Connected to the blootstrap_ble service`)
ipc.config.maxRetries = 0
ipc.connectTo('blootstrap_ble', () => {
ipc.of.blootstrap_ble.on('connect', () => {
log.info('connect', `Connected to the blootstrap_ble service`)
})
ipc.of.blootstrap_ble.on('data', data => {
const str = data.toString()
log.info('data', str)
this._onData(str)
})
ipc.of.blootstrap_ble.on('disconnect', () => {
log.info('disconnect', `Disconnected from the blootstrap_ble service`)
})
ipc.of.blootstrap_ble.on('error', (err) => {
if (err.code === 'EACCES') {
log.warn('ble', `Cannot access ipc`)
} else {
log.error('ble', { error : err })
}
})
})
} catch (e) {
log.error('connectTo', { error : e })
}
ipc.of.blootstrap_ble.on('data', data => {
const str = data.toString()
log.info('data', str)
this._onData(str)
})
ipc.of.blootstrap_ble.on('disconnect', () => {
log.info('disconnect', `Disconnected from the blootstrap_ble service`)
})
ipc.of.blootstrap_ble.on('error', (err) => {
if (err.code === 'EACCES') {
log.warn('ble', `Cannot access ipc`)
} else {
log.error('ble', { error : err })
}
})
})
}
/**
* Binds functions to events that are triggered by BLE messages

View File

@ -13,12 +13,14 @@ const log = require('../log')('wifi')
const exec = require('child_process').exec
const fs = require('fs')
let _entry = null
let _ssid = null
let _cb = null
/** Class representing the wifi features */
class Wifi {
constructor () {
this._callback = () => {}
this._entry = null
this._ssid = null
}
/**
* List available wifi access points
@ -54,14 +56,14 @@ class Wifi {
_readConfigCb (err, data) {
if (err) {
console.error(err)
return this._callback(err)
return _cb(err)
}
if (data.search(networkPattern) === -1) {
data += `\n${this._entry}`
data += `\n${_entry}`
} else {
data = data.replace(networkPattern, this._entry)
data = data.replace(networkPattern, _entry)
}
this._entry = null
_entry = null
fs.writeFile(filePath, data, 'utf8', this._writeConfigCb)
}
/**
@ -73,7 +75,7 @@ class Wifi {
_writeConfigCb (err) {
if (err) {
console.error(err)
return this._callback(err)
return _cb(err)
}
exec(reconfigure, this._reconfigureCb)
}
@ -87,7 +89,7 @@ class Wifi {
_reconfigureCb (err, stdout, stderr) {
if (err) {
console.error(err)
return this._callback(err)
return _cb(err)
}
console.log('Wifi reconfigured')
exec(refresh, this._refreshCb)
@ -102,11 +104,11 @@ class Wifi {
_refreshCb (err, stdout, stderr) {
if (err) {
console.error(err)
return this._callback(err)
return _cb(err)
}
console.log('Wifi refreshed')
//this._callback(null, { ssid : ssid, pwd : pwd.length })
this._callback = () => {}
_cb = () => {}
}
/**
* Function which initializes the processes for adding a wifi access point authentication
@ -116,9 +118,9 @@ class Wifi {
* @param {function} callback Function invoked after process is complete, or fails
*/
setNetwork (ssid, pwd, callback) {
this._entry = `network={\n\tssid="${ssid}"\n\tpsk="${pwd}"\n}\n`
this._callback = callback
this._ssid = ssid
_entry = `network={\n\tssid="${ssid}"\n\tpsk="${pwd}"\n}\n`
_cb = callback
_ssid = ssid
fs.readFile(filePath, 'utf8', this._readConfigCb)
}
/**