File tree 1 file changed +8
-3
lines changed
examples/platform/esp32/time
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 22
22
#include < lib/support/logging/CHIPLogging.h>
23
23
24
24
static constexpr time_t kMinValidTimeStampEpoch = 1704067200 ; // 1 Jan 2019
25
- static constexpr uint32_t kSecondsInADay = 24 * 60 * 60 ;
25
+ static constexpr uint32_t kMilliSecondsInADay = 24 * 60 * 60 * 1000 ;
26
26
27
27
namespace {
28
28
const uint8_t kMaxNtpServerStringSize = 128 ;
@@ -86,6 +86,11 @@ namespace chip {
86
86
namespace Esp32TimeSync {
87
87
void Init (const char * aSntpServerName, const uint16_t aSyncSntpIntervalDay)
88
88
{
89
+ if (!aSyncSntpIntervalDay)
90
+ {
91
+ ChipLogError (DeviceLayer, " Invalid SNTP synchronization time interval." );
92
+ return ;
93
+ }
89
94
chip::Platform::CopyString (sSntpServerName , aSntpServerName);
90
95
if (esp_sntp_enabled ())
91
96
{
@@ -94,9 +99,9 @@ void Init(const char * aSntpServerName, const uint16_t aSyncSntpIntervalDay)
94
99
ChipLogProgress (DeviceLayer, " Initializing SNTP. Using the SNTP server: %s" , sSntpServerName );
95
100
esp_sntp_setoperatingmode (SNTP_OPMODE_POLL);
96
101
esp_sntp_setservername (0 , sSntpServerName );
97
- esp_sntp_set_sync_interval (kSecondsInADay * aSyncSntpIntervalDay);
98
- esp_sntp_init ();
102
+ esp_sntp_set_sync_interval (kMilliSecondsInADay * aSyncSntpIntervalDay);
99
103
sntp_set_time_sync_notification_cb (TimeSyncCallback);
104
+ esp_sntp_init ();
100
105
}
101
106
} // namespace Esp32TimeSync
102
107
} // namespace chip
You can’t perform that action at this time.
0 commit comments