From 3cc94dc7bee2a5519c391eee1c84114c66ad8921 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Tue, 31 May 2022 14:14:55 +0100 Subject: [PATCH 01/13] placeholder files for iotsdk platform --- .../openiotsdk/CHIPDevicePlatformConfig.h | 1 + .../openiotsdk/ConfigurationManagerImpl.cpp | 20 +++- .../openiotsdk/ConfigurationManagerImpl.h | 4 +- .../openiotsdk/ConnectivityManagerImpl.cpp | 9 +- .../openiotsdk/ConnectivityManagerImpl.h | 8 +- .../DeviceNetworkProvisioningDelegateImpl.cpp | 3 + .../openiotsdk/DiagnosticDataProviderImpl.cpp | 1 + src/platform/openiotsdk/Logging.cpp | 4 + .../openiotsdk/NetworkCommissioningDriver.h | 2 - src/platform/openiotsdk/OpenIoTSDKConfig.cpp | 104 ++++++++++++++---- src/platform/openiotsdk/OpenIoTSDKConfig.h | 1 + 11 files changed, 123 insertions(+), 34 deletions(-) diff --git a/src/platform/openiotsdk/CHIPDevicePlatformConfig.h b/src/platform/openiotsdk/CHIPDevicePlatformConfig.h index f9058fbacc82fb..3e9c17c22edc67 100644 --- a/src/platform/openiotsdk/CHIPDevicePlatformConfig.h +++ b/src/platform/openiotsdk/CHIPDevicePlatformConfig.h @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** * @file * Platform-specific configuration overrides for the chip Device Layer diff --git a/src/platform/openiotsdk/ConfigurationManagerImpl.cpp b/src/platform/openiotsdk/ConfigurationManagerImpl.cpp index 2e3cf648639e1d..b61f40d76d6801 100644 --- a/src/platform/openiotsdk/ConfigurationManagerImpl.cpp +++ b/src/platform/openiotsdk/ConfigurationManagerImpl.cpp @@ -18,14 +18,26 @@ /** * @file - * Provides the implementation of the Device Layer Configuration Manager class - * for Open IOT SDK platform. + * Provides the implementation of the Device Layer ConfigurationManager object + * for Open IOT SDK platforms. */ +/* this file behaves like a config.h, comes first */ -#include +// FIXME: Undefine the `sleep()` function included by the CHIPDeviceLayer.h +// from unistd.h to avoid a conflicting declaration with the `sleep()` provided +// by Mbed-OS in mbed_power_mgmt.h. +#define sleep unistd_sleep #include +#undef sleep + #include +#include + +// mbed-os headers +#include "platform/mbed_power_mgmt.h" +#include + namespace chip { namespace DeviceLayer { @@ -150,7 +162,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) // Restart the system. ChipLogProgress(DeviceLayer, "System restarting"); - // ToDo reset system + system_reset(); } } // namespace DeviceLayer diff --git a/src/platform/openiotsdk/ConfigurationManagerImpl.h b/src/platform/openiotsdk/ConfigurationManagerImpl.h index 9f91239eacebaf..f17a94362bd4cd 100644 --- a/src/platform/openiotsdk/ConfigurationManagerImpl.h +++ b/src/platform/openiotsdk/ConfigurationManagerImpl.h @@ -18,8 +18,8 @@ /** * @file - * Provides an implementation of the Configuration Manager class - * for Open IOT SDK platform. + * Provides an implementation of the ConfigurationManager object + * for Open IOT SDK platforms. */ #pragma once diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp index 4d2a0dd4cda6f3..69446e74bab629 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp @@ -21,6 +21,7 @@ * Provides the implementation of the Device Layer Connectivity Manager class * for Open IOT SDK platform. */ +/* this file behaves like a config.h, comes first */ #include @@ -59,9 +60,13 @@ void ConnectivityManagerImpl::AddTask(AsyncWorkFunct workFunct, intptr_t arg) PlatformMgr().ScheduleWork(workFunct, arg); } -void ConnectivityManagerImpl::AddQueueEvent(void * event) +void ConnectivityManagerImpl::AddQueueEvent(void (*func)(nsapi_event_t, intptr_t), nsapi_event_t event, intptr_t data) { - // ToDo add event to queue + PlatformMgrImpl().mQueue.call([func, event, data] { + PlatformMgr().LockChipStack(); + (*func)(event, data); + PlatformMgr().UnlockChipStack(); + }); } } // namespace DeviceLayer diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.h b/src/platform/openiotsdk/ConnectivityManagerImpl.h index 4d7710074ae1d3..394dee5c4acfbc 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.h +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.h @@ -19,7 +19,7 @@ /** * @file * Provides the implementation of the Device Layer Connectivity Manager class - * for Open IOT SDK platform. + * for Open IOT SDK platforms. */ #pragma once @@ -29,14 +29,14 @@ #include #include #include -#include #include +#include namespace chip { namespace DeviceLayer { /** - * Concrete implementation of the ConnectivityManager singleton object for Open IOT SDK platform. + * Concrete implementation of the ConnectivityManager singleton object for Open IoT SDK platforms. */ class ConnectivityManagerImpl final : public ConnectivityManager, public Internal::GenericConnectivityManagerImpl, @@ -61,7 +61,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public: CHIP_ERROR PostEvent(const ChipDeviceEvent * event, bool die); void AddTask(AsyncWorkFunct workFunct, intptr_t arg); - void AddQueueEvent(void * event); + void AddQueueEvent(void (*func)(nsapi_event_t, intptr_t), nsapi_event_t event, intptr_t data); }; /** diff --git a/src/platform/openiotsdk/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/openiotsdk/DeviceNetworkProvisioningDelegateImpl.cpp index 8485e5a3655f32..0c8c5e29dd339c 100644 --- a/src/platform/openiotsdk/DeviceNetworkProvisioningDelegateImpl.cpp +++ b/src/platform/openiotsdk/DeviceNetworkProvisioningDelegateImpl.cpp @@ -24,6 +24,9 @@ #include #include +#include + +using namespace ::chip::DeviceLayer::NetworkCommissioning; namespace chip { namespace DeviceLayer { diff --git a/src/platform/openiotsdk/DiagnosticDataProviderImpl.cpp b/src/platform/openiotsdk/DiagnosticDataProviderImpl.cpp index 93009adf1f8c84..4b675c4ac0143a 100644 --- a/src/platform/openiotsdk/DiagnosticDataProviderImpl.cpp +++ b/src/platform/openiotsdk/DiagnosticDataProviderImpl.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace chip { diff --git a/src/platform/openiotsdk/Logging.cpp b/src/platform/openiotsdk/Logging.cpp index c40f72b38c9479..7dc4a386bfa7c1 100644 --- a/src/platform/openiotsdk/Logging.cpp +++ b/src/platform/openiotsdk/Logging.cpp @@ -31,6 +31,10 @@ #include #include +#define DEFAULT_TRACE_FILTER_LENGTH 24 + +static const char * TRACE_GROUP = "CHIP"; + namespace chip { namespace DeviceLayer { diff --git a/src/platform/openiotsdk/NetworkCommissioningDriver.h b/src/platform/openiotsdk/NetworkCommissioningDriver.h index 36684c4336c861..524f575e9e7bd8 100644 --- a/src/platform/openiotsdk/NetworkCommissioningDriver.h +++ b/src/platform/openiotsdk/NetworkCommissioningDriver.h @@ -30,8 +30,6 @@ namespace chip { namespace DeviceLayer { namespace NetworkCommissioning { -// TODO - class OpenIoTSDKEthernetDriver final : public EthernetDriver { public: diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp index 68da6aabefdc30..5f0522e9f199a6 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp @@ -19,9 +19,9 @@ * @file * Utilities for interacting with the the Open IoT SDK key-value storage. */ +/* this file behaves like a config.h, comes first */ #include -#include #include #include @@ -87,7 +87,18 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, bool & val) return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - // ToDo get key-value + size_t actual_size = 0; + int err; // = kv_get(key, reinterpret_cast(&val), sizeof(val), &actual_size); + + if (err != osOK) + { + return CHIP_ERROR_INTERNAL; + } + + if (actual_size != sizeof(val)) + { + return CHIP_ERROR_BAD_REQUEST; + } return CHIP_NO_ERROR; } @@ -99,7 +110,18 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, uint32_t & val) return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - // ToDo get key-value + size_t actual_size = 0; + int err; // = kv_get(key, reinterpret_cast(&val), sizeof(val), &actual_size); + + if (err != osOK) + { + return CHIP_ERROR_INTERNAL; + } + + if (actual_size != sizeof(val)) + { + return CHIP_ERROR_BAD_REQUEST; + } return CHIP_NO_ERROR; } @@ -111,7 +133,18 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, uint64_t & val) return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - // ToDo get key-value + size_t actual_size = 0; + int err; // = kv_get(key, &val, sizeof(val), &actual_size); + + if (err != osOK) + { + return CHIP_ERROR_INTERNAL; + } + + if (actual_size != sizeof(val)) + { + return CHIP_ERROR_BAD_REQUEST; + } return CHIP_NO_ERROR; } @@ -139,27 +172,44 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t b return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - // ToDo get key-value + kv_info_t info; + + int err; // = kv_get_info(key, &info); + if (err != osOK) + { + return CHIP_ERROR_INTERNAL; + } + + err; // = kv_get(key, reinterpret_cast(buf), bufSize, &outLen); + if (err != osOK) + { + return CHIP_ERROR_INTERNAL; + } + + if (bufSize < info.size) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } return CHIP_NO_ERROR; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, bool val) { - // ToDo set key-value - return CHIP_NO_ERROR; + int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, uint32_t val) { - // ToDo set key-value - return CHIP_NO_ERROR; + int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, uint64_t val) { - // ToDo set key-value - return CHIP_NO_ERROR; + int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueStr(Key key, const char * str) @@ -178,8 +228,8 @@ CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueBin(Key key, const uint8_t * data, // or create. If the pointer is null, the key is removed if it exist. if (data != nullptr) { - // ToDo set key-value - return CHIP_NO_ERROR; + int err; // = kv_set(key, reinterpret_cast(data), dataLen, 0); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } else if (ConfigValueExists(key)) { @@ -194,19 +244,20 @@ CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueBin(Key key, const uint8_t * data, CHIP_ERROR OpenIoTSDKConfig::ClearConfigValue(Key key) { - // ToDo remove key-value - return CHIP_NO_ERROR; + int err; // = kv_remove(key); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } bool OpenIoTSDKConfig::ConfigValueExists(Key key) { - // ToDo check key-value exists - return false; + kv_info_t info; + int err; // = kv_get_info(key, &info); + return err == osOK ? true : false; } CHIP_ERROR OpenIoTSDKConfig::FactoryResetConfig() { - // reset is not used, we want to preserve other setting and factory + // kv_reset is not used, we want to preserve other setting and factory // configuration auto err = ClearNamespace(kConfigNamespace_ChipConfig); if (err != CHIP_NO_ERROR) @@ -259,8 +310,21 @@ CHIP_ERROR OpenIoTSDKConfig::WriteCounter(Key counterId, uint32_t value) CHIP_ERROR OpenIoTSDKConfig::ClearNamespace(const char * ns) { - // ToDo clear key-values in namespace - return CHIP_NO_ERROR; + kv_iterator_t it; + char key[50]; + int err; // = kv_iterator_open(&it, ns); + if (err) + { + return CHIP_ERROR_INTERNAL; + } + // while (kv_iterator_next(it, key, sizeof(key)) != MBED_ERROR_ITEM_NOT_FOUND) + { + // kv_remove(key); + memset(key, 0, sizeof(key)); + } + + // err = kv_iterator_close(it); + return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } void OpenIoTSDKConfig::RunConfigUnitTest() diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.h b/src/platform/openiotsdk/OpenIoTSDKConfig.h index cc03768f7ac20e..9213dd4aca168e 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.h +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include From 760e3920c9dd2eec7df59b3b318ad406c9a0caca Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Tue, 31 May 2022 16:55:42 +0100 Subject: [PATCH 02/13] empty eth commision driver --- .../openiotsdk/NetworkCommissioningDriver.h | 32 +++++++++++++++++++ .../NetworkCommissioningEthernetDriver.cpp | 2 ++ 2 files changed, 34 insertions(+) diff --git a/src/platform/openiotsdk/NetworkCommissioningDriver.h b/src/platform/openiotsdk/NetworkCommissioningDriver.h index 524f575e9e7bd8..ee5867c57d8cef 100644 --- a/src/platform/openiotsdk/NetworkCommissioningDriver.h +++ b/src/platform/openiotsdk/NetworkCommissioningDriver.h @@ -62,6 +62,38 @@ class OpenIoTSDKEthernetDriver final : public EthernetDriver NetworkIterator * GetNetworks() override; }; +class OpenIoTSDKEthernetDriver final : public EthernetDriver +{ +public: + struct EthernetNetworkIterator final : public NetworkIterator + { + EthernetNetworkIterator() = default; + size_t Count() override { return interfaceNameLen > 0 ? 1 : 0; } + bool Next(Network & item) override + { + if (exhausted) + { + return false; + } + exhausted = true; + memcpy(item.networkID, interfaceName, interfaceNameLen); + item.networkIDLen = interfaceNameLen; + item.connected = true; + return true; + } + void Release() override { delete this; } + ~EthernetNetworkIterator() override = default; + + // Public, but cannot be accessed via NetworkIterator interface. + uint8_t interfaceName[kMaxNetworkIDLen]; + uint8_t interfaceNameLen = 0; + bool exhausted = false; + }; + + uint8_t GetMaxNetworks() override { return 1; }; + NetworkIterator * GetNetworks() override; +}; + } // namespace NetworkCommissioning } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp index bbc38c1ccbee0b..4c54df72eb767c 100644 --- a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp +++ b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp @@ -25,6 +25,8 @@ #include #include +#include + using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceLayer::Internal; From 6d7df07f504e82152de18471e462104293b617b7 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 1 Jun 2022 16:43:53 +0100 Subject: [PATCH 03/13] use tdb for keystore --- src/platform/openiotsdk/OpenIoTSDKConfig.cpp | 163 +++++++++++++++---- src/platform/openiotsdk/OpenIoTSDKConfig.h | 5 + 2 files changed, 135 insertions(+), 33 deletions(-) diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp index 5f0522e9f199a6..be8d470af744bb 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -82,15 +83,20 @@ const OpenIoTSDKConfig::Key OpenIoTSDKConfig::kConfigKey_UniqueId = { CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, bool & val) { + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + if (!ConfigValueExists(key)) { return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - size_t actual_size = 0; - int err; // = kv_get(key, reinterpret_cast(&val), sizeof(val), &actual_size); + size_t actual_size = 0; + iotsdk::storage::kv_status err = tdb->get(key, reinterpret_cast(&val), sizeof(val), &actual_size); - if (err != osOK) + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } @@ -105,15 +111,20 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, bool & val) CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, uint32_t & val) { + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + if (!ConfigValueExists(key)) { return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - size_t actual_size = 0; - int err; // = kv_get(key, reinterpret_cast(&val), sizeof(val), &actual_size); + size_t actual_size = 0; + iotsdk::storage::kv_status err = tdb->get(key, reinterpret_cast(&val), sizeof(val), &actual_size); - if (err != osOK) + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } @@ -128,15 +139,20 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, uint32_t & val) CHIP_ERROR OpenIoTSDKConfig::ReadConfigValue(Key key, uint64_t & val) { + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + if (!ConfigValueExists(key)) { return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - size_t actual_size = 0; - int err; // = kv_get(key, &val, sizeof(val), &actual_size); + size_t actual_size = 0; + iotsdk::storage::kv_status err = tdb->get(key, &val, sizeof(val), &actual_size); - if (err != osOK) + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } @@ -167,21 +183,26 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValueStr(Key key, char * buf, size_t bufS CHIP_ERROR OpenIoTSDKConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) { + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + if (!ConfigValueExists(key)) { return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - kv_info_t info; + tdb->info_t info; - int err; // = kv_get_info(key, &info); - if (err != osOK) + iotsdk::storage::kv_status err = tdb->get_info(key, &info); + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } - err; // = kv_get(key, reinterpret_cast(buf), bufSize, &outLen); - if (err != osOK) + err = tdb->get(key, reinterpret_cast(buf), bufSize, &outLen); + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } @@ -196,20 +217,35 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t b CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, bool val) { - int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + + iotsdk::storage::kv_status err = tdb->set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, uint32_t val) { - int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + + iotsdk::storage::kv_status err = tdb->set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValue(Key key, uint64_t val) { - int err; // = kv_set(key, reinterpret_cast(&val), sizeof(val), 0); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + + iotsdk::storage::kv_status err = tdb->set(key, reinterpret_cast(&val), sizeof(val), 0); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueStr(Key key, const char * str) @@ -224,12 +260,17 @@ CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueStr(Key key, const char * str, size CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) { + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + // Two different behavior: If the pointer is not null, the value is updated // or create. If the pointer is null, the key is removed if it exist. if (data != nullptr) { - int err; // = kv_set(key, reinterpret_cast(data), dataLen, 0); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + iotsdk::storage::kv_status err = tdb->set(key, reinterpret_cast(data), dataLen, 0); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } else if (ConfigValueExists(key)) { @@ -244,20 +285,30 @@ CHIP_ERROR OpenIoTSDKConfig::WriteConfigValueBin(Key key, const uint8_t * data, CHIP_ERROR OpenIoTSDKConfig::ClearConfigValue(Key key) { - int err; // = kv_remove(key); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + + iotsdk::storage::kv_status err = tdb->remove(key); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } bool OpenIoTSDKConfig::ConfigValueExists(Key key) { + if (Init() != CHIP_NO_ERROR) + { + return false; + } + kv_info_t info; - int err; // = kv_get_info(key, &info); - return err == osOK ? true : false; + iotsdk::storage::kv_status err = tdb->get_info(key, &info); + return err == iotsdk::storage::kv_status::OK ? true : false; } CHIP_ERROR OpenIoTSDKConfig::FactoryResetConfig() { - // kv_reset is not used, we want to preserve other setting and factory + // tdb->reset is not used, we want to preserve other setting and factory // configuration auto err = ClearNamespace(kConfigNamespace_ChipConfig); if (err != CHIP_NO_ERROR) @@ -310,21 +361,26 @@ CHIP_ERROR OpenIoTSDKConfig::WriteCounter(Key counterId, uint32_t value) CHIP_ERROR OpenIoTSDKConfig::ClearNamespace(const char * ns) { - kv_iterator_t it; + if (Init() != CHIP_NO_ERROR) + { + return CHIP_ERROR_INTERNAL; + } + + iotsdk::storage::iterator_t it; char key[50]; - int err; // = kv_iterator_open(&it, ns); + iotsdk::storage::kv_status err = tdb->iterator_open(&it, ns); if (err) { return CHIP_ERROR_INTERNAL; } - // while (kv_iterator_next(it, key, sizeof(key)) != MBED_ERROR_ITEM_NOT_FOUND) + while (tdb->iterator_next(it, key, sizeof(key)) != MBED_ERROR_ITEM_NOT_FOUND) { - // kv_remove(key); + tdb->remove(key); memset(key, 0, sizeof(key)); } - // err = kv_iterator_close(it); - return err == osOK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + err = tdb->iterator_close(it); + return err == iotsdk::storage::kv_status::OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; } void OpenIoTSDKConfig::RunConfigUnitTest() @@ -333,6 +389,47 @@ void OpenIoTSDKConfig::RunConfigUnitTest() ::chip::DeviceLayer::Internal::RunConfigUnitTest(); } +CHIP_ERROR OpenIoTSDKConfig::Init(void) +{ + if (tdb) + { + return CHIP_NO_ERROR; + } + + flash_bd = new iotsdk::storage::FlashIAPBlockDevice(get_ram_drive_instance(), 0, 0); + + if (!flash_bd) + { + return CHIP_ERROR_INTERNAL; + } + + // Create a TDBStore using the underlying storage + tdb = new iotsdk::storage::TDBStore(flash_bd); + + if (!tdb) + { + delete flash_bd; + return CHIP_ERROR_INTERNAL; + } + + // KVStore uses dual stage initialization so we can handle any errors + // Call the `init` method to setup the TDBStore + iotsdk::storage::kv_status err = tdb->init(); + if (err != iotsdk::storage::kv_status::OK) + { + delete flash_bd; + delete tdb; + // zero tdb as we use it keep track of init + tdb = nullptr; + return CHIP_ERROR_INTERNAL; + } + + return CHIP_NO_ERROR; +} + +iotsdk::storage::TDBStore * OpenIoTSDKConfig::tdb = nullptr; +iotsdk::storage::FlashIAPBlockDevice * OpenIoTSDKConfig::flash_bd = nullptr; + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.h b/src/platform/openiotsdk/OpenIoTSDKConfig.h index 9213dd4aca168e..b50a38ead7bd0a 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.h +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.h @@ -85,6 +85,7 @@ class OpenIoTSDKConfig static CHIP_ERROR ClearConfigValue(Key key); static bool ConfigValueExists(Key key); static CHIP_ERROR FactoryResetConfig(); + static CHIP_ERROR Init(void); // NVS Namespace helper functions. static CHIP_ERROR ConstructCounterKey(Key id, char * buf, size_t bufSize); @@ -93,6 +94,10 @@ class OpenIoTSDKConfig static CHIP_ERROR ClearNamespace(const char * ns); static void RunConfigUnitTest(void); + +private: + static iotsdk::storage::TDBStore * tdb; + static iotsdk::storage::FlashIAPBlockDevice * flash_bd; }; } // namespace Internal From 2f3ac9cf8a1de572ef4bdf20332d6ea6cc040942 Mon Sep 17 00:00:00 2001 From: Hugo L'Hostis Date: Mon, 6 Jun 2022 15:19:54 +0000 Subject: [PATCH 04/13] Fix compilation error This commit fixes the compilation errors from the previous changes on the platform port. system_reset() should be implemented in a future commit for the Open IoT Sdk. Signed-off-by: Hugo L'Hostis --- .../openiotsdk/ConfigurationManagerImpl.cpp | 7 ++-- .../openiotsdk/ConnectivityManagerImpl.cpp | 16 +++++----- .../openiotsdk/ConnectivityManagerImpl.h | 4 +-- .../openiotsdk/NetworkCommissioningDriver.h | 32 ------------------- .../NetworkCommissioningEthernetDriver.cpp | 2 -- src/platform/openiotsdk/OpenIoTSDKConfig.cpp | 11 +++---- src/platform/openiotsdk/OpenIoTSDKConfig.h | 3 ++ 7 files changed, 20 insertions(+), 55 deletions(-) diff --git a/src/platform/openiotsdk/ConfigurationManagerImpl.cpp b/src/platform/openiotsdk/ConfigurationManagerImpl.cpp index b61f40d76d6801..47d117af796f74 100644 --- a/src/platform/openiotsdk/ConfigurationManagerImpl.cpp +++ b/src/platform/openiotsdk/ConfigurationManagerImpl.cpp @@ -34,10 +34,6 @@ #include -// mbed-os headers -#include "platform/mbed_power_mgmt.h" -#include - namespace chip { namespace DeviceLayer { @@ -162,7 +158,8 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) // Restart the system. ChipLogProgress(DeviceLayer, "System restarting"); - system_reset(); + // TODO: implement system_reset() + // system_reset(); } } // namespace DeviceLayer diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp index 69446e74bab629..9f0e23d1108172 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp @@ -60,14 +60,14 @@ void ConnectivityManagerImpl::AddTask(AsyncWorkFunct workFunct, intptr_t arg) PlatformMgr().ScheduleWork(workFunct, arg); } -void ConnectivityManagerImpl::AddQueueEvent(void (*func)(nsapi_event_t, intptr_t), nsapi_event_t event, intptr_t data) -{ - PlatformMgrImpl().mQueue.call([func, event, data] { - PlatformMgr().LockChipStack(); - (*func)(event, data); - PlatformMgr().UnlockChipStack(); - }); -} +// void ConnectivityManagerImpl::AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)) +// { +// PlatformMgrImpl().mQueue.call([func, event, data] { +// PlatformMgr().LockChipStack(); +// (*func)(event, data); +// PlatformMgr().UnlockChipStack(); +// }); +// } } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.h b/src/platform/openiotsdk/ConnectivityManagerImpl.h index 394dee5c4acfbc..40e638a5886b3e 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.h +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.h @@ -29,8 +29,8 @@ #include #include #include +#include #include -#include namespace chip { namespace DeviceLayer { @@ -61,7 +61,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public: CHIP_ERROR PostEvent(const ChipDeviceEvent * event, bool die); void AddTask(AsyncWorkFunct workFunct, intptr_t arg); - void AddQueueEvent(void (*func)(nsapi_event_t, intptr_t), nsapi_event_t event, intptr_t data); + // void AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)); }; /** diff --git a/src/platform/openiotsdk/NetworkCommissioningDriver.h b/src/platform/openiotsdk/NetworkCommissioningDriver.h index ee5867c57d8cef..524f575e9e7bd8 100644 --- a/src/platform/openiotsdk/NetworkCommissioningDriver.h +++ b/src/platform/openiotsdk/NetworkCommissioningDriver.h @@ -62,38 +62,6 @@ class OpenIoTSDKEthernetDriver final : public EthernetDriver NetworkIterator * GetNetworks() override; }; -class OpenIoTSDKEthernetDriver final : public EthernetDriver -{ -public: - struct EthernetNetworkIterator final : public NetworkIterator - { - EthernetNetworkIterator() = default; - size_t Count() override { return interfaceNameLen > 0 ? 1 : 0; } - bool Next(Network & item) override - { - if (exhausted) - { - return false; - } - exhausted = true; - memcpy(item.networkID, interfaceName, interfaceNameLen); - item.networkIDLen = interfaceNameLen; - item.connected = true; - return true; - } - void Release() override { delete this; } - ~EthernetNetworkIterator() override = default; - - // Public, but cannot be accessed via NetworkIterator interface. - uint8_t interfaceName[kMaxNetworkIDLen]; - uint8_t interfaceNameLen = 0; - bool exhausted = false; - }; - - uint8_t GetMaxNetworks() override { return 1; }; - NetworkIterator * GetNetworks() override; -}; - } // namespace NetworkCommissioning } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp index 4c54df72eb767c..bbc38c1ccbee0b 100644 --- a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp +++ b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp @@ -25,8 +25,6 @@ #include #include -#include - using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceLayer::Internal; diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp index be8d470af744bb..41047bba91b42e 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.cpp +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.cpp @@ -23,7 +23,6 @@ #include -#include #include #include #include @@ -193,7 +192,7 @@ CHIP_ERROR OpenIoTSDKConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t b return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; } - tdb->info_t info; + iotsdk::storage::KVStore::info_t info; iotsdk::storage::kv_status err = tdb->get_info(key, &info); if (err != iotsdk::storage::kv_status::OK) @@ -301,7 +300,7 @@ bool OpenIoTSDKConfig::ConfigValueExists(Key key) return false; } - kv_info_t info; + iotsdk::storage::KVStore::info_t info; iotsdk::storage::kv_status err = tdb->get_info(key, &info); return err == iotsdk::storage::kv_status::OK ? true : false; } @@ -366,14 +365,14 @@ CHIP_ERROR OpenIoTSDKConfig::ClearNamespace(const char * ns) return CHIP_ERROR_INTERNAL; } - iotsdk::storage::iterator_t it; + iotsdk::storage::KVStore::iterator_t it; char key[50]; iotsdk::storage::kv_status err = tdb->iterator_open(&it, ns); - if (err) + if (err != iotsdk::storage::kv_status::OK) { return CHIP_ERROR_INTERNAL; } - while (tdb->iterator_next(it, key, sizeof(key)) != MBED_ERROR_ITEM_NOT_FOUND) + while (tdb->iterator_next(it, key, sizeof(key)) != iotsdk::storage::kv_status::ITEM_NOT_FOUND) { tdb->remove(key); memset(key, 0, sizeof(key)); diff --git a/src/platform/openiotsdk/OpenIoTSDKConfig.h b/src/platform/openiotsdk/OpenIoTSDKConfig.h index b50a38ead7bd0a..eafa07e7481b8c 100644 --- a/src/platform/openiotsdk/OpenIoTSDKConfig.h +++ b/src/platform/openiotsdk/OpenIoTSDKConfig.h @@ -25,6 +25,9 @@ #include #include +#include "flash_cs300.h" +#include "iotsdk/FlashIAPBlockDevice.h" +#include "iotsdk/TDBStore.h" #include namespace chip { From be156c0faf9cbdafd4ba83faf4f8da0b910df29e Mon Sep 17 00:00:00 2001 From: Hugo L'Hostis Date: Tue, 31 May 2022 10:34:28 +0000 Subject: [PATCH 05/13] Time functions implementations for Open IoT SDK Signed-off-by: Hugo L'Hostis --- src/platform/openiotsdk/SystemTimeSupport.cpp | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/src/platform/openiotsdk/SystemTimeSupport.cpp b/src/platform/openiotsdk/SystemTimeSupport.cpp index 599866c623082c..53f2c4164162d2 100644 --- a/src/platform/openiotsdk/SystemTimeSupport.cpp +++ b/src/platform/openiotsdk/SystemTimeSupport.cpp @@ -20,87 +20,95 @@ * Provides an implementation of the system time support * for Open IOT SDK platform. */ +/* this file behaves like a config.h, comes first */ #include #include #include #include +#include + +#include "cmsis_os2.h" namespace chip { namespace System { namespace Clock { -namespace Internal { -ClockImpl gClockImpl; -} // namespace Internal +uint64_t TICKS_PER_SECOND = osKernelGetTickFreq(); + +static uint32_t tick_h = 0U; +static uint32_t tick_l = 0U; -static uint64_t get_clock_monotonic() +// GetTick() needs to be called at least twice per tick overflow to work properly. +uint64_t GetTick(void); + +uint64_t GetTick(void) { - // TODO implement - return 0; + uint32_t tick; + tick = osKernelGetTickCount(); + if (tick < tick_l) + { + tick_h++; + } + tick_l = tick; + return (((uint64_t) tick_h << 32) | tick_l); } -// Platform-specific function for getting monotonic system time in microseconds. -// Returns elapsed time in microseconds since an arbitrary, platform-defined epoch. -Microseconds64 ClockImpl::GetMonotonicMicroseconds64() +void SetTick(uint64_t newTick); + +void SetTick(uint64_t newTick) { - return Microseconds64(get_clock_monotonic()); + tick_h = (uint32_t)((newTick & 0xFFFFFFFF00000000LL) >> 32); + tick_l = (uint32_t)(newTick & 0xFFFFFFFFLL); } -// Platform-specific function for getting monotonic system time in milliseconds. -// Return elapsed time in milliseconds since an arbitrary, platform-defined epoch. -Milliseconds64 ClockImpl::GetMonotonicMilliseconds64() +Clock::Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void) { - return std::chrono::duration_cast(GetMonotonicMicroseconds64()); + return Clock::Microseconds64((GetTick() / TICKS_PER_SECOND) * 1000000); } -CHIP_ERROR ClockImpl::GetClock_RealTime(Clock::Microseconds64 & aCurTime) +Clock::Milliseconds64 ClockImpl::GetMonotonicMilliseconds64(void) { - // struct timeval tv; + return Clock::Milliseconds64((GetTick() / TICKS_PER_SECOND) * 1000); +} + +uint64_t GetClock_Monotonic(void) +{ + return (GetTick() / TICKS_PER_SECOND) * 1000000; +} - // TODO get real time in us +uint64_t GetClock_MonotonicMS(void) +{ + return (GetTick() / TICKS_PER_SECOND) * 1000; +} - static_assert(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD >= 0, "We might be letting through negative tv_sec values!"); - // aCurTime = Clock::Microseconds64((static_cast(tv.tv_sec) * UINT64_C(1000000)) + static_cast(tv.tv_usec)); +CHIP_ERROR ClockImpl::GetClock_RealTime(Clock::Microseconds64 & aCurTime) +{ + aCurTime = Clock::Microseconds64(GetClock_Monotonic()); return CHIP_NO_ERROR; } CHIP_ERROR ClockImpl::GetClock_RealTimeMS(Clock::Milliseconds64 & aCurTime) { - // struct timeval tv; - - // TODO get real time in ms - - static_assert(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD >= 0, "We might be letting through negative tv_sec values!"); - // aCurTime = - // Clock::Milliseconds64((static_cast(tv.tv_sec) * UINT64_C(1000)) + (static_cast(tv.tv_usec) / 1000)); + aCurTime = Clock::Milliseconds64(GetClock_MonotonicMS()); return CHIP_NO_ERROR; } CHIP_ERROR ClockImpl::SetClock_RealTime(Clock::Microseconds64 aNewCurTime) { - struct timeval tv; - tv.tv_sec = static_cast(aNewCurTime.count() / UINT64_C(1000000)); - tv.tv_usec = static_cast(aNewCurTime.count() % UINT64_C(1000000)); - - // TODO set real time - - const time_t timep = tv.tv_sec; - struct tm calendar; - localtime_r(&timep, &calendar); - ChipLogProgress(DeviceLayer, "Real time clock set to %lld (%04d/%02d/%02d %02d:%02d:%02d UTC)", tv.tv_sec, calendar.tm_year, - calendar.tm_mon, calendar.tm_mday, calendar.tm_hour, calendar.tm_min, calendar.tm_sec); - + uint64_t newTickCount; + newTickCount = static_cast(aNewCurTime.count() / UINT64_C(1000000)) * TICKS_PER_SECOND; + SetTick(newTickCount); return CHIP_NO_ERROR; } CHIP_ERROR InitClock_RealTime() { - // Use CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD as the initial value of RealTime. - // Then the RealTime obtained from GetClock_RealTime will be always valid. Clock::Microseconds64 curTime = Clock::Microseconds64((static_cast(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD) * UINT64_C(1000000))); + // Use CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD as the initial value of RealTime. + // Then the RealTime obtained from GetClock_RealTime will be always valid. return System::SystemClock().SetClock_RealTime(curTime); } From 321797061dbe88720a522feeb669ac1608d2af42 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Tue, 7 Jun 2022 16:42:20 +0100 Subject: [PATCH 06/13] fill in interface name --- .../openiotsdk/ConnectivityManagerImpl.cpp | 17 +++++++++-------- .../openiotsdk/ConnectivityManagerImpl.h | 2 +- .../NetworkCommissioningEthernetDriver.cpp | 11 ++++++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp index 9f0e23d1108172..a924dcda6e5a5d 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp @@ -60,14 +60,15 @@ void ConnectivityManagerImpl::AddTask(AsyncWorkFunct workFunct, intptr_t arg) PlatformMgr().ScheduleWork(workFunct, arg); } -// void ConnectivityManagerImpl::AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)) -// { -// PlatformMgrImpl().mQueue.call([func, event, data] { -// PlatformMgr().LockChipStack(); -// (*func)(event, data); -// PlatformMgr().UnlockChipStack(); -// }); -// } +void ConnectivityManagerImpl::AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)) +{ + // TODO: + // PlatformMgrImpl().mQueue.call([func, event, data] { + // PlatformMgr().LockChipStack(); + // (*func)(event, data); + // PlatformMgr().UnlockChipStack(); + // }); +} } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.h b/src/platform/openiotsdk/ConnectivityManagerImpl.h index 40e638a5886b3e..6def5b8fc2d408 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.h +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.h @@ -61,7 +61,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public: CHIP_ERROR PostEvent(const ChipDeviceEvent * event, bool die); void AddTask(AsyncWorkFunct workFunct, intptr_t arg); - // void AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)); + void AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)); }; /** diff --git a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp index bbc38c1ccbee0b..f38ee82bd7c52f 100644 --- a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp +++ b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp @@ -22,6 +22,7 @@ * for Open IOT SDK platform. */ +#include #include #include @@ -36,9 +37,13 @@ namespace NetworkCommissioning { NetworkIterator * OpenIoTSDKEthernetDriver::GetNetworks() { auto ret = new EthernetNetworkIterator(); - // TODO fill in - // memcpy(ret->interfaceName, src, len); - // ret->interfaceNameLen = len; + + ifname[NETIF_NAMESIZE]; + ifname = netif_index_to_name(0, ifname); + + ret->interfaceNameLen = strlen(ifname); + memcpy(ret->interfaceName, ifname, ret->interfaceNameLen); + return ret; } From 993148bd0a5f83122f54fb96b4156180a865dc1b Mon Sep 17 00:00:00 2001 From: Hugo L'Hostis Date: Wed, 8 Jun 2022 10:12:39 +0000 Subject: [PATCH 07/13] fix time support SetTick and GetTick Signed-off-by: Hugo L'Hostis --- src/platform/openiotsdk/SystemTimeSupport.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/platform/openiotsdk/SystemTimeSupport.cpp b/src/platform/openiotsdk/SystemTimeSupport.cpp index 53f2c4164162d2..5fce2c74cfbd00 100644 --- a/src/platform/openiotsdk/SystemTimeSupport.cpp +++ b/src/platform/openiotsdk/SystemTimeSupport.cpp @@ -37,12 +37,11 @@ namespace Clock { uint64_t TICKS_PER_SECOND = osKernelGetTickFreq(); -static uint32_t tick_h = 0U; -static uint32_t tick_l = 0U; +static uint32_t tick_h = 0U; +static uint32_t tick_l = 0U; +static uint64_t tick_offset = 0U; // GetTick() needs to be called at least twice per tick overflow to work properly. -uint64_t GetTick(void); - uint64_t GetTick(void) { uint32_t tick; @@ -52,15 +51,12 @@ uint64_t GetTick(void) tick_h++; } tick_l = tick; - return (((uint64_t) tick_h << 32) | tick_l); + return (((uint64_t) tick_h << 32) | tick_l) + tick_offset; } -void SetTick(uint64_t newTick); - void SetTick(uint64_t newTick) { - tick_h = (uint32_t)((newTick & 0xFFFFFFFF00000000LL) >> 32); - tick_l = (uint32_t)(newTick & 0xFFFFFFFFLL); + tick_offset = newTick - GetTick(void); } Clock::Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void) From 51b2da58492e61d3f3ad414e39e299cc9d8c64f4 Mon Sep 17 00:00:00 2001 From: Hugo L'Hostis Date: Wed, 8 Jun 2022 08:35:48 +0000 Subject: [PATCH 08/13] WIP : Platform conversion Signed-off-by: Hugo L'Hostis --- .../openiotsdk/PlatformManagerImpl.cpp | 51 ++++++++++++++++--- src/platform/openiotsdk/PlatformManagerImpl.h | 5 ++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/platform/openiotsdk/PlatformManagerImpl.cpp b/src/platform/openiotsdk/PlatformManagerImpl.cpp index 30bab87126fa60..fa03ca00f79e9f 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.cpp +++ b/src/platform/openiotsdk/PlatformManagerImpl.cpp @@ -38,11 +38,21 @@ using namespace ::chip::System; namespace chip { namespace DeviceLayer { +void ChipTask(void *); + CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { // Members are initialized by the stack // ToDo initalize platform-specific members of stack + // reinitialize a new thread if it was terminated earlier + const osThreadAttr_t thread_attr = { .name = CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, + .stack_size = CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE, + .priority = osPriorityNormal }; + mChipTaskId = osThreadNew(ChipTask, NULL, &thread_attr); + + // Reinitialize the Mutexes + mChipStackMutex = 0; SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); @@ -50,6 +60,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) auto err = System::Clock::InitClock_RealTime(); SuccessOrExit(err); + mShouldRunEventLoop = false; + // Call up to the base class _InitChipStack() to perform the bulk of the initialization. err = GenericPlatformManagerImpl::_InitChipStack(); SuccessOrExit(err); @@ -60,24 +72,29 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) void PlatformManagerImpl::_LockChipStack() { - // ToDo + osMutexAcquire(mChipStackMutex, osWaitForever); } bool PlatformManagerImpl::_TryLockChipStack() { - // ToDo - return true; + if (osMutexAcquire(mChipStackMutex, 0U) == osOK) + { + return true; + } + else + { + return false; + } } void PlatformManagerImpl::_UnlockChipStack() { - // ToDo + osMutexRelease(mChipStackMutex); } CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * eventPtr) { - // ToDo - + // todo return CHIP_NO_ERROR; } @@ -88,7 +105,19 @@ void PlatformManagerImpl::ProcessDeviceEvents() void PlatformManagerImpl::_RunEventLoop() { - // ToDo + + LockChipStack(); + + if (mShouldRunEventLoop) + { + ChipLogError(DeviceLayer, "Error trying to run the event loop while it is already running"); + return; + } + mShouldRunEventLoop = true; + + // run event loop + + UnlockChipStack(); } CHIP_ERROR PlatformManagerImpl::_StartEventLoopTask() @@ -100,7 +129,7 @@ CHIP_ERROR PlatformManagerImpl::_StartEventLoopTask() CHIP_ERROR PlatformManagerImpl::_StopEventLoopTask() { - // ToDo + mShouldRunEventLoop = false; return CHIP_NO_ERROR; } @@ -122,6 +151,12 @@ CHIP_ERROR PlatformManagerImpl::_Shutdown() // ===== Members for internal use by the following friends. +void ChipTask(void *) +{ + ChipLogDetail(DeviceLayer, "CHIP task running"); + RunEventLoop(); +} + PlatformManagerImpl PlatformManagerImpl::sInstance; } // namespace DeviceLayer diff --git a/src/platform/openiotsdk/PlatformManagerImpl.h b/src/platform/openiotsdk/PlatformManagerImpl.h index 24822759e41cf1..c9b3406019c898 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.h +++ b/src/platform/openiotsdk/PlatformManagerImpl.h @@ -24,9 +24,11 @@ #pragma once +#include "cmsis_os2.h" #include #include #include +#include namespace chip { namespace DeviceLayer { @@ -75,6 +77,9 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener using PlatformManager::PostEvent; using PlatformManager::PostEventOrDie; static PlatformManagerImpl sInstance; + bool mShouldRunEventLoop; + osThreadId_t mChipTaskId = 0; + osMutexId_t mChipStackMutex; }; /** From a02587ac65dfe1f2aa3bfa5c43c6b447d21d383f Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 8 Jun 2022 14:47:52 +0100 Subject: [PATCH 09/13] add main loop for platform manager --- .../openiotsdk/PlatformManagerImpl.cpp | 115 ++++++++++++++++-- src/platform/openiotsdk/PlatformManagerImpl.h | 20 ++- 2 files changed, 122 insertions(+), 13 deletions(-) diff --git a/src/platform/openiotsdk/PlatformManagerImpl.cpp b/src/platform/openiotsdk/PlatformManagerImpl.cpp index fa03ca00f79e9f..ebb2d99da237db 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.cpp +++ b/src/platform/openiotsdk/PlatformManagerImpl.cpp @@ -52,7 +52,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) mChipTaskId = osThreadNew(ChipTask, NULL, &thread_attr); // Reinitialize the Mutexes - mChipStackMutex = 0; + mChipStackMutex = osMutexNew(nullptr); + SuccessOrExit(!mChipStackMutex); + mEventTaskMutex = osMutexNew(nullptr); + SuccessOrExit(!mEventTaskMutex); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); @@ -66,6 +69,9 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = GenericPlatformManagerImpl::_InitChipStack(); SuccessOrExit(err); + mPlatformFlags = osEventFlagsNew(nullptr); + SuccessOrExit(!mPlatformFlags); + exit: return err; } @@ -105,31 +111,111 @@ void PlatformManagerImpl::ProcessDeviceEvents() void PlatformManagerImpl::_RunEventLoop() { + // this mutex only needed to guard against multiple launches + { + osMutexAcquire(mEventTaskMutex, osWaitForever); + + if (FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags)) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_BUSY; + } + + osEventFlagsSet(mPlatformFlags, FLAG_EVENT_TASK_RUNNING); - LockChipStack(); + osMutexRelease(mEventTaskMutex); + } + + _RunEventLoopInternal(); +} - if (mShouldRunEventLoop) +void PlatformManagerImpl::_RunEventLoopInternal() +{ + while ((FLAG_STOP_EVENT_TASK & osEventFlagsGet(mPlatformFlags) == 0) { - ChipLogError(DeviceLayer, "Error trying to run the event loop while it is already running"); - return; + ProcessDeviceEvents(); } - mShouldRunEventLoop = true; - // run event loop + osEventFlagsClear(mPlatformFlags, FLAG_STOP_EVENT_TASK); + osEventFlagsSet(mPlatformFlags, FLAG_EVENT_TASK_STOPPED); +} + +void PlatformManagerImpl::ResetEventTask() +{ + osMutexAcquire(mEventTaskMutex, osWaitForever); + mEventTask = nullptr; + osMutexRelease(mEventTaskMutex); +}; - UnlockChipStack(); +void PlatformManagerImpl::RunEventLoopTask(void * arg) +{ + (void) arg; + PlatformManager().RunEventLoop(); + PlatformManagerImpl().ResetEventTask(); + osThreadTerminate(nullptr); } CHIP_ERROR PlatformManagerImpl::_StartEventLoopTask() { - // ToDo + // this mutex only needed to guard against multiple launches + { + osMutexAcquire(mEventTaskMutex, osWaitForever); + + if (FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags)) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_BUSY; + } + + if (mEventTask) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_BUSY; + } + else + { + mEventTask = osThreadNew(RunEventLoopTask, nullptr, nullptr); + + if (!mEventTask) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_INTERNAL; + } + } + + osEventFlagsSet(mPlatformFlags, FLAG_EVENT_TASK_RUNNING); + + osMutexRelease(mEventTaskMutex); + } return CHIP_NO_ERROR; } CHIP_ERROR PlatformManagerImpl::_StopEventLoopTask() { - mShouldRunEventLoop = false; + // this mutex only needed to guard against multiple calls to stop + { + osMutexAcquire(mEventTaskMutex, osWaitForever); + + if (FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags) == 0) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_INCORRECT_STATE; + } + + if (FLAG_STOP_EVENT_TASK & osEventFlagsGet(mPlatformFlags)) + { + osMutexRelease(mEventTaskMutex); + return CHIP_ERROR_INCORRECT_STATE; + } + + osEventFlagsSet(mPlatformFlags, FLAG_STOP_EVENT_TASK); + + osMutexRelease(mEventTaskMutex); + } + + osEventFlagsWait(mPlatformFlags, FLAG_EVENT_TASK_STOPPED, 0, osWaitForever); + osEventFlagsClear(mPlatformFlags, FLAG_EVENT_TASK_RUNNING); return CHIP_NO_ERROR; } @@ -146,6 +232,15 @@ CHIP_ERROR PlatformManagerImpl::_Shutdown() // Call up to the base class _Shutdown() to perform the actual stack de-initialization // and clean-up // + + (void) _StopEventLoopTask(); + osMutexDelete(mChipStackMutex); + osMutexDelete(mPlatformFlags); + osEventFlagsDelete(mEventTaskMutex); + mChipStackMutex = nullptr; + mPlatformFlags = nullptr; + mEventTaskMutex = nullptr; + return GenericPlatformManagerImpl::_Shutdown(); } diff --git a/src/platform/openiotsdk/PlatformManagerImpl.h b/src/platform/openiotsdk/PlatformManagerImpl.h index c9b3406019c898..49a96e50b46ff7 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.h +++ b/src/platform/openiotsdk/PlatformManagerImpl.h @@ -53,21 +53,32 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener /* none so far */ private: + constexpr uint32_t FLAG_EVENT_TASK_STOPPED = 0x1; + constexpr uint32_t FLAG_STOP_EVENT_TASK = 0x2; + constexpr uint32_t FLAG_EVENT_TASK_RUNNING = 0x4; + // ===== Methods that implement the PlatformManager abstract interface. CHIP_ERROR _InitChipStack(void); void _LockChipStack(); bool _TryLockChipStack(); void _UnlockChipStack(); + CHIP_ERROR _PostEvent(const ChipDeviceEvent * event); + void _RunEventLoop(); CHIP_ERROR _StartEventLoopTask(); CHIP_ERROR _StopEventLoopTask(); + CHIP_ERROR _StartChipTimer(System::Clock::Timeout duration); CHIP_ERROR _Shutdown(); void ProcessDeviceEvents(); + static void RunEventLoopTask(void * arg); + void ResetEventTask(); + void _RunEventLoopInternal(); + // ===== Members for internal use by the following friends. friend PlatformManager & PlatformMgr(void); @@ -77,9 +88,12 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener using PlatformManager::PostEvent; using PlatformManager::PostEventOrDie; static PlatformManagerImpl sInstance; - bool mShouldRunEventLoop; - osThreadId_t mChipTaskId = 0; - osMutexId_t mChipStackMutex; + + osEventFlagsId_t mPlatformFlags = nullptr; + osThreadId_t mEventTask = nullptr; + osThreadId_t mChipTaskId = nullptr; + osMutexId_t mChipStackMutex = nullptr; + osMutexId_t mEventTaskMutex = nullptr; }; /** From 508db989c17d3510fb379971b1a5c1c283d2d1db Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 8 Jun 2022 14:50:08 +0100 Subject: [PATCH 10/13] fix --- src/platform/openiotsdk/PlatformManagerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/openiotsdk/PlatformManagerImpl.cpp b/src/platform/openiotsdk/PlatformManagerImpl.cpp index ebb2d99da237db..3335fbf49548ef 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.cpp +++ b/src/platform/openiotsdk/PlatformManagerImpl.cpp @@ -150,7 +150,7 @@ void PlatformManagerImpl::ResetEventTask() void PlatformManagerImpl::RunEventLoopTask(void * arg) { (void) arg; - PlatformManager().RunEventLoop(); + PlatformManager()._RunEventLoopInternal(); PlatformManagerImpl().ResetEventTask(); osThreadTerminate(nullptr); } From 817aece824cf730ffa277067e7afc37fed6c7c9d Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 8 Jun 2022 15:51:47 +0100 Subject: [PATCH 11/13] missing static --- src/platform/openiotsdk/PlatformManagerImpl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/openiotsdk/PlatformManagerImpl.h b/src/platform/openiotsdk/PlatformManagerImpl.h index 49a96e50b46ff7..3a2dd08bb39e4d 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.h +++ b/src/platform/openiotsdk/PlatformManagerImpl.h @@ -53,9 +53,9 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener /* none so far */ private: - constexpr uint32_t FLAG_EVENT_TASK_STOPPED = 0x1; - constexpr uint32_t FLAG_STOP_EVENT_TASK = 0x2; - constexpr uint32_t FLAG_EVENT_TASK_RUNNING = 0x4; + static constexpr uint32_t FLAG_EVENT_TASK_STOPPED = 0x1; + static constexpr uint32_t FLAG_STOP_EVENT_TASK = 0x2; + static constexpr uint32_t FLAG_EVENT_TASK_RUNNING = 0x4; // ===== Methods that implement the PlatformManager abstract interface. From 55415d5ba2d2e3826407e0b714f24fee2a8c426a Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 8 Jun 2022 15:59:15 +0100 Subject: [PATCH 12/13] remove unused code --- src/platform/openiotsdk/ConnectivityManagerImpl.cpp | 10 ---------- src/platform/openiotsdk/ConnectivityManagerImpl.h | 1 - 2 files changed, 11 deletions(-) diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp index a924dcda6e5a5d..0e2585243c76ce 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.cpp +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.cpp @@ -60,15 +60,5 @@ void ConnectivityManagerImpl::AddTask(AsyncWorkFunct workFunct, intptr_t arg) PlatformMgr().ScheduleWork(workFunct, arg); } -void ConnectivityManagerImpl::AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)) -{ - // TODO: - // PlatformMgrImpl().mQueue.call([func, event, data] { - // PlatformMgr().LockChipStack(); - // (*func)(event, data); - // PlatformMgr().UnlockChipStack(); - // }); -} - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/openiotsdk/ConnectivityManagerImpl.h b/src/platform/openiotsdk/ConnectivityManagerImpl.h index 6def5b8fc2d408..b303baaa6e482f 100644 --- a/src/platform/openiotsdk/ConnectivityManagerImpl.h +++ b/src/platform/openiotsdk/ConnectivityManagerImpl.h @@ -61,7 +61,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public: CHIP_ERROR PostEvent(const ChipDeviceEvent * event, bool die); void AddTask(AsyncWorkFunct workFunct, intptr_t arg); - void AddQueueEvent(nsapi_event_t event, intptr_t data, void (*func)(nsapi_event_t, intptr_t)); }; /** From 4ecc918234cf866b12bd054edb0b058c7ee938f2 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 8 Jun 2022 16:16:24 +0100 Subject: [PATCH 13/13] fixes --- src/platform/openiotsdk/Logging.cpp | 2 - .../openiotsdk/PlatformManagerImpl.cpp | 37 ++++++++++++------- src/platform/openiotsdk/PlatformManagerImpl.h | 2 +- src/platform/openiotsdk/SystemTimeSupport.cpp | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/platform/openiotsdk/Logging.cpp b/src/platform/openiotsdk/Logging.cpp index 7dc4a386bfa7c1..b774330582be94 100644 --- a/src/platform/openiotsdk/Logging.cpp +++ b/src/platform/openiotsdk/Logging.cpp @@ -33,8 +33,6 @@ #define DEFAULT_TRACE_FILTER_LENGTH 24 -static const char * TRACE_GROUP = "CHIP"; - namespace chip { namespace DeviceLayer { diff --git a/src/platform/openiotsdk/PlatformManagerImpl.cpp b/src/platform/openiotsdk/PlatformManagerImpl.cpp index 3335fbf49548ef..0c96875d205d0a 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.cpp +++ b/src/platform/openiotsdk/PlatformManagerImpl.cpp @@ -42,6 +42,7 @@ void ChipTask(void *); CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { + CHIP_ERROR err; // Members are initialized by the stack // ToDo initalize platform-specific members of stack @@ -53,25 +54,32 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Reinitialize the Mutexes mChipStackMutex = osMutexNew(nullptr); - SuccessOrExit(!mChipStackMutex); mEventTaskMutex = osMutexNew(nullptr); - SuccessOrExit(!mEventTaskMutex); + mPlatformFlags = osEventFlagsNew(nullptr); + + if (!mChipTaskId || !mChipStackMutex || !mEventTaskMutex || !mPlatformFlags) + { + osMutexDelete(mChipStackMutex); + osMutexDelete(mEventTaskMutex); + osEventFlagsDelete(mPlatformFlags); + osThreadTerminate(mChipTaskId); + mChipTaskId = mChipStackMutex = mEventTaskMutex = mPlatformFlags = nullptr; + + err = CHIP_ERROR_INTERNAL; + } + + SuccessOrExit(err); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); - auto err = System::Clock::InitClock_RealTime(); + err = System::Clock::InitClock_RealTime(); SuccessOrExit(err); - mShouldRunEventLoop = false; - // Call up to the base class _InitChipStack() to perform the bulk of the initialization. err = GenericPlatformManagerImpl::_InitChipStack(); SuccessOrExit(err); - mPlatformFlags = osEventFlagsNew(nullptr); - SuccessOrExit(!mPlatformFlags); - exit: return err; } @@ -117,8 +125,8 @@ void PlatformManagerImpl::_RunEventLoop() if (FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags)) { + // already running osMutexRelease(mEventTaskMutex); - return CHIP_ERROR_BUSY; } osEventFlagsSet(mPlatformFlags, FLAG_EVENT_TASK_RUNNING); @@ -126,12 +134,12 @@ void PlatformManagerImpl::_RunEventLoop() osMutexRelease(mEventTaskMutex); } - _RunEventLoopInternal(); + RunEventLoopInternal(); } -void PlatformManagerImpl::_RunEventLoopInternal() +void PlatformManagerImpl::RunEventLoopInternal() { - while ((FLAG_STOP_EVENT_TASK & osEventFlagsGet(mPlatformFlags) == 0) + while ((FLAG_STOP_EVENT_TASK & osEventFlagsGet(mPlatformFlags)) == 0) { ProcessDeviceEvents(); } @@ -150,7 +158,7 @@ void PlatformManagerImpl::ResetEventTask() void PlatformManagerImpl::RunEventLoopTask(void * arg) { (void) arg; - PlatformManager()._RunEventLoopInternal(); + PlatformManagerImpl().RunEventLoopInternal(); PlatformManagerImpl().ResetEventTask(); osThreadTerminate(nullptr); } @@ -195,9 +203,10 @@ CHIP_ERROR PlatformManagerImpl::_StopEventLoopTask() { // this mutex only needed to guard against multiple calls to stop { + osMutexAcquire(mEventTaskMutex, osWaitForever); - if (FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags) == 0) + if ((FLAG_EVENT_TASK_RUNNING & osEventFlagsGet(mPlatformFlags)) == 0) { osMutexRelease(mEventTaskMutex); return CHIP_ERROR_INCORRECT_STATE; diff --git a/src/platform/openiotsdk/PlatformManagerImpl.h b/src/platform/openiotsdk/PlatformManagerImpl.h index 3a2dd08bb39e4d..2aa2e58f362ac3 100644 --- a/src/platform/openiotsdk/PlatformManagerImpl.h +++ b/src/platform/openiotsdk/PlatformManagerImpl.h @@ -77,7 +77,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener static void RunEventLoopTask(void * arg); void ResetEventTask(); - void _RunEventLoopInternal(); + void RunEventLoopInternal(); // ===== Members for internal use by the following friends. diff --git a/src/platform/openiotsdk/SystemTimeSupport.cpp b/src/platform/openiotsdk/SystemTimeSupport.cpp index 5fce2c74cfbd00..cd96c90cf32b86 100644 --- a/src/platform/openiotsdk/SystemTimeSupport.cpp +++ b/src/platform/openiotsdk/SystemTimeSupport.cpp @@ -56,7 +56,7 @@ uint64_t GetTick(void) void SetTick(uint64_t newTick) { - tick_offset = newTick - GetTick(void); + tick_offset = newTick - GetTick(); } Clock::Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void)