Commit 2270224 2 people authored and committed
1 parent d425515 commit 2270224 Copy full SHA for 2270224
File tree 4 files changed +41
-2
lines changed
4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ assert(chip_device_platform == "esp32")
20
20
21
21
static_library (" ESP32" ) {
22
22
sources = [
23
- " ../FreeRTOS/SystemTimeSupport.cpp" ,
24
23
" ../SingletonConfigurationManager.cpp" ,
25
24
" BLEManagerImpl.h" ,
26
25
" CHIPDevicePlatformConfig.h" ,
@@ -45,6 +44,7 @@ static_library("ESP32") {
45
44
" PlatformManagerImpl.cpp" ,
46
45
" PlatformManagerImpl.h" ,
47
46
" SystemTimeSupport.cpp" ,
47
+ " SystemTimeSupport.h" ,
48
48
" bluedroid/BLEManagerImpl.cpp" ,
49
49
" nimble/BLEManagerImpl.cpp" ,
50
50
]
Original file line number Diff line number Diff line change 29
29
#include < crypto/CHIPCryptoPAL.h>
30
30
#include < platform/ESP32/DiagnosticDataProviderImpl.h>
31
31
#include < platform/ESP32/ESP32Utils.h>
32
+ #include < platform/ESP32/SystemTimeSupport.h>
32
33
#include < platform/PlatformManager.h>
33
34
#include < platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp>
34
35
@@ -123,6 +124,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
123
124
// to finish the initialization process.
124
125
ReturnErrorOnFailure (Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>::_InitChipStack ());
125
126
127
+ ReturnErrorOnFailure (System::Clock::InitClock_RealTime ());
126
128
exit :
127
129
return chip::DeviceLayer::Internal::ESP32Utils::MapError (err);
128
130
}
Original file line number Diff line number Diff line change 25
25
/* this file behaves like a config.h, comes first */
26
26
#include < platform/internal/CHIPDeviceLayerInternal.h>
27
27
28
- #include < lib/support/TimeUtils.h>
29
28
#include < lib/support/logging/CHIPLogging.h>
29
+ #include < platform/ESP32/SystemTimeSupport.h>
30
30
31
31
#include < esp_timer.h>
32
32
@@ -112,6 +112,15 @@ CHIP_ERROR ClockImpl::SetClock_RealTime(Clock::Microseconds64 aNewCurTime)
112
112
return CHIP_NO_ERROR;
113
113
}
114
114
115
+ CHIP_ERROR InitClock_RealTime ()
116
+ {
117
+ Clock::Microseconds64 curTime =
118
+ Clock::Microseconds64 ((static_cast <uint64_t >(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD) * UINT64_C (1000000 )));
119
+ // Use CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD as the initial value of RealTime.
120
+ // Then the RealTime obtained from GetClock_RealTime will be always valid.
121
+ return System::SystemClock ().SetClock_RealTime (curTime);
122
+ }
123
+
115
124
} // namespace Clock
116
125
} // namespace System
117
126
} // namespace chip
Original file line number Diff line number Diff line change
1
+ /*
2
+ *
3
+ * Copyright (c) 2022 Project CHIP Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include < lib/support/TimeUtils.h>
19
+
20
+ namespace chip {
21
+ namespace System {
22
+ namespace Clock {
23
+
24
+ CHIP_ERROR InitClock_RealTime ();
25
+
26
+ } // namespace Clock
27
+ } // namespace System
28
+ } // namespace chip
You can’t perform that action at this time.
0 commit comments