Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menuconfig configuration for only on network pairing (CON-732) #605

Closed
damian-kurek-wizzdev opened this issue Aug 30, 2023 · 19 comments
Closed

Comments

@damian-kurek-wizzdev
Copy link

damian-kurek-wizzdev commented Aug 30, 2023

Describe the question/query that you have
I want to configure my existing project with matter to use only On-network pairing. I looked into [documentation] (https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) and examples. I could not find any info on how to do it.
All my tries with disabling stuff in "CHIP device Layer" ended up in compilation errors

Could someone provide me with some links to examples or documentation that can help me with menuconfig configuration?

@github-actions github-actions bot changed the title Menuconfig configuration for only on network pairing Menuconfig configuration for only on network pairing (CON-732) Aug 30, 2023
@shubhamdp
Copy link
Contributor

For on network pairing your device needs to be on the wifi network. For that you can either use the cli on the device with command matter esp wifi connect ssid passphrase. Or use the CONFIG_DEFAULT_WIFI_SSID and CONFIG_DEFAULT_WIFI_PASSWORD options to configure wifi network.

Once your device is connected to wifi you can use the on network pairing.

@damian-kurek-wizzdev
Copy link
Author

A bit of explanation. I have an existing code base. The firmware already connects to wifi and I want to let a user connect my device using matter to home automation devices. I don't want to edit the current functionality since there are thousands of devices in the market and the code for wifi handling has been working fine for a few years.
Can I configure esp-matter to start on network pairing without reconfiguration of wifi or BLE? (I will provide a Wi-Fi connection myself)
Could you point me to some examples or documentation?
For now, I need to use esp-matter 1.0 since I don't want to update esp-idf to 5.x for now

@shubhamdp
Copy link
Contributor

Thanks for the more explanation. Well in that case, here's the similar issue: #551.

If you do not want to use the BLE for commissioning then you can disable CONFIG_ENABLE_CHIPOBLE options.

For, wifi, call to InitWiFiStack, if this asserts/fails, try commenting it and see if that works.

@damian-kurek-wizzdev
Copy link
Author

damian-kurek-wizzdev commented Sep 1, 2023

I had to change some things in CHIP API since I work with esp-matter 1.0 but I managed to run something. Now I'm not sure if it works. I found somewhere that the logs can be ignored. Is this expected behaviour?

I (9204) chip[DMG]: AccessControlCluster: initializing
I (9214) chip[ZCL]: 0x3f4349edep 0 clus 0x0000_0030 attr 0x0000_0000 not supported
I (9224) chip[ZCL]: Initiating Admin Commissioning cluster.
E (9224) chip[ZCL]: Duplicate attribute override registration failed
I (9234) chip[DIS]: Updating services using commissioning mode 0
I (9244) chip[DIS]: CHIP minimal mDNS started advertising.
E (9254) chip[SVR]: ERROR setting up transport: 6
I (9254) esp_matter_core: Dynamic endpoint 0 added
I (9264) esp_matter_attribute: ********** Endpoint 0x0001's Cluster 0x0003's Attribute 0x0001 is 0 **********
I (9274) MatterThermostatDriver: matterAttributeUpdate: PRE_UPDATE
I (9274) esp_matter_core: Dynamic endpoint 1 added
E (9284) chip[DL]: Long dispatch time: 149 ms, for event type 2
I (9294) chip[DL]: Updating advertising data

@damian-kurek-wizzdev
Copy link
Author

I managed to commission a new device, but I got an error from google home that the device was not certified. I guess it is expected and I need to use a chip tool to communicate with it.

@dhrishi
Copy link
Collaborator

dhrishi commented Sep 1, 2023

@damian-kurek-wizzdev Yes, it is expected. You need to add a Matter integration in the Google developer console account. See this for details: https://developers.home.google.com/matter/get-started

@shubhamdp
Copy link
Contributor

@damian-kurek-wizzdev project-chip/connectedhomeip#29017 might help in your case.

