Android write speed is abysmally slow when working with CPro. (Android!!!)
I have been reading that Android has a very poor implementation of Bluetooth Low Energy with a myriad of issues in communicating with BTLE devices and I think I'm experiencing some of those.
I have written an application to use the Metawear CPro. I have compiled versions that work on Win32 and Android. The Windows version starts up and initialises the CPro very rapidly, with little delay between calls to the write_gatt_char routine and starts up the accelerometer (and other modules) just fine. However the Android version is substantially slower.
The time between calls to write_gatt_char during just the initialization of the CPro take between four (4) and five (5) seconds each to complete. With the twenty (20) odd modules that require initialization this can take over a minute and a half to complete. Then when I attempt to turn on the Accelerometer, Android terminates the application as unresponsive. I have tested this on an ASUS Nexus 7 - 2013 (with the Wi-Fi turned off) and a Samsung Galaxy Tab A6 with the same result.
I have tried using
mbl_mw_settings_set_connection_parameters(11.25, 11.25, 0, MAX_TIME_PER_RESPONSE); // I chose 11.25 as I hear this is the minimum speed allowed on Android 6.
to set a low latency time, but I am not sure if this information is stored in the device and sent to Android during connection or at the time of the command is issued, or it survives battery removal, firmware updates or even just reinitialization. Furthermore, as it is part of the settings module (#17 in the sequence) the change can't be made until after initialization which, as described above is slow to begin with. It's a bit of a chicken and the egg problem.
I was reading the adopted bluetooth characteristics and noted that the 0x2A04 is the BTLE service for Peripheral Preferred Connection Parameters which has a signature similar to mbl_mw_settings_set_connection_parameters and thought if this were added in the firmware it would allow me at least to set the preferred speed through this characteristic before attempting initialisation.
Futher, I was reading this page and noted under the section Latency Patch, they resolved the bulk of problems with slow communications on Android by sending a second L2CAP latency request packet (since Android apparently ignores the first) after connecting. As this is part of the BTLE protocol layer I thought perhaps this may help if implemented in the firmware (although I admit my knowledge of this level is extraordinarily limited and I may be talking out my ...)
Can you provide any thoughts or feedback?
I have written an application to use the Metawear CPro. I have compiled versions that work on Win32 and Android. The Windows version starts up and initialises the CPro very rapidly, with little delay between calls to the write_gatt_char routine and starts up the accelerometer (and other modules) just fine. However the Android version is substantially slower.
The time between calls to write_gatt_char during just the initialization of the CPro take between four (4) and five (5) seconds each to complete. With the twenty (20) odd modules that require initialization this can take over a minute and a half to complete. Then when I attempt to turn on the Accelerometer, Android terminates the application as unresponsive. I have tested this on an ASUS Nexus 7 - 2013 (with the Wi-Fi turned off) and a Samsung Galaxy Tab A6 with the same result.
I have tried using
mbl_mw_settings_set_connection_parameters(11.25, 11.25, 0, MAX_TIME_PER_RESPONSE); // I chose 11.25 as I hear this is the minimum speed allowed on Android 6.
to set a low latency time, but I am not sure if this information is stored in the device and sent to Android during connection or at the time of the command is issued, or it survives battery removal, firmware updates or even just reinitialization. Furthermore, as it is part of the settings module (#17 in the sequence) the change can't be made until after initialization which, as described above is slow to begin with. It's a bit of a chicken and the egg problem.
I was reading the adopted bluetooth characteristics and noted that the 0x2A04 is the BTLE service for Peripheral Preferred Connection Parameters which has a signature similar to mbl_mw_settings_set_connection_parameters and thought if this were added in the firmware it would allow me at least to set the preferred speed through this characteristic before attempting initialisation.
Futher, I was reading this page and noted under the section Latency Patch, they resolved the bulk of problems with slow communications on Android by sending a second L2CAP latency request packet (since Android apparently ignores the first) after connecting. As this is part of the BTLE protocol layer I thought perhaps this may help if implemented in the firmware (although I admit my knowledge of this level is extraordinarily limited and I may be talking out my ...)
Can you provide any thoughts or feedback?
This discussion has been closed.
Comments
No I haven't tried a native Android API since I'm trying for a single code base that compiles on desktop's and tablets and it would be impractical other than to experiment to try and adapt it.
Does the Android version of Metawear/Metabase/Metahub use the Android natively or are they also cross platform as I notice that they seem to connect quickly. If they are native, what might be being done natively that may not be happening when using NDK?