How do I create a characteristic that changes its value?
reteps opened this issue · 1 comments
reteps commented
I want a read-only characteristic that updates every 30 seconds with a random number. How can I do this @mikolak?
const myCharacteristic = new SimulatedCharacteristic({
uuid: '90',
id: 91,
isReadable: true,
isWritableWithResponse: false,
isWritableWithoutResponse: false,
isNotifiable: false,
value: ???
})
mikolak commented
In the constructor of SimulatedPeripheral you should get a reference to the characteristic you want to modify, set up a connection listener and on connection set up an interval that writes to the characteristic every 30 second, and clear that interval on disconnection.