<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107563/error-4-nrf_error_no_mem-after-nrf_ble_scan_filter_set</link><description>Hello, 
 I wrote a firmware based on your example programs from nRF5 SDK. My firmware has it&amp;#39;s own BLE service which can connect to different devices. 
 Recently I added a functionality to set the BLE device name and encryption key via UART. 
 When I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Feb 2024 13:26:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107563/error-4-nrf_error_no_mem-after-nrf_ble_scan_filter_set" /><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/469248?ContentTypeID=1</link><pubDate>Fri, 16 Feb 2024 13:26:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50dd0fa7-e874-4137-a5a0-54440d5540ba</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Please see my answer here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/59798/scan-name-filter-in-ble_app_uart_c-example/243221"&gt;RE: scan name filter in ble_app_uart_c example&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/469213?ContentTypeID=1</link><pubDate>Fri, 16 Feb 2024 11:53:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1742a9c-5cf8-4c1f-ab5c-6d656253b4cd</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Yes, I tried it already (see my second post before your last answer).&lt;/p&gt;
&lt;p&gt;Where can I find the BLE device name in the advertising data so I can manually compare the data?&lt;/p&gt;
&lt;p&gt;I now added a logic so that when my firmware gets the NRF_BLE_SCAN_EVT_FILTER_MATCH event in scan_evt_handler it only connects to the device when the rssi is &amp;gt;= -55&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case NRF_BLE_SCAN_EVT_FILTER_MATCH:
        {
        // When a filter is matched, it generates NRF_BLE_SCAN_EVT_FILTER_MATCH to the main application.
            NRF_LOG_INFO(&amp;quot;NRF_BLE_SCAN_EVT_FILTER_MATCH&amp;quot;);
            if ((last_adv_report.rssi &amp;gt;= -55) &amp;amp;&amp;amp; (last_adv_report.rssi != NULL)) {
                //sd_ble_gap_scan_stop(); // 20240214
                NRF_LOG_INFO(&amp;quot;rssi = %d dBm&amp;quot;, last_adv_report.rssi);
                ble_scan_connect_with_target(&amp;amp;m_scan, &amp;amp;last_adv_report); // 20240214
            }
            break;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;For this I handle the BLE_GAP_EVT_ADV_REPORT in ble_evt_handler and save the adv_report from the advertising event.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GAP_EVT_ADV_REPORT:
        {
            last_adv_report = p_gap_evt-&amp;gt;params.adv_report;
            break;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is a workaround that helps now... But still I would like to make it work correctly with the BLE device name filter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/468327?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2024 08:32:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26e646fa-e2eb-455a-903c-a17f834f2baf</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="tbuenger"]How is this possible? It leads me to believe that (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER) sets the filters in a way so only one of both filters have to match to start a connection. I guess the UUID filter matches with some device and so it starts the connection.[/quote]
&lt;p&gt;Try to set the &amp;#39;match_all&amp;#39; flag to &amp;#39;true&amp;#39; in your&amp;nbsp;&lt;span&gt;nrf_ble_scan_filters_enable() call.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1707726571842v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/468193?ContentTypeID=1</link><pubDate>Fri, 09 Feb 2024 10:48:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adc394ef-f0a9-4851-a7b4-acf89a8fe30c</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;When I remove the battery from my test locking cylinder (should be the peripheral named &amp;quot;BT Test&amp;quot;), initialize the BLE device name with &amp;quot;BT Test&amp;quot; and use nrf_ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), false); the program still gets NRF_BLE_SCAN_EVT_FILTER_MATCH and connects to a device.&lt;/p&gt;
&lt;p&gt;How is this possible? It leads me to believe that (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER) sets the filters in a way so only one of both filters have to match to start a connection. I guess the UUID filter matches with some device and so it starts the connection.&lt;/p&gt;
&lt;p&gt;How can I print the BLE device name&amp;nbsp;on my segger embedded studio terminal directly from the advertisement, that matched my filters? Right now I only set m_target_periph_name and print that with NRF_LOG_INFO(&amp;quot;m_target_periph_name: \&amp;quot;%s\&amp;quot;&amp;quot;, m_target_periph_name);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/468181?ContentTypeID=1</link><pubDate>Fri, 09 Feb 2024 09:51:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:976b1f5c-5fc7-44b3-96ff-b21b2b792aee</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;When I use scan_init() with (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER) with the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&amp;amp;init_scan, 0, sizeof(init_scan));

    init_scan.p_scan_param     = &amp;amp;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(&amp;amp;m_scan, &amp;amp;init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    ble_uuid_t uuid =
    {
        .uuid = BLE_UUID_SDCS_SERVICE,
        .type = BLE_UUID_TYPE_VENDOR_BEGIN,
    };
    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_UUID_FILTER, &amp;amp;uuid);
    APP_ERROR_CHECK(err_code);

    if (ble_device_name_string_init == true)
    {
        if (strlen(ble_device_name_string) != 0)
        {
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              ble_device_name_string);
            APP_ERROR_CHECK(err_code);
        }
    } else {
        
        for(int i=0; i&amp;lt;BDN_STR_LEN; i++) {
            m_target_periph_name[i] = &amp;#39;\0&amp;#39;;
        }
        m_target_periph_name[0] = &amp;#39;B&amp;#39;;
        m_target_periph_name[1] = &amp;#39;T&amp;#39;;
        m_target_periph_name[2] = &amp;#39; &amp;#39;;
        m_target_periph_name[3] = &amp;#39;T&amp;#39;;
        m_target_periph_name[4] = &amp;#39;e&amp;#39;;
        m_target_periph_name[5] = &amp;#39;s&amp;#39;;
        m_target_periph_name[6] = &amp;#39;t&amp;#39;;

        if (strlen(m_target_periph_name) != 0)
        {
            NRF_LOG_INFO(&amp;quot;m_target_periph_name: \&amp;quot;%s\&amp;quot;&amp;quot;, m_target_periph_name);
            NRF_LOG_INFO(&amp;quot;sizeof(m_target_periph_name): %d&amp;quot;, (sizeof(m_target_periph_name)));
            NRF_LOG_INFO(&amp;quot;strlen(m_target_periph_name): %d&amp;quot;, (strlen(m_target_periph_name)));
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              m_target_periph_name);
            APP_ERROR_CHECK(err_code);
            if (err_code == 0) 
            {
                for (int i=0; i&amp;lt;BDN_STR_LEN; i++)
                {
                    ble_device_name_string[i] = &amp;#39;\0&amp;#39;;
                }
                for (int i=0; i&amp;lt;strlen(m_target_periph_name); i++) {
                    ble_device_name_string[i] = m_target_periph_name[i];
                }
                ble_device_name_string_init = true;
            }
        } else {
            NRF_LOG_INFO(&amp;quot;Please set a ble device name via UART.&amp;quot;);
        }
    }

    if (is_connect_per_addr)
    {
       err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                          SCAN_ADDR_FILTER,
                                          m_target_periph_addr.addr);
       APP_ERROR_CHECK(err_code);
    }
    
    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan,
          (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), false);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can see I initialize m_target_periph_name with &amp;quot;BT Test&amp;quot;. Normally this shouldn&amp;#39;t be the default value. Normally I want my default value to be &amp;quot;BT Door&amp;quot; and input a desired BLE device name via UART but because we have multiple locking cylinders lying around in proximity I decided to initialize with &amp;quot;BT Test&amp;quot; for testing purposes now. I want to make sure the program filters correctly after BLE Name AND BLE Service UUID (not OR). I have set the ble device name on my test locking cylinder to &amp;quot;BT Test&amp;quot;.&lt;/p&gt;
