espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
648 stars 151 forks source link

Commissioning fails for Generic-switch with ESP32-H2 board (CON-1324) #1073

Open lboue opened 2 weeks ago

lboue commented 2 weeks ago

Describe the bug

Commissioning fails with Generic-switch example with ESP32-H2 board. Confirmation packets seems to be received, but the commisioning is running down.

[22:05:32]I (69552) chip[DL]: Confirm received for CHIPoBLE TX characteristic indication (con 1) status= 14 
[22:05:35]I (72052) CHIP[DL]: Write request received for CHIPoBLE RX characteristic con 1 16
[22:05:37]I (74562) NimBLE: GATT procedure initiated: indicate; 
[22:05:37]I (74562) NimBLE: att_handle=18
[22:05:37]
[22:05:37]I (74612) chip[DL]: Confirm received for CHIPoBLE TX characteristic indication (con 1) status= 14 
[22:05:40]E (76902) chip[SVR]: Commissioning failed (attempt 1): 32
[22:05:40]I (76902) chip[BLE]: Releasing end point's BLE connection back to application.
[22:05:40]I (76912) chip[DL]: Closing BLE GATT connection (con 1)
[22:05:40]I (76912) NimBLE: GAP procedure initiated: terminate connection; conn_handle=1 hci_reason=19
[22:05:40]
[22:05:40]I (76932) chip[DIS]: Updating services using commissioning mode 1
[22:05:40]E (76932) chip[DIS]: Failed to remove advertised services: 3
[22:05:40]I (76932) chip[DIS]: Advertise commission parameter vendorID=65521 productID=32768 discriminator=3841/15 cm=1 cp=0
[22:05:40]E (76952) chip[DIS]: Failed to advertise commissionable node: 3
[22:05:40]E (76952) chip[DIS]: Failed to finalize service update: 3
[22:05:40]I (76952) chip[DL]: Write request/command received for CHIPoBLE TX CCCD characteristic (con 1 ) indicate = 0
[22:05:40]I (76982) chip[DL]: CHIPoBLE unsubscribe received
[22:05:40]I (76982) chip[DL]: BLE GAP connection terminated (con 1 reason 0x216)
[22:05:40]I (76962) app_main: Commissioning window opened
[22:05:40]I (76992) chip[DL]: Configuring CHIPoBLE advertising (interval 25 ms, connectable)
[22:05:40]I (77002) NimBLE: GAP procedure initiated: advertise; 
[22:05:40]I (77012) NimBLE: disc_mode=2
[22:05:40]I (77012) NimBLE:  adv_channel_map=0 own_addr_type=1 adv_filter_policy=0 adv_itvl_min=40 adv_itvl_max=40

Could you help me to fix this issue?

Steps

cd ~/esp-matter/examples/generic_switch
idf.py clean
idf.py set-target esp32h2
idf.py build
idf.py flash
esptool.py write_flash 0x10000 mfg_binaries/20202020_3841.bin

Environment

Any additional details Log file generic-switch-esp32h2_Commissioning_failed.log

shripad621git commented 1 week ago

@lboue , can you please confirm that during commissioning using apple-home, have you scanned the qrcode specified in the README here. If you have used the appropriate QR code, can you please give a retry as it worked fine for me with apple home. The logs seem to show that the failure is due to ble connection termination by remote user i.e apple home in this case (due to various possible reasons). Seems like an arbitary failure.

lboue commented 1 week ago

Yes, exactly. That's exactly what I did.

With this iPhone, pairing with Matter over Thread development kits from SiliconLabs works perfectly. I only have problems with the esp-matter SDK and ESP32 boards.

lboue commented 1 week ago

I noticed several errors in the log file. Is there any way to fix that?

[22:04:24]E (932) esp_matter_core: Cannot set bounds because of val type mismatch: expected: 8, min: 15, max: 15
[22:04:24]E (1482) chip[DIS]: Failed to remove advertised services: 3
[22:04:24]E (1502) chip[DIS]: Failed to advertise commissionable node: 3
[22:04:24]E (1512) chip[DIS]: Failed to finalize service update: 3

[22:04:40]E (17192) chip[DL]: ble_gap_terminate() failed: Error CHIP:0x00000048
[22:05:40]E (76902) chip[SVR]: Commissioning failed (attempt 1): 32
[22:05:40]E (76932) chip[DIS]: Failed to remove advertised services: 3
[22:05:40]E (76952) chip[DIS]: Failed to advertise commissionable node: 3
[22:05:40]E (76952) chip[DIS]: Failed to finalize service update: 3
[22:06:15]E (112342) chip[DL]: ble_gap_terminate() failed: Error CHIP:0x00000048
lboue commented 6 days ago

I noticed that CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER is enabled in sdkconfig.defaults https://github.com/espressif/esp-matter/blob/a4739acde12cd3e8c845e449986c7540d1a83307/examples/generic_switch/sdkconfig.defaults#L40-L47

But not in sdkconfig.defaults.esp32h2

image

Is this the expected behavior? Should the file sdkconfig.defaults.esp32h2 be modified?

shripad621git commented 5 days ago

@lboue , if you notice the sdkconfig file of your project after setting the target to esp32h2, it has the required options including CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER=y. The sdkconfig.defaults.esp32h2 has configs specific to esp32h2 or the configs that should be overriden for the values already set in sdkconfig.defaultswhen target is esp32h2. For e.g.: CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n' in sdkconfig.defaults and it is enabled in sdkconfig.defaults.esp32h2. If you have a look at the sdkconfig file, it is enabled.

shripad621git commented 5 days ago

@lboue , when we tried at our end, the commissioning seemed to work fine. Can you please mention about what is the frequency of the commissioning failure at your end?

lboue commented 5 days ago

@lboue , when we tried at our end, the commissioning seemed to work fine. Can you please mention about what is the frequency of the commissioning failure at your end?

I've tested with several C6 and H2 boards and it fails every time. I've never succeeded in Matter Thread commissioning with esp-matter SDK. I

shripad621git commented 3 days ago

@lboue , we have tried for about 8-10 iterations of commissioning with the same ios version(17.6.1) as specified above on the same commit specified. It works prefectly fine with esp32h2. For confirming the commissioning over thread, can you please try out the esp32h2 thread-light on launchpad here . Please click on connect device. Select the chip and flash the application. Click on reset device and commission with the QR code provided on the UI. Also, can you please provide the sdkconfig file .

shripad621git commented 3 days ago

@lboue , can you please run the command esptool.py -p <port> read_flash 0x10000 0xc000 /tmp/nvs.bin and provide the nvs bin.