Implemented NTP

This commit is contained in:
2021-08-12 00:23:41 +02:00
parent 162f95ab13
commit 5ceabd378f
22 changed files with 369 additions and 30 deletions

View File

@ -79,4 +79,5 @@ add_definitions(
-DPINS_LEDBACKLIGHT=23
-DLEDBACKLIGHT_INVERTED
-DFEATURE_GARAGE
-DFEATURE_NTP
)

View File

@ -35,6 +35,7 @@ set(headers
bmsutils.h
changevaluedisplay_bluetoothmode.h
changevaluedisplay_bool.h
changevaluedisplay_sntp_sync_mode_t.h
changevaluedisplay_daylightsavingmode.h
changevaluedisplay_larsmmode_mode.h
changevaluedisplay_unifiedmodelmode.h

View File

@ -1,5 +1,6 @@
#pragma once
// local includes
#include "globals.h"
#include "accessorinterface.h"
#include "utils.h"
@ -47,8 +48,21 @@ struct CloudEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRe
struct CloudTransmitTimeoutAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.cloudSettings.cloudTransmitTimeout; } };
#endif
struct TimezoneOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.timeSettings.timezoneOffset; } };
struct TimezoneOffsetAccessor : public virtual AccessorInterface<int32_t>
{
int32_t getValue() const override { return settings.timeSettings.timezoneOffset.count(); }
void setValue(int32_t value) override { settings.timeSettings.timezoneOffset = espchrono::minutes32{value}; saveSettings(); }
};
struct DaylightSavingModeAccessor : public RefAccessorSaveSettings<espchrono::DayLightSavingMode> { espchrono::DayLightSavingMode &getRef() const override { return settings.timeSettings.daylightSavingMode; } };
#ifdef FEATURE_NTP
struct TimeServerEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.timeSettings.timeServerEnabled; } };
struct TimeSyncModeAccessor : public RefAccessorSaveSettings<sntp_sync_mode_t> { sntp_sync_mode_t &getRef() const override { return settings.timeSettings.timeSyncMode; } };
struct TimeSyncIntervalAccessor : public virtual AccessorInterface<int32_t>
{
int32_t getValue() const override { return settings.timeSettings.timeSyncInterval.count(); }
void setValue(int32_t value) override { settings.timeSettings.timeSyncInterval = espchrono::milliseconds32{value}; saveSettings(); }
};
#endif
struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontLeft; } };
struct FrontRightEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontRight; } };

View File

@ -155,6 +155,9 @@ void ChangeValueDisplay<Tvalue>::confirm()
#ifdef FEATURE_BLUETOOTH
#include "changevaluedisplay_bluetoothmode.h"
#endif
#ifdef FEATURE_NTP
#include "changevaluedisplay_sntp_sync_mode_t.h"
#endif
#include "changevaluedisplay_controlmode.h"
#include "changevaluedisplay_controltype.h"
#include "changevaluedisplay_daylightsavingmode.h"

View File

