Reputation: 21
I working on transfering files from smartphone to peripheral device over BLE.
Sending data over BLE is slow (data transfer is being implemented using overwriting one 20 bytes long characterisc). Slow speed is not a problem, because the size of files is really small also (up to 1MB).
In trivial tests everything works good. As long as I try to run file transfer automatically in a loop (e.g. leave it running over night jsut for test purposes), on device with Bluetooth standard 4.2 after short time Android is spamming following content into Logcat :
01-24 13:44:08.411 1002 2449 10116 D [email protected]_controller: ReportSocFailure
01-24 13:44:08.411 1002 2449 10116 D [email protected]_controller: ReportSocFailure send soc failure
01-24 13:44:08.411 1002 2449 10116 E [email protected]_controller: Error reading data from uart
After seconds of spamming this output, following output is written to Logcat, signalising that Bluetooth is being stopped / restarted
1-24 13:44:08.428 1002 2449 2449 W [email protected]_fd_watcher: StopThread: stopped the work thread
01-24 13:44:08.428 1002 2449 2449 D [email protected]_transport: userial clock off
01-24 13:44:38.527 1002 2449 2449 I [email protected]_transport: DeInitTransport: Transport is being closed!
01-24 13:44:38.528 1002 2449 2449 D [email protected]_manager: SetPower: enable: 0
01-24 13:44:38.529 1002 2449 2449 D [email protected]_manager: GetRfkillFd: rfkill_fd: 9
01-24 13:44:38.529 1002 2449 2449 D [email protected]_manager: ControlRfkill: rfkill_fd: 9, enable: 0
01-24 13:44:38.637 1002 2449 2449 W [email protected]_handler: controller Cleanup done
01-24 13:44:38.638 1002 2449 2449 I [email protected]_handler: DataHandler:: joined Init thread
01-24 13:44:38.638 1002 2449 2449 E [email protected]_lock: Release wake lock not initialized/acquired
01-24 13:44:38.638 1002 2449 2449 D [email protected]_lock: CleanUp wakelock is destroyed
01-24 13:44:38.638 1002 2449 2449 W [email protected]_hci: BluetoothHci::close, finish cleanup
01-24 13:44:38.713 u0_a3 3430 3430 D BluetoothSap: Proxy object disconnected
01-24 13:44:38.715 1000 26585 26585 D A2dpProfile: Bluetooth service disconnected
01-24 13:44:38.716 1000 26585 26585 D BluetoothSap: Proxy object disconnected
01-24 13:44:38.718 1000 26585 26585 D SapProfile: Bluetooth service disconnected
01-24 13:44:38.719 1000 26585 26585 D BluetoothInputDevice: Proxy object disconnected
01-24 13:44:38.719 10137 28340 28340 D BluetoothInputDevice: Proxy object disconnected
After these events, service that is used to write out data is restarted, my guess is that because bluetooth module on device is restarted also.
On device with Bluetooth standard 4.0 everything runs OK, I could leave the constant file transfer running for a day and crash will not occur.
Do you please have any ideas or suggestion why this happens ? For interaction with bluetooth adapter I use library RxBle
https://github.com/Polidea/RxAndroidBle
Thanks.
Upvotes: 1
Views: 1587
Reputation: 21
FYI - I have found in issue tracking system of BLE Kotlin Coroutines library similar issue to one I have - my error message exactly matches to error messages reported here :
Problem with file transfer over BLE on Android
In the description of the given issue, it is stated that the issue occurred on device Samsung Galaxy A5, which was exactly the device I was using.
So I have come to the conclusion that this issue is probably related to this specific device, as long as I can run FW updates continuously on multiple different phones without a problem. I have not investigated further.
My solution for this is - when applying update for whatever reason fails(BT error, the battery runs out, the device will go out of BT range), everything will be reset and the update will try to run again. You just cannot predict if/how/when will different devices misbehave - the solution is not to try to patch all possible errors that can occur but give system abitity to recover from the error.
Upvotes: 1
Reputation: 31
from Android api level 21 onwards you have the ability to request a larger MTU size from the peripheral device you are sending to as mentioned here. This will allow you to send up to a packet of 517 bytes and this makes your transfer relatively faster than sending oackets of 20 bytes. However this is possible only if your ble device supports a larger MTU size. If you plan to do firmware updates I would suggest both your peripheral device and the smart phone app should use a proper firmware update protocol and that may also depend on the manufacturer of the bluetooth chip used on your peripheral device. Hope this helps.
Upvotes: 3