&lt;p&gt;I am getting mode = 0x05 (hex) = 5 (decimal) ...&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/mode_5F00_uuid_5F00_name_5F00_with_5F00_bt_5F00_test_5F00_match_5F00_all_5F00_false.png" /&gt;&lt;/p&gt;
&lt;p&gt;With&amp;nbsp;NRF_BLE_SCAN_ALL_FILTER it was mode = 0x1F (hex) = 31 (decimal)&lt;/p&gt;
&lt;p&gt;From the documentation I learned that (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER) enables NRF_BLE_SCAN_NAME_FILTER and NRF_BLE_SCAN_UUID_FILTER. This confused me because of the &amp;quot;|&amp;quot; operator (OR).&lt;/p&gt;
&lt;p&gt;My collegue explained me that since both NRF_BLE_SCAN_UUID_FILTER and NRF_BLE_SCAN_NAME_FILTER are constants that contain number values, the bitwise OR works like a logical AND.&lt;/p&gt;
&lt;p&gt;The last parameter in ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), false); is called match_all in nrf_ble_scan.c/.h. I think this bool allows multiple filters to be set by a combination of constants like (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER). From my tests I notice that I have to set this to false.&lt;/p&gt;
&lt;p&gt;When I use BLE device name &amp;quot;BT Test&amp;quot; and...&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), true);&lt;/td&gt;
&lt;td&gt;can&amp;#39;t connect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), false);&lt;/td&gt;
&lt;td&gt;can connect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, true);&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;can&amp;#39;t connect&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, false);&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;can connect&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;When I initialize BLE device name as &amp;quot;BT Door&amp;quot; and use...&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), true);&lt;/td&gt;
&lt;td&gt;can&amp;#39;t connect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, (NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER), false);&lt;/td&gt;
&lt;td&gt;can connect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, true);&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;can&amp;#39;t connect&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, false);&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;can connect&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In my admin phone app I can only see a &amp;quot;BT Test&amp;quot; device. So I am a bit confused why it can still connect even when I initialize with BLE device name &amp;quot;BT Door&amp;quot;... The firmware on my nRF52840 DK seems to connect to an unintended device in that case. I guess I have to adjust the filter further to give unique results by adding the BLE adress to the filter or add the RSSI and disable connect_if_match.&lt;/p&gt;
&lt;p&gt;What do you think about this? If these are possible solutions I have to do some more research and decide which solution I want to realize.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467949?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 14:15:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b48920e4-7c4c-4255-ac31-bb0f08e1c90e</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Sorry I can&amp;#39;t answer your question.&lt;/p&gt;
&lt;p&gt;I wanted to see whether I can still find a matching peripheral by only using the UUID filter. It didn&amp;#39;t work. From that I inferred that some of the changes I made to the scanning earlier today must have had some error.&lt;/p&gt;
&lt;p&gt;I reverted some of the changes I made this morning:&lt;/p&gt;
&lt;p&gt;- set .extended from true to false in m_scan_param&lt;/p&gt;
&lt;p&gt;- reverted scan_start to what I had before:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scan_start(void)
{
    ret_code_t err_code;

    if (nrf_fstorage_is_busy(NULL))
    {
        m_memory_access_in_progress = true;
        return;
    }

    //ble_conn_state_init(); // 20240207

    NRF_LOG_INFO(&amp;quot;Starting scan.&amp;quot;);

    //sd_ble_gap_scan_stop(); // 20240207
    //err_code = sd_ble_gap_scan_start(&amp;amp;m_scan_param, &amp;amp;scan_buffer); // 20240207

    
    err_code = nrf_ble_scan_start(&amp;amp;m_scan);
    APP_ERROR_CHECK(err_code);
    

    err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;- in scan_init() I changed back to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan,
          NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, false);&lt;/pre&gt; to see if I can still find something that way (all_filters_mode = false):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&amp;amp;init_scan, 0, sizeof(init_scan));

    init_scan.p_scan_param     = &amp;amp;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(&amp;amp;m_scan, &amp;amp;init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    ble_uuid_t uuid =
    {
        .uuid = BLE_UUID_SDCS_SERVICE,
        .type = BLE_UUID_TYPE_VENDOR_BEGIN,
    };
    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_UUID_FILTER, &amp;amp;uuid);
    APP_ERROR_CHECK(err_code);

    if (ble_device_name_string_init == true)
    {
        if (strlen(ble_device_name_string) != 0)
        {
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              //m_target_periph_name);
                                              ble_device_name_string);
            APP_ERROR_CHECK(err_code);
        }
    } else {
        
        for(int i=0; i&amp;lt;BDN_STR_LEN; i++) {
            m_target_periph_name[i] = &amp;#39;\0&amp;#39;;
        }
        m_target_periph_name[0] = &amp;#39;B&amp;#39;;
        m_target_periph_name[1] = &amp;#39;T&amp;#39;;
        m_target_periph_name[2] = &amp;#39; &amp;#39;;
        m_target_periph_name[3] = &amp;#39;T&amp;#39;;
        m_target_periph_name[4] = &amp;#39;e&amp;#39;;
        m_target_periph_name[5] = &amp;#39;s&amp;#39;;
        m_target_periph_name[6] = &amp;#39;t&amp;#39;;
        

        if (strlen(m_target_periph_name) != 0)
        {
            NRF_LOG_INFO(&amp;quot;m_target_periph_name: \&amp;quot;%s\&amp;quot;&amp;quot;, m_target_periph_name);
            NRF_LOG_INFO(&amp;quot;sizeof(m_target_periph_name): %d&amp;quot;, (sizeof(m_target_periph_name)));
            NRF_LOG_INFO(&amp;quot;strlen(m_target_periph_name): %d&amp;quot;, (strlen(m_target_periph_name)));
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              m_target_periph_name);
                                              //ble_device_name_string);
            APP_ERROR_CHECK(err_code);
            if (err_code == 0) 
            {
                for (int i=0; i&amp;lt;BDN_STR_LEN; i++)
                {
                    ble_device_name_string[i] = &amp;#39;\0&amp;#39;;
                }
                for (int i=0; i&amp;lt;strlen(m_target_periph_name); i++) {
                    ble_device_name_string[i] = m_target_periph_name[i];
                }
                ble_device_name_string_init = true;
            }
        } else {
            NRF_LOG_INFO(&amp;quot;Please set a ble device name via UART.&amp;quot;);
        }
    }

    if (is_connect_per_addr)
    {
       err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                          SCAN_ADDR_FILTER,
                                          m_target_periph_addr.addr);
       APP_ERROR_CHECK(err_code);
    }
    
    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan,
          NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, false);
    APP_ERROR_CHECK(err_code);
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With all_filters_mode = false I can establish a connection:&lt;/p&gt;
&lt;p&gt;With all_filters_mode = true I can&amp;#39;t find anything.&lt;/p&gt;
&lt;p&gt;When I try to debug code in nrf_ble_scan.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[...]

