ESP-IDF = v3.3.1
devboard = olimex esp32-evb
Code: Select all
tcpip_adapter_init ();
static httpd_handle_t server = NULL;
ESP_ERROR_CHECK(esp_event_loop_init(onWiFiEvent, &server));
wifi_init_config_t configInit = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK (esp_wifi_init (&configInit));
ESP_ERROR_CHECK (esp_wifi_set_storage (WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
wifi_config_t configWiFi;
memset (&configWiFi, 0, sizeof (wifi_config_t));
memcpy (configWiFi.sta.ssid , settings.Station.Ssid , SSID_LEN);
memcpy (configWiFi.sta.password, settings.Station.Password, PASSWORD_LEN);
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &configWiFi));
memset(&configWiFi, 0, sizeof(wifi_config_t));
memcpy(configWiFi.ap.ssid, settings.SoftAp.Ssid, SSID_LEN);
memcpy(configWiFi.ap.password, settings.SoftAp.Password, PASSWORD_LEN);
configWiFi.ap.ssid_len = Settings::GetInstance().WiFi.SoftApSsid.size();
configWiFi.ap.max_connection = 2;
configWiFi.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &configWiFi));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
Code: Select all
httpd_handle_t server = NULL;
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.max_uri_handlers = 12;
const httpd_uri_t hello = {
.uri = "/hello",
.method = HTTP_GET,
.handler = GetHandler,
/* Let's pass response string in user
* context to demonstrate it's usage */
.user_ctx = (void*)"Hello World!"
};
LOG(MODULE, "Start");
// Start the httpd server
LOG(MODULE, "Starting server on port: '%d'", config.server_port);
if (httpd_start(&server, &config) == ESP_OK) {
// Set URI handlers
LOG(MODULE, "Registering URI handlers");
httpd_register_uri_handler(server, &hello);
return server;