This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error trying to change filter parameters to filter by name on UART example

Hi everyone,

I am working on nrf Connect 3.7.0, SDK v1.6.1 with a nrf52840.

I am not able to change the filter of scanning, only works with UUID filter.

static int scan_init(void)
{
int err;
const char *perName="Uart_periph1";
//static char const test_periph_addr[] = {0x17, 0x49, 0xB7, 0xBE, 0xC4, 0xDC};
struct bt_scan_init_param scan_init = {
.connect_if_match = 1,
.scan_param = &m_scan_param,
.conn_param = NULL,//&m_conn_param,
};

bt_scan_init(&scan_init);
bt_scan_cb_register(&scan_cb);

//err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_NUS_SERVICE);
//if (err) {
// LOG_ERR("Scanning filters cannot be set (err %d)", err);
// return err;
//}

//err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
//if (err) {
// LOG_ERR("Filters cannot be turned on (err %d)", err);
// return err;
//}

err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME,perName);

if (err) {
LOG_ERR("Scanning filters cannot be set (err %d)", err);
return err;
}

err = bt_scan_filter_enable(BT_SCAN_FILTER_TYPE_NAME, false);
if (err) {
LOG_ERR("Filters cannot be turned on (err %d)", err);
return err;
}

LOG_INF("Scan module initialized");
printk("Scan module initialized");
return err;
}

Debugging the error occurs here bt_scan_filter_enable:

This is the main Kconfig part:

The scanning is maked only on coded. I don't know why but on autoconfig.h generated by the compiler...

The filter by name can't be setted.

I am so really stuck, any ideas are welcome

Thanks, regards.

Parents
  • Hi

    Sorry about the late reply, but I've been out of office the last few days.

    What error exactly do you see when debugging the application? Can you check out the central_hr_coded sample that already uses scan filters.

    Also, where is this autoconfig.h file located in your project? I think this is generated every time you compile/build the project.

    Best regards,

    Simon

Reply
  • Hi

    Sorry about the late reply, but I've been out of office the last few days.

    What error exactly do you see when debugging the application? Can you check out the central_hr_coded sample that already uses scan filters.

    Also, where is this autoconfig.h file located in your project? I think this is generated every time you compile/build the project.

    Best regards,

    Simon

Children
  • Yes autoconfig.h is generated every time that you rebuild the project, and apply the configuration that u describe on .defconfig file. I learn it this week, i change parameters directly on autoconfig.h sometimes but i recommend appliy it on .defconfig for save it permanently. The issue is closed.

Related