<?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>CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77986/caf-ble-state-bt-connection-limit</link><description>Hi, 
 I am currently developing an application around the CAF BLE state and advertising components. 
 My setup consists of a nRF9160DK that uses the nRF52840 onboard for BLE. 
 The components themselves work mostly OK, but I run into a problem with the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Jul 2022 21:40:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77986/caf-ble-state-bt-connection-limit" /><item><title>RE: CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/thread/378183?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2022 21:40:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b3d0881-7b22-4fa4-93bc-7bac29d5783c</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;But the scan library is needed if one wants to use scan filters, and that library needs CONFIG_BT_SCAN, which again needs CONFIG_BT_CENTRAL, and then we are back again to the build assert in the CAF module ble_state.c. Would it be possible to change that build assert test. I am using ncs 2.0.0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I posted a new issue on devzone for this:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/90310/caf-ble-state-module-build-assert-when-config_bt_peripheral-and-config_bt_central-is-set"&gt;CAF BLE state module build assert when CONFIG_BT_PERIPHERAL and CONFIG_BT_CENTRAL is set&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/thread/322702?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 14:52:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:475392a2-4a11-4406-bab2-064ad0f4153c</guid><dc:creator>langestefann</dc:creator><description>&lt;p&gt;This works great. Thanks a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/thread/322600?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 07:50:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3065af4b-8766-45cd-992c-37b2c261d995</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Check out the sample I attached, where I use the function&amp;nbsp;bt_le_scan_start() without enabling CONFIG_BT_SCAN or CONFIG_BT_CENTRAL.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The function&amp;nbsp;bt_le_scan_start() is declared in&amp;nbsp;zephyr/include/bluetooth/bluetooth.h (not scan.h) and defined in&amp;nbsp;zephyr/subsys/bluetooth/host/scan.c.&lt;/p&gt;
&lt;p&gt;The file&amp;nbsp;&lt;span&gt;zephyr/subsys/bluetooth/host/scan.c is intergrated into the project&amp;nbsp;due to CONFIG_BT_OBSERVER:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.6.0-rc1-ncs1/subsys/bluetooth/host/CMakeLists.txt#L44-L47"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.6.0-rc1-ncs1/subsys/bluetooth/host/CMakeLists.txt#L44-L47&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/thread/322413?ContentTypeID=1</link><pubDate>Thu, 29 Jul 2021 10:11:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5476067f-489c-4d02-a9d2-68e62ada35ef</guid><dc:creator>langestefann</dc:creator><description>&lt;p&gt;Thanks for your quick reply, this clears some things up. I am relatively new to BLE so happy to learn new things.&lt;/p&gt;
&lt;p&gt;I am still a bit confused about the term &amp;#39;scanning&amp;#39;, since in my project I had set&amp;nbsp;CONFIG_BT_SCAN=y, but this has a direct dependency on&amp;nbsp;BT_CENTRAL=y.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you know if I can still use the scanning module (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/bluetooth/scan.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/bluetooth/scan.html&lt;/a&gt;) in my project?&lt;/p&gt;
&lt;p&gt;Since I had build my scanning code around this module and now the code will no longer build. Should I just use&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bt_le_scan_start()
bt_le_scan_stop()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;directly? Or do you have a better suggestion?&lt;/p&gt;
&lt;p&gt;Again, many thanks&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF BLE state BT connection limit</title><link>https://devzone.nordicsemi.com/thread/322402?ContentTypeID=1</link><pubDate>Thu, 29 Jul 2021 09:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e5570c3-9156-4a25-95a0-6f4e3bd0c456</guid><dc:creator>Simon</dc:creator><description>[quote user=""]- Be a central so that I can scan for advertising packets from other BLE sensors. I will&amp;nbsp;never connect, I just need to be able to parse the advertisement data.[/quote]
&lt;p&gt;&amp;nbsp;If you just want the device to scan without connection, you should not configure it as a central. As mentioned in the ticket&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/71/what-is-a-client-and-server-in-ble"&gt;What is a client and server in BLE?&lt;/a&gt;, the central role has to do with establishing a connection. Instead you should configure it as an observer, which is the non-connecting variant of a central.&lt;/p&gt;
&lt;p&gt;I modified the sample ncs/zephyr/samples/bluetooth/central to make it operate as an observer. I used NCS v1.6.0, and here is the diff:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="diff"&gt;diff --git a/samples/bluetooth/central/prj.conf b/samples/bluetooth/central/prj.conf
index 3e36a99938..091c338db6 100644
--- a/samples/bluetooth/central/prj.conf
+++ b/samples/bluetooth/central/prj.conf
@@ -1,2 +1,4 @@
 CONFIG_BT=y
