25 lines
574 B
JavaScript
25 lines
574 B
JavaScript
const bleno = require('bleno')
|
|
const config = require('../config.json')
|
|
const localEvent = require('../localEvent')
|
|
|
|
const GdataCharacteristic = require('./gdata-characteristic')
|
|
const dataCharacteristic = new GdataCharacteristic()
|
|
|
|
class MainService extends bleno.PrimaryService {
|
|
constructor () {
|
|
super({
|
|
uuid: config.ble.uuid.service,
|
|
characteristics: [
|
|
dataCharacteristic
|
|
]
|
|
})
|
|
}
|
|
}
|
|
|
|
localEvent.on('printResult', async state => {
|
|
let str = state ? 'ok' : 'fail'
|
|
dataCharacteristic.sendNotidy(str)
|
|
})
|
|
|
|
module.exports = MainService
|