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) { function rDir (req, res, next) {
let dir = true let dir = true
let set = false 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) { function index (req, res, next) {
fs.readFile(INDEXPATH, 'utf8', (err, data) => { fs.readFile(INDEXPATH, 'utf8', (err, data) => {
if (err) { if (err) {
@ -290,14 +301,9 @@ function index (req, res, next) {
} }
function init () { function init () {
createServer()
intval.init() intval.init()
ble = new BLE(() => { createServer()
return intval.status() createBLE()
})
ble.on('data', (str) => {
console.log(str)
})
} }
init() init()

View File

@ -171,11 +171,15 @@ class BLE {
return callback(result) return callback(result)
} }
utf8 = data.toString('utf8') utf8 = data.toString('utf8')
console.log(utf8)
obj = JSON.parse(utf8) obj = JSON.parse(utf8)
console.dir(obj)
result = bleno.Characteristic.RESULT_SUCCESS result = bleno.Characteristic.RESULT_SUCCESS
return callback(result) 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) { _onRead (offset, callback) {
const result = bleno.Characteristic.RESULT_SUCCESS const result = bleno.Characteristic.RESULT_SUCCESS