cordova插件ble回调的第二个参数怎么用?
How to use the second parameter of callback of cordova plugin ble?
我在从 ble 读取数据时遇到顺序问题。这个问题被引用 here
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 的版本 1.2.4。所以回调有第二个参数是序列号:
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) {});
如何在我的 ionic 应用程序中使用此序列号?
我收到一个 Observable,但我看不到如何访问此参数:
this.ble.startNotification(device.handle,
BSC_SERVICE_UUID,
BSC_OUTPUT_CHARACTERISTIC_UUID).subscribe(y => {
const x = new Uint8Array(y);
....
});
ionic wrapper 仅发出数据数组。我将合并请求推送到 ionic-native 存储库 here。现在版本 5.28.0 发出一个数组,索引 0 是数据,索引 1 是序列 order
我在从 ble 读取数据时遇到顺序问题。这个问题被引用 here
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 的版本 1.2.4。所以回调有第二个参数是序列号:
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) {});
如何在我的 ionic 应用程序中使用此序列号? 我收到一个 Observable,但我看不到如何访问此参数:
this.ble.startNotification(device.handle,
BSC_SERVICE_UUID,
BSC_OUTPUT_CHARACTERISTIC_UUID).subscribe(y => {
const x = new Uint8Array(y);
....
});
ionic wrapper 仅发出数据数组。我将合并请求推送到 ionic-native 存储库 here。现在版本 5.28.0 发出一个数组,索引 0 是数据,索引 1 是序列 order