#if (NRF_BLE_SCAN_NAME_CNT &amp;gt; 0)
    // Check the name filter.
    if (name_filter_enabled)
    {
        filter_cnt++;
        if (adv_name_compare(p_adv_report, p_scan_ctx))
        {
            filter_match_cnt++;

            // Information about the filters matched.
            scan_evt.params.filter_match.filter_match.name_filter_match = true;
            is_filter_matched = true;
        }
    }
#endif

[...]

#if (NRF_BLE_SCAN_UUID_CNT &amp;gt; 0)
    // Check the UUID filter.
    if (uuid_filter_enabled)
    {
        filter_cnt++;
        if (adv_uuid_compare(p_adv_report, p_scan_ctx))
        {
            filter_match_cnt++;
            // Information about the filters matched.
            scan_evt.params.filter_match.filter_match.uuid_filter_match = true;
            is_filter_matched = true;
        }
    }
#endif

[...]&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I either run into NRF_BREAKPOINT_COND or I can not see the advertisement data:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/4857.png" /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/02742.png" /&gt;&lt;/p&gt;
&lt;p&gt;I will continue to work on this on friday.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467925?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 13:08:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d763f916-9151-43b0-b1ab-4dc6b1ff3339</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks. &amp;#39;NRF_BLE_SCAN_ALL_FILTER&amp;#39; did not show up in my search for some reason, so I assumed you had defined this symbol yourself. Anyway, do you see the same if you replace&amp;nbsp;&lt;span&gt;NRF_BLE_SCAN_ALL_FILTER with (NRF_BLE_SCAN_NAME_FILTER |&amp;nbsp;NRF_BLE_SCAN_UUID_FILTER)?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467909?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 12:23:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:838b8411-7d7a-403d-abab-30ee09d757b0</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/mode.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467908?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 12:17:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc22c03-f519-43dd-8cb2-f92cd1905189</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Can you also post your definition of the&amp;nbsp;NRF_BLE_SCAN_ALL_FILTER symbol?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467907?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 12:16:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ecc65d7-a618-4275-958a-e586235a7024</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;While debugging I noticed that I only need to call nrf_ble_scan_filters_enable() once.&lt;/p&gt;
&lt;p&gt;Now I only use&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, true);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In debug I can see the followin scan_filters:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/scan_5F00_filters.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/467892?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 10:54:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:054672fb-0366-4d6b-a90c-fc24b106502e</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;after a bit more testing and improving the general logic a bit further, the code now runs without errors.&lt;/p&gt;
&lt;p&gt;The problem I have now is that I can&amp;#39;t find the advertising peripheral device when I filter with UUID and BLE device name. Generally I can&amp;#39;t find the peripheral when scanning with the BLE device name.&lt;/p&gt;
&lt;p&gt;I think I should be able to check the name filter operation in adv_name_compare() in nrf_ble_scan.c but when I set a breakpoint inside that function, the debugger never seems to reach that breakpoint.&lt;/p&gt;
&lt;p&gt;Since I want to filter by UUID and BLE device name I coded it like this:&lt;/p&gt;
&lt;p&gt;main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define BLE_GAP_SCAN_BUFFER_EXTENDED_MIN (255)

