Filtering advertisements based on target apperance

I am currently struggling with filtering based on appearance using the Scanning module.

I have a beacon that advertises some dummy data, appearance and service UUID. With the scanning module I was able to filter this advertisement from other advertisements by testing it in an environment with a lot of BLE devices. However, whenever I try to filter both service UUID and appearance or just appearance I do not receive any advertisements that matches with these filters.

The code below works fine.

err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, &beacon_service_uuid);
	if (err) {
		printk("Service UUID scan filter cannot be set (err %d)\n", err);

		return err;
	}
	
err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, true);
	if (err) {
		printk("UUID filters cannot be enabled (err %d)\n", err);
		return err;
	}


The following however does not work
err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_APPEARANCE, &beacon_appearance_uuid);
	if (err) {
	    printk("Appearance UUID scan filter cannot be set (err %d)\n", err);
	    return err;
	}

err = bt_scan_filter_enable(BT_SCAN_APPEARANCE_FILTER, true);
	if (err != 0) {
	    printk("Scan filters cannot be enabled (err %d)\n", err);
	    return err;
	}


I can try to do the filtering whenever I parse the data, but I would like to see if I can already filter advertisements with the filters.

Parents Reply Children
  • No worries, thanks for responding!

    I also was not able to make the appearance filter work whatsoever, so I was turning my focus into purely making the appearance filter work, but did not manage.

    I set my beacon appearance as the following, but maybe that is wrong?

    const uint16_t beacon_appearance_uuid = BT_APPEARANCE_GENERIC_SENSOR;


    As for your last question, I did add CONFIG_BT_SCAN_APPEARANCE_CNT=1 to my prf.conf when testing my application.

Related