ble-server/time-characteristic.js

25 lines
545 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-09 10:15:07 +00:00
class TimeCharacteristic extends bleno.Characteristic {
constructor() {
super({
2017-08-10 01:24:14 +00:00
uuid: config.uuid.service.func.time,
2017-08-09 10:15:07 +00:00
properties: ['read'],
descriptors: [
new bleno.Descriptor({
uuid: '88ff',
value: 'Now Time'
})
]
})
}
onReadRequest(offset, callback) {
console.log(`offset :: ${offset}`)
callback(this.RESULT_SUCCESS, new Buffer(`${Date.now()}`))
}
}
2017-08-10 01:24:14 +00:00
module.exports = TimeCharacteristic