#define BDN_STR_LEN 9

[...]

static ble_gap_scan_params_t const m_scan_param =
{
    .active        = 0x01,
#if (NRF_SD_BLE_API_VERSION &amp;gt; 7)
    .interval_us   = NRF_BLE_SCAN_SCAN_INTERVAL * UNIT_0_625_MS,
    .window_us     = NRF_BLE_SCAN_SCAN_WINDOW * UNIT_0_625_MS,
#else
    .interval      = NRF_BLE_SCAN_SCAN_INTERVAL,
    .window        = NRF_BLE_SCAN_SCAN_WINDOW,
#endif // (NRF_SD_BLE_API_VERSION &amp;gt; 7)
    .filter_policy = BLE_GAP_SCAN_FP_WHITELIST,
    .timeout       = SCAN_DURATION_WITELIST,
    .scan_phys     = BLE_GAP_PHY_1MBPS,
    .extended      = true,
};

static uint8_t scan_buffer_data[BLE_GAP_SCAN_BUFFER_EXTENDED_MIN];

static ble_data_t scan_buffer = {
    scan_buffer_data,
    BLE_GAP_SCAN_BUFFER_MIN
};

static char m_target_periph_name[BDN_STR_LEN];
static char ble_device_name_string[BDN_STR_LEN];
static bool ble_device_name_string_init = false;
static bool is_connect_per_addr = false;

[...]

static void scan_start(void)
{
    ret_code_t err_code;

    if (nrf_fstorage_is_busy(NULL))
    {
        m_memory_access_in_progress = true;
        return;
    }

    ble_conn_state_init(); // 20240207

    NRF_LOG_INFO(&amp;quot;Starting scan.&amp;quot;);

    sd_ble_gap_scan_stop(); // 20240207
    err_code = sd_ble_gap_scan_start(&amp;amp;m_scan_param, &amp;amp;scan_buffer); // 20240207

    /*
    err_code = nrf_ble_scan_start(&amp;amp;m_scan);
    APP_ERROR_CHECK(err_code);
    */

    err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
    APP_ERROR_CHECK(err_code);
}

[...]

static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&amp;amp;init_scan, 0, sizeof(init_scan));

    init_scan.p_scan_param     = &amp;amp;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(&amp;amp;m_scan, &amp;amp;init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    ble_uuid_t uuid =
    {
        .uuid = BLE_UUID_SDCS_SERVICE,
        //.type = BLE_UUID_TYPE_BLE, // fuer BT SIG UUIDs
        .type = BLE_UUID_TYPE_VENDOR_BEGIN, // fuer herstellerspezifische 128 bit UUIDs
    };
    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_UUID_FILTER, &amp;amp;uuid);
    APP_ERROR_CHECK(err_code);

    if (ble_device_name_string_init == true)
    {
        if (strlen(ble_device_name_string) != 0)
        {
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              //m_target_periph_name);
                                              ble_device_name_string);
            APP_ERROR_CHECK(err_code);
        }
    } else {
        
        for(int i=0; i&amp;lt;BDN_STR_LEN; i++) {
            m_target_periph_name[i] = &amp;#39;\0&amp;#39;;
        }
        m_target_periph_name[0] = &amp;#39;B&amp;#39;;
        m_target_periph_name[1] = &amp;#39;T&amp;#39;;
        m_target_periph_name[2] = &amp;#39; &amp;#39;;
        m_target_periph_name[3] = &amp;#39;T&amp;#39;;
        m_target_periph_name[4] = &amp;#39;e&amp;#39;;
        m_target_periph_name[5] = &amp;#39;s&amp;#39;;
        m_target_periph_name[6] = &amp;#39;t&amp;#39;;
        

        if (strlen(m_target_periph_name) != 0)
        {
            NRF_LOG_INFO(&amp;quot;m_target_periph_name: \&amp;quot;%s\&amp;quot;&amp;quot;, m_target_periph_name);
            NRF_LOG_INFO(&amp;quot;sizeof(m_target_periph_name): %d&amp;quot;, (sizeof(m_target_periph_name)));
            NRF_LOG_INFO(&amp;quot;strlen(m_target_periph_name): %d&amp;quot;, (strlen(m_target_periph_name)));
            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              m_target_periph_name);
                                              //ble_device_name_string);
            APP_ERROR_CHECK(err_code);
            if (err_code == 0) 
            {
                for (int i=0; i&amp;lt;BDN_STR_LEN; i++)
                {
                    ble_device_name_string[i] = &amp;#39;\0&amp;#39;;
                }
                for (int i=0; i&amp;lt;strlen(m_target_periph_name); i++) {
                    ble_device_name_string[i] = m_target_periph_name[i];
                }
                ble_device_name_string_init = true;
            }
        } else {
            NRF_LOG_INFO(&amp;quot;Please set a ble device name via UART.&amp;quot;);
        }
    }

    if (is_connect_per_addr)
    {
       err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                          SCAN_ADDR_FILTER,
                                          m_target_periph_addr.addr);
       APP_ERROR_CHECK(err_code);
    }

    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_NAME_FILTER, true);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_UUID_FILTER, true);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ALL_FILTER, true);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;sdk_config.h:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;e&amp;gt; NRF_BLE_SCAN_FILTER_ENABLE - Enabling filters for the Scanning Module.
