noble / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
MIT License
2.12k stars 447 forks source link

Call updateValueCallback from outside bleno #476

Closed robot2015 closed 2 years ago

robot2015 commented 2 years ago

Is it possible to trigger updateValueCallback from outside bleno.Characteristic? For example: user pushes a button on the peripheral device, triggering the call to updateValueCallback.

I checked the pizza and echo examples, and both call updateValueCallback within bleno.Characteristic.

I also checked SO post: How to implement update value callback when peripheral itself is changing the characteristic value. Here, setInterval is called to check if the value has changed. If yes, then call updateValueCallback. This seems inefficient. Is there a better way?

Thanks!

robot2015 commented 2 years ago

Nevermind. I used an EventEmitter as in pizza-bake-characteristic.js example.