From 0a12d5467f1f63628114ca65b6fcd0a80c904a36 Mon Sep 17 00:00:00 2001 From: GOB Date: Tue, 2 May 2023 19:01:00 +0900 Subject: [PATCH] Add support SD-Updater and fixes rootCA and read himawari image --- platformio.ini | 41 ++++++++++--- src/himawari/himawari_task.cpp | 57 ++++++++--------- src/jma/jma_task.cpp | 59 +++++++++--------- src/main.cpp | 109 ++++++++++++++++++++++++++++----- src/weather_map.cpp | 5 +- 5 files changed, 188 insertions(+), 83 deletions(-) diff --git a/platformio.ini b/platformio.ini index ece1700..d7648c2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -4,7 +4,8 @@ ; WiFi.begin() use it. ;----------------------------------------------------------------------- [env] -platform = espressif32@4.4.0 +;platform = espressif32@4.4.0 +platform = espressif32@^6.2.0 ;platform = espressif32 framework = arduino @@ -14,16 +15,15 @@ board_build.f_cpu = 240000000L ; https://www.a-quest.com/download.html Download AquesTalk ESP32 and extract ./lib folder. lib_ldf_mode = deep -lib_deps = https://github.com/M5Stack/M5Unified.git @ ^0.1.3 +lib_deps = https://github.com/M5Stack/M5Unified.git @ ^0.1.6 h2zero/NimBLE-Arduino @ ^1.4.0 - https://github.com/GOB52/gob_json.git @ ^0.0.3 + https://github.com/GOB52/gob_json.git @ ^0.0.4 https://github.com/GOB52/gob_datetime.git @ ^0.1.1 monitor_speed = 115200 monitor_filters = esp32_exception_decoder, time upload_speed = 921600 - ; Definition ; M5S_WXBEACON2_TIMEZONE_LOCATION : Your time-zone location string. default as "Asia/Tokyo" (e.g. "Asia/Tokyo" "America/Los_Angeles" "Australia/Lord_Howe") ; M5S_WXBEACON2_AUTO_REQUEST_INTERVAL_SEC : Auto request interval (Unit: second) @@ -34,7 +34,6 @@ build_flags = -Wall -Wextra -Wreturn-local-addr -Werror=format -Werror=return-lo -D M5S_WXBEACON2_AUTO_TALK_INTERVAL_SEC=60 -D M5S_WXBEACON2_DEBUG_INFO -D GOB_JSON_LOG_LEVEL=5 -;300,60 ; -------------------------------- ;Choose build options @@ -69,13 +68,27 @@ board_build.partitions = min_spiffs.csv [env:core2_master] extends = core2_env build_type=release -build_flags=${env.build_flags} ${option_release.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -D NDEBUG +build_flags=${env.build_flags} ${option_release.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DNDEBUG [env:core2_release] extends = core2_env build_type=release build_flags=${env.build_flags} ${option_release.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue +[env:core2_master_SDU] +extends = core2_env +build_type=release +build_flags=${env.build_flags} ${option_release.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DNDEBUG -DM5S_WXBEACON2_ENABLE_SD_UPDATER +lib_deps = ${env.lib_deps} + tobozo/M5Stack-SD-Updater + +[env:core2_release_SDU] +extends = core2_env +build_type=release +build_flags=${env.build_flags} ${option_release.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DM5S_WXBEACON2_ENABLE_SD_UPDATER +lib_deps = ${env.lib_deps} + tobozo/M5Stack-SD-Updater + [env:core2_log] extends = core2_env build_type=release @@ -90,13 +103,27 @@ build_flags=${env.build_flags} ${option_debug.build_flags} -DBOARD_HAS_PSRAM -mf [env:basic_master] extends = m5s_env build_type=release -build_flags=${env.build_flags} ${option_release.build_flags} -D NDEBUG +build_flags=${env.build_flags} ${option_release.build_flags} -DNDEBUG [env:basic_release] extends = m5s_env build_type=release build_flags=${env.build_flags} ${option_release.build_flags} +[env:basic_master_SDU] +extends = m5s_env +build_type=release +build_flags=${env.build_flags} ${option_release.build_flags} -DNDEBUG -DM5S_WXBEACON2_ENABLE_SD_UPDATER +lib_deps = ${env.lib_deps} + tobozo/M5Stack-SD-Updater + +[env:basic_release_SDU] +extends = m5s_env +build_type=release +build_flags=${env.build_flags} ${option_release.build_flags} -DM5S_WXBEACON2_ENABLE_SD_UPDATER +lib_deps = ${env.lib_deps} + tobozo/M5Stack-SD-Updater + [env:basic_map] extends = m5s_env build_type=release diff --git a/src/himawari/himawari_task.cpp b/src/himawari/himawari_task.cpp index a437f53..f7b063d 100644 --- a/src/himawari/himawari_task.cpp +++ b/src/himawari/himawari_task.cpp @@ -88,26 +88,25 @@ PROGMEM const char HIMAWARI_URI_FORMAT[] = "https://www.data.jma.go.jp/mscweb/da // Expire at Mon, 10 Nov 2031 00:00:00 GMT PROGMEM const char root_ca_ECC[] = R"***(-----BEGIN CERTIFICATE----- -MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD -QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT -MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j -b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB -CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 -nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt -43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P -T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 -gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO -BgNVHQ8BAf8EBAMCAYYwDwYDVR0TA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lNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO +ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw +awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs +OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF +coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc +okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8 +t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy +1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/ +SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 -----END CERTIFICATE----- )***"; @@ -124,20 +123,20 @@ void himawari_task(void*) ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); // Connect WiFi - int8_t ctry = 3; + int8_t ctry = 5; do { WiFi.mode(WIFI_STA); WiFi.begin(); int tcount = 20; - while(tcount-- > 0 && WiFi.status() != WL_CONNECTED) - { - delay(500); - } - if(WiFi.status() == WL_CONNECTED) { break; } + while(tcount-- > 0 && WiFi.status() != WL_CONNECTED) { delay(500); } + + auto s = WiFi.status(); + if(s == WL_CONNECTED) { break; } + WiFi.disconnect(true); WiFi.mode(WIFI_OFF); - WB2_LOGD("Retry begin"); + WB2_LOGD("Retry begin:%d", s); delay(10); }while(ctry--); @@ -200,12 +199,14 @@ void himawari_task(void*) break; } + http.setTimeout(30); // seconds gtry = 16; do { while(http.connected() && client.available()) { size_t read = std::min(blockSize, szTmp); + WB2_LOGD("Try read:%zu", read); while(read) { auto len = client.readBytes(jpg + off, read); @@ -218,7 +219,7 @@ void himawari_task(void*) if(callbackOnProgress) { callbackOnProgress(off, jpgsz); } delay(100); } - WB2_LOGD("http:%d", http.connected()); + WB2_LOGD("http:%d ava:%zu", http.connected(), client.available()); if(off < jpgsz) { WB2_LOGD("Not enough read"); delay(500); } }while(off < jpgsz && gtry--); diff --git a/src/jma/jma_task.cpp b/src/jma/jma_task.cpp index a35f1ae..f59583c 100644 --- a/src/jma/jma_task.cpp +++ b/src/jma/jma_task.cpp @@ -19,32 +19,31 @@ jma::progress_callback callbackOnProgress; PROGMEM const char JMA_FORECAST_URI_FORMAT[] = "https://www.jma.go.jp/bosai/forecast/data/forecast/%06d.json"; // DigiCert Global Root CA of www.jma.go.jp. -// Exxpire at Mon, 10 Nov 2031 00:00:00 GMT. PROGMEM const char root_ca_JMA[] = - R"***(-----BEGIN CERTIFICATE----- -MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD -QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT -MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j -b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB -CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 -nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4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mlj +YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV +OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr +zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM +VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ +hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO +ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw +awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs +OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF +coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc +okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8 +t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy +1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/ +SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 +-----END CERTIFICATE----- )***"; + // Cities from which data is obtained. PROGMEM const jma::officecode_t requestTable[] = { @@ -80,14 +79,14 @@ void jma_forecast_task(void*) WiFi.mode(WIFI_STA); WiFi.begin(); int tcount = 20; - while(tcount-- > 0 && WiFi.status() != WL_CONNECTED) - { - delay(500); - } - if(WiFi.status() == WL_CONNECTED) { break; } + while(tcount-- > 0 && WiFi.status() != WL_CONNECTED) { delay(500); } + + auto s = WiFi.status(); + if(s == WL_CONNECTED) { break; } + WiFi.disconnect(true); WiFi.mode(WIFI_OFF); - WB2_LOGD("Retry begin"); + WB2_LOGD("Retry begin:%d", s); delay(10); }while(ctry--); @@ -138,7 +137,7 @@ void jma_forecast_task(void*) WB2_LOGD("Failed to GET() %d", httpcode); break; } - + client.setTimeout(30); // seconds // parse JSON JMAHandler handler; goblib::json::StreamingParser parser(&handler); diff --git a/src/main.cpp b/src/main.cpp index 57fc27c..3dd542d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,12 +6,23 @@ @file main.cpp @brief Program entry */ +#ifdef ARDUINO_M5STACK_Core2 +#include +#endif +#if defined(M5S_WXBEACON2_ENABLE_SD_UPDATER) +#include +#endif #include +#if defined(M5S_WXBEACON2_ENABLE_SD_UPDATER) +#include +#endif #include #include + #include #include // esp_bt_controller_mem_release #include // esp_random() is hardware RNG. (No random seed initialization is required) +#include #include #include "utility.hpp" @@ -29,23 +40,20 @@ #include #include -#ifdef ARDUINO_M5STACK_Core2 -#include "himawari/himawari.hpp" -#include "himawari/himawari_task.hpp" -#include "himawari/himawari_screen.hpp" -#endif - #include #include #include #include #include -#if __has_include () -#include -#else // esp_idf_version.h has been introduced in Arduino 1.0.5 (ESP-IDF3.3) -#define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) -#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(3,2,0) +#ifdef ARDUINO_M5STACK_Core2 +#include "himawari/himawari.hpp" +#include "himawari/himawari_task.hpp" +#include "himawari/himawari_screen.hpp" +#endif + +#ifndef TFCARD_CS_PIN +# define TFCARD_CS_PIN (4) #endif using goblib::datetime::LocalTime; @@ -214,17 +222,40 @@ struct ESP32RNG // Configurate Time by NTP. void configTime() { + // Check RTC if exists + if(M5.Rtc.isEnabled()) + { + auto dt = M5.Rtc.getDateTime(); // GMT + if(dt.date.year > 2016) + { + WB2_LOGI("RTC time already set. (GMT) %04d/%02d/%2d %02d:%02d:%02d", + dt.date.year, dt.date.month, dt.date.date, + dt.time.hours, dt.time.minutes, dt.time.seconds); + + // Set timezone + auto ptz = goblib::datetime::locationToPOSIX(M5S_WXBEACON2_TIMEZONE_LOCATION); + setenv("TZ", ptz ? ptz : "NONE", 1); + tzset(); + return; + } + } + WB2_LOGI("Configrate time"); + // WiFi connect WiFi.begin(); // Connect to credential in Hardware. (ESP32 saves the last WiFi connection) - int tcount = 20; + int tcount = 32; while(tcount-- > 0 && WiFi.status() != WL_CONNECTED) { M5.Display.printf("."); - delay(500); + delay(1000); } if(WiFi.status() != WL_CONNECTED) { + M5.Display.clear(TFT_RED); + M5.Display.setCursor(0,0); + M5.Display.printf("Failed to connect WiFi"); WB2_LOGE("Failed to connect WiFi"); + delay(1000); abort(); } @@ -236,10 +267,32 @@ void configTime() // waiting for time synchronization { std::tm discard{}; - getLocalTime(&discard, 10 * 1000); + if(!getLocalTime(&discard, 10 * 1000 /* timeout */)) + { + M5.Display.clear(TFT_BLUE); + M5.Display.setCursor(0,0); + M5.Display.printf("Failed to configTime"); + WB2_LOGE("Failed to configTime"); + delay(1000); + abort(); + } + M5.Display.setCursor(0,0); + auto ldt = goblib::datetime::LocalDateTime::now(); + M5.Display.printf("Configrated: %s", ldt.toString().c_str()); + delay(1000); } WiFi.disconnect(true); WiFi.mode(WIFI_OFF); + + // Set RTC if exists + if(M5.Rtc.isEnabled()) + { + time_t t = time(nullptr) + 1; + while(t > time(nullptr)) ; + M5.Rtc.setDateTime(gmtime(&t)); + auto ldt = goblib::datetime::LocalDateTime::now(); + WB2_LOGI("Set RTC:%s", ldt.toString().c_str()); + } } // @@ -640,14 +693,34 @@ void setup() // Incrase internal heap. esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); - // - M5.begin(); + // M5Unified + auto cfg = M5.config(); + cfg.external_rtc = true; // Enable RTC if exists +#if defined(__M5GFX_M5MODULEDISPLAY__) + cfg.module_display.logical_width = 320; + cfg.module_display.logical_height = 240; +#endif + cfg.external_speaker.module_display = true; + + M5.begin(cfg); +#if defined(__M5GFX_M5MODULEDISPLAY__) + M5.setPrimaryDisplayType(m5::board_t::board_M5ModuleDisplay); +#endif + auto bd = M5.getBoard(); WB2_LOGI("M5.board : %x", bd); // 2:M5Stack Basic/Gray 3:Core2 if (M5.Display.width() < M5.Display.height()) { M5.Display.setRotation(M5.Display.getRotation() ^ 1); } + + // SD-Updater +#if defined(M5S_WXBEACON2_ENABLE_SD_UPDATER) + checkSDUpdater(SD); + SD.end(); // No more use SD +#endif + + // Speaker auto scfg = M5.Speaker.config(); scfg.task_priority = speakerPriority; scfg.task_pinned_core = speakerCore; @@ -767,7 +840,9 @@ void loop() } else if(M5.BtnB.wasClicked()) { - /* Nop */ +#ifdef ARDUINO_M5STACK_Core2 + _requestHimawari(); +#endif } /* A button diff --git a/src/weather_map.cpp b/src/weather_map.cpp index 8e812bd..4118b7d 100644 --- a/src/weather_map.cpp +++ b/src/weather_map.cpp @@ -83,7 +83,10 @@ void drawWeatherIcon(m5gfx::M5GFX* dst, jma::officecode_t oc, jma::weathercode_t auto pos = positionTable.at(oc); // WB2_LOGD("%d:%d:%d p:%d", oc, wc, ic, png != nullptr); auto ret = dst->drawPng(png, -1, pos->x * 2, pos->y * 2); - if(ret == 0) { WB2_LOGV("mem:%u", esp_get_free_internal_heap_size()); } + if(ret == 0) + { + WB2_LOGE("Failed to drawPn largeest internal:%u", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL)); + } } // }