//==========================================================
#ifndef NRF_BLE_SCAN_FILTER_ENABLE
#define NRF_BLE_SCAN_FILTER_ENABLE 1
#endif
// &amp;lt;o&amp;gt; NRF_BLE_SCAN_UUID_CNT - Number of filters for UUIDs. 
#ifndef NRF_BLE_SCAN_UUID_CNT
#define NRF_BLE_SCAN_UUID_CNT 1
#endif

// &amp;lt;o&amp;gt; NRF_BLE_SCAN_NAME_CNT - Number of name filters. 
#ifndef NRF_BLE_SCAN_NAME_CNT
#define NRF_BLE_SCAN_NAME_CNT 1
#endif

// &amp;lt;o&amp;gt; NRF_BLE_SCAN_SHORT_NAME_CNT - Number of short name filters. 
#ifndef NRF_BLE_SCAN_SHORT_NAME_CNT
#define NRF_BLE_SCAN_SHORT_NAME_CNT 0
#endif

// &amp;lt;o&amp;gt; NRF_BLE_SCAN_ADDRESS_CNT - Number of address filters. 
#ifndef NRF_BLE_SCAN_ADDRESS_CNT
#define NRF_BLE_SCAN_ADDRESS_CNT 0
#endif

// &amp;lt;o&amp;gt; NRF_BLE_SCAN_APPEARANCE_CNT - Number of appearance filters. 
#ifndef NRF_BLE_SCAN_APPEARANCE_CNT
#define NRF_BLE_SCAN_APPEARANCE_CNT 0
#endif

// &amp;lt;/e&amp;gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;sdcs_c.h:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief   Macro for defining a ble_sdcs_c instance.
 *
 * @param   _name   Name of the instance.
 * @hideinitializer
 */
#define BLE_SDCS_C_DEF(_name)                                                                        \
static ble_sdcs_c_t _name;                                                                           \
NRF_SDH_BLE_OBSERVER(_name ## _obs,                                                                 \
                     BLE_SDCS_C_BLE_OBSERVER_PRIO,                                                   \
                     ble_sdcs_c_on_ble_evt, &amp;amp;_name)

/** @brief Macro for defining multiple ble_sdcs_c instances.
 *
 * @param   _name   Name of the array of instances.
 * @param   _cnt    Number of instances to define.
 * @hideinitializer
 */
#define BLE_SDCS_C_ARRAY_DEF(_name, _cnt)                 \
static ble_sdcs_c_t _name[_cnt];                          \
NRF_SDH_BLE_OBSERVERS(_name ## _obs,                     \
                      BLE_SDCS_C_BLE_OBSERVER_PRIO,       \
                      ble_sdcs_c_on_ble_evt, &amp;amp;_name, _cnt)


/** @brief  Maximum number of RR intervals to be decoded for each SDCS notifications (any extra RR intervals are ignored).
 *
 * This define should be defined in the sdk_config.h file to override the default.
 */
#ifndef BLE_SDCS_C_RR_INTERVALS_MAX_CNT
#define BLE_SDCS_C_RR_INTERVALS_MAX_CNT 20
#endif

#define SDCS_BASE_UUID {0x9F, 0xDC, 0x9C, 0x81, 0xFF, 0xFe, 0x94, 0x89, 0xE5, 0x11, 0x94, 0x9D, 0x00, 0xED, 0xCB, 0x5D} // little endian

#define BLE_UUID_SDCS_SERVICE   0xED00
#define SDCS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN // 0x02 /**&amp;lt; UUID type for the Nordic UART Service (vendor specific). */

#define BLE_UUID_SDCS_PIPE_CHARACTERISTIC 0xED20

#define BLE_CLIENT_CHARACTERISTIC_CONFIG_UUID {{0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb}}

[...]&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/466198?ContentTypeID=1</link><pubDate>Fri, 26 Jan 2024 11:26:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce3b74f7-9afc-4634-bcbf-0bf4565879d5</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Ok, I found out my firmware uses the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/examples_bsp_btn_ble.html"&gt;BSP BLE Button Module&lt;/a&gt;... This module fires the &lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__bsp.html#ggad026454d14088f6f37bd2ba15fe816dfa080e5a2f7e4d93b3ac7e1f7d5b93f09c"&gt;BSP_EVENT_SLEEP&lt;/a&gt; event when BLE is not connected and Button 1 is released (This was case in my program).&lt;/p&gt;
&lt;p&gt;In my main.c I handled the &lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__bsp.html#ggad026454d14088f6f37bd2ba15fe816dfa080e5a2f7e4d93b3ac7e1f7d5b93f09c"&gt;BSP_EVENT_SLEEP&lt;/a&gt; the following way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BSP_EVENT_SLEEP:
            NRF_LOG_INFO(&amp;quot;BSP_EVENT_SLEEP&amp;quot;);
            nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
            break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This lead to my program going to sleep.&lt;/p&gt;
