Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow to use temporary strings in configTime#8606

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
d-a-v merged 2 commits intoesp8266:masterfrommcspr:sntp/private-strings
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
13 changes: 11 additions & 2 deletionscores/esp8266/Arduino.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -269,10 +269,13 @@ long map(long, long, long, long, long);

void setTZ(const char* tz);

void configTime(int timezone, int daylightOffset_sec, const char* server1,
// configure time using POSIX TZ string
// server pointers *must remain valid* for the duration of the program
void configTime(const char* tz, const char* server1,
const char* server2 = nullptr, const char* server3 = nullptr);

void configTime(const char* tz, const char* server1,
// configures with approximated TZ value. part of the old api, prefer configTime with TZ variable
void configTime(int timezone, int daylightOffset_sec, const char* server1,
const char* server2 = nullptr, const char* server3 = nullptr);

// esp32 api compatibility
Expand All@@ -290,6 +293,12 @@ bool getLocalTime(struct tm * info, uint32_t ms = 5000);
#include "WCharacter.h"
#include "WString.h"

// configTime wrappers for temporary server{1,2,3} strings
void configTime(int timezone, int daylightOffset_sec, String server1,
String server2 = String(), String server3 = String());
void configTime(const char* tz, String server1,
String server2 = String(), String server3 = String());

#include "HardwareSerial.h"
#include "Esp.h"
#include "Updater.h"
Expand Down
26 changes: 26 additions & 0 deletionscores/esp8266/time.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,19 @@ void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, c
sntp_init();
}

void configTime(int timezone_sec, int daylightOffset_sec, String server1, String server2, String server3)
{
static String servers[3];
servers[0] = std::move(server1);
servers[1] = std::move(server2);
servers[2] = std::move(server3);

configTime(timezone_sec, daylightOffset_sec,
servers[0].length() ? servers[0].c_str() : nullptr,
servers[1].length() ? servers[1].c_str() : nullptr,
servers[2].length() ? servers[2].c_str() : nullptr);
}

void setTZ(const char* tz){

char tzram[strlen_P(tz) + 1];
Expand All@@ -228,6 +241,19 @@ void configTime(const char* tz, const char* server1, const char* server2, const
sntp_init();
}

void configTime(const char* tz, String server1, String server2, String server3)
{
static String servers[3];
servers[0] = std::move(server1);
servers[1] = std::move(server2);
servers[2] = std::move(server3);

configTime(tz,
servers[0].length() ? servers[0].c_str() : nullptr,
servers[1].length() ? servers[1].c_str() : nullptr,
servers[2].length() ? servers[2].c_str() : nullptr);
}

static BoolCB _settimeofday_cb;

void settimeofday_cb (const TrivialCB& cb)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp