Good day,
i would like to know if it is possible to continue broadcasting even if the device is already connected. i am using nrf52832 with SDK17.1
Good day,
i would like to know if it is possible to continue broadcasting even if the device is already connected. i am using nrf52832 with SDK17.1
If you have NRF_SDH_BLE_PERIPHERAL_LINK_COUNT more than 1, then you can just call advertising_start() in the ble_evt_handler-> BLE_GAP_EVT_CONNECTED event. The code for advertising start is shown in many ble_peripheral examples.
/**@brief Function for starting advertising.
*/
static void advertising_start(void)
{
ret_code_t err_code;
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
APP_ERROR_CHECK(err_code);
bsp_board_led_on(ADVERTISING_LED);
}when device gets connected, i want it to advertise as non-connectable. and when it gets disconnected, it should return to connectable advertisement again. is this possible?
when device gets connected, i want it to advertise as non-connectable. and when it gets disconnected, it should return to connectable advertisement again. is this possible?
Yes, you can do that. In the connected event you can do below and start the advertiser
static ble_gap_adv_params_t m_adv_params;
// Initialize advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));
m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
m_adv_params.p_peer_addr = NULL; // Undirected advertisement.
m_adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL;
m_adv_params.duration = 0; // Never time out.
err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
APP_ERROR_CHECK(err_code);
When you disconnect and get the disconnected event, you can stop the non connectable advertising and reconfigure it to be connectable and start the advertiser again as connectable.
i get an error in the sd_ble_gap_adv_set_configure.
<error> app: ERROR 4 [NRF_ERROR_NO_MEM] at: 0x0002871F