简体   繁体   English

cordova 插件 ble-central 的问题

[英]Issue with the cordova plugin ble-central

I'm new in the world of the Ionic framework and I'm developing an Ionic app using bluetooth-low-energy (the cordova plugin ble-central).我是 Ionic 框架世界的新手,我正在使用蓝牙低能耗(cordova 插件 ble-central)开发一个 Ionic 应用程序。 Everything has worked well until two days ago.直到两天前,一切都运行良好。 Now, the scan() function doesn't work anymore.现在, scan() function 不再起作用了。 The function is correctly called and the bluetooth and location permission are allowed.正确调用了function,允许蓝牙和定位权限。 I've made no changes on my code that would explain this issue.我没有对我的代码进行任何更改来解释这个问题。 I've also tried to uninstall/install the app, reboot my android phone and also used another phone.我也试过卸载/安装应用程序,重启我的 android 手机,还使用了另一部手机。 Nothing work.没有工作。

Below a snips of my manifest:下面是我的清单的片段:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature android:name="android.hardware.location.gps" />

and the bluetooth code:和蓝牙代码:

this.ble.scan([], 5).subscribe( 
              device => 
                  this.onDeviceDiscovered(device),// Never reached
              error => { 
                  this.scanError(error).catch(e => console.log('scan error ' + e)); // Never reached
              },
              () => console.log('completed')); // Never reached


          // Debug
          setTimeout(this.setStatus.bind(this), 6000, 'Scan completed');

The function setStatus is for debugging. function setStatus用于调试。

I've read and tried a lot of things but nothing work.我已经阅读并尝试了很多东西,但没有任何效果。 Thanks for your help!谢谢你的帮助!

PS: Of course, the bluetooth and the gps are active when I'm using my app. PS:当然,当我使用我的应用程序时,蓝牙和 gps 是活动的。

Since android api 29, ACCESS_FINE_LOCATION permission is used instead of ACCESS_COARSE_LOCATION.自 android api 29 起,使用 ACCESS_FINE_LOCATION 权限代替 ACCESS_COARSE_LOCATION。 The mantainer of cordova-plugin-ble-central have not accepted a pull request that correct this issue yet. cordova-plugin-ble-central 的维护者尚未接受纠正此问题的拉取请求。

I did the necessary changes on my fork and it is working fine now on android 10, api 29...我对叉子进行了必要的更改,现在它在 android 10、api 29 上运行良好...

Maybe you can use it by removing the old:也许您可以通过删除旧的来使用它:

ionic cordova plugin rm cordova-plugin-ble-central

And adding my fork:并添加我的叉子:

ionic cordova plugin add git+https://github.com/dslima90/cordova-plugin-ble-central.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM