What is the correct way to close the BLE connection?

Hi,

I have a central, where I want to close the BLE connection and restart the device. I have a button interrupt that does this:

static void button_changed(uint32_t button_state, uint32_t has_changed){

  int _err;
  if (has_changed & DK_BTN1_MSK) {
    printk("resetting the device.\n");
    _err = bt_conn_disconnect(central_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
    printk("bt_conn_disconnect error: %d,\n", _err);
    bt_conn_unref(central_conn);
	central_conn = NULL;

    k_sleep(K_MSEC(1));
    
    // reset the system
    //NVIC_SystemReset();
    sys_reboot(0);
    
  }

}

However, when the device reboots. I get this warning and the scanner does not connect to the peripheral:

The connection information is probably saved in a non-volatile memory, right? How do you properly disconnection the Bluetooth connection?

Thanks for the help!!!

 

Related