noble / bleno

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

value sent several times on read request #452

Open abelhoui opened 4 years ago

abelhoui commented 4 years ago

Hi all,

I've been working on bleno to implement a peripheral BLE device, and i'm now facing a problem when i execute the read request from my phone using a ble scanner app, to read a characteristic value from my peripheral device which is a rpi running a BLE peripheral demo using bleno : the value is sent several times when the value size exceeds some particular number of bytes !!!

`var vehicle_id = 'ivESK_Wagen 1.03'

var vehicle_id_buf = Buffer.from(vehicle_id);

VehicleIDCharacteristic.prototype.onReadRequest = function(offset, callback) { callback(this.RESULT_SUCCESS, vehicle_id_buf); }; ` ++++exemple 2:

`var vehicle_id = 'ivESK_Wagen 1.03 : here we are running a read test for the vehicle_id read operation'

var vehicle_id_buf = Buffer.from(vehicle_id);

VehicleIDCharacteristic.prototype.onReadRequest = function(offset, callback) { callback(this.RESULT_SUCCESS, vehicle_id_buf); }; `

Thanks !

aptarmy commented 4 years ago

Any update on this? I am facing the same issue on my Raspi Zero W. With few bytes response onRead, the library works very well, but if Raspi peripheral response is exceeded some number of bytes, onRead method get called several times.

abelhoui commented 4 years ago

Any update on this? I am facing the same issue on my Raspi Zero W. With few bytes response onRead, the library works very well, but if Raspi peripheral response is exceeded some number of bytes, onRead method get called several times.

Heyy @aptarmy yeah that's due to Ble limitation you cannot send more than 21 bytes at time so you should use fragmentation for that. check the link below: https://github.com/noble/bleno/blob/master/test.js#L36

aptarmy commented 4 years ago

Thank you so much