Restart, update and reset all have ble and restify endpoints
This commit is contained in:
parent
b56afa3ba7
commit
5f71e48c38
|
@ -618,9 +618,25 @@ mobile.resetSuccess = function () {
|
|||
};
|
||||
|
||||
mobile.update = function () {
|
||||
|
||||
const reset = confirm(`Check for updates? You will be disconnected from the INTVAL3 during this process.`);
|
||||
if (!reset) return false;
|
||||
let opts = {
|
||||
type : 'reset'
|
||||
};
|
||||
ble.write(mobile.ble.device.id,
|
||||
mobile.ble.SERVICE_ID,
|
||||
mobile.ble.CHAR_ID,
|
||||
stringToBytes(JSON.stringify(opts)),
|
||||
mobile.updateSuccess,
|
||||
mobile.ble.onError);
|
||||
};
|
||||
|
||||
mobile.updateSuccess = function () {
|
||||
alert()
|
||||
};
|
||||
|
||||
mobile.restart = function () {}
|
||||
|
||||
/**
|
||||
* Mobile helper functions
|
||||
*/
|
||||
|
|
42
index.js
42
index.js
|
@ -38,8 +38,12 @@ function createServer () {
|
|||
app.get( '/sequence', rSequence)
|
||||
app.post('/sequence', rSequence)
|
||||
|
||||
app.post('/reset', rReset)
|
||||
app.get( '/status', rStatus)
|
||||
app.post('/reset', rReset)
|
||||
app.get('/update', rUpdate)
|
||||
app.get('/restart', rRestart)
|
||||
|
||||
|
||||
app.listen(PORT, () => {
|
||||
log.info('server', { name : APPNAME, port : PORT })
|
||||
})
|
||||
|
@ -55,7 +59,10 @@ function createBLE () {
|
|||
ble.on('delay', bDelay)
|
||||
ble.on('counter', bCounter)
|
||||
ble.on('sequence', bSequence)
|
||||
|
||||
ble.on('reset', bReset)
|
||||
ble.on('update', bUpdate)
|
||||
ble.on('restart', bRestart)
|
||||
}
|
||||
|
||||
//Restify functions
|
||||
|
@ -337,6 +344,18 @@ function rSequence (req, res, next) {
|
|||
}
|
||||
}
|
||||
|
||||
function rUpdate (req, res, next) {
|
||||
exec('sh ./scripts/update.sh', (err, stdio, stderr) => {
|
||||
res.send({ success : true })
|
||||
process.exit(0)
|
||||
})
|
||||
}
|
||||
|
||||
function rRestart (req, res, next) {
|
||||
res.send({ success : true })
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
//Ble functions
|
||||
|
||||
function bFrame (obj, cb) {
|
||||
|
@ -509,6 +528,21 @@ function bReset (obj, cb) {
|
|||
setTimeout(cb, 10)
|
||||
}
|
||||
|
||||
function bUpdate (obj, cb) {
|
||||
cb()
|
||||
setTimeout(() => {
|
||||
exec('sh ./scripts/update.sh', (err, stdio, stderr) => {
|
||||
process.exit(0)
|
||||
})
|
||||
}, 20)
|
||||
}
|
||||
function bRestart (obj, cb) {
|
||||
cb()
|
||||
setTimeout(() => {
|
||||
process.exit(0)
|
||||
}, 20)
|
||||
}
|
||||
|
||||
function seq () {
|
||||
let dir = intval._state.frame.dir
|
||||
let exposure = intval._state.frame.exposure
|
||||
|
@ -539,12 +573,6 @@ function seq () {
|
|||
}
|
||||
}
|
||||
|
||||
function update (req, res, next) {
|
||||
exec('sh ./scripts/update.sh', (err, stdio, stderr) => {
|
||||
process.exit()
|
||||
})
|
||||
}
|
||||
|
||||
function index (req, res, next) {
|
||||
fs.readFile(INDEXPATH, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
|
|
Loading…
Reference in New Issue