Update ESP-IDF examples

This commit is contained in:
valeros
2020-09-01 21:48:00 +03:00
parent ff997d3677
commit 1ceb7b9d92
73 changed files with 1492 additions and 846 deletions
+7 -11
View File
@@ -7,23 +7,19 @@
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:nano32]
[env]
platform = espressif32
framework = espidf
board = nano32
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
monitor_speed = 115200
[env:esp32dev]
board = esp32dev
[env:nano32]
board = nano32
[env:espea32]
platform = espressif32
framework = espidf
board = espea32
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
monitor_speed = 115200
[env:esp320]
platform = espressif32
framework = espidf
board = esp320
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
monitor_speed = 115200
@@ -0,0 +1,2 @@
CONFIG_EXAMPLE_WIFI_SSID="MYSSID"
CONFIG_EXAMPLE_WIFI_PASSWORD="MYPASS"
@@ -24,13 +24,13 @@
/* Constants that aren't configurable in menuconfig */
#define WEB_SERVER "example.com"
#define WEB_PORT 80
#define WEB_URL "http://example.com/"
#define WEB_PORT "80"
#define WEB_PATH "/"
static const char *TAG = "example";
static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n"
"Host: "WEB_SERVER"\r\n"
static const char *REQUEST = "GET " WEB_PATH " HTTP/1.0\r\n"
"Host: "WEB_SERVER":"WEB_PORT"\r\n"
"User-Agent: esp-idf/1.0 esp32\r\n"
"\r\n";
@@ -46,7 +46,7 @@ static void http_get_task(void *pvParameters)
char recv_buf[64];
while(1) {
int err = getaddrinfo(WEB_SERVER, "80", &hints, &res);
int err = getaddrinfo(WEB_SERVER, WEB_PORT, &hints, &res);
if(err != 0 || res == NULL) {
ESP_LOGE(TAG, "DNS lookup failed err=%d res=%p", err, res);
@@ -119,10 +119,10 @@ static void http_get_task(void *pvParameters)
}
}
void app_main()
void app_main(void)
{
ESP_ERROR_CHECK( nvs_flash_init() );
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.