Hello all,
Currently I am developing a code in which a central (nRF52840) scans and reads adverisement packets from 2 beacons (no connection required). I decided to use an adress filter to limit the amount of advertisement data received; however, it seems that it is not working because:
1. I´m getting TONS of advertisement packets that don´t look similar to what I´m expecting.
2. The event NRF_BLE_SCAN_EVT_FILTER_MATCH is never triggered.
Below I´ll show you some key points of the code:
Declarition of the target MAC address (AC:23:3F:A9:EF:E2)
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
static bool is_connect_per_addr = true; /**< If you want to connect to a peripheral with a given address, set this to true and put the correct address in the variable below. */
static ble_gap_addr_t const m_target_periph_addr =
{
/* Possible values for addr_type:
BLE_GAP_ADDR_TYPE_PUBLIC,
BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,
BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. */
//.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
.addr = {0xE2, 0xEF, 0xA9, 0x3F, 0x23, 0xAC}
//.addr = {0x41, 0x8C, 0xFE, 0x05, 0x1C, 0x00}
};
Filters settings
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void scan_init(void)
{
ret_code_t err_code;
nrf_ble_scan_init_t init_scan;
//static char const test_periph_addr[] = {0xEA, 0xEF, 0xA9, 0x3F, 0x23, 0xAC};
memset(&init_scan, 0, sizeof(init_scan));
init_scan.p_scan_param = &m_scan_param;
init_scan.connect_if_match = true;
init_scan.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
APP_ERROR_CHECK(err_code);
ble_uuid_t uuid =
{
.uuid = TARGET_UUID,
.type = BLE_UUID_TYPE_VENDOR_BEGIN,
};
ADV_REPORT EVENT
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
ret_code_t err_code;
ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
NRF_LOG_INFO("Advertisement report");
//on_adv_report(&p_gap_evt->params.adv_report);
//if( p_gap_evt->params.adv_report.direct_addr.addr == m_target_periph_addr.addr)
//{
// NRF_LOG_INFO("Found");
//}
uint8_t data_length = p_gap_evt->params.adv_report.data.len;
NRF_LOG_INFO("Data length: %d", data_length);
uint8_t i;
Thank you so much in advance