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 

    Changes to MAX_CONN_INTERVAL and FIRST_CONN_PARAMS_UPDATE_DELAY don't reduce this time.

    About the application. The peripheral device is in sleep mode (System ON). After a certain period of time, the device wakes up, it connects to the central device, transfers data, and then goes to sleep.
    Transmission while I have is slow, from the moment of waking up to falling asleep takes about 1.2 seconds, with the transfer of 1 packet. It seems to me that this is a very incorrect setting on my part, but so far I have not really understood the transmission intervals.

  • Hi

    I agree, this sounds very slow. Have you done any other changes to the ble_app_cscs example except changing these values? Your central is the Xiaomi Redmi 5+ right? What is the distance between the two devices when you are testing? You can also try changing APP_ADV_DURATION to be lower to see if the issue is that you application is advertising for too long. 

    Best regards,

    Simon

  • Hi

    Concerning APP_ADV_DURATION. I do not use the timeout for advertising, because I personally control the time of the advertising after I leave the sleep mode. That is, when the device wakes up, I launch an advertisement (sd_ble_gap_adv_start) and after a certain period of time I immerse the device into sleep, having previously turned off the advertisement (sd_ble_gap_adv_stop).

    The distance between the device and the smartphone is about half a meter, but if you walk a few meters, the result does not change.

    No other changes were made except for the previously mentioned variables. If it's not difficult for you, can you list the main reasons that may affect connection and data transfer times?

    Thank you in advance.

  • Hi

    Reasons for slow connection/data transfer include:

    • Your central (phone) deciding the connection interval, which seems to be the case in your original post.
    • Your phone not supporting maximum transfer speed (see this post).
    • Connection/advertising interval parameters set higher than desired
    • Advertising interval between peripheral and central overlapping, so the central has trouble reading

    These are some common reasons for slow transfer, but it's hard to say what exactly is wrong in your instance.

    Best regards,

    Simon

  • Hi

    I managed to slightly reduce the transmission time. Thanks for the link, suggested tips in it helped me.

    I also better figured out these times.
    The transfer of useful data starts from the moment of BLE_GAP_EVT_CONN_PARAM_UPDATE, in this event I start a timer. After the client receives the data, I break the connection. Considering the time from the beginning of the transmission to the interruption of the connection, the time is approximately 80 ms, which is much better.)

    But the total time from the moment the peripheral device wakes up to the interruption of the connection is still about 1 second. The reason for the large delay is the re-entry of the BLE_GAP_EVT_CONN_PARAM_UPDATE event.
    If the MAX_CONN_PARAMS_UPDATE_COUNT parameter is set to 0, then there will be no re-entry, but the client will also not receive the data. I suppose that this is related to the necessary, central device, connection interval. At the first entry, it always sets 7.5 ms (read with p_ble_evt-> evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval). When re-entering exposes 11 ms and apparently this time is satisfactory for the transfer of the data packet.

    Changes in the MIN_CONN_INTERVAL and MAX_CONN_INTERVAL parameters do not change the situation, I still get 2 times in the BLE_GAP_EVT_CONN_PARAM_UPDATE event.
    Since the program gets 2 times in a row to this event, it takes about 800 ms, which is quite a lot. I would like to somehow reduce this time if possible.
    Just want to understand why the central device does not immediately set the necessary connection interval time.

    Thank you in advance.

Related