2017-08-09 10:15:07 +00:00
|
|
|
const bleno = require('bleno')
|
2017-09-07 15:40:51 +00:00
|
|
|
const config = require('../config.json')
|
|
|
|
const localEvent = require('../localEvent')
|
2017-08-09 10:15:07 +00:00
|
|
|
|
|
|
|
const GdataCharacteristic = require('./gdata-characteristic')
|
2017-08-23 06:51:42 +00:00
|
|
|
const dataCharacteristic = new GdataCharacteristic()
|
2017-08-09 10:15:07 +00:00
|
|
|
|
|
|
|
class MainService extends bleno.PrimaryService {
|
2017-09-05 10:36:35 +00:00
|
|
|
constructor () {
|
2017-08-09 10:15:07 +00:00
|
|
|
super({
|
2017-09-07 15:40:51 +00:00
|
|
|
uuid: config.ble.uuid.service,
|
2017-08-09 10:15:07 +00:00
|
|
|
characteristics: [
|
2017-08-23 06:51:42 +00:00
|
|
|
dataCharacteristic
|
2017-08-09 10:15:07 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 15:31:25 +00:00
|
|
|
localEvent.on('printResult', async state => {
|
|
|
|
let str = state ? 'ok' : 'fail'
|
2017-08-23 06:51:42 +00:00
|
|
|
dataCharacteristic.sendNotidy(str)
|
|
|
|
})
|
|
|
|
|
2017-08-10 01:24:14 +00:00
|
|
|
module.exports = MainService
|