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.

  • If i use the default scann with UUID i haven't any problem for scan, but my devices never connect. I will change the filter because i read on documentation that on coded phy isn't possible use this UUID filter.

  • It's so strange, when i change autoconfig.h manually to set:

    #define CONFIG_BT_SCAN_UUID_CNT 0
    #define CONFIG_BT_SCAN_NAME_CNT 1
    #define CONFIG_BT_SCAN_SHORT_NAME_CNT 0

     When I build the project, there aren't errors and my scan starts. But autoconfig.h is modified automatically by the compiler i think, and Segger studio ask me if i want to reload the project, if i accept autoconfig.h seems like:

    #define CONFIG_BT_SCAN_UUID_CNT 1
    #define CONFIG_BT_SCAN_NAME_CNT 0
    #define CONFIG_BT_SCAN_SHORT_NAME_CNT 0

    And if i build that project with that autoconfig.h i get the error described previously. I do't know why is my autoconfig modified automatically when i build, and why is modified always with the same parameters, independenly of my code.

  • 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

  • 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