问题描述
这是一个安卓问题。使用离子 + 模板项目。 我需要在 BLE.write 之后断开设备并重新连接,所以我在 BLE.write 成功完成后调用这个函数
reconnectDevice(device) {
BLE.disconnect(device.id).then(() => {
BLE.connect(device.id).subscribe(
peripheralData => {
this.device = peripheralData;
localStorage.setItem('device',JSON.stringify(this.device));
error => {
console.log('Error: ',error);
}
}
);
});
}
问题是 BLE.connect 总是返回失败回调,说“外设断开连接”,我不明白为什么。
正如医生所说
https://github.com/don/cordova-plugin-ble-central#connect
The disconnect callback is not called when the application calls ble.disconnect. The disconnect callback is how your app kNows the peripheral inintiated a disconnect.
我看到了关于此的其他问题,但我看到问题已通过提交解决。顺便说一句,我仍然有这个问题,我已经将最后一个插件版本添加到我的项目中。
也许我把这两个函数调用错了?在 ios 上,此代码运行顺利。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)