Open Jai-GAY opened 7 years ago
further search found this could help some diagnostics. from the app screenshot, faster discovery device has the Slave Connection Interval Range. Our prototype using nRF51 DK Development Kit for Bluetooth (slow) does not has the Slave Connection Interval Range, is it due to this problem that our prototype has a slow connection + service discovery connection speed ? right now we are not sure where Nordic's employee recommends the way to speed up service discovery is to reduce the connection interval when doing service discovery. we are still exploring where to change it and what does Master here means ?
any suggestions or guidance are welcome.
nRF Connect for mobile (previously called nRF Master Control Panel) and Increase Service Discovery Speed by Master Why service discovery command of BLE takes a lot of time?
Please create a case on devzone when you have a question. You can request higher priority connection using requestConnectionPriority, See here: https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#requestConnectionPriority(int)
not helpful.
02-08 17:25:18.854 D/BluetoothGatt: requestConnectionPriority() - params: 1 02-08 17:25:18.856 D/UartService: discoverServices requestConnectionPriority 02-08 17:25:18.857 D/BluetoothGatt: discoverServices() - device: F7:73:DE:00:4D:DE 02-08 17:25:18.859 I/UartService: Attempting to start service discovery:true 02-08 17:25:24.436 D/BluetoothGatt: onSearchComplete() = Device=F7:73:DE:00:4D:DE Status=0 02-08 17:25:24.436 W/UartService: onServicesDiscovered mBluetoothGatt = android.bluetooth.BluetoothGatt@dacc29d 02-08 17:25:24.436 D/UartService: broadcastUpdate 1 02-08 17:25:24.448 D/BLE_com: ACTION_GATT_SERVICES_DISCOVERED
Hi, first of all, it of course depends on number of services and characteristics on your device. Secondly, before Android 5 the minimum Conn Interval was 7.5ms, after that it's 11.5ms. Also, when your device chooses min and max interval, it probably uses the max one to lower battery consumption. You'd have to use sniffer to check what's going on there. Try setting lower connection interval at the beginning and after service discovery switching it back to power saving.
Also, those 50s on your photos is set in the adv packet. You may write the any value you want, it doesn't matter for the connection actually, just like the complete local name. You have to set the proper constants (defines) in your project instead. Afair they are in main.c.
You may read the proper ones from Connection Parameters characteristic in the Generic Access service.
still not very useful no matter how early i set requestConnectionPriority. from 4.20 CONNECTION PARAMETER UPDATE REQUEST (CODE0x12) it seems to us that the LE slave play a part to speed up the discovery process. i verified this on a Android 4.4.2 phone running nRF Connect and repeat the steps on our prototype (using nRF51 DK) and one equipment we brought from the market. the speed that we brought from the market is still the same compared to using Android 5.x or 6.x phones running nRF Connect.
we like to know / confirm where should we exactly tune it (Phone / LE slave) before we put resource to investigate, understand and modify it. we hope to hear concrete sharing from experts as we have limited resources and new in BLE.
02-09 10:00:09.242 D/BluetoothGatt: connect() - device: F7:73:DE:00:4D:DE, auto: false 02-09 10:00:09.242 D/BluetoothGatt: registerApp() 02-09 10:00:09.242 D/BluetoothGatt: registerApp() - UUID=58a31293-5d05-445c-9495-21f01e0324ae 02-09 10:00:09.244 D/UartService: Trying to create a new connection. 02-09 10:00:09.244 D/BluetoothGatt: requestConnectionPriority() - params: 1 02-09 10:00:09.244 D/UartService: discoverServices requestConnectionPriority 02-09 10:00:09.245 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5 02-09 10:00:09.897 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=F7:73:DE:00:4D:DE 02-09 10:00:09.897 D/UartService: onConnectionStateChange state = 2 02-09 10:00:09.898 D/UartService: broadcastUpdate 1 02-09 10:00:09.898 I/UartService: Connected to GATT server. 02-09 10:00:09.902 D/BLE_com: ACTION_GATT_CONNECTED 02-09 10:00:09.903 D/BluetoothGatt: discoverServices() - device: F7:73:DE:00:4D:DE 02-09 10:00:09.905 I/UartService: Attempting to start service discovery:true 02-09 10:00:15.609 D/BluetoothGatt: onSearchComplete() = Device=F7:73:DE:00:4D:DE Status=0 02-09 10:00:15.609 W/UartService: onServicesDiscovered mBluetoothGatt = android.bluetooth.BluetoothGatt@83ec228 02-09 10:00:15.610 D/UartService: broadcastUpdate 1 02-09 10:00:15.611 D/BluetoothGatt: requestConnectionPriority() - params: 0 02-09 10:00:15.613 D/UartService: onServicesDiscovered requestConnectionPriority 02-09 10:00:15.625 D/BLE_com: ACTION_GATT_SERVICES_DISCOVERED
As you know there is no callback for requesting connection parameters in Android. It's a bug and will hopefully be fixed one day. Until then you have know what the actual interval is. Target device may reject request from the master. So I'd recommend to configure it on the peripheral side. Actually, as far as I remember, when I was testing some samples from the SDK, newer Androids send this request on their own before Service Discovery and then after. Perhaps your device rejects it? You'd have to sniff the communication. You may enable hci log in Android Bluetooth settings, do connection, turn off hci log and you'll find a file hci snoop log in the main folder. You may then open it using Wireshark.
from this log it shows that from mBluetoothGatt.discoverServices() to public void onServicesDiscovered(BluetoothGatt gatt, int status) callback took about 6 seconds for android 6.0.1 & 5.x. for android 4.4.2 it takes about 10 seconds, for android 4.3 about 1 second.
i like to know is there way to control / improve it ?
12:02:41.642 D/BluetoothGatt: connect() - device: F7:73:DE:00:4D:DE, auto: false 12:02:41.642 D/BluetoothGatt: registerApp() 12:02:41.642 D/BluetoothGatt: registerApp() - UUID=8a45498c-dcdf-4987-970d-0395638f72c6 12:02:41.644 D/UartService: Trying to create a new connection. 12:02:41.644 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5 12:02:42.775 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=F7:73:DE:00:4D:DE 12:02:42.775 D/UartService: onConnectionStateChange state = 2 12:02:42.777 D/UartService: broadcastUpdate 1 12:02:42.777 I/UartService: Connected to GATT server. 12:02:42.796 D/BluetoothGatt: discoverServices() - device: F7:73:DE:00:4D:DE 12:02:42.801 I/UartService: Attempting to start service discovery:true 12:02:48.298 D/BluetoothGatt: onSearchComplete() = Device=F7:73:DE:00:4D:DE Status=0 12:02:48.298 W/UartService: mBluetoothGatt = android.bluetooth.BluetoothGatt@ace296b 12:02:48.299 D/UartService: broadcastUpdate 1 12:02:48.304 D/BLE_com: ACTION_GATT_SERVICES_DISCOVERED