Set direction with bluetooth, also resolve an unfortunate bug where I repeatedly spelled "undefined" as "udnefined"
This commit is contained in:
parent
d8e6a2206e
commit
ae03b97f96
47
index.js
47
index.js
|
@ -46,6 +46,7 @@ function createBLE () {
|
||||||
return intval.status()
|
return intval.status()
|
||||||
})
|
})
|
||||||
ble.on('frame', bFrame)
|
ble.on('frame', bFrame)
|
||||||
|
ble.on('dir', bDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restify functions
|
//Restify functions
|
||||||
|
@ -59,7 +60,7 @@ function rDir (req, res, next) {
|
||||||
dir = req.query.dir
|
dir = req.query.dir
|
||||||
}
|
}
|
||||||
set = true
|
set = true
|
||||||
} else if (req.body && typeof req.body.dir !== 'udnefined') {
|
} else if (req.body && typeof req.body.dir !== 'undefined') {
|
||||||
if (typeof req.body.dir === 'string') {
|
if (typeof req.body.dir === 'string') {
|
||||||
dir = (req.body.dir === 'true')
|
dir = (req.body.dir === 'true')
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +88,7 @@ function rExposure (req, res, next) {
|
||||||
exposure = req.query.exposure
|
exposure = req.query.exposure
|
||||||
}
|
}
|
||||||
set = true
|
set = true
|
||||||
} else if (req.body && typeof req.body.exposure !== 'udnefined') {
|
} else if (req.body && typeof req.body.exposure !== 'undefined') {
|
||||||
if (typeof req.body.exposure === 'string') {
|
if (typeof req.body.exposure === 'string') {
|
||||||
exposure = parseInt(req.body.exposure)
|
exposure = parseInt(req.body.exposure)
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,7 +120,7 @@ function rDelay (req, res, next) {
|
||||||
}
|
}
|
||||||
set = true
|
set = true
|
||||||
}
|
}
|
||||||
if (req.body && typeof req.body.delay !== 'udnefined') {
|
if (req.body && typeof req.body.delay !== 'undefined') {
|
||||||
if (typeof req.body.delay === 'string') {
|
if (typeof req.body.delay === 'string') {
|
||||||
delay = parseInt(req.body.delay)
|
delay = parseInt(req.body.delay)
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +211,7 @@ function rFrame (req, res, next) {
|
||||||
delay = req.query.delay
|
delay = req.query.delay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (req.body && typeof req.body.delay !== 'udnefined') {
|
if (req.body && typeof req.body.delay !== 'undefined') {
|
||||||
if (typeof req.body.delay === 'string') {
|
if (typeof req.body.delay === 'string') {
|
||||||
delay = parseInt(req.body.delay)
|
delay = parseInt(req.body.delay)
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,12 +287,44 @@ function rSequence (req, res, next) {
|
||||||
//Ble functions
|
//Ble functions
|
||||||
|
|
||||||
function bFrame (obj, cb) {
|
function bFrame (obj, cb) {
|
||||||
let dir = intval._state.frame.dir
|
let dir = true
|
||||||
let len = 630
|
let exposure = 0
|
||||||
console.dir(obj)
|
|
||||||
|
if (intval._state.frame.dir !== true) {
|
||||||
|
dir = false
|
||||||
|
}
|
||||||
|
if (typeof obj.dir !== 'undefined') {
|
||||||
|
if (typeof obj.dir === 'string') {
|
||||||
|
dir = (obj.dir === 'true')
|
||||||
|
} else {
|
||||||
|
dir = obj.dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof obj.dir !== 'undefined') {
|
||||||
|
exposure
|
||||||
|
}
|
||||||
|
log.info('frame', { method : 'ble', dir : dir, exposure : exposure })
|
||||||
|
/*intval.frame(dir, exposure, (len) => {
|
||||||
|
return cb()
|
||||||
|
})*/
|
||||||
setTimeout(cb, 630)
|
setTimeout(cb, 630)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bDir (obj, cb) {
|
||||||
|
let dir = true
|
||||||
|
let set = false
|
||||||
|
if (obj.dir !== 'undefined') {
|
||||||
|
if (typeof obj.dir === 'string') {
|
||||||
|
dir = (obj.dir === 'true')
|
||||||
|
} else {
|
||||||
|
dir = obj.dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intval.setDir(dir)
|
||||||
|
log.info('dir', { method: 'ble', dir : dir })
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
|
||||||
function index (req, res, next) {
|
function index (req, res, next) {
|
||||||
fs.readFile(INDEXPATH, 'utf8', (err, data) => {
|
fs.readFile(INDEXPATH, 'utf8', (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue