I am developing a BLE application on Nexus 4 using Android BLE API. I have a few questions/doubts:
1) Is there a way to set/override the connection or notification interval of BLE central device. I have found that for Android, the default connection interval is fixed to 7.5ms. Is there a way to change this connection/notification delay interval settings.
Source : http://processors.wiki.ti.com/index.php/Bluetooth_SensorTag?DCMP=lprf-stdroid&HQS=lprf-stdroid-pr-wiki1#Supported_Android_devices
2) On connecting to the remote device, I am facing an issue of getting disconnection after random period of time interval. There are many people facing the connection drop issue stating that android is unstable when they are using Android 4.3 API for BLE connection. Is there any solution for this?
EDIT
what else I observe here is when it is taking time to reconnect then it's coming with some L2CAP log ...following the log
Trying to create a new connection laststate_ BOND_NONE D/BluetoothGatt( 9620): connect() - device: 1C:BA:81:11:CA:36, auto: true D/BluetoothGatt( 9620): registerApp() D/BluetoothGatt( 9620): registerApp() - UUID=1a9a0911-4d5c-41dc-8ac0-0284ef550510 D/BtGatt.GattService( 3208): registerClient() - UUID=1adsds0911-4sdsc-41dc-8ac0-0sdsdf550510 D/BtGatt.btif( 3208): btif_gattc_register_app D/BtGatt.btif( 3208): btgattc_handle_event: Event 1000 D/BtGatt.btif( 3208): btif_gattc_upstreams_evt: Event 0 D/BtGatt.GattService( 3208): onClientRegistered() - UUID=1a9a0911-4d5c-41dc-8ac0-0284ef550510, clientIf=5 D/BluetoothGatt( 9620): onClientRegistered() - status=0 clientIf=5 D/BtGatt.GattService( 3208): clientConnect() - address=1C:BA:8C:1E:CA:36, isDirect=true D/BtGatt.btif( 3208): btif_gattc_open D/BtGatt.btif( 3208): btgattc_handle_event: Event 1004 D/BtGatt.btif( 3208): btif_get_device_type: Device [1c:ba:8c:1e:ca:36] type 2, addr. type 0 W/bt-l2cap( 3208): L2CAP - LE - cannot start new connection at conn st: 3
Any idea how can clear cahce mantain by L2CAP?
A BLE connection interval is the time between two data transfer events (BLE connection events) between the central and the peripheral device. The theoretical value ranges from 7.5 ms to 4 secs (with increments of 1.25 ms).
Bluetooth Baseband / Radio For Bluetooth 4.0, the BLE Radio is capable of transmitting 1 symbol per microsecond and one bit of data can be encoded in each symbol. This gives a raw radio bitrate of 1 Megabit per second (Mbps).
The 720 milliseconds are called the “supervision timeout” in BLE and are exchanged between the phone and the peripheral as part of the connection request: The hexadecimal value 0x48 in the red rectangle (decimal 72) is multiplied by 10 milliseconds to define the connection supervision timeout.
x protocol SPEC, when the iPhone/Android phone play as role of BLE central mode, the limitation to have active connection at the same time is up to 8 devices.
When I studied the Android BLE API, I could not find an API for changing the connection interval and supervision timeout (maybe slave latency as well, can't remember from the top of my head). I you do need to change these, you must do it from the slave device.
The answer from Ashwini you can just ignore, what he says is simply not correct. A Bluetooth 4.0 compliant master device must support connection intervals from 7.5 ms up to 4.0s. The slave device may request a change in connection parameters and sends a connection parameter update request, and the master will update the connection parameter accordingly.
On the other hand, the master (in your case the Android device) could have an interest in changing the connection interval on its own, in order to save power, and you would like to change the connection interval to a more relaxed interval.
In my opinion the Android API and even the hardware implementation on several devices are immature and using BLE, in the sense that BLE was intended, draws to much power on an Android device. In the future I believe you will see much better support on the API level and a division of the host and controller so that the controller can maintain connectivity even when the main CPU of the mobile device is sleeping. That will save a lot of power and you can maintain connectivity with your BLE devices 24/7 without any major constrain on you battery life.
@Ashwini : As mentioned in the last comment with connection interval 7.5 it is working better for some amount of time. After some time, the L2CAP issue appears and the connectivity doesnt work unless the bluetooth adapter is reset. Also, a weird behavior is been noticed when the bluetooth adapter is disabled and re-enabled again programtically. We get the following GKI error below:
> /GKI_LINUX( 2232): ##### ERROR : GKI_exception: GKI_exception(): Task State Table > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: TASK ID [0] task name [BTU] state [0] > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: TASK ID [1] task name [BTIF] state [1] > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: TASK ID [2] task name [A2DP-MEDIA] state [1] > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: GKI_exception 65531 Sending to unknown dest##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: > 02-05 15:49:24.466 E/GKI_LINUX( 2232): > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: * GKI_exception(): 65531 Sending to unknown dest > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### > 02-05 15:49:24.466 E/GKI_LINUX( 2232): ##### ERROR : GKI_exception: *************** > 02-05 15:49:24.466 E/GKI_LINUX( 2232): #####
Also, does this createBond API helps in improving the connection with BLE device (which actually doesnt need pairing for connection) ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With