evothings / cordova-ble

Bluetooth Low Energy plugin for Cordova
http://www.evothings.com/
Apache License 2.0
243 stars 103 forks source link

Way to detect Bluetooth device is off on an Android? #36

Closed mobilars closed 9 years ago

mobilars commented 10 years ago

I've got a cordova-ble app on an Android (S4) device, and during startup I quite common get the following (see trace below). I think it might be because I commonly do a reset (evothings.ble.reset();) because the whole BLE-stack on Android feels unstable. It seems then that sometimes bluetooth is turned off and not back on, and I think that's the reason why I get the below trace. Is there a way to check whether BLE is on from within Javascript, and possibly turn it on?

D/BluetoothAdapter(18863): stopLeScan() D/BluetoothAdapter(18863): startLeScan(): null E/BluetoothAdapter(18863): E/BluetoothAdapter(18863): android.os.DeadObjectException E/BluetoothAdapter(18863): at android.os.BinderProxy.transact(Native Method ) E/BluetoothAdapter(18863): at android.bluetooth.IBluetoothGatt$Stub$Proxy.r egisterClient(IBluetoothGatt.java:813) E/BluetoothAdapter(18863): at android.bluetooth.BluetoothAdapter.startLeSca n(BluetoothAdapter.java:1680) E/BluetoothAdapter(18863): at android.bluetooth.BluetoothAdapter.startLeSca n(BluetoothAdapter.java:1641) E/BluetoothAdapter(18863): at com.evothings.BLE.startScan(BLE.java:108) E/BluetoothAdapter(18863): at com.evothings.BLE.execute(BLE.java:41) E/BluetoothAdapter(18863): at org.apache.cordova.CordovaPlugin.execute(Cord ovaPlugin.java:84) E/BluetoothAdapter(18863): at org.apache.cordova.CordovaPlugin.execute(Cord ovaPlugin.java:65) E/BluetoothAdapter(18863): at org.apache.cordova.PluginManager.execHelper(P luginManager.java:242) E/BluetoothAdapter(18863): at org.apache.cordova.PluginManager.exec(PluginM anager.java:227) E/BluetoothAdapter(18863): at org.apache.cordova.ExposedJsApi.exec(ExposedJ sApi.java:53) E/BluetoothAdapter(18863): at com.android.org.chromium.base.SystemMessageHa ndler.nativeDoRunLoopOnce(Native Method) E/BluetoothAdapter(18863): at com.android.org.chromium.base.SystemMessageHa ndler.handleMessage(SystemMessageHandler.java:27) E/BluetoothAdapter(18863): at android.os.Handler.dispatchMessage(Handler.ja va:102) E/BluetoothAdapter(18863): at android.os.Looper.loop(Looper.java:157) E/BluetoothAdapter(18863): at android.os.HandlerThread.run(HandlerThread.ja va:61) W/BluetoothAdapter(20010): getBluetoothService() called with no BluetoothManager Callback W/BluetoothAdapter(20010): getBluetoothService() called with no BluetoothManager Callback W/BluetoothAdapter(20010): getBluetoothService() called with no BluetoothManager Callback

mobilars commented 9 years ago

Seems to have been fixed very well in the newest version.