ble-server/time-characteristic.js
2017-08-10 09:24:14 +08:00

25 lines
545 B
JavaScript

const bleno = require('bleno')
const config = require('./config.json')
class TimeCharacteristic extends bleno.Characteristic {
constructor() {
super({
uuid: config.uuid.service.func.time,
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()}`))
}
}
module.exports = TimeCharacteristic