I wrote a small program which once connected to wifi should receive TCPIP packages.
My program is listed below:
Code: Select all
nvs_flash_init();
tcpip_adapter_init();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_get_mac(WIFI_IF_STA, mac) );
printf("MAC address: " MACSTR "\r\n", MAC2STR(mac));
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
wifi_config_t sta_config = {
.sta = {
.ssid = "my_wifi",
.password = "123456",
.bssid_set = false
}
};
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
ESP_ERROR_CHECK( esp_wifi_internal_reg_rxcb(WIFI_IF_STA, &my_wifi_rxcb) );
ESP_ERROR_CHECK( esp_wifi_start() );
ESP_ERROR_CHECK( esp_wifi_connect() );
Thank you for your responses,
Wamor