<?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>Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113635/adding-custom-ble-services-to-matter</link><description>We are developing Matter/Thread based Smart Lock product. One of the product requirements is that the product should be able to connect to a BLE mobile APP at all times i.e. before and after provisioned into matter/Thread network. The BLE will be used</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 02 Aug 2024 14:49:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113635/adding-custom-ble-services-to-matter" /><item><title>RE: Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/thread/496852?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2024 14:49:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3873fb3-1e2e-45ce-bfbe-99676fbba3e1</guid><dc:creator>SubuMuthu</dc:creator><description>&lt;p&gt;Thank you Marte,&lt;/p&gt;
&lt;p&gt;It worked!&amp;nbsp; The below are the exact changes that I made.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#---Enable BLE&lt;/p&gt;
&lt;p&gt;CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048&lt;/p&gt;
&lt;p&gt;CONFIG_BT=y&lt;br /&gt;CONFIG_BT_SMP=y&lt;/p&gt;
&lt;p&gt;CONFIG_BT_BONDABLE=n&lt;/p&gt;
&lt;p&gt;CONFIG_BT_RX_STACK_SIZE=1536&lt;/p&gt;
&lt;p&gt;CONFIG_BT_DEVICE_APPEARANCE=833&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Appreciate your support!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Subu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/thread/496851?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2024 10:13:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdbce166-e9a5-4d5f-8521-35bf8909d904</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Subu&lt;/p&gt;
[quote user="SubuMuthu"]So, as a first step (Step #1),&amp;nbsp; we made a copy of NUS source code from&amp;nbsp;&lt;span&gt;&amp;nbsp;“nus.c, nus.h, bt_nus_service.h, bt_nus_service.cpp”, modified ONLY UUUID&amp;#39;s and&amp;nbsp; renamed the function call appropriately.&lt;/span&gt;[/quote]
&lt;p&gt;So you did not include the custom service you made in this test case, only enabled Bluetooth, SMP and peripheral role?&lt;/p&gt;
[quote user="SubuMuthu"]The stack does not start and crashes when&amp;nbsp; the build is made with &amp;quot;CONFIG_BT_SMP=y&amp;quot;.[/quote]
&lt;p&gt;Disabling bonding with CONFIG_BT_BONDABLE=n should fix this issue. Bonding cannot be enabled for Matter BLE services, as this makes it non-compliant with the Matter specification due to the requirement that a static random address shall be used for Matter BLE service advertising purposes.&lt;/p&gt;
&lt;p&gt;If you look at &lt;a href="https://github.com/nrfconnect/sdk-connectedhomeip/blob/v2.6.1/config/nrfconnect/chip-module/Kconfig.features#L104-L105"&gt;https://github.com/nrfconnect/sdk-connectedhomeip/blob/v2.6.1/config/nrfconnect/chip-module/Kconfig.features#L104-L105&lt;/a&gt;, you can see that bonding gets disabled when CONFIG_CHIP_NUS is enabled, which is why you do not see this issue when using NUS in Matter samples.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/thread/496850?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 13:01:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0862cd06-6ecc-47a4-b54c-08de86258e0c</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Subu,&lt;/p&gt;
&lt;p&gt;Thank you for the additional information. I am looking into this and will get back to you tomorrow.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/thread/496849?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2024 15:15:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5712724c-7512-4c41-ad31-f905dd505f7d</guid><dc:creator>SubuMuthu</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks for responding!&lt;/p&gt;
&lt;p&gt;Yes, we need a custom BLE service that works with Matter. You also asked why we can&amp;nbsp; not use NUS and what additional features are needed.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It is not the additional feature that we are looking for. We already tried NUS. In our view, it is good example for prototyping but we could&amp;nbsp; take the source code, modify and develop our custom&amp;nbsp; BLE service based on source code provided by Nordic SDK.&lt;/p&gt;
&lt;p&gt;What changes are we looking for in NUS?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;NUS service puts out the pairing code via debug terminal. Our product - door lock, does not have access to debug terminal. we will come up with different solution.&lt;/li&gt;
&lt;li&gt;Our product is door lock and&amp;nbsp; it is access control market application. With that the security is the most important one and we will require the below modifications:
&lt;ol&gt;
&lt;li&gt;Instead of NUS UUID&amp;#39;s, we will have company specific UUID&lt;/li&gt;
&lt;li&gt;Whitelisting will be done to connect the smart lock to&amp;nbsp; our App only.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;We have few other proprietary&amp;nbsp; schemes which I do not want to describe here.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, as a first step (Step #1),&amp;nbsp; we made a copy of NUS source code from&amp;nbsp;&lt;span&gt;&amp;nbsp;“nus.c, nus.h, bt_nus_service.h, bt_nus_service.cpp”, modified ONLY UUUID&amp;#39;s and&amp;nbsp; renamed the function call appropriately.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NOTE: we did not make any other modifications.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The &amp;quot;prj.conf&amp;quot; had,&lt;/p&gt;
&lt;p&gt;-----------&lt;/p&gt;
&lt;p&gt;#CONFIG_CHIP_NUS=y - disabled it&lt;/p&gt;
&lt;p&gt;#--- Enable BLE&lt;/p&gt;
&lt;p&gt;CONFIG_BT=y&lt;/p&gt;
&lt;p&gt;CONFIG_BT_SMP=y&lt;/p&gt;
&lt;p&gt;CONFIG_BT_PERIPHERAL=y&lt;/p&gt;
&lt;p&gt;---------&lt;/p&gt;
&lt;p&gt;We built and tried. The device did not even start. Below is the crash/ log from debug terminal:&lt;/p&gt;
&lt;p&gt;----&lt;/p&gt;
&lt;p&gt;[08:47:26:806] uart:~$ *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***␍␊&lt;/p&gt;
&lt;p&gt;[08:47:26:878] E: 77 [DL]Failed to create BLE identity: 0␍␊&lt;/p&gt;
&lt;p&gt;[08:47:26:882] E: 81 [DL]BLEManager initialization failed: 200000c␍␊&lt;/p&gt;
&lt;p&gt;[08:47:26:888] E: PlatformMgr().InitChipStack() failed [Error: 0]␍␊&lt;/p&gt;
&lt;p&gt;[08:47:26:894] E: Exited with code 200000c␍␊&lt;/p&gt;
&lt;p&gt;----&lt;/p&gt;
&lt;p&gt;Step #2:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When we modified the &amp;quot;prj.conf&amp;quot; (note that SMP is disabled)&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;
&lt;p&gt;-----------&lt;/p&gt;
&lt;p&gt;#CONFIG_CHIP_NUS=y - disabled it&lt;/p&gt;
&lt;p&gt;#--- Enable BLE&lt;/p&gt;
&lt;p&gt;CONFIG_BT=y&lt;/p&gt;
&lt;p&gt;#CONFIG_BT_SMP=y -- disable the security&lt;/p&gt;
&lt;p&gt;CONFIG_BT_PERIPHERAL=y&lt;/p&gt;
&lt;p&gt;---------&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then modified the source code to remove the security, built and tried it. This time, the crash did not occur, the device started and we were able to connect to the BLE service while running Matter.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Step #3:&lt;/p&gt;
&lt;p&gt;Then we added the &amp;quot;CONFIG_BT_SMP=y&amp;quot; , kept the same source code as in Step #2, build and tried. The device failed to start and the crash occurred as in Step #1 (same logs).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So in summary,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The custom BLE service is a copy of Nordic&amp;#39;s NUS code. We verified it without security.&lt;/li&gt;
&lt;li&gt;The stack does not start and crashes when&amp;nbsp; the build is made with &amp;quot;CONFIG_BT_SMP=y&amp;quot;.&lt;/li&gt;
&lt;li&gt;I do not believe my custom BLE code is causing the crash. The crash occurs at the init stages of CHIP stack.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I can share the source code but what you will see is the NUS source code with functional calls renamed to something else.&lt;/p&gt;
&lt;p&gt;Please advise.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Subu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding custom BLE services to Matter</title><link>https://devzone.nordicsemi.com/thread/496848?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 14:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0ecb34f-d577-420c-bc9a-c1a671f6ce9f</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to confirm, you have made a custom BLE service that you want to use with Matter? Have you tested the service in a BLE-only example without Matter, to verify that the service itself works as expected?&lt;/p&gt;
&lt;p&gt;Can you clarify what the custom BLE service is supposed to do and what additional features you need that is not provided by the NUS guide? It might not be that the BLE sample you are using (&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/bluetooth/peripheral/prj.conf"&gt;zephyr/samples/bluetooth/peripheral/prj.conf at main · zephyrproject-rtos/zephyr (github.com)&lt;/a&gt;) is the best starting point, and it might be better to use one of the BLE samples in the nRF Connect SDK instead (&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth"&gt;https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>