&lt;p&gt;Now I commented those lines of code and it solved my problem&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks for helping me figuring this out!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465861?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 15:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26b599c6-11ce-4c56-a8c1-d44f2e2c9d10</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;No worries. I&amp;#39;ll leave this thread open.&amp;nbsp;&lt;/p&gt;
[quote userid="104738" url="~/f/nordic-q-a/107563/error-4-nrf_error_no_mem-after-nrf_ble_scan_filter_set/465856"]I checked the code further and found out, that the error is caused in main()[/quote]
&lt;p&gt;This is a different assert check. The&amp;nbsp;crash log pointed to the assert here:&amp;nbsp;C:\nRF5_SDK_17.0.2_d674dde\components\libraries\pwr_mgmt\nrf_pwr_mgmt.c:418&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465856?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 15:42:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f8885ab-a590-45f5-9042-56358865f052</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Hello Vidar.&lt;/p&gt;
&lt;p&gt;Sorry, I closed this ticket by excident...&lt;/p&gt;
&lt;p&gt;I checked the code further and found out, that the error is caused in main()&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;[...]

// Enter main loop.
    for (;;)
    {
        if (uart_started == true)
        {
            uint8_t cr;
            while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
            
[...]&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;by the call of app_uart_get(&amp;amp;cr).&lt;/p&gt;
&lt;p&gt;Inside of app_uart_get(uint8_t * p_byte) the first command is ASSERT(p_byte).&lt;/p&gt;
&lt;p&gt;This is defined in nrf_assert.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef _lint
#define ASSERT(expr)                                                          \
if (expr)                                                                     \
{                                                                             \
}                                                                             \
else                                                                          \
{                                                                             \
    while (1);                                                                \
}
#else //_lint
#define ASSERT(expr)                                                          \
if (NRF_ASSERT_PRESENT)                                                       \
{                                                                             \
    if (expr)                                                                 \
    {                                                                         \
    }                                                                         \
    else                                                                      \
    {                                                                         \
        assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__);         \
    }                                                                         \
}

#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In debug I found that p_byte got a value of 0x00004001 and *p_byte is 0x80.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand why this is a problem but it is a problem. I think it is a problem with app_uart_fifo.&lt;/p&gt;
&lt;p&gt;Do you have any idea what could be the issue here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465827?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 14:01:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10b1f266-cef6-4629-ab18-67c1dc86bd1c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I understand.&lt;/p&gt;
&lt;p&gt;This assert is triggered if you attempt to enter the system OFF mode while debugging the application. Also, note that asserts are only enabled in the &amp;#39;Debug&amp;#39; build configuration. This might explain why you have not encountered the error before.&lt;/p&gt;
[quote userid="104738" url="~/f/nordic-q-a/107563/error-4-nrf_error_no_mem-after-nrf_ble_scan_filter_set/465821"]How can I investigate this &amp;quot;system off&amp;quot; assertion in debug?[/quote]
&lt;p&gt;You can start by looking for references to &amp;quot;sleep&amp;quot;, &amp;quot;SYSOFF&amp;quot;, &amp;quot;nrf_pwr_mgmt_shutdown&amp;quot;, etc in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465821?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:54:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91a37fbd-9cf3-4752-92bd-5ae19ed5269b</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Sadly I am not allowed to upload the whole project because it has confidential code. I can only post general code here... I asked my collegue about this earlier already but he doesn&amp;#39;t allow it. I think I can share some more parts from my main.c... I have to ask my collegue about this. How can I investigate this &amp;quot;system off&amp;quot; assertion in debug? I am using Segger Embedded Studio for ARM 5.42a&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465818?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:49:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0579c76d-12e2-40eb-a6ab-401661d03373</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I saw it, but it is only displaying a portion of the callback, and I&amp;#39;m not sure what else, if anything, is included in the callback. I&amp;#39;m trying to understand where and when your application will try to enter system off. Can you upload your whole project instead?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465817?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c93edb17-9026-4ad4-8f5b-5ea91ea5289c</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;You can see the code for the button callback in the 4th post in this topic. Basicly the button only stops the scanning by calling nrf_ble_scan_stop() and then sets&amp;nbsp;uart_started = true...&amp;nbsp; see:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BSP_EVENT_KEY_0:
        {   
            nrf_ble_scan_stop();
            
            NRF_LOG_INFO(&amp;quot;Button 1 pressed.&amp;quot;);
            //nrf_gpio_pin_toggle(LED_4); 
            NRF_LOG_INFO(&amp;quot;Please enter a new #encryption_key and/or $ble device name: &amp;quot;);
            uart_receive();
            break;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After uart_started got set to true, the firmware should run the code for uart processing by running the code in the if query in main().This already worked when my device had established a BLE connection.Now I try to run into this code before I got a working BLE connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465814?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa95ab84-8363-4318-87c4-25632a658c9d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Please post the code for your button callback.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465812?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:32:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdabe598-d3b1-44d0-b252-01d4cfcca5fa</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;The error appears right after I press the button. From the log I can see that the program starts reading input via UART but then it seems to get the error immediately. I didn&amp;#39;t type anything in putty and I didn&amp;#39;t get this problem before I changed the scanning. The difference is, that now I try to receive input via uart before my device has established a working BLE connection to SDCS and before I had the connection and then I initiated uart input processing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465808?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 13:25:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f274ce3f-dcbf-4923-a53d-efedad9b70ba</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="tbuenger"]Now I&amp;#39;m getting this error:[/quote]
&lt;p&gt;This assertion is raised because the program attempts to enter System OFF mode (deep sleep) while the chip is in debug interface mode. I&amp;#39;m not sure where or when your application will try to enter sleep.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465794?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 12:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a60b519b-f7c4-4eef-b085-52d6e4cc0cb0</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Some more information for clarification:&lt;/p&gt;
&lt;p&gt;In my uart_receive() I only set uart_started = true...&lt;/p&gt;
&lt;p&gt;The real logic for processing uart is in my main():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    // Initialize.
    log_init(); // uses UART
    timer_init();
    //bsp_board_init(BSP_INIT_LEDS);
    power_management_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    //gpio_init();
    uart_started = false;
    uart_init(); // uses UART
    ble_stack_init();
    gatt_init();
    peer_manager_init();
    db_discovery_init();
    //hrs_c_init();
    sdcs_c_init();
    bas_c_init();
    scan_init();

    NRF_LOG_INFO(&amp;quot;SDCS client started.&amp;quot;);

    scanning_start(&amp;amp;erase_bonds);  

    // Enter main loop.
    for (;;)
    {
        if (uart_started == true)
        {
            uint8_t cr;
            while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
            while (app_uart_put(cr) != NRF_SUCCESS);
            
            if (uart_receive_index &amp;lt; UART_RECEIVE_MAX_LENGTH)
            {
                uart_receive_data[uart_receive_index++] = cr;
            }
            
            if (uart_receive_index &amp;gt;= UART_RECEIVE_MAX_LENGTH ||
                cr == 0xD) // Enter
              //cr == 0x20) // Spacebar
            {
                NRF_LOG_INFO(&amp;quot;\r\nExit UART.\r\n&amp;quot;);
                //printf(&amp;quot; \r\nExit UART.\r\n&amp;quot;);
                
                /*
                NRF_LOG_INFO(&amp;quot;received data [line 1]: %x %x %x %x&amp;quot;, uart_receive_data[0], uart_receive_data[1], uart_receive_data[2], uart_receive_data[3]);
                NRF_LOG_INFO(&amp;quot;received data [line 2]: %x %x %x %x&amp;quot;, uart_receive_data[4], uart_receive_data[5], uart_receive_data[6], uart_receive_data[7]);
                NRF_LOG_INFO(&amp;quot;received data [line 3]: %x %x %x %x&amp;quot;, uart_receive_data[8], uart_receive_data[9], uart_receive_data[10], uart_receive_data[11]);
                NRF_LOG_INFO(&amp;quot;received data [line 4]: %x %x %x %x&amp;quot;, uart_receive_data[12], uart_receive_data[13], uart_receive_data[14], uart_receive_data[15]);
                */
                
                uart_started = false;
                // determine length of input string
                if (cr == 0xD) {
                    uart_receive_length = (uart_receive_index -1);
                } else {
                    uart_receive_length = uart_receive_index;
                }
                NRF_LOG_INFO(&amp;quot;uart_receive_length: 0x%x = %d&amp;quot;, uart_receive_length, uart_receive_length);

[...]
// then I have some code which checks the input strings
[...]

                if (name_length != 0) {
                    NRF_LOG_INFO(&amp;quot;name_length: %d&amp;quot;, name_length);
                    if (name_length &amp;gt; BDN_STR_LEN)
                    {
                        NRF_LOG_INFO(&amp;quot;Entered BLE name is too long! Max BLE name is %d characters!&amp;quot;, BDN_STR_LEN);
                    } else { 
                        if (name_length &amp;lt; 1) {
                            NRF_LOG_INFO(&amp;quot;Entered BLE name is too short!&amp;quot;);
                        } else {
                            for (int i=0; i&amp;lt;BDN_STR_LEN; i++) {
                                ble_device_name_string[i] = &amp;#39; &amp;#39;;
                            }
                            for (int i=0; (i&amp;lt;name_length &amp;amp;&amp;amp; i&amp;lt;BDN_STR_LEN); i++) {
                                ble_device_name_string[i] = input_string[(i+name_begin_index)];
                            }
                            NRF_LOG_INFO(&amp;quot;ble_device_name_string: %s&amp;quot;, ble_device_name_string);
                            
                            // Remove all filters.
                            ret_code_t err_code;
                            err_code = nrf_ble_scan_all_filter_remove(&amp;amp;m_scan);
                            APP_ERROR_CHECK(err_code);

                            ble_uuid_t uuid =
                            {
                                .uuid = BLE_UUID_SDCS_SERVICE,
                                //.type = BLE_UUID_TYPE_BLE, // for BT SIG UUIDs
                                .type = BLE_UUID_TYPE_VENDOR_BEGIN, // for vendor specific 128 bit UUIDs
                            };
                            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_UUID_FILTER, &amp;amp;uuid);
                            APP_ERROR_CHECK(err_code);

                            err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                              SCAN_NAME_FILTER,
                                              ble_device_name_string);
                            APP_ERROR_CHECK(err_code);

                            if (is_connect_per_addr)
                            {
                                err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                                         SCAN_ADDR_FILTER,
                                                         m_target_periph_addr.addr);
                                APP_ERROR_CHECK(err_code);
                            }
                            
                            err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan,NRF_BLE_SCAN_ALL_FILTER,true); // alle gesetzten filter muessen zutreffen
                            input_valid = true;
                        }
                    }
                }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465780?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 12:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91ab3905-11b0-4631-9c20-e25be6c4ba18</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Hello Vidar,&lt;/p&gt;
&lt;p&gt;thanks for your advice. I adjusted my program accordingly and it helped. Now I&amp;#39;m working on the next step and got a different problem:&lt;/p&gt;
&lt;p&gt;When I disconnected after changing the filters, I noticed that my device always connected to a SDCS device (SDCS = Secure Data Container Service... It&amp;#39;s our own BLE service). That lead me to believe that it didn&amp;#39;t use the name filter correctly but only established the connection based on the UUID.&lt;/p&gt;
&lt;p&gt;I then changed&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, false);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan,NRF_BLE_SCAN_ALL_FILTER,true);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I also added&amp;nbsp;nrf_ble_scan_stop(); to the beginning of my Button event code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BSP_EVENT_KEY_0:
        {   
            nrf_ble_scan_stop();
            
            NRF_LOG_INFO(&amp;quot;Button 1 pressed.&amp;quot;);
            //nrf_gpio_pin_toggle(LED_4); 
            NRF_LOG_INFO(&amp;quot;Please enter a new #encryption_key and/or $ble device name: &amp;quot;);
            uart_receive();
            break;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;m getting this error:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.
&amp;lt;info&amp;gt; app: SDCS client started.
&amp;lt;info&amp;gt; app: Starting scan.
&amp;lt;info&amp;gt; app: Button 1 pressed.
&amp;lt;info&amp;gt; app: Please enter a new #encryption_key and/or $ble device name: 
&amp;lt;info&amp;gt; app: 
UART started.

&amp;lt;error&amp;gt; app: ERROR 3735928559 [Unknown error code] at C:\nRF5_SDK_17.0.2_d674dde\components\libraries\pwr_mgmt\nrf_pwr_mgmt.c:418
PC at: 0x0002744B
&amp;lt;error&amp;gt; app: End of error report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I think I need to improve the connection handling e.g. only start the authentication process, when I have an active connection... Or only start UART input when my device is ready... Any tips on how and where I should add some of these&amp;nbsp; required if queries to improve firmware stability? Please help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465017?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2024 11:43:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6b01781-eaef-4df4-8a62-04de1f8ca9f0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Tobias,&lt;/p&gt;
&lt;p&gt;Each time you call nrf_ble_scan_filter_set(), a new name is added to the filter. The number of names allocated for this filter is determined by the NRF_BLE_SCAN_NAME_CNT symbol in your sdk_config.h header and&amp;nbsp;&lt;span&gt;NRF_ERROR_NO_MEM is returned when you exceed this number.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;A solution can be to call&amp;nbsp;nrf_ble_scan_all_filter_remove() before adding the new name filter.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ERROR 4 [NRF_ERROR_NO_MEM] after nrf_ble_scan_filter_set()</title><link>https://devzone.nordicsemi.com/thread/465015?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2024 11:35:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c9d7b30-edcb-4255-a9f3-8d66470e3281</guid><dc:creator>tbuenger</dc:creator><description>&lt;p&gt;Debug log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.
&amp;lt;info&amp;gt; app: SDCS client started.
&amp;lt;info&amp;gt; app: Starting scan.
&amp;lt;info&amp;gt; app: NRF_BLE_SCAN_EVT_FILTER_MATCH
&amp;lt;info&amp;gt; app: Connected. m_conn_handle: 0x0
&amp;lt;info&amp;gt; app: GATT ATT MTU on connection 0x0 changed to 247.
&amp;lt;info&amp;gt; app: BLE_GATTC_EVT_EXCHANGE_MTU_RSP
&amp;lt;info&amp;gt; app: Data length for connection 0x0 updated to 251.
&amp;lt;info&amp;gt; app: SDCS discovered.
&amp;lt;info&amp;gt; app: BLE Device Name: BT Door
&amp;lt;info&amp;gt; app: Waiting for Button press...
&amp;lt;info&amp;gt; app: Button 1 -&amp;gt; set new ble device name ($name) and/or encryption key (#key) via uart
&amp;lt;info&amp;gt; app: Button 2 -&amp;gt; start authentication
&amp;lt;info&amp;gt; app: Button 3 -&amp;gt; remote access open door request
&amp;lt;info&amp;gt; ble_sdcs_c: Configuring CCCD. CCCD Handle = 14, Connection Handle = 0
&amp;lt;info&amp;gt; app: BLE_GATTC_EVT_WRITE_RSP, gatt_status: 0x0
&amp;lt;info&amp;gt; app: BLE_GATT_HVX_NOTIFICATION
&amp;lt;info&amp;gt; app: Button 1 pressed.
&amp;lt;info&amp;gt; app: Please enter a new encryption_key: 
&amp;lt;info&amp;gt; app: 
UART started.

&amp;lt;info&amp;gt; app: 
Exit UART.

&amp;lt;info&amp;gt; app: uart_receive_length: 0x13 = 19
&amp;lt;info&amp;gt; app: name_length: 7
&amp;lt;info&amp;gt; app: ble_device_name_string (0 - 4): B T   T e
&amp;lt;info&amp;gt; app: ble_device_name_string (5 - 8): s t    
&amp;lt;error&amp;gt; app: ERROR 4 [NRF_ERROR_NO_MEM] at C:\nRF5_SDK_17.0.2_d674dde\examples\ble_central\ble_app_sdcs_c\main.c:1836
PC at: 0x00029F41
&amp;lt;error&amp;gt; app: End of error report
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>