@ -0,0 +1,50 @@
#pragma once
// esp-idf includes
#include <esp_log.h>
// local includes
#include "changevaluedisplay.h"
#include "menudisplay.h"
#include "utils.h"
#include "actions/setvalueaction.h"
#include "actions/backproxyaction.h"
#include "icons/back.h"
#include "texts.h"
namespace {
template<>
class ChangeValueDisplay<sntp_sync_mode_t> :
public MenuDisplay,
public virtual AccessorInterface<sntp_sync_mode_t>,
public virtual ActionInterface
{
using Base = MenuDisplay;
public:
ChangeValueDisplay();
void start() override;
};
ChangeValueDisplay<sntp_sync_mode_t>::ChangeValueDisplay()
{
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<sntp_sync_mode_t>, StaticText<TEXT_IMMED>>>(SNTP_SYNC_MODE_IMMED, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<sntp_sync_mode_t>, StaticText<TEXT_SMOOTH>>>(SNTP_SYNC_MODE_SMOOTH, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&icons::back>>>(*this);
}
void ChangeValueDisplay<sntp_sync_mode_t>::start()
{
Base::start();
switch (const auto value = getValue())
{
case SNTP_SYNC_MODE_IMMED: setSelectedIndex(0); break;
case SNTP_SYNC_MODE_SMOOTH: setSelectedIndex(1); break;
default:
ESP_LOGW("BOBBY", "Unknown sntp_sync_mode_t: %i", int(value));
setSelectedIndex(2);
}
}
}

View File

@ -7,10 +7,13 @@
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
#include "texts.h"
#include "accessors/settingsaccessors.h"
#include "espstrutils.h"
// forward declares
namespace {
@ -19,20 +22,14 @@ class TimeSettingsMenu;
} // namespace
namespace {
class CurrentUtcDateTime : public virtual TextInterface
{
public:
std::string text() const override { return fmt::format("utc: {}", espchrono::toString(espchrono::toDateTime(espchrono::utc_clock::now()))); }
};
class CurrentUtcDateTimeText : public virtual TextInterface { public:
std::string text() const override { return fmt::format("utc: {}", espchrono::toString(espchrono::toDateTime(espchrono::utc_clock::now()))); }};
class CurrentLocalDateTime : public virtual TextInterface
{
public:
std::string text() const override { return fmt::format("local: {}", espchrono::toString(espchrono::toDateTime(espchrono::local_clock::now()))); }
};
class CurrentLocalDateTimeText : public virtual TextInterface { public:
std::string text() const override { return fmt::format("local: {}", espchrono::toString(espchrono::toDateTime(espchrono::local_clock::now()))); }};
using TimezoneOffsetChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
ChangeValueDisplay<int32_t>,
StaticText<TEXT_OFFSET>,
TimezoneOffsetAccessor,
BackActionInterface<SwitchScreenAction<TimeSettingsMenu>>,
@ -47,6 +44,27 @@ using DaylightSavingModeChangeDisplay = makeComponent<
SwitchScreenAction<TimeSettingsMenu>
>;
#ifdef FEATURE_NTP
using TimeSyncModeChangeDisplay = makeComponent<
ChangeValueDisplay<sntp_sync_mode_t>,
StaticText<TEXT_NTPMODE>,
TimeSyncModeAccessor,
BackActionInterface<SwitchScreenAction<TimeSettingsMenu>>,
SwitchScreenAction<TimeSettingsMenu>
>;
using TimeSyncIntervalChangeDisplay = makeComponent<
ChangeValueDisplay<int32_t>,
StaticText<TEXT_NTPINTERVAL>,
TimeSyncIntervalAccessor,
BackActionInterface<SwitchScreenAction<TimeSettingsMenu>>,
SwitchScreenAction<TimeSettingsMenu>
>;
class NtpSyncStatusText : public virtual TextInterface { public:
std::string text() const override { return fmt::format("Status: {}", espcpputils::toString(sntp_get_sync_status())); }};
#endif
class TimeSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_TIME>,
@ -55,10 +73,17 @@ class TimeSettingsMenu :
public:
TimeSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, CurrentUtcDateTime, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTime, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CurrentUtcDateTimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OFFSET>, SwitchScreenAction<TimezoneOffsetChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DAYLIGHTSAVINGMODE>, SwitchScreenAction<DaylightSavingModeChangeDisplay>>>();
#ifdef FEATURE_NTP
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPENABLED>, ToggleBoolAction, CheckboxIcon, TimeServerEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPSERVER>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPMODE>, SwitchScreenAction<TimeSyncModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPINTERVAL>, SwitchScreenAction<TimeSyncIntervalChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, NtpSyncStatusText, DummyAction>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
}
};

View File

@ -1,9 +1,13 @@
#pragma once
// Arduino includes
#include <Arduino.h>
// 3rdparty lib includes
#include <espchrono.h>
#include <tickchrono.h>
// local includes
#include "dpad.h"
#include "buttons.h"
#include "types.h"
@ -38,7 +42,7 @@ dpad::State Helper<OUT, IN1, IN2>::read()
pinMode(IN1, INPUT_PULLUP);
pinMode(IN2, INPUT_PULLUP);
delay(1);
vPortYield();
const bool result0 = digitalRead(IN1)==LOW;
const bool result1 = digitalRead(IN2)==LOW;
@ -48,7 +52,7 @@ dpad::State Helper<OUT, IN1, IN2>::read()
pinMode(IN1, INPUT_PULLDOWN);
pinMode(IN2, INPUT_PULLDOWN);
delay(1);
vPortYield();
const bool result2 = digitalRead(IN1);
const bool result3 = digitalRead(IN2);

View File

@ -1,11 +1,16 @@
#pragma once
// system includes
#include <array>
// Arduino includes
#include <Arduino.h>
// 3rdparty lib includes
#include <espchrono.h>
#include <tickchrono.h>
// local includes
#include "buttons.h"
#include "types.h"
@ -73,7 +78,7 @@ State Helper<OUT, IN1, IN2, IN3, IN4>::read()
pinMode(IN3, INPUT_PULLUP);
pinMode(IN4, INPUT_PULLUP);
delay(1);
vPortYield();
result[0] = digitalRead(IN1)==LOW;
result[1] = digitalRead(IN2)==LOW;
@ -87,7 +92,7 @@ State Helper<OUT, IN1, IN2, IN3, IN4>::read()
pinMode(IN3, INPUT_PULLDOWN);
pinMode(IN4, INPUT_PULLDOWN);
delay(1);
vPortYield();
result[4] = digitalRead(IN1);
result[5] = digitalRead(IN2);

View File

@ -151,6 +151,9 @@ std::optional<espchrono::millis_clock::time_point> lastBleUpdate;
#ifdef FEATURE_CLOUD
std::optional<espchrono::millis_clock::time_point> lastCloudUpdate;
#endif
#ifdef FEATURE_NTP
std::optional<espchrono::millis_clock::time_point> lastNtpUpdate;
#endif
}
extern "C" void app_main()
@ -297,6 +300,11 @@ extern "C" void app_main()
initCloud();
#endif
#ifdef FEATURE_NTP
bootLabel.redraw("time");
initTime();
#endif
bootLabel.redraw("switchScreen");
#if defined(FEATURE_DPAD_5WIRESW) && defined(DPAD_5WIRESW_DEBUG)
@ -427,6 +435,15 @@ extern "C" void app_main()
}
#endif
#ifdef FEATURE_NTP
if (!lastNtpUpdate || now - *lastNtpUpdate >= 100ms)
{
updateTime();
lastNtpUpdate = now;
}
#endif
#ifdef FEATURE_WEBSERVER
handleWebserver();
#endif

