-
Notifications
You must be signed in to change notification settings - Fork 176
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
Wifi control with ESP-Matter (CON-668) #551
Comments
@smeisner Are you using Arduino library?
|
EDIT: @shubhamdp I missed your question; Yes, I am using the Arduino library. @shubhamdp Thanks for the reply, but this is not what I am seeing. If I start wifi then call to start Matter, I get:
|
This looks like multiple initialization of wifi. I guess, your code and Matter both initializes the wifi twice. Right now, I could suggest one thing. (But Matter code should handle if wifi is already initialized, will fix this).
PS: I have no idea if |
Thanks ... I haven't tried this yet, but when you say " ... and perform connect" are you referring to wifi connect? If so, that would be calling After walking thru quite a bit of CHIP/Matter code (...and ESP-matter code ... and Arduino ESP-matter code), it does seem the problem is both I do have things working as far as wifi is up (via starting matter) and I can provide a web server on the interface. But none of the Arduino wifi API calls work (get hostname, IP addr, RSSI, etc). But this is only working since the SSID and PSK are already in NVS. If I clear that, it does not work. If the user needs to select a different SSID (or first time running the device), this solution does not work at all. |
I have posted a question in the esp32-arduino-matter issues board (Yacubane/esp32-arduino-matter#36) since I am using that code (with the Arduino framework) and cannot open/close the commissioning window. @shubhamdp In your last reply, you mentioned "(But Matter code should handle if wifi is already initialized, will fix this)." Is this something on the roadmap? |
@smeisner Thanks for trying out the steps. Need to put some guards here: https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32Utils.cpp#L319. I am adding this to the roadmap, will get this fix as soon as possible. |
I have managed to get things working. Removing all Arduino API calls to wifi and using ESP-IDF calls really helped out. The real problem is coordinating taking the stack down before switching to Matter ... or vice versa. @shubhamdp For the most part, I used the suggestions you provided. The problem I encountered was the ESP-Arduino-Matter library doesn't have full support, so I was unable to open/close the provisioning window. Code has been checked into the branch named 'Matter' in my github repo: https://github.com/smeisner/smart-thermostat. The interesting modules are https://github.com/smeisner/smart-thermostat/blob/matter/app/src/matter.cpp and https://github.com/smeisner/smart-thermostat/blob/matter/app/src/wifi.cpp Keep in mind this project is still a work in progress. So don't beat me up on code quality ...yet!! :D |
BTW, I still believe allowing Matter to start after the wifi stack is initialized is still very valuable. The work I did in my repo is not trivial and I feel it is possibly going to crash due to the complexity. So I am still looking forward to the feature you mentioned in #551 (comment) |
@smeisner please take a look at project-chip/connectedhomeip#29017. |
@shubhamdp Thanks for the heads-up! Line 336 is exactly what I need, but the entire change set looks great! When this is merged, I will certainly give the new code a try. |
@shubhamdp I just had a thought; in the current implementation, if wifi connection drops, matter will initiate a reconnect. With the change in this PR, who will be responsible for re-connecting to the AP? I am hoping/assuming not matter. |
@smeisner Even in this case, reconnection will be managed by chip stack. https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32Utils.cpp#L365.
There is a big state machine here, which would need some though for making it happen. |
Ok good to know. I would have assumed incorrectly! |
I am working on an ESP32-S3 based device that has a touch screen and can use it to provide wifi credentials (SSID and PSK). I do not want to rely on commissioning via bluetooth. Allowing the user to use the touchscreen is way easier!
If I start wifi the usual way (
WiFi.begin(ssid, pass)
) the credentials get cached. Then on the next reboot, callingesp_matter::start()
uses this info to connect to my WLAN. Of course, if I also callWiFi.begin()
, that crashes.This device will serve a web page (for config), use SNTP for time and a few other uses for wifi. So my questions;
WiFi.begin(ssid, pass)
and provide the instance to Matter?The text was updated successfully, but these errors were encountered: