NimBLE whitelist not working

elevate456
Posts: 1
Joined: Thu Jan 09, 2025 10:55 am

NimBLE whitelist not working

Postby elevate456 » Thu Jan 09, 2025 11:06 am

Set-up
- ESP-IDF v5.4
- MCU: ESP32

I can still connect to the peripheral even the advertising filter policy is set to 1.

The code i used on setting-up the white list:
  1.  
  2.    ble_addr_t addresses =
  3.     {
  4.         .type = 0,
  5.         .val = {0xe8, 0xdb, 0x84, 0x03, 0xf5, 0x62}  // e8:db:84:03:f5:62
  6.     };
  7.  
  8.     /* Begin advertising. */
  9.     memset(&adv_params, 0, sizeof adv_params);
  10.     adv_params.itvl_min =  BLE_GAP_ADV_ITVL_MS(1000);
  11.     adv_params.itvl_max =  BLE_GAP_ADV_ITVL_MS(1010);
  12.     adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
  13.     adv_params.disc_mode = BLE_GAP_DISC_MODE_NON;
  14.  
  15.     rc = ble_gap_wl_set(&addresses, 1);
  16.     if (rc != 0) {
  17.         MODLOG_DFLT(ERROR, "error setting whitelist data; rc=%d\n", rc);
  18.         return;
  19.     }
  20.  
  21.     adv_params.filter_policy = BLE_HCI_CONN_FILT_USE_WL;
  22.  
  23.     rc = ble_gap_adv_set_fields(&fields);
  24.     if (rc != 0) {
  25.         MODLOG_DFLT(ERROR, "error setting advertisement data; rc=%d\n", rc);
  26.         return;
  27.     }
  28.  
  29.     rc = ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER,
  30.                            &adv_params, bleprph_gap_event, NULL);
  31.     if (rc != 0) {
  32.         MODLOG_DFLT(ERROR, "error enabling advertisement; rc=%d\n", rc);
  33.         return;
  34.     }
  35.  

valeroso
Posts: 1
Joined: Thu Jan 16, 2025 8:20 pm

Re: NimBLE whitelist not working

Postby valeroso » Thu Jan 16, 2025 8:28 pm

You're using the wrong filter value. If you want to allow connections only from whitelisted devices the value should be one of:

Code: Select all

0x02 - Process scan requests from all devices and 
connection requests only from devices that are in the Filter Accept List.
0x03 - Process scan and connection requests only from devices in the Filter Accept List.
Define you're using doesn't belong to ble_gap_adv_params.filter_policy. It actually has value 0x01 which corresponds to "Process connection requests from all devices and scan requests only from devices that are in the Filter Accept List".

Although should check whether other parameters are correct.

Who is online

Users browsing this forum: nopnop2002 and 75 guests