diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 3fa6e2a2fb793c..b6ad67a64944fd 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -258,7 +258,6 @@ config("strict_warnings") { # to be more fine-grained than current_os, but it's not clear that # we can access that here. if (current_os != "freertos" && current_os != "mbed" && - current_os != "zephyr" && # cmsis-rtos is OpenIOT current_os != "cmsis-rtos" && # cyw30739 is one of the Infineon builds diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp index 61c4d7a7227337..b1d0012761092c 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.ipp @@ -122,7 +122,7 @@ CHIP_ERROR GenericPlatformManagerImpl_Zephyr::_StopEventLoopTask(void template void GenericPlatformManagerImpl_Zephyr::_Shutdown(void) { -#if CONFIG_REBOOT +#ifdef CONFIG_REBOOT sys_reboot(SYS_REBOOT_WARM); #else // NB: When this is implemented, |mInitialized| can be removed. diff --git a/src/platform/Zephyr/PlatformManagerImpl.cpp b/src/platform/Zephyr/PlatformManagerImpl.cpp index c900d072778c61..3b97a5c4a346e1 100644 --- a/src/platform/Zephyr/PlatformManagerImpl.cpp +++ b/src/platform/Zephyr/PlatformManagerImpl.cpp @@ -21,9 +21,9 @@ * for Zephyr platforms. */ -#if !CONFIG_NORDIC_SECURITY_BACKEND +#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) #include // nogncheck -#endif // !CONFIG_NORDIC_SECURITY_BACKEND +#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) #include @@ -45,7 +45,7 @@ PlatformManagerImpl PlatformManagerImpl::sInstance{ sChipThreadStack }; static k_timer sOperationalHoursSavingTimer; -#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen) { const struct device * entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); @@ -71,7 +71,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s return ret; } -#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) void PlatformManagerImpl::OperationalHoursSavingTimerEventHandler(k_timer * timer) { @@ -108,20 +108,20 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; -#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Minimum required from source before entropy is released ( with mbedtls_entropy_func() ) (in bytes) const size_t kThreshold = 16; -#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Initialize the configuration system. err = Internal::ZephyrConfig::Init(); SuccessOrExit(err); -#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Add entropy source based on Zephyr entropy driver err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, kThreshold); SuccessOrExit(err); -#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Call _InitChipStack() on the generic implementation base class to finish the initialization process. err = Internal::GenericPlatformManagerImpl_Zephyr::_InitChipStack(); diff --git a/src/platform/Zephyr/ThreadStackManagerImpl.h b/src/platform/Zephyr/ThreadStackManagerImpl.h index 1345a9ba27bc5a..c0c66b492c6b1d 100644 --- a/src/platform/Zephyr/ThreadStackManagerImpl.h +++ b/src/platform/Zephyr/ThreadStackManagerImpl.h @@ -29,9 +29,9 @@ #include #include -#if !CONFIG_SOC_SERIES_RISCV_TELINK_B9X +#if !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X) #include -#endif // !CONFIG_SOC_SERIES_RISCV_TELINK_B9X +#endif // !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X) #include diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index c260dbe4ac4f58..8407b1e6bcd001 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -87,19 +87,27 @@ #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING #endif +#ifdef CONFIG_NET_L2_OPENTHREAD #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD +#else +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0 +#endif +#ifdef CONFIG_WIFI_NRF700X #define CHIP_DEVICE_CONFIG_ENABLE_WIFI CONFIG_WIFI_NRF700X - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #else +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #endif +#ifdef CONFIG_BT #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT +#else +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0 +#endif // ========== Platform-specific Configuration ========= @@ -126,6 +134,8 @@ #if !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) /// Use mallinfo() to obtain the heap usage statistics exposed by SoftwareDiagnostics cluster attributes. #define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 1 +#else +#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 0 #endif // !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) #endif // CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO @@ -217,9 +227,11 @@ #endif // CONFIG_CHIP_ENABLE_DNS_CLIENT #endif // CONFIG_CHIP_ENABLE_DNSSD_SRP -#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT +#if defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED) #define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED -#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT +#else +#define CHIP_DEVICE_CONFIG_THREAD_SSED 0 +#endif // defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED) #ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL #ifdef CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL @@ -246,7 +258,7 @@ #endif // CONFIG_CHIP_EXTENDED_DISCOVERY #ifndef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH -#if CONFIG_CHIP_FACTORY_DATA +#ifdef CONFIG_CHIP_FACTORY_DATA // UID will be copied from the externally programmed factory data, so we don't know the actual length and we need to assume some max // boundary. #define CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH CONFIG_CHIP_FACTORY_DATA_ROTATING_DEVICE_UID_MAX_LEN diff --git a/src/platform/nrfconnect/CHIPPlatformConfig.h b/src/platform/nrfconnect/CHIPPlatformConfig.h index 078ab065c5897c..fc524daacbd859 100644 --- a/src/platform/nrfconnect/CHIPPlatformConfig.h +++ b/src/platform/nrfconnect/CHIPPlatformConfig.h @@ -70,7 +70,7 @@ #define CHIP_CONFIG_MAX_FABRICS 5 #endif -#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION +#ifdef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION // Disable some of the too detailed log modules to save flash #define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0 #define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0 diff --git a/src/platform/nrfconnect/ExternalFlashManager.h b/src/platform/nrfconnect/ExternalFlashManager.h index 2a1b3f7f19ff63..6ecfb5075934b8 100644 --- a/src/platform/nrfconnect/ExternalFlashManager.h +++ b/src/platform/nrfconnect/ExternalFlashManager.h @@ -35,7 +35,7 @@ class ExternalFlashManager virtual void DoAction(Action aAction) { -#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR +#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NORDIC_QSPI_NOR) // utilize the QSPI driver sleep power mode const auto * qspi_dev = DEVICE_DT_GET(DT_INST(0, nordic_qspi_nor)); if (device_is_ready(qspi_dev)) diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp index 45adec502140e5..caa1ad434f9254 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.cpp +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -19,7 +19,7 @@ #include "CHIPDevicePlatformConfig.h" #include -#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE #include #include #endif @@ -101,7 +101,7 @@ CHIP_ERROR FactoryDataProvider::Init() template CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) { -#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE size_t cdLen = 0; if (Internal::ZephyrConfig::ReadConfigValueBin(Internal::ZephyrConfig::kConfigKey_CertificationDeclaration, diff --git a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp index 2e0806d75aa052..357a2aeb8a4f99 100644 --- a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp +++ b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp @@ -25,7 +25,7 @@ #include #include -#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE #include #include #include @@ -40,7 +40,7 @@ namespace chip { namespace { -#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE // Cd globals are needed to be accessed from dfu image writer lambdas uint8_t sCdBuf[chip::Credentials::kMaxCMSSignedCDMessage] = { 0 }; size_t sCdSavedBytes = 0; @@ -89,7 +89,7 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl() ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer))); }; -#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE dfu_image_writer cdWriter; cdWriter.image_id = CONFIG_CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID; cdWriter.open = [](int id, size_t size) { return size <= sizeof(sCdBuf) ? 0 : -EFBIG; }; diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h index 5e248a3bebe229..a22ab4789173db 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.h +++ b/src/platform/nrfconnect/wifi/WiFiManager.h @@ -178,11 +178,6 @@ class WiFiManager static_assert(kConnectionRecoveryMinIntervalMs < kConnectionRecoveryMaxIntervalMs); static_assert(kConnectionRecoveryJitterMs <= kConnectionRecoveryMaxIntervalMs); -#if CHIP_DEVICE_CONFIG_ENABLE_SED - static constexpr uint8_t kDefaultDTIMInterval = 3; - static constexpr uint8_t kBeaconIntervalMs = 100; -#endif - CHIP_ERROR Init(); CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback, bool internalScan = false); diff --git a/src/platform/telink/CHIPDevicePlatformConfig.h b/src/platform/telink/CHIPDevicePlatformConfig.h index a3ce958945c0fe..1849ea0ff57918 100644 --- a/src/platform/telink/CHIPDevicePlatformConfig.h +++ b/src/platform/telink/CHIPDevicePlatformConfig.h @@ -87,10 +87,19 @@ #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING #endif +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD + +#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0 +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 +#else #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 - -#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD +#endif #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT @@ -187,7 +196,7 @@ #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE -#if CONFIG_PM +#ifdef CONFIG_PM #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4864 #else #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192 @@ -237,3 +246,7 @@ #define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL) #endif // CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL #endif // CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL + +#ifndef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE +#define CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE 0 +#endif // CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE diff --git a/src/platform/telink/CHIPPlatformConfig.h b/src/platform/telink/CHIPPlatformConfig.h index d636003733dac3..9e7c9516dd3fe4 100644 --- a/src/platform/telink/CHIPPlatformConfig.h +++ b/src/platform/telink/CHIPPlatformConfig.h @@ -62,7 +62,7 @@ #define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1 #endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS -#if CONFIG_PM +#ifdef CONFIG_PM #ifndef CHIP_CONFIG_ENABLE_SERVER_IM_EVENT #define CHIP_CONFIG_ENABLE_SERVER_IM_EVENT 0 @@ -106,6 +106,10 @@ #define CHIP_CONFIG_MAX_FABRICS 5 #endif +#ifndef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION +#define CONFIG_CHIP_LOG_SIZE_OPTIMIZATION 0 +#endif + #if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION // Disable some of the too detailed log modules to save flash #define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0 diff --git a/src/platform/telink/SystemPlatformConfig.h b/src/platform/telink/SystemPlatformConfig.h index 8c1d5334029583..5a7b56e9afb5fd 100644 --- a/src/platform/telink/SystemPlatformConfig.h +++ b/src/platform/telink/SystemPlatformConfig.h @@ -48,7 +48,7 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1 // Reduce packet buffer pool size (default 15) to reduce ram consumption -#if CONFIG_PM +#ifdef CONFIG_PM #define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 #else #define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h index 420cefef1290f4..15e6abdb5d4e83 100644 --- a/src/system/SystemConfig.h +++ b/src/system/SystemConfig.h @@ -733,7 +733,7 @@ struct LwIPEvent; * Defaults to enabled on Zephyr platforms that do not enable Zephyr POSIX layer. */ #ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && CONFIG_NET_SOCKETS_POSIX_NAMES +#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && defined(CONFIG_NET_SOCKETS_POSIX_NAMES) #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 1 #else #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 0 @@ -765,7 +765,7 @@ struct LwIPEvent; * Defaults to enabled on Zephyr platforms that enable CONFIG_EVENTFD. */ #ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD -#if defined(__ZEPHYR__) && CONFIG_EVENTFD +#if defined(__ZEPHYR__) && defined(CONFIG_EVENTFD) #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 1 #else #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0