ble-server/main-service.js

25 lines
597 B
JavaScript
Raw Normal View History

2017-08-09 10:15:07 +00:00
const bleno = require('bleno')
2017-08-10 01:24:14 +00:00
const config = require('./config.json')
2017-08-23 06:51:42 +00:00
const localEvent = require('./localEvent')
2017-08-09 10:15:07 +00:00
2017-08-23 06:51:42 +00:00
// const TimeCharacteristic = require('./time-characteristic')
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-08-23 06:51:42 +00:00
constructor() {
2017-08-09 10:15:07 +00:00
super({
2017-08-10 01:24:14 +00:00
uuid: config.uuid.service.id,
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 06:51:42 +00:00
localEvent.on('printResult', async str => {
dataCharacteristic.sendNotidy(str)
})
2017-08-10 01:24:14 +00:00
module.exports = MainService