ble-server/gdata-characteristic.js

26 lines
602 B
JavaScript

const bleno = require('bleno')
class DataCharacteristic extends bleno.Characteristic {
constructor() {
super({
uuid: '8787',
properties: ['write', 'writeWithoutResponse'],
descriptors: [
new bleno.Descriptor({
uuid: '8888',
value: 'Now'
})
]
})
}
onWriteRequest(data, offset, withoutResponse, callback) {
console.log(`offset :: ${offset} , withoutRes :: ${withoutResponse}`)
console.log(`get data`, data)
if (withoutResponse) {
callback(this.RESULT_SUCCESS)
}
}
}
module.exports = DataCharacteristic