View File

@ -1,5 +1,11 @@
#pragma once
// esp-idf includes
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h>
#include <esp_sntp.h>
#endif
// 3rdparty lib includes
#include <espchrono.h>
@ -7,6 +13,8 @@
#include "settings.h"
#include "stringsettings.h"
using namespace std::chrono_literals;
namespace presets {
constexpr Settings::Limits defaultLimits {
.iMotMax = DEFAULT_IMOTMAX,
@ -25,8 +33,13 @@ constexpr Settings::Limits kidsLimits {
};
constexpr Settings::TimeSettings defaultTimeSettings {
.timezoneOffset = 60,
.daylightSavingMode = espchrono::DayLightSavingMode::EuropeanSummerTime
.timezoneOffset = 60min,
.daylightSavingMode = espchrono::DayLightSavingMode::EuropeanSummerTime,
#ifdef FEATURE_NTP
.timeServerEnabled = true,
.timeSyncMode = SNTP_SYNC_MODE_IMMED,
.timeSyncInterval = espchrono::milliseconds32{CONFIG_LWIP_SNTP_UPDATE_DELAY},
#endif
};
constexpr Settings::ControllerHardware defaultControllerHardware {
@ -245,7 +258,10 @@ StringSettings makeDefaultStringSettings()
.otaUrl = {},
#endif
#ifdef FEATURE_GARAGE
.garageUrl = "http://insecure.brunner.ninja/tor.php",
.garageUrl = {},
#endif
#ifdef FEATURE_NTP
.timeServer = "europe.pool.ntp.org",
#endif
};
}

View File

@ -6,6 +6,13 @@
// esp-idf includes
#include <esp_wifi_types.h>
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h>
#include <esp_sntp.h>
#endif
// 3rdparty lib includes
#include <espchrono.h>
// local includes
#include "bobbycar-common.h"
@ -54,8 +61,14 @@ struct Settings
#endif
struct TimeSettings {
int16_t timezoneOffset;
espchrono::minutes32 timezoneOffset;
espchrono::DayLightSavingMode daylightSavingMode;
#ifdef FEATURE_NTP
bool timeServerEnabled;
sntp_sync_mode_t timeSyncMode;
espchrono::milliseconds32 timeSyncInterval;
#endif
} timeSettings;
struct ControllerHardware {
@ -160,6 +173,11 @@ void Settings::executeForEveryCommonSetting(T &&callable)
callable("timezoneOffset", timeSettings.timezoneOffset);
callable("daylightSaving", timeSettings.daylightSavingMode);
#ifdef FEATURE_NTP
callable("timeServerEnab", timeSettings.timeServerEnabled);
callable("timeSyncMode", timeSettings.timeSyncMode);
callable("timeSyncInterv", timeSettings.timeSyncInterval);
#endif
callable("wheelDiameter", controllerHardware.wheelDiameter);
callable("numMagnetPoles", controllerHardware.numMagnetPoles);

View File

@ -5,9 +5,13 @@
#include <optional>
// esp-idf includes
#include <esp_log.h>
#include <nvs_flash.h>
#include <nvs.h>
#include <esp_log.h>
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h>
#include <esp_sntp.h>
#endif
// 3rdparty lib includes
#include <fmt/core.h>
@ -230,6 +234,48 @@ template<> struct nvsGetterHelper<espchrono::DayLightSavingMode> { static esp_er
*out_value = espchrono::DayLightSavingMode(tempValue);
return err;
}};
template<> struct nvsGetterHelper<espchrono::milliseconds32> { static esp_err_t nvs_get(nvs_handle handle, const char* key, espchrono::milliseconds32* out_value)
{
int32_t tempValue;
esp_err_t err = nvs_get_i32(handle, key, &tempValue);
if (err == ESP_OK)
*out_value = espchrono::milliseconds32(tempValue);
return err;
}};
template<> struct nvsGetterHelper<espchrono::seconds32> { static esp_err_t nvs_get(nvs_handle handle, const char* key, espchrono::seconds32* out_value)
{
int32_t tempValue;
esp_err_t err = nvs_get_i32(handle, key, &tempValue);
if (err == ESP_OK)
*out_value = espchrono::seconds32(tempValue);
return err;
}};
template<> struct nvsGetterHelper<espchrono::minutes32> { static esp_err_t nvs_get(nvs_handle handle, const char* key, espchrono::minutes32* out_value)
{
int32_t tempValue;
esp_err_t err = nvs_get_i32(handle, key, &tempValue);
if (err == ESP_OK)
*out_value = espchrono::minutes32(tempValue);
return err;
}};
template<> struct nvsGetterHelper<espchrono::hours32> { static esp_err_t nvs_get(nvs_handle handle, const char* key, espchrono::hours32* out_value)
{
int32_t tempValue;
esp_err_t err = nvs_get_i32(handle, key, &tempValue);
if (err == ESP_OK)
*out_value = espchrono::hours32(tempValue);
return err;
}};
#ifdef FEATURE_NTP
template<> struct nvsGetterHelper<sntp_sync_mode_t> { static esp_err_t nvs_get(nvs_handle handle, const char* key, sntp_sync_mode_t* out_value)
{
uint8_t tempValue;
esp_err_t err = nvs_get_u8(handle, key, &tempValue);
if (err == ESP_OK)
*out_value = sntp_sync_mode_t(tempValue);
return err;
}};
#endif
template<typename T>
bool SettingsPersister::load(T &settings)
@ -317,6 +363,28 @@ template<> struct nvsSetterHelper<espchrono::DayLightSavingMode> { static esp_er
{
return nvs_set_u8(handle, key, uint8_t(value));
}};
template<> struct nvsSetterHelper<espchrono::milliseconds32> { static esp_err_t nvs_set(nvs_handle handle, const char* key, espchrono::milliseconds32 value)
{
return nvs_set_i32(handle, key, value.count());
}};
template<> struct nvsSetterHelper<espchrono::seconds32> { static esp_err_t nvs_set(nvs_handle handle, const char* key, espchrono::seconds32 value)
{
return nvs_set_i32(handle, key, value.count());
}};
template<> struct nvsSetterHelper<espchrono::minutes32> { static esp_err_t nvs_set(nvs_handle handle, const char* key, espchrono::minutes32 value)
{
return nvs_set_i32(handle, key, value.count());
}};
template<> struct nvsSetterHelper<espchrono::hours32> { static esp_err_t nvs_set(nvs_handle handle, const char* key, espchrono::hours32 value)
{
return nvs_set_i32(handle, key, value.count());
}};
#ifdef FEATURE_NTP
template<> struct nvsSetterHelper<sntp_sync_mode_t> { static esp_err_t nvs_set(nvs_handle handle, const char* key, sntp_sync_mode_t value)
{
return nvs_set_u8(handle, key, uint8_t(value));
}};
#endif
template<typename T>
bool SettingsPersister::save(T &settings)

View File

@ -26,6 +26,10 @@ struct StringSettings
std::string garageUrl;
#endif
#ifdef FEATURE_NTP
std::string timeServer;
#endif
template<typename T>
void executeForEveryCommonSetting(T &&callable);
@ -69,6 +73,9 @@ void StringSettings::executeForEveryCommonSetting(T &&callable)
#ifdef FEATURE_GARAGE
callable("garageUrl", garageUrl);
#endif
#ifdef FEATURE_NTP
callable("timeServer", timeServer);
#endif
}
template<typename T>

