<?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>Can&amp;#39;t connect to peripheral</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73741/can-t-connect-to-peripheral</link><description>I&amp;#39;m trying to connect a 52832 board to a peripheral BLE device. NRF52832 SD: s132 v7.0.1 SDK 16.0.0 As a first step, I&amp;#39;m not setting flters, I just want to connect to any peripheral. There are lots of advertising peripherals nearby, I can scan and connect</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Apr 2021 10:07:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73741/can-t-connect-to-peripheral" /><item><title>RE: Can't connect to peripheral</title><link>https://devzone.nordicsemi.com/thread/305252?ContentTypeID=1</link><pubDate>Fri, 16 Apr 2021 10:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2119795a-268e-42a6-8dda-0c50c80415c3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Are you saying that it works as intended now that you&amp;#39;re setting filters with the nrf_ble_scan_filter_set() function and the issue is resolved, or does the problem still persist with this nrf_ble_scan_init() function?&lt;/p&gt;
&lt;p&gt;If it&amp;#39;s resolved, feel free to verify your answer to mark this case as solved.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't connect to peripheral</title><link>https://devzone.nordicsemi.com/thread/305093?ContentTypeID=1</link><pubDate>Thu, 15 Apr 2021 12:22:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80f03419-4113-449e-b79d-c99e67153555</guid><dc:creator>QuentinFarizon</dc:creator><description>&lt;p&gt;Thank you, it works like this :&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;    err_code = nrf_ble_scan_init(&amp;amp;m_scan, &amp;amp;init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                       SCAN_NAME_FILTER,
                                       &amp;quot;Bala&amp;quot;);
    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);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't connect to peripheral</title><link>https://devzone.nordicsemi.com/thread/304174?ContentTypeID=1</link><pubDate>Mon, 12 Apr 2021 06:31:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:741bfdbc-ccba-4b3a-b75d-6ab6c4fec4ec</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;In your init function here, it seems like you enable all filters, which might cause some issues for you Please try setting this to&amp;nbsp;&lt;strong&gt;NRF_BLE_SCAN_NAME_FILTER&lt;/strong&gt;. Can you also show me how the device name is set in your peripheral device?&lt;/p&gt;
&lt;p&gt;From what I can see, this scan_init should let you connect to a peripheral advertising with the device name Bala.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't connect to peripheral</title><link>https://devzone.nordicsemi.com/thread/304045?ContentTypeID=1</link><pubDate>Fri, 09 Apr 2021 13:50:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93ead4b6-ee45-440c-b0d0-34f42552f4ab</guid><dc:creator>QuentinFarizon</dc:creator><description>&lt;p&gt;Sorry for the XY problem :)&lt;br /&gt;Indeed, my goal&amp;nbsp;is connecting to a device by its name, with a filter set. As it was not working, I tried the above, but I understand now why it didn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Here was my filtering code that doesn&amp;#39;t connect to my peripheral.&lt;br /&gt;&amp;quot;Bala&amp;quot; is the name of mu peripheral, I see it in nRF connect and can connect to it.&lt;br /&gt;&lt;br /&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);

    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan,
                                       SCAN_NAME_FILTER,
                                       &amp;quot;Bala&amp;quot;);
    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;br /&gt;&lt;br /&gt;Here are the logs :&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; &amp;lt;debug&amp;gt; ble_scan: Adding filter on Bala name
00&amp;gt; &amp;lt;debug&amp;gt; ble_scan: BLE_GAP_SCAN_TIMEOUT
00&amp;gt; &amp;lt;info&amp;gt; app: Scan timed out.
00&amp;gt; &amp;lt;debug&amp;gt; ble_scan: Scanning parameters have been changed successfully
00&amp;gt; &amp;lt;debug&amp;gt; ble_scan: Scanning
00&amp;gt; &amp;lt;debug&amp;gt; ble_scan: BLE_GAP_SCAN_TIMEOUT&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't connect to peripheral</title><link>https://devzone.nordicsemi.com/thread/303905?ContentTypeID=1</link><pubDate>Fri, 09 Apr 2021 07:29:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7155e6a-4bc8-4672-9c75-31d6b2c99784</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;When you have the&amp;nbsp;&lt;strong&gt;init_scan.connect_if_match = true;&amp;nbsp;&lt;/strong&gt;set in your scan_init,&amp;nbsp;the scan module automatically conencts after a filter match or successful identification of a device from the whitelist. So if you don&amp;#39;t have any filters added to your whitelist, you won&amp;#39;t connect to any devices at all. If you add multiple filters (I.E. all the services you would like to connect to) in your scanning module the connect_if_match should connect to the first discovered device matching any criteria.&lt;/p&gt;
&lt;p&gt;I would suggest checking out the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__ble__scan.html"&gt;scanning module in the SDK&lt;/a&gt; to get more information on I.E. filters, triggering connections from scanning, etc. What exactly is your goal here? Just connecting to the first discovered advertising device doesn&amp;#39;t seem like the ultimate use case.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>