-CONFIG_BT_CENTRAL=y
+CONFIG_BT_OBSERVER=y
\ No newline at end of file
diff --git a/samples/bluetooth/central/src/main.c b/samples/bluetooth/central/src/main.c
index c2a164cccb..f58203f145 100644
--- a/samples/bluetooth/central/src/main.c
+++ b/samples/bluetooth/central/src/main.c
@@ -14,49 +14,21 @@
 
 #include &amp;lt;bluetooth/bluetooth.h&amp;gt;
 #include &amp;lt;bluetooth/hci.h&amp;gt;
-#include &amp;lt;bluetooth/conn.h&amp;gt;
 #include &amp;lt;bluetooth/uuid.h&amp;gt;
 #include &amp;lt;bluetooth/gatt.h&amp;gt;
 #include &amp;lt;sys/byteorder.h&amp;gt;
 
 static void start_scan(void);
 
-static struct bt_conn *default_conn;
-
 static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
                         struct net_buf_simple *ad)
 {
        char addr_str[BT_ADDR_LE_STR_LEN];
        int err;
 
-       if (default_conn) {
-               return;
-       }
-
-       /* We&amp;#39;re only interested in connectable events */
-       if (type != BT_GAP_ADV_TYPE_ADV_IND &amp;amp;&amp;amp;
-           type != BT_GAP_ADV_TYPE_ADV_DIRECT_IND) {
-               return;
-       }
 
        bt_addr_le_to_str(addr, addr_str, sizeof(addr_str));
        printk(&amp;quot;Device found: %s (RSSI %d)\n&amp;quot;, addr_str, rssi);
-
-       /* connect only to devices in close proximity */
-       if (rssi &amp;lt; -70) {
-               return;
-       }
-
-       if (bt_le_scan_stop()) {
-               return;
-       }
-
-       err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
-                               BT_LE_CONN_PARAM_DEFAULT, &amp;amp;default_conn);
-       if (err) {
-               printk(&amp;quot;Create conn to %s failed (%u)\n&amp;quot;, addr_str, err);
-               start_scan();
-       }
 }
 
 static void start_scan(void)
@@ -73,54 +45,6 @@ static void start_scan(void)
        printk(&amp;quot;Scanning successfully started\n&amp;quot;);
 }
 
-static void connected(struct bt_conn *conn, uint8_t err)
-{
-       char addr[BT_ADDR_LE_STR_LEN];
-
-       bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
-
-       if (err) {
-               printk(&amp;quot;Failed to connect to %s (%u)\n&amp;quot;, addr, err);
-
-               bt_conn_unref(default_conn);
-               default_conn = NULL;
-
-               start_scan();
-               return;
-       }
-
-       if (conn != default_conn) {
-               return;
-       }
-
-       printk(&amp;quot;Connected: %s\n&amp;quot;, addr);
-
-       bt_conn_disconnect(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
-}
-
-static void disconnected(struct bt_conn *conn, uint8_t reason)
-{
-       char addr[BT_ADDR_LE_STR_LEN];
-
-       if (conn != default_conn) {
-               return;
-       }
-
-       bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
-
-       printk(&amp;quot;Disconnected: %s (reason 0x%02x)\n&amp;quot;, addr, reason);
-
-       bt_conn_unref(default_conn);
-       default_conn = NULL;
-
-       start_scan();
-}
-
-static struct bt_conn_cb conn_callbacks = {
-               .connected = connected,
-               .disconnected = disconnected,
-};
-
 void main(void)
 {
        int err;
@@ -133,7 +57,7 @@ void main(void)
 
        printk(&amp;quot;Bluetooth initialized\n&amp;quot;);
 
-       bt_conn_cb_register(&amp;amp;conn_callbacks);
+       //bt_conn_cb_register(&amp;amp;conn_callbacks);
 
        start_scan();
 }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>