It is nRF54L15 + SDK 3.0 + Matter application.
I have developed a custom BLE service that is based on Nordic's proprietary NUS BLE service. The BLE custom service is enabled at start up, connects to a BLE App for configuration and after that the App tells the product to join the matter network.
I have looked at the NUS services from door lock example.
1. When the button is pressed in DK, ButtonEventHandler in sdk/nrf/samples/matter/common/src/board/board.cpp calls StartBLEAdvertisementHandler(action) (line 225).
2. StartLEAdvertisement calls StartBLEAdvertisement()
Based on the above, in my application,
1. At startup, Nrf::Matter::PrepareServer()) is called. The BLE service (is identical to NUS) is called. It uses the below to start the BLE service.
PlatformMgr().LockChipStack(); CHIP_ERROR ret = BLEAdvertisingArbiter::InsertRequest(mAdvertisingRequest); PlatformMgr().UnlockChipStack();
2. The BLE app connects for configuration.
3. The BLE App asks Matter application to start the Matter server. Nrf::Matter::StartServer() is called.
4. After completion, stop the BLE server
PlatformMgr().LockChipStack(); BLEAdvertisingArbiter::CancelRequest(mAdvertisingRequest); PlatformMgr().UnlockChipStack();
I: 11008675 [DIS]Updating services using commissioning mode 1 E: 11008681 [DIS]Failed to remove advertised services: 3 I: 11008687 [DIS]Advertise commission parameter vendorID=65521 productID=32774 discriminator=3840/15 cm=1 cp=0 E: 11008698 [DIS]Failed to advertise commissionable node: 3 E: 11008704 [DIS]Failed to finalize service update: 3 [2418774876] MTI BLE Advertising stopped I: 11008714 [DL]Advertising start failed, will retry once connection is released E: 11008722 [DL]Failed to start CHIPoBLE advertising: -12 I: 11008727 [DL]CHIPoBLE advertising already stopped E: 11008733 [DL]Could not start CHIPoBLE service due to error: 200000c
Observation:
Although Step #4 stops the custom BLE service, the customer BLE service is restarted automatically and the advertisement begins. I tried to stop the custom adv after step 4 and before step #5 but without any success.
However, matter commissioning works, if BLE App is not connected. For clarity,
1. Step #1 is the same as above - At startup, Nrf::Matter::PrepareServer()) is called.
2. Then BLE custom service is initialized. BLE custom service is advertised. App is not connected.
3. Start Matter server - Nrf::Matter::StartServer() is called.
4. Stop the BLE server.
5. Then start Nrf::Board::StartBLEAdvertisement();
Please let me know.
Thanks
Subu