Fixed
Status Update
Comments
ss...@google.com <ss...@google.com> #3
Hi,
Can you provide the below requested information to better understand the issue:
logcat output
Seehttp://developer.android.com/tools/help/logcat.html . Copy and paste relevant sections of the logcat output into this issue.
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Screen capture of the issue
Press the volume down and power buttons simultaneously. The image will appear in your gallery. Attach the screenshot file to this issue.
Note: Please upload the bug report and screenshot to google drive and share the folder to android-bugreport@google.com, then share the link here.
Can you provide the below requested information to better understand the issue:
logcat output
See
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Screen capture of the issue
Press the volume down and power buttons simultaneously. The image will appear in your gallery. Attach the screenshot file to this issue.
Note: Please upload the bug report and screenshot to google drive and share the folder to android-bugreport@google.com, then share the link here.
ss...@google.com <ss...@google.com> #4
Please provide the information requested in previous comment to investigate this issue further.
ph...@gmail.com <ph...@gmail.com> #5
No logs are required to understand this issue, but here you are:
LogCat:
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: connect() - device: E3:EC:B1:48:6D:C2, auto: false
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: registerApp()
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: registerApp() - UUID=bc1025ec-3562-491f-af57-7e50ecd45086
06-20 14:19:16.918 16597-16610/myapp D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-20 14:19:17.763 16597-16609/myapp D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=E3:EC:B1:48:6D:C2
06-20 14:19:17.779 16597-20691/myapp D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=E3:EC:B1:48:6D:C2
06-20 14:19:18.506 16597-16597/myapp D/BluetoothGatt: discoverServices() - device: E3:EC:B1:48:6D:C2
06-20 14:19:18.512 16597-16609/myapp D/BluetoothGatt: onSearchComplete() = Device=E3:EC:B1:48:6D:C2 Status=0
// Shortly after service discovery ended I turn off the connected nRF51 device.
// I wait for the Disconnect event for more than 20 seconds.
06-20 14:19:40.340 16597-16609/myapp D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=E3:EC:B1:48:6D:C2
06-20 14:19:40.342 16597-20025/myapp D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=6 device=E3:EC:B1:48:6D:C2
06-20 14:19:40.372 16597-20025/myapp E/BluetoothLeBasicConn: Connection state changing error: 8
Also I've attached the Bluetooth HCI log.
LogCat:
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: connect() - device: E3:EC:B1:48:6D:C2, auto: false
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: registerApp()
06-20 14:19:16.916 16597-16597/myapp D/BluetoothGatt: registerApp() - UUID=bc1025ec-3562-491f-af57-7e50ecd45086
06-20 14:19:16.918 16597-16610/myapp D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-20 14:19:17.763 16597-16609/myapp D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=E3:EC:B1:48:6D:C2
06-20 14:19:17.779 16597-20691/myapp D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=E3:EC:B1:48:6D:C2
06-20 14:19:18.506 16597-16597/myapp D/BluetoothGatt: discoverServices() - device: E3:EC:B1:48:6D:C2
06-20 14:19:18.512 16597-16609/myapp D/BluetoothGatt: onSearchComplete() = Device=E3:EC:B1:48:6D:C2 Status=0
// Shortly after service discovery ended I turn off the connected nRF51 device.
// I wait for the Disconnect event for more than 20 seconds.
06-20 14:19:40.340 16597-16609/myapp D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=E3:EC:B1:48:6D:C2
06-20 14:19:40.342 16597-20025/myapp D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=6 device=E3:EC:B1:48:6D:C2
06-20 14:19:40.372 16597-20025/myapp E/BluetoothLeBasicConn: Connection state changing error: 8
Also I've attached the Bluetooth HCI log.
ph...@gmail.com <ph...@gmail.com> #6
PS. The last LogCat and snoop_hci log were created on Nexus 6P, Android N preview 4, so it does not look fixed.
Please, tag it with Preview N tag.
Please, tag it with Preview N tag.
em...@gmail.com <em...@gmail.com> #7
I agree that 20 seconds is quite much for a default supervision timeout. Apple has 720 ms as default timeout I think (which I on the other hand think is a bit low).
I think 4 seconds would be quite good. If it does not receive any packets within 4 seconds it's quite likely it won't receive any other packet in the next 15 seconds anyway.
As said by the others, no logs are needed for this issue since it is not really a bug but rather an improvement suggestion.
I think 4 seconds would be quite good. If it does not receive any packets within 4 seconds it's quite likely it won't receive any other packet in the next 15 seconds anyway.
As said by the others, no logs are needed for this issue since it is not really a bug but rather an improvement suggestion.
ov...@gmail.com <ov...@gmail.com> #8
Hi,
I also encounter this problem.
I suggest Android could provide an API for developer to
change BLE Supervision Timeout.
I also encounter this problem.
I suggest Android could provide an API for developer to
change BLE Supervision Timeout.
ar...@google.com <ar...@google.com> #9
Please provide bugreport requested in comment #2 to investigate further.
em...@gmail.com <em...@gmail.com> #11
Kind of same thing here: https://code.google.com/p/android/issues/detail?id=222238
A difference is that in this report (197129) the reporter initially also reported that the peripheral preferred connection parameters are not followed, which is rather more a feature request since following that is optional.
A difference is that in this report (197129) the reporter initially also reported that the peripheral preferred connection parameters are not followed, which is rather more a feature request since following that is optional.
ar...@google.com <ar...@google.com> #12
We have passed this request on to the development team and will update with more information as it becomes available.
td...@gmail.com <td...@gmail.com> #14
Philip, I think that value is the default when connectionParameterUpdate() is called. The *initial* default is here:
http://androidxref.com/7.0.0_r1/xref/system/bt/stack/include/btm_ble_api.h#182
#define BTM_BLE_CONN_TIMEOUT_DEF 2000
A reasonable fix is:
1. Change BTM_BLE_CONN_TIMEOUT_DEF to 100 (1 second)
2. Change connectionParameterUpdate() to get the timeout from a resource, like the other connection parameters (why they didn't do that in the first place is a mystery).
3. Set the timeouts for the different connection priorities to sensible defaults.
The values are here by the way:https://android.googlesource.com/platform/packages/apps/Bluetooth/+/master/res/values/config.xml
<!-- Specifies the min/max connection interval parameters for high priority,
balanced and low power GATT configurations. These values are in
multiples of 1.25ms. -->
<integer name="gatt_high_priority_min_interval">9</integer>
<integer name="gatt_high_priority_max_interval">12</integer>
<!-- Default specs recommended interval is 30 (24 * 1.25) -> 50 (40 * 1.25)
ms. -->
<integer name="gatt_balanced_priority_min_interval">24</integer>
<integer name="gatt_balanced_priority_max_interval">40</integer>
<integer name="gatt_low_power_min_interval">80</integer>
<integer name="gatt_low_power_max_interval">100</integer>
<!-- Specifies latency parameters for high priority, balanced and low power
GATT configurations. These values represents the number of packets a
slave device is allowed to skip. -->
<integer name="gatt_high_priority_latency">0</integer>
<integer name="gatt_balanced_priority_latency">0</integer>
<integer name="gatt_low_power_latency">2</integer>
<!-- These should be added -->
<!-- Connection supervision timeout multipliers (the timeout in units of 10 ms). -->
<integer name="gatt_high_priority_timeout">100</integer>
<integer name="gatt_balanced_priority_timeout">100</integer>
<integer name="gatt_low_power_timeout">200</integer>
Apple have guidelines for how to choose these. Note that the connection timeout should never be more than 6 seconds.
See section 3.6 here:https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf
#define BTM_BLE_CONN_TIMEOUT_DEF 2000
A reasonable fix is:
1. Change BTM_BLE_CONN_TIMEOUT_DEF to 100 (1 second)
2. Change connectionParameterUpdate() to get the timeout from a resource, like the other connection parameters (why they didn't do that in the first place is a mystery).
3. Set the timeouts for the different connection priorities to sensible defaults.
The values are here by the way:
<!-- Specifies the min/max connection interval parameters for high priority,
balanced and low power GATT configurations. These values are in
multiples of 1.25ms. -->
<integer name="gatt_high_priority_min_interval">9</integer>
<integer name="gatt_high_priority_max_interval">12</integer>
<!-- Default specs recommended interval is 30 (24 * 1.25) -> 50 (40 * 1.25)
ms. -->
<integer name="gatt_balanced_priority_min_interval">24</integer>
<integer name="gatt_balanced_priority_max_interval">40</integer>
<integer name="gatt_low_power_min_interval">80</integer>
<integer name="gatt_low_power_max_interval">100</integer>
<!-- Specifies latency parameters for high priority, balanced and low power
GATT configurations. These values represents the number of packets a
slave device is allowed to skip. -->
<integer name="gatt_high_priority_latency">0</integer>
<integer name="gatt_balanced_priority_latency">0</integer>
<integer name="gatt_low_power_latency">2</integer>
<!-- These should be added -->
<!-- Connection supervision timeout multipliers (the timeout in units of 10 ms). -->
<integer name="gatt_high_priority_timeout">100</integer>
<integer name="gatt_balanced_priority_timeout">100</integer>
<integer name="gatt_low_power_timeout">200</integer>
Apple have guidelines for how to choose these. Note that the connection timeout should never be more than 6 seconds.
See section 3.6 here:
ca...@gmail.com <ca...@gmail.com> #15
Original value discussed was in this line in the code:
https://android.googlesource.com/platform/packages/apps/Bluetooth/+/d828b42ed91213bd6115b84bc16809f13fc7afe6/src/com/android/bluetooth/gatt/GattService.java#1614
Most recent value as I write this (Android Oreo) seems to be here:
https://android.googlesource.com/platform/packages/apps/Bluetooth/+/7d0fe2d612a7cc522af1ee3837e3b96d27b58a33/src/com/android/bluetooth/gatt/GattService.java#2064
The timeout still seems to start at 20 seconds as far as I can see :(
Most recent value as I write this (Android Oreo) seems to be here:
The timeout still seems to start at 20 seconds as far as I can see :(
ma...@gmail.com <ma...@gmail.com> #16
It is sp 2018 and the timeout it still 20 , Google Developers team please change one line of code.
al...@classycode.com <al...@classycode.com> #17
#16 Google has zero interest in BLE. :-(
is...@google.com <is...@google.com>
gb...@gmail.com <gb...@gmail.com> #18
A trick I have used to detect that it has been disconnected is to read the RSSI value every second, if the value has not changed in the last 4 seconds, I read the RSSI several times with a delay of milliseconds, with this I confirm that the device is disconnected because the RSSI has been frozen. It's the best thing that has occurred to me until the android developers decide to get to work on this.
jp...@google.com <jp...@google.com> #19
connection timeout was lowered to 5 seconds.
jp...@google.com <jp...@google.com> #20
One more note: Remote device can still request connection parameter update to change the timeout if needed for particular use case.
td...@gmail.com <td...@gmail.com> #22
Ha miracles do happen! I think 5 seconds is still a quite long (ideally it would be configurable) but it is much better than 20 seconds.
jp...@google.com <jp...@google.com> #23
As I mentioned in #20, remote can request whatever timeout it wants, and we will accept this value.
td...@gmail.com <td...@gmail.com> #24
Yeah I meant the app should be able to do it. It's very common not to be in control of the peripheral.
jm...@gmail.com <jm...@gmail.com> #25
In an Android to Android connection, will the timeout be controlled by the initiator, the respondent, the shorter of the two, or the longer of the two, or will it be different on each side? I'd also like to cast my vote for some level of app control if possible, but this is a very positive development regardless.
[Deleted User] <[Deleted User]> #26
Woot!
Description
Tested on nRF51 DK with sample HeartRateService application.
Tested using nRF Master Control Panel app on Android.
I connect to a BLE device from the phone using any app.
I turn off the connected device, or go out of range.
It takes around 20 seconds for the Android to send the disconnect (with status = 8 (GATT CONN TIMEOUT)) event.
The timeout is too long for many use cases. The bus can go far away with your keys in 20 seconds...
The Supervision Timeout Multiplier in the PPCP characteristic in my case is 400 which means that the disconnection should be reported after 400x10ms = 4 sec, not ~20 sec.