Issue
I have an issue with sequence order when reading data from ble. This issue is referenced here
The version 1.2.4 of cordova-plugin-ble-central has a new parameter to get the sequence order and leave a chance to the client to reorder the packet. The PR is here. So the callback has a second parameter that is the sequence number:
ble.startNotification("device", "service", "characteristic", function (data, sequence) {
/*
* The sequence parameter will be undefined on iOS. On Android it will be
* monotonically increasing, starting at 0 for the first call to this callback function
* and then increasing by 1 for each callback in order. There will be no gaps in
* the sequence number so it is safe to wait forever for the next expected number.
*
* So, if you receive sequence 0 and then 2, it is guaranteed that 1 has already been
* processed by the plugin and dispatched into a queue for delivery so it will arrive
* to your callback.
*/
}, function (err) {});
How can i use this sequence number in my ionic app? I receive an Observable and I don’t see how access this parameter:
this.ble.startNotification(device.handle,
BSC_SERVICE_UUID,
BSC_OUTPUT_CHARACTERISTIC_UUID).subscribe(y => {
const x = new Uint8Array(y);
....
});
Solution
The ionic wrapper emitted only the data array. I pushed a merged request to ionic-native repository here. Now the version 5.28.0 emit an array with at index 0 the data and at index 1 the sequence order
Answered By - Troopers
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.