@damian-kurek-wizzdev
Copy link
Author

@shubhamdp I did something similar and managed to make it work (I guess). I will post a patch for connecthomeip when I'm sure that it works (patch for release 1.0). I think your changes will allow the same functionality. My only concern is that if a user configured matter to use WiFi AP via menuconfig and then created WiFi AP with a different ssid it won't work for him. I guess some additional checks would be required to check if the WiFi AP name on esp32 is the same as the name and password as one configured in menuconfig. Not sure if it explains my concerns.

@damian-kurek-wizzdev
Copy link
Author

@dhrishi Thanks that helped a lot.
In case someone will look here for a solution for the "device was not certified":

  1. Go to https://console.home.google.com/projects and add your test device
  2. Enable developer mode on your mobile phone
  3. Remember to use the same email when adding the test device and in Google Home app

@damian-kurek-wizzdev
Copy link
Author

I can commission the device and everything works fine, but after I reboot, the device goes offline at Google Home and never returns. I can see that the matter server starts on esp32. Any idea @shubhamdp?

@shubhamdp
Copy link
Contributor

Can you share the logs?

@vaemc
Copy link

vaemc commented Sep 5, 2023

@damian-kurek-wizzdev project-chip/connectedhomeip#29017 might help in your case.

@shubhamdp Hi. when will the connectedhomeip of esp-matter sdk be updated to project-chip/connectedhomeip#29017?

@damian-kurek-wizzdev
Copy link
Author

damian-kurek-wizzdev commented Sep 5, 2023

logs.txt

Ignore error messages in comms and MatterThermostatDriver I added them for debuging. I set some values for matter server from esp.

@damian-kurek-wizzdev
Copy link
Author

damian-kurek-wizzdev commented Sep 5, 2023

Release 1.0 patch I used to make it work
connectedhomeip.txt

@shubhamdp
Copy link
Contributor

@damian-kurek-wizzdev project-chip/connectedhomeip#29017 might help in your case.

@shubhamdp Hi. when will the connectedhomeip of esp-matter sdk be updated to project-chip/connectedhomeip#29017?

We are in the process of updating the submodule, will be out soon.

@shubhamdp
Copy link
Contributor

logs.txt

Ignore error messages in comms and MatterThermostatDriver I added them for debuging. I set some values for matter server from esp.

From log file, I see the device is already connected to wifi and advertising as commissionable device.

E (9316) coms: StartAdvertisement
I (9326) chip[DIS]: Updating services using commissioning mode 1
I (9336) chip[DIS]: CHIP minimal mDNS started advertising.
I (9336) chip[DIS]: Advertise commission parameter vendorID=65521 productID=32768 discriminator=3840/15 cm=1
I (9346) chip[DIS]: CHIP minimal mDNS configured as 'Commissionable node device'; instance name: A3CEE3E23C2724DB.
I (9366) chip[DIS]: mDNS service published: _matterc._udp

And with that you should be able to commission the device. If you are having problem with commissioning, try to check if your device is advertising on mdns using avahi-browse(linux) or dns-sd(mac).

What you said earlier was, you are able to commission the device but unable control after reboot. I did not find any such case in the logs. But, in the patch, you have also commented the below lines which registers the event handler. Matter SDK has the state machine for managing WiFi, and some actions related to mdns does takes places in that event handler which is required. Try uncommenting them?

+//        esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL);
+//        esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL);

@damian-kurek-wizzdev
Copy link
Author

You are right uncommenting the IP/wifi handlers seems to fix it. I will fix the patch and post it again.

@sxsx2yzyz
Copy link

Can this plan pass CSA testing and can this product be launched? (Users must use my app+blufi for network configuration before they can use Google home, Alexa, or Apple home for network pairing)

@damian-kurek-wizzdev
Copy link
Author

Everything works fine and I can control my device using matter. Thanks for help @shubhamdp @dhrishi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants