Hello
I'm using nrf52832 and sdk v17.0 and I'm testing in the example of ble_app_uart.
I'm creating a feature that Bluetooth disconnecting and then stops advertising. I use 'sd_ble_gap_disconnect' and 'adverting_stop' to do these two things. There's no problem using these separately, but if try to use them together at once, there's an error.
This code calls two functions when the app sends a value '6'.
//Nus Service
static void advertising_stop()
{
ret_code_t err_code;
err_code = sd_ble_gap_adv_stop(m_advertising.adv_handle);
APP_ERROR_CHECK(err_code);
}
static void nus_data_handler(ble_nus_evt_t * p_evt) //Receive data from App
{
ret_code_t err_code;
uint8_t string_buffer[BLE_NUS_MAX_DATA_LEN+1];
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
memcpy(string_buffer, p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
string_buffer[p_evt->params.rx_data.length] = 0;
if(strcmp("6", string_buffer) == 0) //test : bluetooth disconnect & no advertising
{
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); //disconnect pairing
APP_ERROR_CHECK(err_code);
advertising_stop();
}
}
}
This is the log output from the nrf connect app.
I 15:19:15.753 Connection parameters updated (interval: 61.25ms, latency: 0, timeout: 4000ms) V 15:19:27.410 Writing request to characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e D 15:19:27.410 gatt.writeCharacteristic(6e400002-b5a3-f393-e0a9-e50e24dcca9e, value=0x36) E 15:19:31.528 Error 133 (0x85): GATT ERROR D 15:19:31.584 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 15:19:31.585 Error 8 (0x8): GATT CONN TIMEOUT I 15:19:31.585 Disconnected D 15:19:31.642 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
Can I know about this problem?
Thank you for your help.