Connection parameters in nrf ble

want to know how can i judge that the variation is caused in the connection interval, connection supervision timeout, slave latency once i have flashed ble_app_template code in nrf52832 s132.

Parents
  • Hello,

    The best way to see exactly how your connection parameter configuration affects the connection would be to use the nRF Sniffer tool to see exactly what is happening on-air.
    Alternatively, if you just would like to play around with different connection parameters to see how each of them affects your connection you could take a look at the experimental ATT MTU throughput example from the SDK.
     
    If you would like to visualize different connection parameter configurations you could take a look at the Online Power Profiler, which will let you see the effects of each configuration on the packet exchanges (as well as estimated power consumption).

    Best regards,
    Karl

  • Karl i am finding a difficulty in normal understanding the connection interval thing. Actually, by definition of CI i found it is the time btw two consecutive events for which the radio is turned ON. how can i judge this in nrf connect app?

  • Hello again, RIDHIMA

    Ridhi said:
    but the the device doesnot show any adevrtising?

    If you do not see the device advertise after the change you will need to proceed with regular debugging techniques.
    - Does your application build and flash without errors or warnings?
    - Is there any indication that your program is running as it should, or to the contrary?
    - What does your logger output when you attempt to run your program? Are there any LEDS or other peripheral indicating that the program is executed as expected?
    - Are you able to open a debug session? Does the programcounter get stuck anywhere in your program, or end up someplace unexpectedly?

    If you make sure to add DEBUG in your preprocessor defines, like shown in the included image, the logger will output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Ridhi said:
    I wanted to set the Connection interval as either 100/1000/2000/4000ms, how cn this be achieved?

    Yes, the maximal connection interval length is 4000 ms, anything equal to or lower than that is fine.

    Best regards,
    Karl

  • no karl, putting in ble_App_template or ble_blinky code doesnt show up advertsing

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(3000, UNIT_1_25_MS)

    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(3000, UNIT_1_25_MS)

  • Karl Ylvisaker said:
    If you do not see the device advertise after the change you will need to proceed with regular debugging techniques.
    - Does your application build and flash without errors or warnings?
    - Is there any indication that your program is running as it should, or to the contrary?
    - What does your logger output when you attempt to run your program? Are there any LEDS or other peripheral indicating that the program is executed as expected?
    - Are you able to open a debug session? Does the programcounter get stuck anywhere in your program, or end up someplace unexpectedly?

    If you make sure to add DEBUG in your preprocessor defines, like shown in the included image, the logger will output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Please answer the questions and perform the steps in my previous comment so we may proceed with the debugging of your issue.

    Best regards,
    Karl

  • Does your application build and flash without errors or warnings?

    -Yes

    Is there any indication that your program is running as it should, or to the contrary?

    -I have ran ble_blinky code/ ble_App tempalate which on advertsing ideally blinks with Nordic Blinky / Nordic template name

    What does your logger output when you attempt to run your program? Are there any LEDS or other peripheral indicating that the program is executed as expected

    -blinky code

    Are you able to open a debug session? Does the program counter get stuck anywhere in your program, or end up someplace unexpectedly

    -no

    in nordic blinky code nrf sdk v17 s132 on dev kit nrf52832 ideally:

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */

    then the code runs and flashes adv name with led blinking.

    I am working on ble power optimization. I want to change the connection parameters and check the current consumption.

    As suggested by you in above discussion Connection interval had to be set like:

    ----For 100ms Connection Interval

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */

    ----For 1000 ms Connection Interval

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */

    But the max range of Connection interval from ble specs is 7.5 to 4000ms.

    so, when i set 

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(2000 or 3000 or 4000, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(2000 or 3000 or 4000, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */

     the device doesnt advertise anything??

  • Hello,

    I just tried this with the Blinky example on my end, and it works as expected.
    Could you confirm for me whether you are updating your connection supervision timeout in accordance with these new connection interval parameters?
    The supervision timeout must uphold the conn_sup_timeout * 4 > (1+ slave_latency)*max_conn_interval constraint.
    If this is not upheld you will get an NRF_ERROR_INVALID_PARAMS or similar. In your case, that means that a 2000 ms interval will need more than 8000 ms supervision timeout, with a slave latency of 0.
    Though, if this was the case I would expect the program counter to go to the APP_BREAKPOINT_COND unexpectedly, so if you are not seeing this happening that might be something to look into.

     @note  If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
            conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
            that corresponds to the following Bluetooth Spec requirement:
            The Supervision_Timeout in milliseconds shall be larger than
            (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.

    This is an exempt from the ble_gap_conn_params_t documentation.

    Best regards,
    Karl

Reply
  • Hello,

    I just tried this with the Blinky example on my end, and it works as expected.
    Could you confirm for me whether you are updating your connection supervision timeout in accordance with these new connection interval parameters?
    The supervision timeout must uphold the conn_sup_timeout * 4 > (1+ slave_latency)*max_conn_interval constraint.
    If this is not upheld you will get an NRF_ERROR_INVALID_PARAMS or similar. In your case, that means that a 2000 ms interval will need more than 8000 ms supervision timeout, with a slave latency of 0.
    Though, if this was the case I would expect the program counter to go to the APP_BREAKPOINT_COND unexpectedly, so if you are not seeing this happening that might be something to look into.

     @note  If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
            conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
            that corresponds to the following Bluetooth Spec requirement:
            The Supervision_Timeout in milliseconds shall be larger than
            (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.

    This is an exempt from the ble_gap_conn_params_t documentation.

    Best regards,
    Karl

Children
  • i have set max min Connection interval as 2000 and supervision tiemout as 8000ms. This in blinky code worked. But when i am setting max min CI as 4000ms it is not working.

    Also, i am not getting what is this connection supervision timeout. 

  • Karl pls assist at earliest:

    In code pls help how to do:

    1). 100ms Connection interval what shall be possible values of Slave latency and  Connection supervision timeout

    2). 200ms Connection interval what shall be possible values of Slave latency and  Connection supervision timeout

    3). 1000ms Connection interval what shall be possible values of Slave latency and  Connection supervision timeout

    4). 4000ms Connection interval what shall be possible values of Slave latency and  Connection supervision timeout

     how to know about how connection supervision timeout and slave latency are working like in blinky example say

  • Ridhi said:
    i have set max min Connection interval as 2000 and supervision tiemout as 8000ms. This in blinky code worked. But when i am setting max min CI as 4000ms it is not working.

    Strange that you did not have to use 8001.25 ms connection timeout, but I suppose it should be an equal to or greater sign instead of just a greater sign.

    The BLE specification equation has to hold for the parameters to be valid, so instead of calculating all of them I will demonstrate on your 4) question, and then you can apply the same logic to the 1-3) cases.
    For a 4000 ms connection interval, with a slave latency for 1 (for the sake of the example), you will need your connection supervision timeout to be 16000 ms at least.
    I tested this on my end with 16010 ms, and I am not seeing any errors - it is working as expected.
    You could try with these parameters yourself in the BLE blinky application and see if you observe the same.

    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(4000, UNIT_1_25_MS)        /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(4000, UNIT_1_25_MS)        /**< Maximum acceptable connection interval (1 second). */
    #define SLAVE_LATENCY                   1                                       /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(16010, UNIT_10_MS)         /**< Connection supervisory time-out (4 seconds). */
    

    Ridhi said:
    Also, i am not getting what is this connection supervision timeout. 

    Please see my earlier comment explaining the connection supervision timeout. Please do not hesitate to ask if any part of it should be unclear.

    Best regards,
    Karl

  • Ok Karl i got to understand about the above discussion about connection interval.

    I tried to understand your comment and discussion about supervision timeout but i am not able to understand. Eg: say i have nordic blinky code and i set the supervision timeout as 4 secs. i am not getting what and how this we can see its effect on nrf connect app. 

    i have slave latency of 0 say, in nordic blinky code there are two services:  button and led. how will pheripheral know that it has no data to send so it sets the slave latency.

    i am very much confused inunderstanding

  • Ridhi said:
    i have slave latency of 0 say, in nordic blinky code there are two services:  button and led. how will pheripheral know that it has no data to send so it sets the slave latency.

    I am sorry to hear that, RIDHIMA. Please do not hesitate to ask if any part of my answer should be unclear, so that I may elaborate.

    Ridhi said:
    say i have nordic blinky code and i set the supervision timeout as 4 secs. i am not getting what and how this we can see its effect on nrf connect app. 

    The simplest explanation of the connection supervision timeout is: "It is how long will the device attempt to contact a peer that has stopped responding"
    So, if you have 4 s supervision timeout on your peripheral, and you are in connection with a nRF Connect central. If the central stops responding to the peripheral (they both expect to exchange a packet at least for once every connection interval) such as if it leaves the area, or goes into an elevator or similar, they will both still try to communicate with each other for each passing connection interval - in hopes that they will hear from each other again, and continue the connection. The connection supervision timeout tells them how long they should keep trying to reach the peer that is no longer responding.
    When a connection is terminated the devices will usually go back into either scanning or advertising so that they can find a new connection. This will not happen until the connection supervision timeout has expired., because both devices still consider the connection as working so long as it has not expired (even though they do not hear anything from their peer).

    Ridhi said:
    how will pheripheral know that it has no data to send so it sets the slave latency.

    The peripheral can know this by checking the contents of the packet it intends to send in the upcoming connection event.
    If the packet is empty and the slave latency is > 0 it can skip the upcomming connection event. If the packet is non-empty (contains data) it should transmit during the event.

    Best regards,
    Karl

Related