Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pico-SDK v2.1.0 support #133

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libs/pico-telnetd
Submodule pico-telnetd updated 1 files
+0 −1 src/server.c
1 change: 1 addition & 0 deletions src/fanpico.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 3 additions & 5 deletions src/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#include "hardware/rtc.h"
#include "pico/stdlib.h"
#include "cJSON.h"

Expand Down Expand Up @@ -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)) {
Expand Down
8 changes: 3 additions & 5 deletions src/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ));
}

Expand Down
1 change: 0 additions & 1 deletion src/syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <stdarg.h>
#include <time.h>
#include <assert.h>
#include "hardware/rtc.h"
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "lwip/pbuf.h"
Expand Down
1 change: 0 additions & 1 deletion src/telnetd.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#include "hardware/rtc.h"
#include "pico/stdlib.h"
#include "pico/stdio/driver.h"
#include "pico/cyw43_arch.h"
Expand Down
14 changes: 14 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Loading