Push dev work to master #2
|
@ -1,6 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const ipc = require('node-ipc')
|
const ipc = require('node-ipc')
|
||||||
|
const log = require('../log')('ble')
|
||||||
|
|
||||||
function capitalize (s) {
|
function capitalize (s) {
|
||||||
return s[0].toUpperCase() + s.slice(1)
|
return s[0].toUpperCase() + s.slice(1)
|
||||||
|
@ -12,20 +13,20 @@ class Blootstrap {
|
||||||
this._onData = () => {}
|
this._onData = () => {}
|
||||||
ipc.connectTo('blootstrap_ble', () => {
|
ipc.connectTo('blootstrap_ble', () => {
|
||||||
ipc.of.blootstrap_ble.on('connect', () => {
|
ipc.of.blootstrap_ble.on('connect', () => {
|
||||||
ipc.log(`Connected to the blootstrap_ble service`)
|
log.info('connect', `Connected to the blootstrap_ble service`)
|
||||||
|
|
||||||
})
|
})
|
||||||
ipc.of.blootstrap_ble.on('data', data => {
|
ipc.of.blootstrap_ble.on('data', data => {
|
||||||
const str = data.toString()
|
const str = data.toString()
|
||||||
ipc.log(str)
|
log.info('data', str)
|
||||||
this._onData(str)
|
this._onData(str)
|
||||||
})
|
})
|
||||||
ipc.of.blootstrap_ble.on('disconnect', () => {
|
ipc.of.blootstrap_ble.on('disconnect', () => {
|
||||||
ipc.log(`Disconnected from the blootstrap_ble service`)
|
log.info('disconnect', `Disconnected from the blootstrap_ble service`)
|
||||||
})
|
})
|
||||||
ipc.of.blootstrap_ble.on('error', (err) => {
|
ipc.of.blootstrap_ble.on('error', (err) => {
|
||||||
if (err.code === 'EACCES') {
|
if (err.code === 'EACCES') {
|
||||||
console.log(`Cannot access ipc`)
|
log.warn('error', `Cannot access ipc`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue