Removing bond from device, Windows keeps trying to connectn

I'm using the BLE mouse example, and the problem I'm having is if I remove the pairing/bonding information from the device, Windows will keep trying to pair with the device:





Essentially, what I want is to only have one bond on the device. If a user presses a button, it should disconnect any active connections, remove the bonding information, then start advertising again. Because Windows has the old bonding information still stored, it tries to connect repeatedly. How can this be avoided, without saying to someone to remove the bond from their PC. If I take for example my MX mouse, I remove the bonding on it, by connecting to a different device, go back into pairing mode, my Windows PC doesn't keep trying to connect to the device. In fact.

  • Hi,

    There should not be a need to disable and re-enable the Bluetooth stack. When the central is not able to connect, is the advertising connectable? And is the device advertising without a whitelist? Could it be that the whitelist is still populated, perhaps becaue the bond has not been deleted (I don't see bt_unpair() here anymore, but perhaps that is just that it was not copy pasted in here)? Do you have logs and a sniffer trace that shows what is happening?

  • I've been changing the code around which is why it wasn't there, sorry.

    I've captured packets, but I'm not sure that's it's giving useful information



    I've also seen these packets



    Pressing the button to clear the bonds, filter list and change the address looks like this

    		int err;
    
    		pairing_button = true;
    
    		err = bt_conn_disconnect(conn_mode->conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
    		if (err) {
    			printk("Cannot disconnect err= %d \n", err);
    		}
    		else
    			printk("Disconnected device\n");
    
    		err = bt_le_adv_stop();
    		if (err) {
    			printk("Cannot stop advertising err= %d \n", err);
    			return;
    		}
    		else
    			printk("Advertising stopped\n");
    		
    		err = bt_unpair(BT_ID_1, NULL);
    		if (err) {
    			printk("Cannot unpair for default ID");
    			return err;
    		}
    		else
    			printk("Unpaired\n");
    
    		for (size_t i = 1; i < CONFIG_BT_ID_MAX; i++) {
    			err = bt_id_reset(i, NULL, NULL);
    			if (err < 0) {
    				printk("Cannot reset id %zu (err %d)\n", i, err);
    			}
    			else
    				printk("Reset id: %d\n", i);
    		}
    
    		err = bt_le_filter_accept_list_clear();
    		if (err) {
    			printk("Cannot clear accept list (err: %d)\n", err);
    		} else {
    			printk("Accept list cleared succesfully\n");
    		}
    
    		k_work_submit(&advertise_acceptlist_work);
    
    		pairing_button = false;



  • I've figured out what the problem was. When turning off the BLE from the PC, I advertise using the accept list 

    adv_param.options |= BT_LE_ADV_OPT_FILTER_CONN;

    But after pressing the button to clear the bonds I don't remove BT_LE_ADV_OPT_FILTER_CONN, but I've added the else clause which fixed it.

    	if (option != 0)
    	{
    		adv_param.options |= BT_LE_ADV_OPT_FILTER_CONN;
    		printk("Using filter accept list\n");
    	}
    	else
    	{
    		adv_param.options = (BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME),
    		printk("Not using filter accept list\n");
    	}



    Out of curiosity, does scanning the packets show these parameters, because I couldn't see it on wireshark

Related