diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2731118..ac5537e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -10,8 +10,8 @@ env: BUILD_THREADS: 4 BUILD_TYPE: Release # Pico-SDK version - PICO_SDK_REF: 2.0.0 - PICOTOOL_REF: 2.0.0 + PICO_SDK_REF: 2.1.0 + PICOTOOL_REF: 2.1.0 jobs: build: @@ -23,8 +23,8 @@ jobs: strategy: matrix: - fanpico_board: ["0804", "0804D", "0401D" ] - pico_board: ["pico", "pico_w", "pico2"] + fanpico_board: ["0804", "0804D", "0401D"] + pico_board: ["pico", "pico_w", "pico2", "pico2_w"] steps: - name: Arm GNU Toolchain (arm-none-eabi-gcc) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b8df41b..09a3740 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -23,7 +23,7 @@ on: env: BUILD_TYPE: Release # Pico-SDK version - PICO_SDK_REF: 2.0.0 + PICO_SDK_REF: 2.1.0 jobs: analyze: diff --git a/libs/pico-telnetd b/libs/pico-telnetd index 82a688d..a4f1d3d 160000 --- a/libs/pico-telnetd +++ b/libs/pico-telnetd @@ -1 +1 @@ -Subproject commit 82a688d553b616d9af4410ec5fa7f29fd11af396 +Subproject commit a4f1d3de741f67c4e4ec8168a9978f7953c4b852 diff --git a/src/fanpico.h b/src/fanpico.h index 306ea69..8b50436 100644 --- a/src/fanpico.h +++ b/src/fanpico.h @@ -508,6 +508,7 @@ struct timespec* time_t_to_timespec(time_t t, struct timespec *ts); char* time_t_to_str(char *buf, size_t size, const time_t t); bool str_to_time_t(const char *str, time_t *t); bool rtc_get_tm(struct tm *tm); +bool rtc_get_time(time_t *t); const char *mac_address_str(const uint8_t *mac); int valid_wifi_country(const char *country); int valid_hostname(const char *name); diff --git a/src/httpd.c b/src/httpd.c index e0698b9..71c4056 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -23,7 +23,6 @@ #include #include #include -#include "hardware/rtc.h" #include "pico/stdlib.h" #include "cJSON.h" @@ -253,10 +252,9 @@ u16_t fanpico_ssi_handler(const char *tag, char *insert, int insertlen, /* printf("ssi_handler(\"%s\",%lx,%d,%u,%u)\n", tag, (uint32_t)insert, insertlen, current_tag_part, *next_tag_part); */ if (!strncmp(tag, "datetime", 8)) { - datetime_t t; - if (rtc_get_datetime(&t)) { - printed = snprintf(insert, insertlen, "%04d-%02d-%02d %02d:%02d:%02d", - t.year, t.month, t.day, t.hour, t.min, t.sec); + time_t t; + if (rtc_get_time(&t)) { + time_t_to_str(insert, insertlen, t); } } if (!strncmp(tag, "uptime", 6)) { diff --git a/src/mqtt.c b/src/mqtt.c index 8c8529a..be475aa 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -23,9 +23,7 @@ #include #include #include -#include "hardware/rtc.h" #include "pico/stdlib.h" -#include "pico/util/datetime.h" #include "cJSON.h" #ifdef LIB_PICO_CYW43_ARCH #include "pico/cyw43_arch.h" @@ -695,7 +693,7 @@ static char* json_status_message() cJSON *json, *l, *o; int i; float rpm; - datetime_t t; + time_t t; if (!(json = cJSON_CreateObject())) goto panic; @@ -745,10 +743,10 @@ static char* json_status_message() cJSON_AddItemToArray(l, o); } - if ( rtc_get_datetime(&t) ) { + if ( rtc_get_time(&t) ) { /* Send Data Time stamp to broker for possible use */ char datetime_buf[32]; - datetime_to_str(datetime_buf, sizeof(datetime_buf), &t); + time_t_to_str(datetime_buf, sizeof(datetime_buf), t); cJSON_AddItemToObject(json, "datetime", cJSON_CreateString( datetime_buf )); } diff --git a/src/syslog.c b/src/syslog.c index bfc6745..612620a 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -23,7 +23,6 @@ #include #include #include -#include "hardware/rtc.h" #include "pico/stdlib.h" #include "pico/cyw43_arch.h" #include "lwip/pbuf.h" diff --git a/src/telnetd.c b/src/telnetd.c index f9e9ff4..86da93e 100644 --- a/src/telnetd.c +++ b/src/telnetd.c @@ -23,7 +23,6 @@ #include #include #include -#include "hardware/rtc.h" #include "pico/stdlib.h" #include "pico/stdio/driver.h" #include "pico/cyw43_arch.h" diff --git a/src/util.c b/src/util.c index 94f02e9..4698bd6 100644 --- a/src/util.c +++ b/src/util.c @@ -165,6 +165,20 @@ bool rtc_get_tm(struct tm *tm) } +bool rtc_get_time(time_t *t) +{ + struct timespec ts; + + if (!t || !aon_timer_is_running()) + return false; + + aon_timer_get_time(&ts); + *t = timespec_to_time_t(&ts); + + return true; +} + + const char *mac_address_str(const uint8_t *mac) { static char buf[32];