Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed May 2, 2023
2 parents d569b32 + 0a12d54 commit 3e18824
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 83 deletions.
41 changes: 34 additions & 7 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
57 changes: 29 additions & 28 deletions src/himawari/himawari_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK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VR0OBBYEFAqFqXdlBZh8QIH4D5cs
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-----
)***";

Expand All @@ -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--);

Expand Down Expand Up @@ -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);
Expand All @@ -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--);

Expand Down
59 changes: 29 additions & 30 deletions src/jma/jma_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr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l+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[] =
{
Expand Down Expand Up @@ -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--);

Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 3e18824

Please sign in to comment.