BLE not connecting after disconnect

I have a problem with connecting to my device after i disconnect from it.

I have tried ubond function, it does not work.

This is my disconnect function:

/*
	@brief callback function when BT connection is disconnected
*/
static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF("Disconnected: %s, reason 0x%02x %s", addr, reason, bt_hci_err_to_str(reason));

	if (auth_conn) {
		bt_conn_unref(auth_conn);
		auth_conn = NULL;
	}

	if (current_conn) {
		bt_conn_unref(current_conn);
		current_conn = NULL;
	}
	
	advertising_stop();
	advertising_start();
}

I have a service with 2 characteristics and one configuration

        BT_GATT_CCC(rx_ccc_cfg_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
this is just for disable/enable notifications function.


I use nrf connect application on my mobile phone, and i connect to it, but after disconnecting i cannot again connect to the device.

Also adding advertising data:
// Declaring the advertising data
struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA(BT_DATA_NAME_COMPLETE, ble_dev_name, 16),
};

// Declaring the scanning data
struct bt_data sd[] = {
	BT_DATA(BT_DATA_UUID128_ALL, uuid_128, sizeof(uuid_128)),
	BT_DATA(BT_DATA_MANUFACTURER_DATA, manufacturer_data, sizeof(manufacturer_data))
};

// Declaring advertising parameters
static struct bt_le_adv_param adv_param = 
{
	.options = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_IDENTITY, 	/* Connectable advertising and use identity address */
	.interval_max = BT_GAP_ADV_FAST_INT_MAX_1,							/* 0x30 units, 48 units, 30ms */
	.interval_min = BT_GAP_ADV_FAST_INT_MIN_1,							/* 0x60 units, 96 units, 60ms */
	.peer = NULL														/* Set to NULL for undirected advertising */
};


I am using 2.9 version of nrf connect for vscode.
Parents
  • Also security is not enabled, I do not use any security regarding it.

    Also this is part of prj.conf file:

    # Configure your preferred connection parameters
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y //this also added to try all
    
    CONFIG_BT_MAX_PAIRED=1



    int err= bt_unpair(BT_ID_DEFAULT,BT_ADDR_LE_ANY); this is unpair function not unbond as i mentioned above.
Reply
  • Also security is not enabled, I do not use any security regarding it.

    Also this is part of prj.conf file:

    # Configure your preferred connection parameters
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y //this also added to try all
    
    CONFIG_BT_MAX_PAIRED=1



    int err= bt_unpair(BT_ID_DEFAULT,BT_ADDR_LE_ANY); this is unpair function not unbond as i mentioned above.
Children
No Data
Related