View File

@ -332,7 +332,11 @@ constexpr char TEXT_CLOUDSENDRATE[] = "Cloud send rate";
//TimeSettingsMenu
//constexpr char TEXT_TIME[] = "Time";
constexpr char TEXT_OFFSET[] = "Offset";
constexpr char TEXT_DAYLIGHTSAVINGMODE[] = "Daylight Saving Mode";
constexpr char TEXT_DAYLIGHTSAVINGMODE[] = "Daylight Saving";
constexpr char TEXT_NTPENABLED[] = "NTP Enabled";
constexpr char TEXT_NTPSERVER[] = "NTP Server";
constexpr char TEXT_NTPMODE[] = "NTP Mode";
constexpr char TEXT_NTPINTERVAL[] = "NTP Interval";
//constexpr char TEXT_BACK[] = "Back";
//ChangeValueDisplay<BluetoothMode>
@ -345,6 +349,11 @@ constexpr char TEXT_TRUE[] = "true";
constexpr char TEXT_FALSE[] = "false";
//constexpr char TEXT_BACK[] = "Back";
//ChangeValueDisplay<sntp_sync_mode_t>
constexpr char TEXT_IMMED[] = "IMMED";
constexpr char TEXT_SMOOTH[] = "SMOOTH";
//constexpr char TEXT_BACK[] = "Back";
//ChangeValueDisplay<ControlMode>
constexpr char TEXT_OPENMODE[] = "Open mode";
constexpr char TEXT_VOLTAGE[] = "Voltage";

