In this post, we will go through an example in which the esp32 connects to a wifi softAP as a station
The reference code is
https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station
The SSID and password is defined at the top
Here the CONFIG_XXXXX macros are in sdkconfig.h file
This configuration file is actually modified when you use the $idf.py menuconfig command
So set the SSID and password of your router using menuconfig
The code uses the default event loop to register and handle the WIFI connection related events
Initialize the underlying TCP/IP stack using the following function
Initialize wifi_init_config_t type configuration variable by putting the default values and then initialize the wifi stack
Create the default event loop & Register for WIFI events to the default event loop
Set the SSID and Password to the wifi stack
Set the wifi stack as Station Mode and start it
Now as the wifi connection events occur it will get hanlded by the handler function
Compile and flash the program
Check the output log
0 comments:
Post a Comment