Zephyr standalone platform update (#34135)

* fix zephyr build (west)

* Use different Kconfig

In order to let the user choose his own pack of functionality. I guess BLUETOOTH shouldn't be enable by default,
because Bluetooth isn't mandatory for a Matter device

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Remove ZephyrSocket

Because zephyr has recvmsg now

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Support ip_mreq and ip_mreqn

Because Zephyr seems to not have ip_mreq, only ip_mreqn, so add an extra flag in platform config to make the choice.
This issue is only meets when doing ipv4 on a Zephyr platform

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Add missing functions to BLE

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Add specific configs and dependencies for Zephyr platform

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Revert "Remove ZephyrSocket"

This reverts commit f283940c0312c9d4820a9e68610f319f356e45c8.
Also, fix things discussed with Damian-Nordic

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Don't use ZephyrSocket.h

Since zephyr implement recvsg now

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Remove git artifact

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Restyled by whitespace

* Restyled by clang-format

* Re-add ZephyrSocket.h include

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Remove BLE Read declarations

As discussed in conversations

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Allow net_if only with Ethernet or Wifi connection

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Check if Ethernet is defined

Because all manufactures don't implement it

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>

* Restyled by clang-format

---------

Signed-off-by: Caldeira, Quentin <QuentinCaldeira@eaton.com>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/config/zephyr/app/enable-gnu-std.cmake b/config/zephyr/app/enable-gnu-std.cmake
index 5f31e1a..37c1823 100644
--- a/config/zephyr/app/enable-gnu-std.cmake
+++ b/config/zephyr/app/enable-gnu-std.cmake
@@ -2,5 +2,5 @@
 target_compile_options(gnu17
     INTERFACE 
         $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>
-        -D_SYS__PTHREADTYPES_H_)
-target_link_libraries(app PRIVATE gnu17)
+        -D_DEFAULT_SOURCE)
+target_link_libraries(app PRIVATE gnu17)
\ No newline at end of file
diff --git a/config/zephyr/chip-module/CMakeLists.txt b/config/zephyr/chip-module/CMakeLists.txt
index 6d84a96..575e4ff 100644
--- a/config/zephyr/chip-module/CMakeLists.txt
+++ b/config/zephyr/chip-module/CMakeLists.txt
@@ -39,29 +39,27 @@
 get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/zephyr/chip-gn REALPATH)
 get_filename_component(COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT}/config/common/cmake REALPATH)
 
-# Additional configuration
-if (CONFIG_CHIP_PW_RPC)
-    set(CONFIG_CHIP_LIB_PW_RPC YES)
-endif()
 
 # Get common Cmake sources
 include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn_args.cmake)
 include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn.cmake)
 
-# Prepare compiler flags
-matter_add_flags(-isystem${ZEPHYR_BASE}/../modules/crypto/mbedtls/include/)
-
 if (CONFIG_POSIX_API)
-    matter_add_flags(-D_SYS__PTHREADTYPES_H_)
+    matter_add_flags(-D_DEFAULT_SOURCE)
     matter_add_flags(-isystem${ZEPHYR_BASE}/include/zephyr/posix)
 endif()
 
+if(CONFIG_MBEDTLS)
+    zephyr_include_directories($<TARGET_PROPERTY:mbedTLS,INTERFACE_INCLUDE_DIRECTORIES>)
+    zephyr_compile_definitions($<TARGET_PROPERTY:mbedTLS,INTERFACE_COMPILE_DEFINITIONS>)
+endif()
+
 zephyr_get_compile_flags(ZEPHYR_CFLAGS_C C)
-matter_add_cflags(${ZEPHYR_CFLAGS_C})
+matter_add_cflags("${ZEPHYR_CFLAGS_C}")
 zephyr_get_compile_flags(ZEPHYR_CFLAGS_CC CXX)
-matter_add_cxxflags(${ZEPHYR_CFLAGS_CC})
+matter_add_cxxflags("${ZEPHYR_CFLAGS_CC}")
 zephyr_get_gnu_cpp_standard(ZEPHYR_GNU_CPP_STD)
