how to change the BLE data transmission rate in nrf52840 sdk s140?
how to change the BLE data transmission rate in nrf52840 sdk s140?
BLE has three bitrates 2M/1M/Coded PHY. 2M PHY being the fastest.
Data transmission rate also depends on the maximum packet size and connection interval.
Have a look at the throughput examples: Nordic Semiconductor Infocenter
BLE has three bitrates 2M/1M/Coded PHY. 2M PHY being the fastest.
Data transmission rate also depends on the maximum packet size and connection interval.
Have a look at the throughput examples: Nordic Semiconductor Infocenter
Excellent comment!
Additionally you may see which connection parameters that yield the highest throughput in the SoftDevice throughput documentation.
Best regards,
Karl
static void gap_params_init(void) { uint32_t err_code; ble_gap_conn_params_t gap_conn_params; ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) DEVICE_NAME, strlen(DEVICE_NAME)); APP_ERROR_CHECK(err_code); memset(&gap_conn_params, 0, sizeof(gap_conn_params)); gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL; gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL; gap_conn_params.slave_latency = SLAVE_LATENCY; gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT; err_code = sd_ble_gap_ppcp_set(&gap_conn_params); APP_ERROR_CHECK(err_code); }
in this code where actually data rate was initialised i am reffering the ble uart example
Line 16-19 of the code snippet is where the connection parameter preferences of the peripheral device is set. However, please note that the peripheral may only make requests to use its preferred parameters, while the central is the one that actually decides which parameters will be used. The central may reject the peripheral's request, if it prefers other parameters itself. This is not a problem if you control both sides of the link, but in the case of a phone or similar it is worth noting.
Are you familiar with the nRF Sniffer tool? It is a powerful tool to wield when developing with BLE since it lets you see the on-air exchanges between your devices. In this case, a sniffer trace would immediately let you see which connection parameters is being used for the connection.
Best regards,
Karl
line 16 and 19 represent the max_connection interval and connection time out but i am asking about data rate either 1mbps/2mbps where actually that is set?
"but i am asking about data rate either 1mbps/2mbps where actually that is set?"
The default bitrate is 1mbps. This is established through the advertisement preceding the connection.
During the connection you can update the PHY on one side of the connection. If the other side of the connection gets the update event and accepts the PHY update, the new PHY will be used.
Have a look at :github.com/.../main.c