Push dev work to master #2

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

View File

@ -285,10 +285,11 @@ function rSequence (req, res, next) {
//Ble functions //Ble functions
function bFrame (cb) { function bFrame (obj, cb) {
let dir = intval._state.frame.dir let dir = intval._state.frame.dir
let len = 630 let len = 630
cb({ dir: dir, len : len }) console.dir(obj)
setTimeout(cb, 630)
} }
function index (req, res, next) { function index (req, res, next) {

View File

@ -165,6 +165,7 @@ class BLE {
let result = {} let result = {}
let utf8 let utf8
let obj let obj
let fn
if (offset) { if (offset) {
log.warn(`Offset scenario`) log.warn(`Offset scenario`)
result = bleno.Characteristic.RESULT_ATTR_NOT_LONG result = bleno.Characteristic.RESULT_ATTR_NOT_LONG
@ -173,15 +174,15 @@ class BLE {
utf8 = data.toString('utf8') utf8 = data.toString('utf8')
obj = JSON.parse(utf8) obj = JSON.parse(utf8)
result = bleno.Characteristic.RESULT_SUCCESS result = bleno.Characteristic.RESULT_SUCCESS
if (obj.type && this[`_on${capitalize(obj.type)}`]) { fn = `_on${capitalize(obj.type)}`
this[`_on${capitalize(obj.type)}`]( obj => { if (obj.type && this[fn]) {
let str = JSON.stringify(obj) return this[fn](obj, () => {
let data = new Buffer(str) callback(result)
return callback(result, data.slice(offset, data.length))
}) })
} else { } else {
return callback(result) return callback(result)
} }
} }
_onRead (offset, callback) { _onRead (offset, callback) {
const result = bleno.Characteristic.RESULT_SUCCESS const result = bleno.Characteristic.RESULT_SUCCESS