Adding custom BLE services to Matter

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 to configure the product directly instead of the ecosystems APP like Apple Home, Google Home etc.

I have followed the below:

https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/matter/getting_started/adding_bt_services.html

Matter: Door lock (nordicsemi.com) including Nordic UART services.

And also reviewed various examples for creating custom BLE services.

Based on the above, 

  1. Successfully built “NUS” (provided by Nordic SDK) and  tried it. It works.
  2. Successfully duplicated the “NUS” by copying the source files “nus.c, nus.h, bt_nus_service.h, bt_nus_service.cpp”, modified ONLY UUUID and the functions calls,  built and tested the custom service
    1. I did not add any  config parameters. “CONFIG_CHIP_NUS”  builds  the Nordic NUS service and also the custom BLE service.
    2. Nordic's nRF toolbox and nRF connect shows both the services. Was able to send the "Lock" and "Unlock" commands from the Apps.
  3. The above method will work for us however, we do not want “Nordic UART services” running. It consumes not only memory, resources but also  allows anyone to connect to the service which is a security issue for us. Please note that this is a door lock and we have proprietary means to provide security which requires custom BLE services.
  4. I tried to build the custom BLE service only.
    1. From the same example above,  I removed  “CONFIG_BLE_NUS” from proj.conf
    2. Looking at the BLE examples  that Nordic provided and also from the Zephyr example (zephyr/samples/bluetooth/peripheral/prj.conf at main · zephyrproject-rtos/zephyr (github.com), I added the below config parameters to proj.conf

----------------------------------------

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

 

CONFIG_BT_RX_STACK_SIZE=1536

 

CONFIG_BT=y

CONFIG_LOG=y

CONFIG_BT_SMP=y

CONFIG_BT_SIGNING=y

CONFIG_BT_PERIPHERAL=y

CONFIG_BT_DIS=y

CONFIG_BT_ATT_PREPARE_COUNT=5

 

CONFIG_BT_DEVICE_NAME="MTI Sample Lock"

CONFIG_BT_DEVICE_APPEARANCE=833

CONFIG_BT_DEVICE_NAME_DYNAMIC=y

CONFIG_BT_DEVICE_NAME_MAX=65

 

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

CONFIG_BT_SETTINGS=y

-----------------

 

When Flashed to nRF5340 DK, the DK is not   starting. Please see the crash messages from the debug port.

-------

 

[08:47:26:806] uart:~$ *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***␍␊

[08:47:26:878] E: 77 [DL]Failed to create BLE identity: 0␍␊

[08:47:26:882] E: 81 [DL]BLEManager initialization failed: 200000c␍␊

[08:47:26:888] E: PlatformMgr().InitChipStack() failed [Error: 0]␍␊

[08:47:26:894] E: Exited with code 200000c␍␊

               

                       ----

 

Further probing and experimenting, I found that CONFIG_BT_SMP=y is causing the crash. If I remove  "CONFIG_BT_SMP and CONFIG_BT_SIGNING"  ( I also made changed the code to remove security),  the crash would go away but it caused issues with Matter provisioning (Matter provisioning hung). Regardless, this will not help us because we need secure LE..

 

                It looks like there is an issue with the CONFIG settings and I can not find any  information from Nordic Dev/Blogs  or from the Blogs.

 

                One of the reason that we are interested in nRF SoC’s is due to this feature so please help to resolve.

 

                It will be great if  you can provide sample code for BLE custom service that runs with Matter.   The example from NUS is great but it is not enough.

Thanks

Subu Muthu

Parents Reply Children
No Data
Related