View File

@ -1,7 +1,15 @@
#pragma once
// esp-idf includes
#include <esp_log.h>
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h>
#include <esp_sntp.h>
#endif
// 3rdparty lib includes
#include <espchrono.h>
#include <espstrutils.h>
// local includes
#include "globals.h"
@ -10,3 +18,84 @@ auto espchrono::local_clock::timezone() noexcept -> time_zone
{
return time_zone{minutes32{settings.timeSettings.timezoneOffset}, settings.timeSettings.daylightSavingMode};
}
namespace {
#ifdef FEATURE_NTP
void time_sync_notification_cb(struct timeval *tv);
void initTime()
{
sntp_setoperatingmode(SNTP_OPMODE_POLL);
static_assert(SNTP_MAX_SERVERS >= 1);
sntp_setservername(0, stringSettings.timeServer.c_str());
sntp_set_time_sync_notification_cb(time_sync_notification_cb);
sntp_set_sync_mode(settings.timeSettings.timeSyncMode);
sntp_set_sync_interval(espchrono::milliseconds32{settings.timeSettings.timeSyncInterval}.count());
if (settings.timeSettings.timeServerEnabled)
{
ESP_LOGI("BOBBY", "sntp_init() ...");
sntp_init();
if (!sntp_enabled())
{
ESP_LOGE("BOBBY", "sntp_init() failed");
}
}
}
void updateTime()
{
if (bool(sntp_enabled()) != settings.timeSettings.timeServerEnabled)
{
if (settings.timeSettings.timeServerEnabled)
{
ESP_LOGD("BOBBY", "calling sntp_init()...");
sntp_init();
ESP_LOGI("BOBBY", "sntp_init() finished");
}
else
{
ESP_LOGD("BOBBY", "calling sntp_stop()...");
sntp_stop();
ESP_LOGI("BOBBY", "sntp_stop() finished");
}
}
if (stringSettings.timeServer != sntp_getservername(0))
{
ESP_LOGD("BOBBY", "calling sntp_getservername() with %s...", stringSettings.timeServer.c_str());
sntp_setservername(0, stringSettings.timeServer.c_str());
ESP_LOGI("BOBBY", "sntp_getservername() finished");
}
if (settings.timeSettings.timeSyncMode != sntp_get_sync_mode())
{
ESP_LOGD("BOBBY", "calling sntp_set_sync_mode() with %s...", espcpputils::toString(settings.timeSettings.timeSyncMode).c_str());
sntp_set_sync_mode(settings.timeSettings.timeSyncMode);
ESP_LOGI("BOBBY", "sntp_set_sync_mode() finished");
}
if (settings.timeSettings.timeSyncInterval != espchrono::milliseconds32{sntp_get_sync_interval()})
{
ESP_LOGD("BOBBY", "calling sntp_set_sync_interval() with %s...", espchrono::toString(settings.timeSettings.timeSyncInterval).c_str());
sntp_set_sync_interval(espchrono::milliseconds32{settings.timeSettings.timeSyncInterval}.count());
ESP_LOGI("BOBBY", "sntp_set_sync_interval() finished");
}
}
tl::expected<void, std::string> time_requestSync()
{
ESP_LOGI("BOBBY", "called");
if (!sntp_restart())
return tl::make_unexpected("sntp_restart() failed");
return {};
}
void time_sync_notification_cb(struct timeval *tv)
{
if (tv)
ESP_LOGI("BOBBY", "%ld", tv->tv_sec);
else
ESP_LOGI("BOBBY", "nullptr");
}
#endif
}

View File

@ -167,6 +167,18 @@ CONFIG_LOG_LOCAL_LEVEL_ASYNC_HTTP_INFO=y
CONFIG_LOG_LOCAL_LEVEL_ASYNC_HTTP=3
# end of Simple Async HTTP Request
#
# espcpputils settings
#
# CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_NONE is not set
# CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_ERROR is not set
# CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_WARN is not set
CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_INFO=y
# CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_DEBUG is not set
# CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL_VERBOSE is not set
CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL=3
# end of espcpputils settings
#
# Simple WiFi Stack settings
#