This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Connection Interval

Hi everyone,

I'm new to working with Bluetooth/

My problem is that the connection interval time sent by the central device does not converge with the time I see using an oscilloscope or a configured timer for 1 ms.
The principle of operation of my program is that the peripheral device sleeps for a certain time and wakes up at a specified interval. The central device at this time is trying to connect to it. Using the timer, I count the time from when the device woke up to the time of the BLE_GAP_EVT_CONNECTED event and to the time of the BLE_GAP_EVT_CONN_PARAM_UPDATE event. The time difference between these events is about 600 ms. I can not understand why such a difference in time. Maybe I did not correctly understand the meaning of the parameters MIN_CONN_INTERVAL and MAX_CONN_INTERVAL? If so, then how can you reduce the time for a full connection, so that the BLE_GAP_EVT_CONN_PARAM_UPDATE event occurs as soon as possible.

To check what the actual value is transmitted by the central device, you can make a breakpoint during the execution of the program at the time of the BLE_GAP_EVT_CONN_PARAM_UPDATE event, which I actually did.

According to the received data, the central device set the value of the maximum and minimum interval of 7.5 ms.In the peripheral device, I have the following parameters:

MIN_CONN_INTERVAL    MSEC_TO_UNITS (7.5, UNIT_1_25_MS)

MAX_CONN_INTERVAL   MSEC_TO_UNITS (30, UNIT_1_25_MS)

SLAVE_LATENCY            1

CONN_SUP_TIMEOUT   MSEC_TO_UNITS (250, UNIT_10_MS)

I also read that the connection interval can vary from 7.5 ms to 4 s, maybe this value is the connection interval for my central device?

Chip: BT840F (analog nRF52840);

SDK: nRF5_SDK_15.2.0;

Softdevice: s132_nrf52_6.1.0_softdevice;

Phone: Xiaomi Redmi 5+.

Thanks in advance for your help.

  • Hi

    Did you check the return values from sending the notifications (or start sending data function). 

    I checked the return value and the result was NRF_SUCCESS.
    I also want to clarify that the transfer of useful data itself does not lead to this error. As I showed in the ble_app_cscs example, several connections occur during the establishment of a connection between two devices. After that, you can already freely send and receive data.

    It is the central that decides the connection interval on connection, not the peripheral, so it will be 7.5ms when first connecting

    From my point of view, it seems a bit strange that the central device gives out 7.5 ms by the first attempt, whereas everywhere it is described that android applications need at least 15-20 ms.

    I think the reason of your delay might be that you haven't enabled notifications correctly. You will have to do this from your central (phone). How and when do you do this?
    Indeed, I use a third-party application that my colleagues write. Perhaps they need to make some more adjustments.
    But I want to note that the last example I gave in the last message (screenshot from the terminal) was made on the nRF52832 DK board with a modified ble_app_cscs example, which I also posted. And I checked the operation of the peripheral application using the nRF Connect application.

    Thank you in advance

  • So did you at any point try with an unmodified ble_app_cscs example, the nRF52832DK board, and the nRFConnect application?

    It seems very strange that multiple connection events occur. Are you sure you are connecting to the intended device? Can you look at the connection event and find which address you are connecting to? This should be possible by using p_ble_evt -> evt.params.connected.peer_addr.addr[i].

    Best regards,

    Simon

  • Hi

    Yes, I tried using the ble_app_cscs example. It works correctly. The modification consisted only in adding code to find out the number of reconnections and their parameters.

    About the address. The type of address I have is BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE, therefore the address does not correspond to the central device and changes periodically.

    Regarding the number of reconnections and changes in the value of the connection interval. As stated in the comments here, in the current versions of the android, the connection algorithm is laid, first with a connection interval of 7.5 ms, and after that, the connection is already with parameters supported by both devices.

  • Ok

    Seeing as you have multiple connection events, there will have to be some disconnect event as well somewhere. Could you try to write the disconnect reason by using p_ble_evt->evt.gap_evt.disconnected.reason so we can see why your application disconnects the first time around. This function uses the definitions stated in ble_hci.h

    Best regards,

    Simon

  • Specifically, the disconnection in the BLE_GAP_EVT_CONN_PARAM_UPDATE event does not occur, since the sd_ble_gap_disconnect function is not called anywhere. Perhaps there is a restart function or some similar, perhaps it is called.

    I checked the reason of the shutdown in the BLE_GAP_EVT_CONN_PARAM_UPDATE and BLE_GAP_EVT_DISCONNECTED events. In the first option, disconnection occurs when I click the "Disconnect" button in the nRF Connect application. In the second option, the disconnection occurs when the second reconnection occurs.

    1 option:

    Reasons:

    0x06 - BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING

    0x27 - Requested QoS Not Supported (in file ble_hci.h this definitions commented out)

    0x1E - BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS

    0x13 - BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION

    2 option:

    Reasons:

    0x06 - BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING

    0x27 - Requested QoS Not Supported (in file ble_hci.h this definitions commented out)

    0x16 - BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION

Related