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 22 additions and 12 deletions
Showing only changes of commit 4aadc5a9df - Show all commits

View File

@ -41,10 +41,14 @@ function createServer () {
})
}
function bleBindings () {
function createBLE () {
ble = new BLE(() => {
return intval.status()
})
ble.on('frame', bFrame)
}
//Restify functions
function rDir (req, res, next) {
let dir = true
let set = false
@ -279,6 +283,13 @@ function rSequence (req, res, next) {
}
}
//Ble functions
function bFrame (cb) {
console.log(str)
cb({ dir: true, len : 630 })
}
function index (req, res, next) {
fs.readFile(INDEXPATH, 'utf8', (err, data) => {
if (err) {
@ -290,14 +301,9 @@ function index (req, res, next) {
}
function init () {
createServer()
intval.init()
ble = new BLE(() => {
return intval.status()
})
ble.on('data', (str) => {
console.log(str)
})
createServer()
createBLE()
}
init()

View File

@ -171,12 +171,16 @@ class BLE {
return callback(result)
}
utf8 = data.toString('utf8')
console.log(utf8)
obj = JSON.parse(utf8)
console.dir(obj)
result = bleno.Characteristic.RESULT_SUCCESS
if (obj.type && this[`_on${capitalize(obj.type)}`]) {
this[`_on${capitalize(obj.type)}`]( data => {
return callback(result, data.slice(offset, data.length))
})
} else {
return callback(result)
}
}
_onRead (offset, callback) {
const result = bleno.Characteristic.RESULT_SUCCESS
const state = getState()