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

[question] I want to perform MQTT initialization connection after WIFI connection #80

Open
ookamipjq opened this issue Apr 27, 2024 · 1 comment

Comments

@ookamipjq
Copy link

I am using the code of this warehouse for mass production planning. According to the code execution process in the main function, after the esp32 is powered on, it first obtains the certificate stored inside the module and passes it into the network context. It performs the MQTT kernel before WIFI initialization. Initialization. Now I want to connect to WIFI after powering on for the first time, and get the certificate content from HTTP to connect to AWS. How can I put MQTT initialization on the WIFI connection and do it after I get the certificate from HTTP.

@cookpate
Copy link
Member

cookpate commented May 6, 2024

Without changing the demo APIs, one could check if the certificate is available in flash before continuing with the demo. If it is not, then initialize WiFi without starting the CoreMQTT Agent in order to perform the HTTP download, store the received certificate in flash, then restart the device.

If restarting a device would take too long, a device could stop the WiFi after retrieving a certificate in order to start coreMQTT-Agent correctly. A clean app_wifi_stop() function could stop the WiFi connection (but not de-init), then clear the bits in wifi_event_group to re-arm the WiFi connected event.

Take a look instead at how WiFi is initialized in the demo main/networking/wifi/app_wifi.c

Also, refer to Espressif documentation on the ESP WIFI API:
https://docs.espressif.com/projects/esp-idf/en/v5.1.3/esp32c3/api-reference/network/esp_wifi.html

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

2 participants