-matter_add_cxxflags(${ZEPHYR_GNU_CPP_STD})
+matter_add_cxxflags("${ZEPHYR_GNU_CPP_STD}")
 
 # Set up custom OpenThread configuration
 
@@ -81,21 +79,52 @@
     DEBUG           CONFIG_DEBUG
     LIB_SHELL       CONFIG_CHIP_LIB_SHELL
     LIB_TESTS       CONFIG_CHIP_BUILD_TESTS
-    LIB_PW_RPC      CONFIG_CHIP_PW_RPC
     PROJECT_CONFIG  ${CONFIG_CHIP_PROJECT_CONFIG}
 )
-matter_add_gn_arg_string("zephyr_ar"                              ${CMAKE_AR})
-matter_add_gn_arg_string("zephyr_cc"                              ${CMAKE_C_COMPILER})
-matter_add_gn_arg_string("zephyr_cxx"                             ${CMAKE_CXX_COMPILER})
-matter_add_gn_arg_bool  ("chip_enable_openthread"                 CONFIG_NET_L2_OPENTHREAD)
-matter_add_gn_arg_bool  ("chip_openthread_ftd"                    CONFIG_OPENTHREAD_FTD)
-matter_add_gn_arg_bool  ("chip_inet_config_enable_ipv4"           CONFIG_NET_IPV4)
-matter_add_gn_arg_bool  ("chip_inet_config_enable_tcp_endpoint"   CONFIG_CHIP_BUILD_TESTS)
+
+matter_add_gn_arg_string("zephyr_ar"                                ${CMAKE_AR})
+matter_add_gn_arg_string("zephyr_cc"                                ${CMAKE_C_COMPILER})
+matter_add_gn_arg_string("zephyr_cxx"                               ${CMAKE_CXX_COMPILER})
+matter_add_gn_arg_bool  ("chip_logging"                             CONFIG_LOG)
+matter_add_gn_arg_bool  ("chip_error_logging"                       CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
+matter_add_gn_arg_bool  ("chip_progress_logging"                    CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
+matter_add_gn_arg_bool  ("chip_detail_logging"                      CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
+matter_add_gn_arg_bool  ("chip_automation_logging"                  FALSE)
+matter_add_gn_arg_bool  ("chip_enable_openthread"                   CONFIG_NET_L2_OPENTHREAD)
+matter_add_gn_arg_bool  ("chip_openthread_ftd"                      CONFIG_OPENTHREAD_FTD)
+matter_add_gn_arg_bool  ("chip_inet_config_enable_ipv4"             CONFIG_CHIP_IPV4)
+matter_add_gn_arg_bool  ("chip_enable_wifi"                         CONFIG_WIFI)
+matter_add_gn_arg_bool  ("chip_config_network_layer_ble"            CONFIG_BT)
+matter_add_gn_arg_bool  ("chip_mdns_minimal"                        CONFIG_WIFI)
+matter_add_gn_arg_bool  ("chip_mdns_minimal"                        CONFIG_NET_L2_ETHERNET)
+matter_add_gn_arg_bool  ("chip_mdns_platform"                       CONFIG_NET_L2_OPENTHREAD)
+matter_add_gn_arg_bool  ("chip_inet_config_enable_tcp_endpoint"     CONFIG_CHIP_BUILD_TESTS)
+matter_add_gn_arg_bool  ("chip_inet_config_enable_udp_endpoint"     CONFIG_NET_UDP)
+matter_add_gn_arg_bool  ("chip_inet_config_enable_tcp_endpoint"     CONFIG_NET_TCP)
+matter_add_gn_arg_bool  ("chip_malloc_sys_heap"                     CONFIG_CHIP_MALLOC_SYS_HEAP)
+
 
 if (CONFIG_CHIP_ENABLE_DNSSD_SRP)
     matter_add_gn_arg_string("chip_mdns" "platform")
 endif()
 
+if(CONFIG_WIFI)
+    matter_add_gn_arg_string("chip_mdns" "minimal")
+elseif (CONFIG_NET_L2_ETHERNET)
+    matter_add_gn_arg_string("chip_mdns" "minimal")
+elseif (CONFIG_NET_L2_OPENTHREAD)
+    matter_add_gn_arg_string("chip_mdns" "platform")
+else()
+    matter_add_gn_arg_string("chip_mdns" "none")
+endif()
+
+if (CONFIG_CHIP_PW_RPC)
+    set(PIGWEED_DIR "//third_party/pigweed/repo")
+    matter_add_gn_arg_string("pw_assert_BACKEND" ${PIGWEED_DIR}/pw_assert_log:check_backend)
+    matter_add_gn_arg_string("pw_log_BACKEND" ${PIGWEED_DIR}/pw_log_basic)
+    matter_add_gn_arg("pw_build_LINK_DEPS" [\"${PIGWEED_DIR}/pw_assert:impl\",\ \"${PIGWEED_DIR}/pw_log:impl\"])
+endif()
+
 matter_generate_args_tmp_file()
 
 # ==============================================================================
@@ -103,7 +132,6 @@
 # ==============================================================================
 matter_build(chip
     LIB_SHELL   ${CONFIG_CHIP_LIB_SHELL}
-    LIB_PW_RPC  ${CONFIG_CHIP_PW_RPC}
     LIB_TESTS   ${CONFIG_CHIP_BUILD_TESTS}
     GN_DEPENDENCIES kernel
 )
diff --git a/config/zephyr/chip-module/Kconfig.bt b/config/zephyr/chip-module/Kconfig.bt
new file mode 100644
index 0000000..5472245
--- /dev/null
+++ b/config/zephyr/chip-module/Kconfig.bt
@@ -0,0 +1,68 @@
+#
+#   Copyright (c) 2021 Project CHIP Authors
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+# Bluetooth Low Energy configs
+config BT
+	bool
+	default y
+
+config BT_PERIPHERAL
+	bool
+	default y
+
+config BT_PERIPHERAL_PREF_MIN_INT
+	int
+	default 36
+
+config BT_PERIPHERAL_PREF_MAX_INT
+	int
+	default 36
+
+config BT_GAP_AUTO_UPDATE_CONN_PARAMS
+	bool
+	default y
+
+config BT_GATT_DYNAMIC_DB
+	bool
+	default y
+
+config BT_DEVICE_NAME_DYNAMIC
+	bool
+	default y
+
+config BT_DEVICE_NAME_MAX
+	int
+	default 15
+
+config BT_MAX_CONN
+	int
+	default 1
+
+config BT_L2CAP_TX_MTU
+	int
+	default 247
+
+config BT_BUF_ACL_RX_SIZE
+	int
+	default 251
+
+config BT_BUF_ACL_TX_SIZE
+	int
+	default 251
+
+config BT_RX_STACK_SIZE
+	int
+	default 1200
\ No newline at end of file
diff --git a/config/zephyr/chip-module/Kconfig.defaults b/config/zephyr/chip-module/Kconfig.defaults
index d21562c..f092de9 100644
--- a/config/zephyr/chip-module/Kconfig.defaults
+++ b/config/zephyr/chip-module/Kconfig.defaults
@@ -20,26 +20,6 @@
 
 if CHIP
 
-config LOG
-	bool
-	default y
-
-if LOG
-
-choice LOG_MODE
-	default LOG_MODE_MINIMAL
-endchoice
-
-choice MATTER_LOG_LEVEL_CHOICE
-	default MATTER_LOG_LEVEL_DBG
-endchoice
-
-config LOG_DEFAULT_LEVEL
-	int
-	default 2
-
-endif
-
 # disable synchronous printk to avoid blocking IRQs which
 # may affect time sensitive components
 config PRINTK_SYNC
@@ -119,58 +99,7 @@
 	int
 	default 80
 
-# Bluetooth Low Energy configs
-config BT
-	bool
-	default y
 
-config BT_PERIPHERAL
-	bool
-	default y
-
-config BT_PERIPHERAL_PREF_MIN_INT
-	int
-	default 36
-
-config BT_PERIPHERAL_PREF_MAX_INT
-	int
-	default 36
-
-config BT_GAP_AUTO_UPDATE_CONN_PARAMS
-	bool
-	default y
-
-config BT_GATT_DYNAMIC_DB
-	bool
-	default y
-
-config BT_DEVICE_NAME_DYNAMIC
-	bool
-	default y
-
-config BT_DEVICE_NAME_MAX
-	int
-	default 15
-
-config BT_MAX_CONN
-	int
-	default 1
-
-config BT_L2CAP_TX_MTU
-	int
-	default 247
-
-config BT_BUF_ACL_RX_SIZE
-	int
-	default 251
-
-config BT_BUF_ACL_TX_SIZE
-	int
-	default 251
-
-config BT_RX_STACK_SIZE
-	int
-	default 1200
 
 config CHIP_OTA_REQUESTOR
 	bool
diff --git a/config/zephyr/chip-module/Kconfig.mbedtls b/config/zephyr/chip-module/Kconfig.mbedtls
new file mode 100644
index 0000000..3e4fdc1
--- /dev/null
+++ b/config/zephyr/chip-module/Kconfig.mbedtls
@@ -0,0 +1,64 @@
+#
+#   Copyright (c) 2021 Project CHIP Authors
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+if CHIP
+
+config MBEDTLS
+    default y
+
+config MBEDTLS_ENTROPY_ENABLED
+    default y
+
+config MBEDTLS_ENTROPY_ENABLED
+    default y
+
+config MBEDTLS_ZEPHYR_ENTROPY
+    default y
+
+config MBEDTLS_ENABLE_HEAP
+    default y
+
+config MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
+    default y
+
+config MBEDTLS_ECP_ALL_ENABLED
+    default y
+
+config MBEDTLS_ECP_C
+    default y 
+
+config MBEDTLS_PKCS5_C
+    default y
+
+config MBEDTLS_HKDF_C
+    default y
+
+config MBEDTLS_CIPHER_CCM_ENABLED
+    default y
+
+config MBEDTLS_CTR_DRBG_ENABLED
+    default y 
+
+config MBEDTLS_CIPHER_AES_ENABLED
+    default y
+
+config MBEDTLS_ECDH_C
+    default y
+
+config MBEDTLS_ECDSA_C
+    default y
+
+endif #CHIP
\ No newline at end of file
diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h
index c3653a4..e84276c 100644
--- a/src/inet/InetConfig.h
+++ b/src/inet/InetConfig.h
@@ -283,4 +283,16 @@
 #define HAVE_SO_BINDTODEVICE 0
 #endif
 
+/**
+ *  @def INET_CONFIG_UDP_SOCKET_MREQN
+ *
+ *  @brief
+ *    Should be set to 1 if your platform can handle struct ip_mreqn,
+ *    mandatory in UDPEndPointSocket.cpp
+ */
+
+#ifndef INET_CONFIG_UDP_SOCKET_MREQN
+#define INET_CONFIG_UDP_SOCKET_MREQN 0
+#endif
+
 // clang-format on
diff --git a/src/inet/UDPEndPointImplSockets.cpp b/src/inet/UDPEndPointImplSockets.cpp
index f1831c4..c80db4d 100644
--- a/src/inet/UDPEndPointImplSockets.cpp
+++ b/src/inet/UDPEndPointImplSockets.cpp
@@ -785,11 +785,22 @@
         interfaceAddr.s_addr = htonl(INADDR_ANY);
     }
 
+#if INET_CONFIG_UDP_SOCKET_MREQN
+    struct ip_mreqn lMulticastRequest;
+    memset(&lMulticastRequest, 0, sizeof(lMulticastRequest));
+    lMulticastRequest.imr_ifindex   = aInterfaceId.GetPlatformInterface(); /* Network interface index */
+    lMulticastRequest.imr_address   = interfaceAddr;                       /* IP address of local interface */
+    lMulticastRequest.imr_multiaddr = aAddress.ToIPv4();                   /* IP multicast group address*/
+
+#else
+
     struct ip_mreq lMulticastRequest;
     memset(&lMulticastRequest, 0, sizeof(lMulticastRequest));
     lMulticastRequest.imr_interface = interfaceAddr;
     lMulticastRequest.imr_multiaddr = aAddress.ToIPv4();
 
+#endif
+
     const int command = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
     if (setsockopt(mSocket, IPPROTO_IP, command, &lMulticastRequest, sizeof(lMulticastRequest)) != 0)
     {
diff --git a/src/platform/Zephyr/BUILD.gn b/src/platform/Zephyr/BUILD.gn
index f271d2e..f1d9bdb 100644
--- a/src/platform/Zephyr/BUILD.gn
+++ b/src/platform/Zephyr/BUILD.gn
@@ -38,6 +38,7 @@
     "ConnectivityManagerImpl.h",
     "DiagnosticDataProviderImpl.cpp",
     "DiagnosticDataProviderImpl.h",
+    "DiagnosticDataProviderImplGetter.cpp",
     "InetPlatformConfig.h",
     "KeyValueStoreManagerImpl.cpp",
     "KeyValueStoreManagerImpl.h",
diff --git a/src/platform/Zephyr/CHIPDevicePlatformConfig.h b/src/platform/Zephyr/CHIPDevicePlatformConfig.h
index e7622f6..687e743 100644
--- a/src/platform/Zephyr/CHIPDevicePlatformConfig.h
+++ b/src/platform/Zephyr/CHIPDevicePlatformConfig.h
@@ -46,9 +46,41 @@
 #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
+// Check if Zephyr app use NET_L2_OPENTHREAD
+#ifndef CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#ifdef CONFIG_NET_L2_OPENTHREAD
+#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
+#endif // CONFIG_NET_L2_OPENTHREAD
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
 
-#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT
+// Check if Zephyr app use BT
+#ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
+#ifdef CONFIG_BT
+#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
+#endif // CONFIG_BT
+#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
+
+// Check if Zephyr app use WIFI
+#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI
+#ifdef CONFIG_WIFI
+#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 1
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
+#endif // CONFIG_WIFI
+#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
+// Check if Zephyr app use NET_L2_ETHERNET
+
+#ifndef CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
+#ifdef CONFIG_NET_L2_ETHERNET
+#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 1
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 0
+#endif // CONFIG_NET_L2_ETHERNET
+#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
 
 // ========== Platform-specific Configuration =========
 
@@ -75,6 +107,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
 
diff --git a/src/platform/Zephyr/CHIPPlatformConfig.h b/src/platform/Zephyr/CHIPPlatformConfig.h
index c463fb2..aabad7a 100644
--- a/src/platform/Zephyr/CHIPPlatformConfig.h
+++ b/src/platform/Zephyr/CHIPPlatformConfig.h
@@ -52,4 +52,9 @@
 
 #ifndef CHIP_CONFIG_MAX_FABRICS
 #define CHIP_CONFIG_MAX_FABRICS 5
+
+#define INET_CONFIG_UDP_SOCKET_MREQN 1
+
+#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0
+
 #endif
diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp
index ad70b34..2b1070a 100644
--- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp
+++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp
@@ -32,6 +32,12 @@
 
 #include "InetUtils.h"
 
+#ifdef CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
+#if (CHIP_DEVICE_CONFIG_ENABLE_WIFI) || (CHIP_DEVICE_CONFIG_ENABLE_ETHERNET)
+#include <zephyr/net/net_if.h>
+#endif //(CHIP_DEVICE_CONFIG_ENABLE_WIFI) || (CHIP_DEVICE_CONFIG_ENABLE_ETHERNET)
+#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
+
 #include <lib/support/CodeUtils.h>
 #include <lib/support/logging/CHIPLogging.h>
 
diff --git a/src/platform/Zephyr/Logging.cpp b/src/platform/Zephyr/Logging.cpp
index a5c1ad7..4f73225 100644
--- a/src/platform/Zephyr/Logging.cpp
+++ b/src/platform/Zephyr/Logging.cpp
@@ -3,6 +3,7 @@
 #include <platform/logging/LogV.h>
 
 #include <lib/core/CHIPConfig.h>
+#include <lib/support/EnforceFormat.h>
 #include <lib/support/logging/Constants.h>
 
 #include <zephyr/kernel.h>
@@ -41,7 +42,7 @@
  * CHIP log output function.
  */
 
-void LogV(const char * module, uint8_t category, const char * msg, va_list v)
+void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
     char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
     snprintfcb(formattedMsg, sizeof(formattedMsg), "[%s]", module);