diff --git a/src/lib/shell/streamer_esp32.cpp b/src/lib/shell/streamer_esp32.cpp index c92170ec730812..ce711849efaa34 100644 --- a/src/lib/shell/streamer_esp32.cpp +++ b/src/lib/shell/streamer_esp32.cpp @@ -18,6 +18,8 @@ #include #include +#include "sdkconfig.h" + #include "esp_console.h" #include "esp_vfs_dev.h" #include "linenoise/linenoise.h" @@ -25,10 +27,12 @@ #include #include #include -#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM + +#if defined(CONFIG_ESP_CONSOLE_UART_DEFAULT) || defined(CONFIG_ESP_CONSOLE_UART_CUSTOM) #include "driver/uart.h" #endif -#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG + +#ifdef CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG #include "driver/usb_serial_jtag.h" #include "esp_vfs_usb_serial_jtag.h" #endif @@ -55,7 +59,7 @@ int streamer_esp32_init(streamer_t * streamer) fflush(stdout); fsync(fileno(stdout)); setvbuf(stdin, NULL, _IONBF, 0); -#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM +#if defined(CONFIG_ESP_CONSOLE_UART_DEFAULT) || defined(CONFIG_ESP_CONSOLE_UART_CUSTOM) esp_vfs_dev_uart_port_set_rx_line_endings((uart_port_t) CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); esp_vfs_dev_uart_port_set_tx_line_endings((uart_port_t) CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); if (!uart_is_driver_installed((uart_port_t) CONFIG_ESP_CONSOLE_UART_NUM)) @@ -79,7 +83,7 @@ int streamer_esp32_init(streamer_t * streamer) esp_vfs_dev_uart_use_driver(0); #endif // CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM -#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG +#ifdef CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR); esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); @@ -121,10 +125,10 @@ ssize_t streamer_esp32_read(streamer_t * streamer, char * buf, size_t len) ssize_t streamer_esp32_write(streamer_t * streamer, const char * buf, size_t len) { -#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM +#if defined(CONFIG_ESP_CONSOLE_UART_DEFAULT) || defined(CONFIG_ESP_CONSOLE_UART_CUSTOM) return uart_write_bytes((uart_port_t) CONFIG_ESP_CONSOLE_UART_NUM, buf, len); #endif -#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG +#ifdef CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG return usb_serial_jtag_write_bytes(buf, len, 0); #endif } diff --git a/src/messaging/ReliableMessageProtocolConfig.h b/src/messaging/ReliableMessageProtocolConfig.h index 3dce56b9e98f56..beceee6c52de46 100644 --- a/src/messaging/ReliableMessageProtocolConfig.h +++ b/src/messaging/ReliableMessageProtocolConfig.h @@ -30,10 +30,6 @@ #include #include -#if CHIP_SYSTEM_CONFIG_USE_LWIP -#include -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - namespace chip { /** @@ -129,14 +125,14 @@ namespace chip { #ifndef CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE #if CHIP_SYSTEM_CONFIG_USE_LWIP -#if !LWIP_PBUF_FROM_CUSTOM_POOLS && PBUF_POOL_SIZE != 0 +#if !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL && PBUF_POOL_SIZE != 0 // Configure the table size to be less than the number of packet buffers to make sure // that not all buffers are held by the retransmission entries, in which case the device // is unable to receive an ACK and hence becomes unavailable until a message times out. #define CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE std::min(PBUF_POOL_SIZE - 1, CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS) #else #define CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS -#endif // !LWIP_PBUF_FROM_CUSTOM_POOLS && PBUF_POOL_SIZE != 0 +#endif // !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL && PBUF_POOL_SIZE != 0 #else // CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/platform/ESP32/BLEManagerImpl.h b/src/platform/ESP32/BLEManagerImpl.h index 3f466fc24ac97b..5308a377c43e6a 100644 --- a/src/platform/ESP32/BLEManagerImpl.h +++ b/src/platform/ESP32/BLEManagerImpl.h @@ -32,16 +32,17 @@ #include -#if CONFIG_BT_BLUEDROID_ENABLED +#ifdef CONFIG_BT_BLUEDROID_ENABLED #include "esp_bt.h" #include "esp_gap_ble_api.h" -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include "esp_gattc_api.h" #endif #include "esp_gatts_api.h" #include -#elif CONFIG_BT_NIMBLE_ENABLED + +#elif defined(CONFIG_BT_NIMBLE_ENABLED) /* min max macros in NimBLE can cause build issues with generic min max * functions defined in CHIP.*/ @@ -60,17 +61,15 @@ struct ble_gatt_char_context void * arg; }; -#endif - -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER && CONFIG_BT_NIMBLE_ENABLED -#include "nimble/blecent.h" -#endif +#endif // CONFIG_BT_BLUEDROID_ENABLED -#include "ble/Ble.h" -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include -#endif +#ifdef CONFIG_BT_NIMBLE_ENABLED +#include "nimble/blecent.h" +#endif // CONFIG_BT_NIMBLE_ENABLED +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER #define MAX_SCAN_RSP_DATA_LEN 31 @@ -78,7 +77,7 @@ namespace chip { namespace DeviceLayer { namespace Internal { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER enum class BleScanState : uint8_t { kNotScanning, @@ -117,30 +116,30 @@ struct BLEScanConfig void * mAppState = nullptr; }; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER /** * Concrete implementation of the BLEManager singleton object for the ESP32 platform. */ class BLEManagerImpl final : public BLEManager, private Ble::BleLayer, private Ble::BlePlatformDelegate, -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER private Ble::BleApplicationDelegate, private Ble::BleConnectionDelegate, private ChipDeviceScannerDelegate #else private Ble::BleApplicationDelegate -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER { public: uint8_t scanResponseBuffer[MAX_SCAN_RSP_DATA_LEN]; BLEManagerImpl() {} -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER CHIP_ERROR ConfigureBle(uint32_t aAdapterId, bool aIsCentral); -#if CONFIG_BT_BLUEDROID_ENABLED +#ifdef CONFIG_BT_BLUEDROID_ENABLED static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t * param); -#endif -#endif +#endif // CONFIG_BT_BLUEDROID_ENABLED +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER CHIP_ERROR ConfigureScanResponseData(ByteSpan data); void ClearScanResponseData(void); @@ -164,10 +163,10 @@ class BLEManagerImpl final : public BLEManager, CHIP_ERROR _SetDeviceName(const char * deviceName); uint16_t _NumConnections(void); void _OnPlatformEvent(const ChipDeviceEvent * event); -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * event); CHIP_ERROR _SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val); -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER ::chip::Ble::BleLayer * _GetBleLayer(void); // ===== Members that implement virtual methods on BlePlatformDelegate. @@ -191,23 +190,23 @@ class BLEManagerImpl final : public BLEManager, void NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) override; // ===== Members that implement virtual methods on BleConnectionDelegate. -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void NewConnection(chip::Ble::BleLayer * bleLayer, void * appState, const SetupDiscriminator & connDiscriminator) override; void NewConnection(chip::Ble::BleLayer * bleLayer, void * appState, BLE_CONNECTION_OBJECT connObj) override{}; CHIP_ERROR CancelConnection() override; // ===== Members that implement virtual methods on ChipDeviceScannerDelegate -#if CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_BT_NIMBLE_ENABLED virtual void OnDeviceScanned(const struct ble_hs_adv_fields & fields, const ble_addr_t & addr, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override; -#elif CONFIG_BT_BLUEDROID_ENABLED +#elif defined(CONFIG_BT_BLUEDROID_ENABLED) virtual void OnDeviceScanned(esp_ble_addr_type_t & addr_type, esp_bd_addr_t & addr, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override; -#endif +#endif // CONFIG_BT_NIMBLE_ENABLED void OnScanComplete() override; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER // ===== Members for internal use by the following friends. friend BLEManager & BLEMgr(void); @@ -240,12 +239,12 @@ class BLEManagerImpl final : public BLEManager, kMaxDeviceNameLength = 16 }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER BLEAdvConfig mBLEAdvConfig; -#endif -#if CONFIG_BT_NIMBLE_ENABLED +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_BT_NIMBLE_ENABLED uint16_t mSubscribedConIds[kMaxConnections]; -#endif +#endif // CONFIG_BT_NIMBLE_ENABLED struct CHIPoBLEConState { @@ -278,11 +277,11 @@ class BLEManagerImpl final : public BLEManager, CHIPoBLEConState mCons[kMaxConnections]; CHIPoBLEServiceMode mServiceMode; -#if CONFIG_BT_BLUEDROID_ENABLED +#ifdef CONFIG_BT_BLUEDROID_ENABLED esp_gatt_if_t mAppIf; -#elif CONFIG_BT_NIMBLE_ENABLED +#elif defined(CONFIG_BT_NIMBLE_ENABLED) uint16_t mNumGAPCons; -#endif +#endif // CONFIG_BT_BLUEDROID_ENABLED uint16_t mServiceAttrHandle; uint16_t mRXCharAttrHandle; uint16_t mTXCharAttrHandle; @@ -303,7 +302,7 @@ class BLEManagerImpl final : public BLEManager, void CancelBleAdvTimeoutTimer(void); static void BleAdvTimeoutHandler(TimerHandle_t xTimer); -#if CONFIG_BT_BLUEDROID_ENABLED +#ifdef CONFIG_BT_BLUEDROID_ENABLED void HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t * param); void HandleGATTCommEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t * param); void HandleRXCharWrite(esp_ble_gatts_cb_param_t * param); @@ -314,7 +313,7 @@ class BLEManagerImpl final : public BLEManager, void HandleDisconnect(esp_ble_gatts_cb_param_t * param); CHIPoBLEConState * GetConnectionState(uint16_t conId, bool allocate = false); bool ReleaseConnectionState(uint16_t conId); -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER CHIP_ERROR HandleGAPConnect(esp_ble_gattc_cb_param_t p_data); CHIP_ERROR HandleGAPCentralConnect(esp_ble_gattc_cb_param_t p_data); @@ -326,7 +325,7 @@ class BLEManagerImpl final : public BLEManager, static void HandleGATTEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t * param); static void HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t * param); -#elif CONFIG_BT_NIMBLE_ENABLED +#elif defined(CONFIG_BT_NIMBLE_ENABLED) CHIP_ERROR DeinitBLE(); static void ClaimBLEMemory(System::Layer *, void *); @@ -361,7 +360,7 @@ class BLEManagerImpl final : public BLEManager, void HandleC3CharRead(struct ble_gatt_char_context * param); #endif /* CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING */ -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static int btshell_on_mtu(uint16_t conn_handle, const struct ble_gatt_error * error, uint16_t mtu, void * arg); bool SubOrUnsubChar(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, @@ -370,9 +369,9 @@ class BLEManagerImpl final : public BLEManager, static void OnGattDiscComplete(const struct peer * peer, int status, void * arg); static void HandleConnectFailed(CHIP_ERROR error); CHIP_ERROR HandleRXNotify(struct ble_gap_event * event); -#endif -#endif -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#endif // CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static void CancelConnect(void); static void HandleConnectTimeout(chip::System::Layer *, void * context); void InitiateScan(BleScanState scanType); @@ -382,7 +381,7 @@ class BLEManagerImpl final : public BLEManager, void CleanScanConfig(); BLEScanConfig mBLEScanConfig; bool mIsCentral; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER static void DriveBLEState(intptr_t arg); }; diff --git a/src/platform/ESP32/BUILD.gn b/src/platform/ESP32/BUILD.gn index 167d0eb6bc139c..1b84a21b06d9d7 100644 --- a/src/platform/ESP32/BUILD.gn +++ b/src/platform/ESP32/BUILD.gn @@ -204,5 +204,8 @@ static_library("ESP32") { ] } - cflags = [ "-Wconversion" ] + cflags = [ + "-Wconversion", + "-Wundef", + ] } diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 273fd562d60883..e6d7870c35fda6 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -48,13 +48,20 @@ #endif /* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID */ +#ifdef CONFIG_ENABLE_MATTER_OVER_THREAD #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_ENABLE_MATTER_OVER_THREAD +#else +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0 +#endif // CONFIG_ENABLE_MATTER_OVER_THREAD + #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CONFIG_OPENTHREAD_DNS_CLIENT -#if CONFIG_ENABLE_ETHERNET_TELEMETRY +#ifdef CONFIG_ENABLE_ETHERNET_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 1 -#endif +#else +#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 0 +#endif // CONFIG_ENABLE_ETHERNET_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP | CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #if CHIP_DEVICE_CONFIG_ENABLE_WIFI @@ -72,14 +79,29 @@ #endif /* CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP */ #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI -#if CONFIG_ENABLE_ICD_SERVER +#ifdef CONFIG_ENABLE_ICD_SERVER #define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_ICD_SLOW_POLL_INTERVAL_MS) #define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_ICD_FAST_POLL_INTERVAL_MS) #endif // CHIP_CONFIG_ENABLE_ICD_SERVER +#ifdef CONFIG_ENABLE_CHIPOBLE #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_ENABLE_CHIPOBLE +#else +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0 +#endif // CONFIG_ENABLE_CHIPOBLE + +#ifdef CONFIG_ENABLE_EXTENDED_DISCOVERY #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY CONFIG_ENABLE_EXTENDED_DISCOVERY +#else +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 0 +#endif // CONFIG_ENABLE_EXTENDED_DISCOVERY + +#ifdef CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE +#else +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 0 +#endif // CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE + #define CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX CONFIG_BLE_DEVICE_NAME_PREFIX #define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN #define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX @@ -92,8 +114,19 @@ #define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT #define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS CONFIG_ENABLE_TEST_SETUP_PARAMS #define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER CONFIG_USE_TEST_SERIAL_NUMBER + +#ifdef CONFIG_ENABLE_THREAD_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY CONFIG_ENABLE_THREAD_TELEMETRY +#else +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 +#endif // CONFIG_ENABLE_THREAD_TELEMETRY + +#ifdef CONFIG_ENABLE_THREAD_TELEMETRY_FULL #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL CONFIG_ENABLE_THREAD_TELEMETRY_FULL +#else +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 +#endif // CONFIG_ENABLE_THREAD_TELEMETRY_FULL + #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE @@ -105,10 +138,20 @@ #define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS CONFIG_CHIP_DISCOVERY_TIMEOUT_SECS #define CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE CONFIG_ENABLE_ESP32_BLE_CONTROLLER #define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART + +#ifdef CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT #define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT +#else +#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 0 +#endif // Options for background chip task +#ifdef CONFIG_ENABLE_BG_EVENT_PROCESSING #define CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING CONFIG_ENABLE_BG_EVENT_PROCESSING +#else +#define CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING 0 +#endif // CONFIG_ENABLE_BG_EVENT_PROCESSING + #define CHIP_DEVICE_CONFIG_BG_TASK_PRIORITY CONFIG_BG_CHIP_TASK_PRIORITY #define CHIP_DEVICE_CONFIG_BG_MAX_EVENT_QUEUE_SIZE CONFIG_BG_MAX_EVENT_QUEUE_SIZE #define CHIP_DEVICE_CONFIG_BG_TASK_STACK_SIZE CONFIG_BG_CHIP_TASK_STACK_SIZE diff --git a/src/platform/ESP32/CHIPDevicePlatformEvent.h b/src/platform/ESP32/CHIPDevicePlatformEvent.h index b7664ef8c69145..7aad43df14add4 100644 --- a/src/platform/ESP32/CHIPDevicePlatformEvent.h +++ b/src/platform/ESP32/CHIPDevicePlatformEvent.h @@ -44,7 +44,7 @@ enum kESPSystemEvent = kRange_PublicPlatformSpecific, }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER /** * Enumerates ESP32 platform-specific event types that are internal to the Chip Device Layer. */ @@ -58,7 +58,7 @@ enum InternalPlatformSpecificEventTypes kPlatformESP32BLEIndicationReceived, }; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER } // namespace DeviceEventType /** @@ -89,7 +89,7 @@ struct ChipDevicePlatformEvent final wifi_event_ap_probe_req_rx_t WiFiApProbeReqRecved; } Data; } ESPSystemEvent; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER struct { BLE_CONNECTION_OBJECT mConnection; @@ -112,7 +112,7 @@ struct ChipDevicePlatformEvent final BLE_CONNECTION_OBJECT mConnection; chip::System::PacketBuffer * mData; } BLEIndicationReceived; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER }; }; diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index bed7cb02357b3e..82b6a6262a1e1b 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -58,7 +58,12 @@ #define CHIP_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS CONFIG_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS + +#ifdef CONFIG_SECURITY_TEST_MODE #define CHIP_CONFIG_SECURITY_TEST_MODE CONFIG_SECURITY_TEST_MODE +#else +#define CHIP_CONFIG_SECURITY_TEST_MODE 0 +#endif // CONFIG_SECURITY_TEST_MODE #ifndef CHIP_CONFIG_MAX_FABRICS #define CHIP_CONFIG_MAX_FABRICS CONFIG_MAX_FABRICS @@ -76,7 +81,7 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #endif -#if CONFIG_ENABLE_ICD_SERVER +#ifdef CONFIG_ENABLE_ICD_SERVER #ifndef CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC #define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC CONFIG_ICD_IDLE_MODE_INTERVAL_SEC diff --git a/src/platform/ESP32/ChipDeviceScanner.h b/src/platform/ESP32/ChipDeviceScanner.h index 601e1ac6bab0b0..d921ba08e859a2 100644 --- a/src/platform/ESP32/ChipDeviceScanner.h +++ b/src/platform/ESP32/ChipDeviceScanner.h @@ -20,9 +20,9 @@ #include #include -#if CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_BT_NIMBLE_ENABLED #include "host/ble_hs.h" -#elif CONFIG_BT_BLUEDROID_ENABLED +#elif defined(CONFIG_BT_BLUEDROID_ENABLED) #include "esp_bt.h" #include "esp_bt_main.h" #include "esp_gap_ble_api.h" @@ -47,7 +47,7 @@ class ChipDeviceScannerDelegate virtual ~ChipDeviceScannerDelegate() {} // Called when a CHIP device was found -#if CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_BT_NIMBLE_ENABLED virtual void OnDeviceScanned(const struct ble_hs_adv_fields & fields, const ble_addr_t & addr, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) = 0; #else @@ -90,7 +90,7 @@ class ChipDeviceScanner CHIP_ERROR StopScan(); bool mIsScanning = false; -#if CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_BT_NIMBLE_ENABLED void ReportDevice(const struct ble_hs_adv_fields & fields, const ble_addr_t & addr); #else void ReportDevice(esp_ble_gap_cb_param_t & fields, esp_bd_addr_t & addr); diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index 62dc02cba74628..55c8758bb85fe7 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -223,7 +223,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersion(uint32_t & softwareVer) CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) { -#if CONFIG_ENABLE_ESP32_LOCATIONCAPABILITY +#ifdef CONFIG_ENABLE_ESP32_LOCATIONCAPABILITY uint32_t value = 0; CHIP_ERROR err = ReadConfigValue(ESP32Config::kConfigKey_LocationCapability, value); @@ -237,7 +237,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) #else location = static_cast(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor); return CHIP_NO_ERROR; -#endif +#endif // CONFIG_ENABLE_ESP32_LOCATIONCAPABILITY } CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t codeLen) @@ -246,7 +246,7 @@ CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t VerifyOrReturnError((code != nullptr) && (codeLen == 2), CHIP_ERROR_INVALID_ARGUMENT); // Setting country is only possible on WiFi supported SoCs -#if CONFIG_ESP32_WIFI_ENABLED +#ifdef CONFIG_ESP32_WIFI_ENABLED // Write CountryCode to esp_phy layer ReturnErrorOnFailure(MapConfigError(esp_phy_update_country_info(code))); #endif diff --git a/src/platform/ESP32/ConfigurationManagerImpl.h b/src/platform/ESP32/ConfigurationManagerImpl.h index 3779ac816dc463..1416df35d93b65 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.h +++ b/src/platform/ESP32/ConfigurationManagerImpl.h @@ -25,6 +25,8 @@ #pragma once +#include + #include #include #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 0add13da49886c..e2940173b135ce 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 3810862a0f57b6..a3e369a85917aa 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -1108,7 +1108,7 @@ void ConnectivityManagerImpl::OnStationIPv6AddressAvailable(const ip_event_got_i event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; PlatformMgr().PostEventOrDie(&event); -#if CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER +#ifdef CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER uint8_t station_mac[6]; if (esp_wifi_get_mac(WIFI_IF_STA, station_mac) == ESP_OK) { @@ -1136,7 +1136,7 @@ void ConnectivityManagerImpl::OnStationIPv6AddressAvailable(const ip_event_got_i } #endif // CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER -#if CONFIG_ENABLE_ROUTE_HOOK +#ifdef CONFIG_ENABLE_ROUTE_HOOK esp_route_hook_init(esp_netif_get_handle_from_ifkey(ESP32Utils::kDefaultWiFiStationNetifKey)); #endif } diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index ff36ca21662152..154be055d92e9c 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -230,14 +230,14 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** { ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); } -#if !CONFIG_DISABLE_IPV4 +#ifndef CONFIG_DISABLE_IPV4 if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK) { memcpy(ifp->Ipv4AddressesBuffer[0], &(ipv4_info.ip.addr), kMaxIPv4AddrSize); ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); ifp->IPv4Addresses = app::DataModel::List(ifp->Ipv4AddressSpans, 1); } -#endif +#endif // !defined(CONFIG_DISABLE_IPV4) static_assert(kMaxIPv6AddrCount <= UINT8_MAX, "Count might not fit in ipv6_addr_count"); static_assert(ArraySize(ip6_addr) >= LWIP_IPV6_NUM_ADDRESSES, "Not enough space for our addresses."); diff --git a/src/platform/ESP32/ESP32SecureCertDACProvider.cpp b/src/platform/ESP32/ESP32SecureCertDACProvider.cpp index a1bdedf03e1711..f9c2f242ec3a47 100644 --- a/src/platform/ESP32/ESP32SecureCertDACProvider.cpp +++ b/src/platform/ESP32/ESP32SecureCertDACProvider.cpp @@ -23,13 +23,13 @@ #include #include -#if CONFIG_USE_ESP32_ECDSA_PERIPHERAL +#ifdef CONFIG_USE_ESP32_ECDSA_PERIPHERAL #include #endif // CONFIG_USE_ESP32_ECDSA_PERIPHERAL #define TAG "dac_provider" -#if CONFIG_SEC_CERT_DAC_PROVIDER +#ifdef CONFIG_SEC_CERT_DAC_PROVIDER namespace chip { namespace DeviceLayer { @@ -139,7 +139,7 @@ CHIP_ERROR ESP32SecureCertDACProvider ::SignWithDeviceAttestationKey(const ByteS // This flow is for devices supporting ECDSA peripheral if (keyType == ESP_SECURE_CERT_ECDSA_PERIPHERAL_KEY) { -#if CONFIG_USE_ESP32_ECDSA_PERIPHERAL +#ifdef CONFIG_USE_ESP32_ECDSA_PERIPHERAL Crypto::ESP32P256Keypair keypair; uint8_t efuseBlockId; @@ -163,7 +163,7 @@ CHIP_ERROR ESP32SecureCertDACProvider ::SignWithDeviceAttestationKey(const ByteS } else // This flow is for devices which do not support ECDSA peripheral { -#if !CONFIG_USE_ESP32_ECDSA_PERIPHERAL +#ifndef CONFIG_USE_ESP32_ECDSA_PERIPHERAL Crypto::P256Keypair keypair; char * sc_keypair = NULL; uint32_t sc_keypair_len = 0; diff --git a/src/platform/ESP32/OTAImageProcessorImpl.cpp b/src/platform/ESP32/OTAImageProcessorImpl.cpp index 51e9fe50468d22..73ba759c87c599 100644 --- a/src/platform/ESP32/OTAImageProcessorImpl.cpp +++ b/src/platform/ESP32/OTAImageProcessorImpl.cpp @@ -27,7 +27,7 @@ #include "esp_system.h" #include "lib/core/CHIPError.h" -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA #include #endif // CONFIG_ENABLE_ENCRYPTED_OTA @@ -150,7 +150,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) return; } -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA CHIP_ERROR chipError = imageProcessor->DecryptStart(); if (chipError != CHIP_NO_ERROR) { @@ -171,7 +171,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) auto * imageProcessor = reinterpret_cast(context); VerifyOrReturn(imageProcessor, ChipLogError(SoftwareUpdate, "ImageProcessor context is null")); -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA if (CHIP_NO_ERROR != imageProcessor->DecryptEnd()) { ChipLogError(SoftwareUpdate, "Failed to end pre encrypted OTA"); @@ -213,7 +213,7 @@ void OTAImageProcessorImpl::HandleAbort(intptr_t context) return; } -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA imageProcessor->DecryptAbort(); #endif // CONFIG_ENABLE_ENCRYPTED_OTA @@ -253,7 +253,7 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) esp_err_t err; ByteSpan blockToWrite = block; -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA error = imageProcessor->DecryptBlock(block, blockToWrite); if (error != CHIP_NO_ERROR) { @@ -266,7 +266,7 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) err = esp_ota_write(imageProcessor->mOTAUpdateHandle, blockToWrite.data(), blockToWrite.size()); -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA free((void *) (blockToWrite.data())); #endif // CONFIG_ENABLE_ENCRYPTED_OTA @@ -297,7 +297,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) PostOTAStateChangeEvent(DeviceLayer::kOtaApplyComplete); -#if CONFIG_OTA_AUTO_REBOOT_ON_APPLY +#ifdef CONFIG_OTA_AUTO_REBOOT_ON_APPLY // HandleApply is called after delayed action time seconds are elapsed, so it would be safe to schedule the restart DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(CONFIG_OTA_AUTO_REBOOT_DELAY_MS), HandleRestart, nullptr); #else @@ -362,7 +362,7 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & block) return CHIP_NO_ERROR; } -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA CHIP_ERROR OTAImageProcessorImpl::InitEncryptedOTA(const CharSpan & key) { VerifyOrReturnError(mEncryptedOTAEnabled == false, CHIP_ERROR_INCORRECT_STATE); diff --git a/src/platform/ESP32/OTAImageProcessorImpl.h b/src/platform/ESP32/OTAImageProcessorImpl.h index 4162711eef847a..c33407dad74511 100644 --- a/src/platform/ESP32/OTAImageProcessorImpl.h +++ b/src/platform/ESP32/OTAImageProcessorImpl.h @@ -23,7 +23,7 @@ #include #include -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA #include #endif // CONFIG_ENABLE_ENCRYPTED_OTA @@ -42,7 +42,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface bool IsFirstImageRun() override; CHIP_ERROR ConfirmCurrentImage() override; -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA // @brief This API initializes the handling of encrypted OTA image // @param key null terminated RSA-3072 key in PEM format // @return CHIP_NO_ERROR on success, appropriate error code otherwise @@ -66,7 +66,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface esp_ota_handle_t mOTAUpdateHandle; OTAImageHeaderParser mHeaderParser; -#if CONFIG_ENABLE_ENCRYPTED_OTA +#ifdef CONFIG_ENABLE_ENCRYPTED_OTA CHIP_ERROR DecryptStart(); CHIP_ERROR DecryptEnd(); void DecryptAbort(); diff --git a/src/platform/ESP32/OpenthreadLauncher.cpp b/src/platform/ESP32/OpenthreadLauncher.cpp index 8c76c1db809082..ed04692cbed08e 100644 --- a/src/platform/ESP32/OpenthreadLauncher.cpp +++ b/src/platform/ESP32/OpenthreadLauncher.cpp @@ -161,7 +161,7 @@ esp_err_t openthread_init_stack(void) assert(s_platform_config); // Initialize the OpenThread stack ESP_ERROR_CHECK(esp_openthread_init(s_platform_config)); -#if CONFIG_OPENTHREAD_CLI +#ifdef CONFIG_OPENTHREAD_CLI esp_openthread_matter_cli_init(); cli_command_transmit_task(); #endif diff --git a/src/platform/ESP32/SystemTimeSupport.cpp b/src/platform/ESP32/SystemTimeSupport.cpp index c303c7420c42c0..613e79b6067858 100644 --- a/src/platform/ESP32/SystemTimeSupport.cpp +++ b/src/platform/ESP32/SystemTimeSupport.cpp @@ -50,7 +50,7 @@ Milliseconds64 ClockImpl::GetMonotonicMilliseconds64(void) CHIP_ERROR ClockImpl::GetClock_RealTime(Microseconds64 & aCurTime) { -#if CONFIG_ENABLE_SNTP_TIME_SYNC +#ifdef CONFIG_ENABLE_SNTP_TIME_SYNC struct timeval tv; if (gettimeofday(&tv, nullptr) != 0) { @@ -69,7 +69,7 @@ CHIP_ERROR ClockImpl::GetClock_RealTime(Microseconds64 & aCurTime) return CHIP_NO_ERROR; #else return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -#endif +#endif // CONFIG_ENABLE_SNTP_TIME_SYNC } CHIP_ERROR ClockImpl::GetClock_RealTimeMS(Milliseconds64 & aCurTime) diff --git a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp index 72d738df7e3293..3e5cc6091e9314 100644 --- a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp +++ b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp @@ -28,25 +28,25 @@ #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include "sdkconfig.h" -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include #endif -#if CONFIG_BT_BLUEDROID_ENABLED +#ifdef CONFIG_BT_BLUEDROID_ENABLED -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include #endif #include #include #include -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include #include #include #endif #include -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include #include #endif @@ -79,7 +79,7 @@ struct ESP32ChipServiceData ChipBLEDeviceIdentificationInfo DeviceIdInfo; }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static constexpr uint16_t kNewConnectionScanTimeout = 60; static constexpr uint16_t kConnectTimeout = 20; #endif @@ -96,7 +96,7 @@ const uint8_t UUID_CHIPoBLEChar_RX[] = { 0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18 }; const uint8_t UUID_CHIPoBLEChar_TX[] = { 0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18 }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER const uint8_t ShortUUID_CHIPoBLE_CharTx_Desc[] = { 0x02, 0x29 }; #endif const ChipBleUUID ChipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, @@ -147,12 +147,12 @@ const uint16_t CHIPoBLEGATTAttrCount = sizeof(CHIPoBLEGATTAttrs) / sizeof(CHIPoB } // unnamed namespace -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER ChipDeviceScanner & mDeviceScanner = Internal::ChipDeviceScanner::GetInstance(); #endif BLEManagerImpl BLEManagerImpl::sInstance; constexpr System::Clock::Timeout BLEManagerImpl::kFastAdvertiseTimeout; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static esp_gattc_char_elem_t * char_elem_result = NULL; static esp_gattc_descr_elem_t * descr_elem_result = NULL; @@ -203,7 +203,7 @@ CHIP_ERROR BLEManagerImpl::_Init() CHIP_ERROR err; // Initialize the Chip BleLayer. -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER err = BleLayer::Init(this, this, this, &DeviceLayer::SystemLayer()); #else err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer()); @@ -217,7 +217,7 @@ CHIP_ERROR BLEManagerImpl::_Init() mRXCharAttrHandle = 0; mTXCharAttrHandle = 0; mTXCharCCCDAttrHandle = 0; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART && !mIsCentral); mFlags.Set(Flags::kFastAdvertisingEnabled, !mIsCentral); #else @@ -360,14 +360,14 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) break; default: -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER HandlePlatformSpecificBLEEvent(event); #endif break; } } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEvent) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -743,7 +743,7 @@ void BLEManagerImpl::ConnectDevice(esp_bd_addr_t & addr, esp_ble_addr_type_t add bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER uint8_t value[2]; int rc; @@ -771,7 +771,7 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER uint8_t value[2]; int rc; @@ -813,7 +813,7 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) // Release the associated connection state record. ReleaseConnectionState(conId); -#if !CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifndef CONFIG_ENABLE_ESP32_BLE_CONTROLLER // Force a refresh of the advertising state. mFlags.Set(Flags::kAdvertisingRefreshNeeded); mFlags.Clear(Flags::kAdvertisingConfigured); @@ -840,7 +840,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU VerifyOrExit(conState != NULL, err = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(conState->PendingIndBuf.IsNull(), err = CHIP_ERROR_INCORRECT_STATE); -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER ChipLogDetail(Ble, "Sending indication for CHIPoBLE TX characteristic (con %u, len %u)", conId, data->DataLength()); #endif @@ -869,7 +869,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, PacketBufferHandle pBuf) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER ChipLogProgress(Ble, "In send write request\n"); int rc; @@ -1655,7 +1655,7 @@ void BLEManagerImpl::HandleDisconnect(esp_ble_gatts_cb_param_t * param) } } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER CHIP_ERROR BLEManagerImpl::HandleRXNotify(esp_ble_gattc_cb_param_t param) { System::PacketBufferHandle buf = System::PacketBufferHandle::NewWithData(param.notify.value, param.notify.value_len); @@ -1889,7 +1889,7 @@ uint16_t BLEManagerImpl::_NumConnections(void) return numCons; } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void BLEManagerImpl::HandleGAPConnectionFailed() { if (sInstance.mIsCentral) @@ -1965,7 +1965,7 @@ void BLEManagerImpl::HandleGATTEvent(esp_gatts_cb_event_t event, esp_gatt_if_t g void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t * param) { CHIP_ERROR err = CHIP_NO_ERROR; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER esp_ble_gap_cb_param_t * scan_result = (esp_ble_gap_cb_param_t *) param; #endif @@ -2051,7 +2051,7 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb } break; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER case ESP_GAP_BLE_SCAN_RESULT_EVT: { mDeviceScanner.ReportDevice(*scan_result, scan_result->scan_rst.bda); } diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index 54219bfa4d84e6..c153e4b592c8ea 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -28,31 +28,37 @@ #include "sdkconfig.h" -#if CONFIG_BT_NIMBLE_ENABLED +#ifdef CONFIG_BT_NIMBLE_ENABLED -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER + #include #include #include #include #include -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER + +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER + #include #include #include #include "esp_bt.h" #include "esp_log.h" + #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) #include "esp_nimble_hci.h" #endif -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER + +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER #include "blecent.h" -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER + #include "host/ble_hs.h" #include "host/ble_hs_pvcy.h" #include "host/ble_uuid.h" @@ -77,10 +83,10 @@ namespace Internal { namespace { TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static constexpr uint16_t kNewConnectionScanTimeout = 60; static constexpr uint16_t kConnectTimeout = 20; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER struct ESP32ChipServiceData { @@ -90,9 +96,9 @@ struct ESP32ChipServiceData const ble_uuid16_t ShortUUID_CHIPoBLEService = { BLE_UUID_TYPE_16, 0xFFF6 }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER const ble_uuid16_t ShortUUID_CHIPoBLE_CharTx_Desc = { BLE_UUID_TYPE_16, 0x2902 }; -#endif +#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER const ble_uuid128_t UUID128_CHIPoBLEChar_RX = { BLE_UUID_TYPE_128, { 0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18 } @@ -106,11 +112,11 @@ const ble_uuid128_t UUID_CHIPoBLEChar_TX = { { BLE_UUID_TYPE_128 }, { 0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18 } }; -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +#ifdef CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING const ble_uuid128_t UUID_CHIPoBLEChar_C3 = { { BLE_UUID_TYPE_128 }, { 0x04, 0x8F, 0x21, 0x83, 0x8A, 0x74, 0x7D, 0xB8, 0xF2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64 } }; -#endif +#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING SemaphoreHandle_t semaphoreHandle = NULL; @@ -120,7 +126,7 @@ uint8_t own_addr_type = BLE_OWN_ADDR_RANDOM; } // unnamed namespace -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER ChipDeviceScanner & mDeviceScanner = Internal::ChipDeviceScanner::GetInstance(); #endif BLEManagerImpl BLEManagerImpl::sInstance; @@ -159,7 +165,7 @@ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = { }, }; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void BLEManagerImpl::HandleConnectFailed(CHIP_ERROR error) { if (sInstance.mIsCentral) @@ -218,7 +224,7 @@ CHIP_ERROR BLEManagerImpl::_Init() VerifyOrReturnError(sbleAdvTimeoutTimer != nullptr, CHIP_ERROR_NO_MEMORY); // Initialize the Chip BleLayer. -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER err = BleLayer::Init(this, this, this, &DeviceLayer::SystemLayer()); #else err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer()); @@ -230,7 +236,7 @@ CHIP_ERROR BLEManagerImpl::_Init() mC3CharAttrHandle = 0; #endif mTXCharCCCDAttrHandle = 0; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART && !mIsCentral); mFlags.Set(Flags::kFastAdvertisingEnabled, !mIsCentral); #else @@ -404,14 +410,14 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) break; default: -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER HandlePlatformSpecificBLEEvent(event); #endif break; } } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEvent) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -498,7 +504,7 @@ static int OnSubscribeCharComplete(uint16_t conn_handle, const struct ble_gatt_e bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER const struct peer_dsc * dsc; uint8_t value[2]; int rc; @@ -536,7 +542,7 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER const struct peer_dsc * dsc; uint8_t value[2]; int rc; @@ -585,7 +591,7 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) ChipLogError(DeviceLayer, "ble_gap_terminate() failed: %s", ErrorStr(err)); } -#if !CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifndef CONFIG_ENABLE_ESP32_BLE_CONTROLLER // Force a refresh of the advertising state. mFlags.Set(Flags::kAdvertisingRefreshNeeded); mFlags.Clear(Flags::kAdvertisingConfigured); @@ -638,7 +644,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU return true; } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER static int OnWriteComplete(uint16_t conn_handle, const struct ble_gatt_error * error, struct ble_gatt_attr * attr, void * arg) { ChipLogDetail(Ble, "Write complete; status:%d conn_handle:%d attr_handle:%d", error->status, conn_handle, attr->handle); @@ -658,7 +664,7 @@ static int OnWriteComplete(uint16_t conn_handle, const struct ble_gatt_error * e bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, chip::System::PacketBufferHandle pBuf) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER const struct peer_chr * chr; int rc; const struct peer * peer = peer_find(conId); @@ -1020,10 +1026,10 @@ void BLEManagerImpl::ClaimBLEMemory(System::Layer *, void *) // Free up all the space occupied by ble and add it to heap esp_err_t err = ESP_OK; -#if CONFIG_IDF_TARGET_ESP32 +#ifdef CONFIG_IDF_TARGET_ESP32 err = esp_bt_mem_release(ESP_BT_MODE_BTDM); -#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2 || \ - CONFIG_IDF_TARGET_ESP32C6 +#elif defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) || \ + defined(CONFIG_IDF_TARGET_ESP32H2) || defined(CONFIG_IDF_TARGET_ESP32C6) err = esp_bt_mem_release(ESP_BT_MODE_BLE); #endif @@ -1290,7 +1296,7 @@ uint16_t BLEManagerImpl::_NumConnections(void) return numCons; } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER void BLEManagerImpl::HandleGAPConnectionFailed(struct ble_gap_event * gapEvent, CHIP_ERROR error) { ChipLogError(Ble, "BLE GAP connection failed; status:%d", gapEvent->connect.status); @@ -1379,7 +1385,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPPeripheralConnect(struct ble_gap_event * gap CHIP_ERROR BLEManagerImpl::HandleGAPConnect(struct ble_gap_event * gapEvent) { -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER int rc; rc = ble_gattc_exchange_mtu(gapEvent->connect.conn_handle, NULL, NULL); @@ -1405,7 +1411,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(struct ble_gap_event * gapEvent) mNumGAPCons--; } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER peer_delete(gapEvent->disconnect.conn.conn_handle); #endif @@ -1542,7 +1548,7 @@ int BLEManagerImpl::ble_svr_gap_event(struct ble_gap_event * event, void * arg) ESP_LOGD(TAG, "BLE_GAP_EVENT_MTU = %d channel id = %d", event->mtu.value, event->mtu.channel_id); break; -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER case BLE_GAP_EVENT_NOTIFY_RX: ESP_LOGD(TAG, "BLE_GAP_EVENT_NOTIFY_RX received %s conn_handle:%d attr_handle:%d attr_len:%d", event->notify_rx.indication ? "indication" : "notification", event->notify_rx.conn_handle, @@ -1735,7 +1741,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) return err; } } -#if CONFIG_BT_NIMBLE_HOST_BASED_PRIVACY +#ifdef CONFIG_BT_NIMBLE_HOST_BASED_PRIVACY else { err = MapBLEError(ble_hs_pvcy_rpa_config(NIMBLE_HOST_ENABLE_RPA)); @@ -1773,7 +1779,7 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg) sInstance.DriveBLEState(); } -#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER +#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER CHIP_ERROR BLEManagerImpl::HandleRXNotify(struct ble_gap_event * ble_event) { uint8_t * data = OS_MBUF_DATA(ble_event->notify_rx.om, uint8_t *); diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h index 15e6abdb5d4e83..e91f59298f683e 100644 --- a/src/system/SystemConfig.h +++ b/src/system/SystemConfig.h @@ -178,6 +178,23 @@ /* Configuration option variables defined below */ +/** + * @def CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL + * + * @brief + * Enable the use of lwIP pbufs from a custom pool + * + * This config option exist because not all platforms defines LWIP_PBUF_FROM_CUSTOM_POOLS in lwip/opt.h + * Defaults to LWIP_PBUF_FROM_CUSTOM_POOLS if defined, otherwise 0 + */ +#ifndef CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL +#if CHIP_SYSTEM_CONFIG_USE_LWIP && defined(LWIP_PBUF_FROM_CUSTOM_POOLS) +#define CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL LWIP_PBUF_FROM_CUSTOM_POOLS +#else +#define CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL 0 +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && defined(LWIP_PBUF_FROM_CUSTOM_POOLS) +#endif // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL + /** * @def CHIP_SYSTEM_CONFIG_POSIX_LOCKING * diff --git a/src/system/SystemPacketBufferInternal.h b/src/system/SystemPacketBufferInternal.h index e6acb76f6b6e80..e4f1391867a5ae 100644 --- a/src/system/SystemPacketBufferInternal.h +++ b/src/system/SystemPacketBufferInternal.h @@ -27,10 +27,6 @@ #include #include -#if CHIP_SYSTEM_CONFIG_USE_LWIP -#include -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - /** * CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_HEAP * @@ -82,7 +78,7 @@ * * True if packet buffers are allocated from an LwIP custom pool. */ -#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && !LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_STANDARD_POOL 1 #else #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_STANDARD_POOL 0 @@ -93,7 +89,7 @@ * * True if packet buffers are allocated from an LwIP custom pool. */ -#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_CUSTOM_POOL 1 #else #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_CUSTOM_POOL 0 diff --git a/src/system/SystemStats.cpp b/src/system/SystemStats.cpp index 5ef16369ccc853..3a844b6179040b 100644 --- a/src/system/SystemStats.cpp +++ b/src/system/SystemStats.cpp @@ -38,7 +38,7 @@ namespace System { namespace Stats { static const Label sStatsStrings[chip::System::Stats::kNumEntries] = { -#if CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_USE_LWIP && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) "SystemLayer_Num" desc, #include "lwippools.h" #undef LWIP_PBUF_MEMPOOL @@ -107,7 +107,7 @@ bool Difference(Snapshot & result, Snapshot & after, Snapshot & before) void UpdateLwipPbufCounts(void) { -#if LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL size_t lwip_pool_idx = PBUF_CUSTOM_POOL_IDX_END; size_t system_idx = 0; @@ -119,12 +119,12 @@ void UpdateLwipPbufCounts(void) system_idx++; } -#else // LWIP_PBUF_FROM_CUSTOM_POOLS +#else // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL chip::System::Stats::GetResourcesInUse()[kSystemLayer_NumPacketBufs] = MEMP_STATS_GET(used, MEMP_PBUF_POOL); chip::System::Stats::GetHighWatermarks()[kSystemLayer_NumPacketBufs] = MEMP_STATS_GET(max, MEMP_PBUF_POOL); -#endif // LWIP_PBUF_FROM_CUSTOM_POOLS +#endif // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL } #endif // CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_STATS && MEMP_STATS diff --git a/src/system/SystemStats.h b/src/system/SystemStats.h index 24c1dad9ae36c5..35f3e19ca299be 100644 --- a/src/system/SystemStats.h +++ b/src/system/SystemStats.h @@ -27,6 +27,7 @@ // Include configuration headers #include #include +#include // Include dependent headers #include @@ -47,7 +48,7 @@ namespace Stats { enum { -#if CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_USE_LWIP && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) kSystemLayer_Num##name, #include "lwippools.h" #undef LWIP_PBUF_MEMPOOL