Bluetooth Service - android

I have a problem with an android app that use bluetooth to communicate with other devices.
The problem is after some times (days) the bluetooth seem not work anymore but in the app seems to be on (the bluetooth manager tell me is on) but doesn't find any bluetooth devices. If I restart the app nothing change, the behaviour is the same. But if I reboot the device the app start work properly.
I download the log with the logcat command via adb and before the problem start I see a lot of lines of this type:
MediaRouterService: restoreBluetoothA2dp(false)
How I could resolve this problem without reboot the device?
I try to restart the app without success
I restart the devices and the app and it works as espected

Related

Android BLE not reading/writing nothing sometimes, restarts working after using a third-party app

I'm trying to develop an android app to connect to a BLE device. The app works fine, but sometimes (maybe becouse of a connection fail) every "onDescriptorRead", "onDescriptorWrite", "onCharacteristicWrite", etc. have status: 1 and nothing works.
When this happens, nothing solves the problem, i've tried restarting bluetooh on my phone, restarting the phone and restarting the BLE device. After a lot of tryes i found something that solve the problem:
Using this third-party app:
https://play.google.com/store/apps/details?id=com.macdom.ble.blescanner
I close my app, than I open the BLE Scanner app and through it I disconnect and reconnect my device. Then if I return to my app, everything returns to work as aspected.
The question is: what is this app doing to my phone (maybe a particular method to disconnect the BLE device) that is restoring a working connection?

Can't disconnect BLE devices when killing the app with background plugin on

I'm developing an app that interfaces with BLE devices using this plugin.
Inside the app, I can pair the devices and monitor their status.
If I close the app I want to disconnect the devices from the smartphone, and when I open it again, I want the app to reconnect automatically to known devices.
Everything works fine without using the background plugin, but I need to use it since the app needs to monitor the BLE devices even when it's in the background.
The problem happens ONLY if I use the background plugin: if I open again the app, the known devices are not reconnected INSIDE the app, but it appears they are already/still connected to the smartphone from the previous time (even if not shown in the Bluetooth devices in the phone settings).
It seems that the Bluetooth connection to known devices isn't really being closed when I kill the app.
It appears like the device is still connected as therefore it doesn't show up when I scan in the app.
I can't reconnect until I close the app, switch off and then on again Bluetooth, and reopen the app.
The steps are very simples:
I open and connect the first time from the phone to the BLE product
Communication is OK, data is sent and received
I close (kill) the application from the smartphone (Without turning off Bluetooth/BLE from smartphone)
I relaunch the application ---> Known device is not reconnected but appears to be somehow still paired with the phone (if I press the pairing button it does not go into pairing mode, that happens if it is already bonded to a phone).
Why this behavior? Looks like something in the background plugin prevents the Bluetooth connection to be closed on app closing. I specify that:
it only occurs using the background plugin, without it activated everything works ok
this behavior occurs only with Android (don't use the background plugin for iOS)
it does happen only on some Android smartphones: tried three different phones, with Android version v4.4, v5.1.1, and v6.0.1, and only two of them show this issue (android version 4.4 on S3 and 6.0.1 on S5 Neo).
Thanks

Debug application over internet using eclipse

I have the following problem:
My phones USB port is broken and I have no way of running app on the phone other than sending it over bluetooth and install it every time I make changes to the code. So every time I make changes, I gotta spend min+ to see them in action. I don't want to use emulator.
Is there a way I can make eclipse run my app on the phone over the internet when I build/run the app the same way it does over USB? Thanks!

Android BLE Re Connectivity Issue

I have and Android device to connect to a BLE Device. If I restart the android device it connects straight away and works fine. After If I close the app and start again, It will connect but never get any characteristic change notification.
When I close the app and start again it mostly works.
And if I go to Bluetooth settings and turn off the Bluetooth and turn it on back, In this case as well the application connects directly and works fine.
I close and clean all related resources properly and exit properly, and I don't see the app in DDMS as well.
But it seems even then the at driver level, it is still connected and BLE device still sending data.
Thanks
when reconnecting a remote device the connection remains inside of onClientRegistered() method and it takes a lot of time to reconnect or does not finish to establish the connection, I think is probably an android issue. Regards
It has been a long time and this was a bit frustrating. The problem is because of the Notifications.
The problem can be on either/both ends that is Android or BLE Device.
But the rule is as the best thing I figured out is to make sure I disable all notifications before exiting the application. So, the driver level or BLE device doesn't keep hanging in the older connection...
One should do that not only for Android side but also disable on BLE device side using
protected static final UUID CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
This worked for me :)

Motorola Bluetooth Low energy readGattCharacterisitics does not return

I'm working on developing an android application on Motorola Razr phone (running android version 2.3.5) for testing Bluetooth low energy device (similar to keyfob of TI's CC2540). I'm using the MOT_BTLE_Stubs.jar provided by Motorola for my application.
From my application, I'm able to connect to the device. But readGattCharacteristicValue does not seem to be working, which was working sometime back. I'm trying to read the value from a handle. It used to return the value everytime I read in the broadcast receiver. But now it does not respond. I've added an intent filter to receive the ACTION_GATT_CHARACTERISTICS_READ. It does not return the value in broadcast receiver.
I reverted back the old code. It does not work anymore. Looks like there is some configuration problem in the blue tooth settings on the phone. I'm unable to flush the cache contents.
If anyone has faced the same issue and have resolved it please let me know the solution.
I am using the ICS_R2, so no help there. But to flush the cache, root the phone, and delete /data/misc/bluetoothd, then reboot the phone:
adb shell
su
busybox rm -rf /data/misc/bluetoothd
adb reboot

Categories

Resources