Search code examples
androidbluetoothandroid-sourcebluetooth-lowenergy

Bluedroid: How to send LL_CONNECTION_UPDATE_REQ


I want to force send a LL_CONNECTION_UPDATE_REQ to a slave with some specific connection parameters. How do I achieve this in Bluedroid? Is it possible from Bluedroid?

Target: AOSP v5.1+


Solution

  • By calling function btsnd_hcic_ble_upd_ll_conn_params() [in l2c_ble.c] Function is defined in hciblecmds.c

    If slave and master both support Connection Parameter Update Procedure defined in 9.3.9 in BLUETOOTH SPECIFICATION Version 4.2 spec and declared in LL_FEATURE_REQ (2.4.2.9) and LL_FEATURE_RSP (2.4.2.10), Link layer sends LL_CONNECTION_PARAM_REQ (2.4.2.16).

    If either of hosts don't support this feature, LL sends LL_CONNECTION_UPDATE_REQ 2.4.2.1

    From 9.3.9.2 Conditions in BLUETOOTH SPECIFICATION Version 4.2:

    A Central initiating the connection parameter update procedure shall use the Link Layer Connection Update procedure defined in [Vol. 6], Part B Section 5.1.1 with the required connection parameters if either the Central or the Peripheral does not support the Connection Parameters Request Link Layer Control procedure.

    If both the Central and Peripheral support the Connection Parameters Request Link Layer control procedure, then the Central or Peripheral initiating the connection parameter update procedure shall use the Connection Parameters Request Link Layer Control procedure defined in [Vol. 6], Part B Section 5.1.7 with the required connection parameters.

    Although I'd add here that btsnd_hcic_ble_upd_ll_conn_params() only takes min and max connection intervals and uses them as a hint.

    In my experience, when a range of values is passed, LL chooses any value within the range.

    I have only done limited testing, so I am not sure if LL will ALWAYS choose from supplied range, or can it choose from outside this range in some conditions, e.g. if an already connected slave has CI outside this range

    From 5.1.1 Connection Update Procedure, LL will always choose Connection interval from range supplied by host. Thanks @Emil for pointing this out.