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

Data Rate problem

Hi,guys I set BLE parameters like this:

#define MIN_CONN_INTERVAL                MSEC_TO_UNITS(500, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(1000, UNIT_1_25_MS) 
#define CONN_SUP_TIMEOUT                 MSEC_TO_UNITS(4000, UNIT_10_MS)
#define SLAVE_LATENCY     0

#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) 
#define NEXT_CONN_PARAMS_UPDATE_DELAY    APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)
#define MAX_CONN_PARAMS_UPDATE_COUNT         3  

In my project I use timer1 and timer2 to ganerate 4 channels PWM, when I sent data to adjust the pwm, in the first several seconds the data rate is 20bytes per 100ms , but then it becomes about 20bytes per 400ms, How can I fix it. Thank you very much.

  • Hi

    See this thread on how the connection parameter update procedure works.

    You might also find useful information in the current consumption guide, section about "Tuning Connection Parameters".

    These two threads (1) (2) discuss how to actually see what the connection parameters are.

    This thread might also be helpful with additional information.

    In short

    • MIN_CONN_INTERVAL and MAX_CONN_INTERVAL values determine what is the desired connection interval of the peripheral.

    • The CONN_SUP_TIMEOUT determines for how long the connection should last with no activity received from central device.

    • SLAVE_LATENCY determines if peripheral is obligated to respond to every packet from central or not.

    • FIRST_CONN_PARAMS_UPDATE_DELAY determines when the first connecton parameter update request is sent, and NEXT_CONN_PARAMS_UPDATE_DELAY determines the delay to subsequent connection parameter update requests. MAX_CONN_PARAMS_UPDATE_COUNT determines how often the request should be sent.

    Update 7.9.2015 The connection parameter update procedure is triggered when notification is enabled from the central device. Look at the conn_params_negotiation function in ble_conn_params.c. You can set a breakpoint there to verify that it is called when you enable notifications. In the conn_params_negotiation function, a timer is started and expires after FIRST_CONN_PARAMS_UPDATE_DELAY milliseconds. When the timer expires, the update_timeout_handler is called which in turns calls sd_ble_gap_conn_param_update that sends the connection parameter update request to the central.

    When a connection parameter update is received from the central, it is checked if the proposed connection interval proposed by the central is within MIN_CONN_INTERVAL and MAX_CONN_INTERVAL . If the connection interval is within MIN_CONN_INTERVAL and MAX_CONN_INTERVAL, then the connection parameters are accepted. If not, another connection parameter update request is sent.

    Check the links that I sent earlier in order to see what the actual connection interval is that is proposed by the cental. If you specify the connection interval 500ms - 1000ms but you get 400ms from the central, then the peripheral will not accept the connection parameters and will send another connection parameter update request to the central. The peripheral will however start to use right away the 400ms connecton interval as the central proposed. When the peripheral has sent out three connection parameters update requests and the central has still not sent an acceptable connection interval (i.e. between 500ms and 1000ms) then the peripheral will disconnect, as done in the on_conn_params_evt event handler in e.g. the ble_app_hrs example in nRF51 SDK 9.0.0. I suspect the disconnection will happen after approximately 15 seconds as the MAX_CONN_PARAMS_UPDATE_COUNT = 3 and connection parameter update requests are sent every 5 seconds.

  • Thank you for your answer, further more what will cause the Peripheral sends parameter update request to central? IIs that Just like there are too many events the Peripheral can't hanlde ,too data to receive ,so it should tell the Central to slow down? I sent data to adjust the pwm, in the first several seconds the data rate is 20bytes per 100ms , but then it becomes about 20bytes per 400ms. The central slows down.

Related