diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index 31b18003d65e05..8f18f730999cde 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -99,7 +99,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ChipLogProgress(DeviceLayer, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ChipLogProgress(DeviceLayer, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index a3046af0f59c0b..0b05da8e240985 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -212,7 +212,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event static bool isOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); wifiLED.Set(true); chip::app::DnssdServer::Instance().StartServer(); diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index 0c6b50607b739d..58a59b2603d6de 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -73,7 +73,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/chef/esp32/main/main.cpp b/examples/chef/esp32/main/main.cpp index 8dadae04d554f6..03751d641dafd1 100644 --- a/examples/chef/esp32/main/main.cpp +++ b/examples/chef/esp32/main/main.cpp @@ -78,7 +78,7 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) case DeviceEventType::kInternetConnectivityChange: if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ChipLogProgress(Shell, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ChipLogProgress(Shell, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index bb8fe22d4e609d..cb023f73b6ea87 100644 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -78,7 +78,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - printf("Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + printf("IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp index 69dc7bb2744e02..852522e7832e07 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp @@ -129,7 +129,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - log_info("Server ready at: %s:%d\r\n", event->InternetConnectivityChange.address, CHIP_PORT); + log_info("IPv4 Server ready...\r\n"); // TODO // wifiLED.Set(true); chip::app::DnssdServer::Instance().StartServer(); diff --git a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp index 9c1d21f03c7af6..eaffb0b8efee36 100644 --- a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp @@ -161,7 +161,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event static bool isOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); if (!isOTAInitialized) diff --git a/examples/lock-app/esp32/main/DeviceCallbacks.cpp b/examples/lock-app/esp32/main/DeviceCallbacks.cpp index 1d176bdb86f54c..10a2c37d223889 100644 --- a/examples/lock-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lock-app/esp32/main/DeviceCallbacks.cpp @@ -100,7 +100,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp b/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp index 83174c06e1c17a..b4ed0159ebf89c 100644 --- a/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp @@ -82,7 +82,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index 31b18003d65e05..8f18f730999cde 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -99,7 +99,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ChipLogProgress(DeviceLayer, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ChipLogProgress(DeviceLayer, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp index 4daa73dd48a00b..c58596631b8f70 100644 --- a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp @@ -90,7 +90,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event static bool isOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); if (!isOTAInitialized) { diff --git a/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp b/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp index 80c2320c26781a..ea388f20a06b89 100644 --- a/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp @@ -88,7 +88,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event { if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { - ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + ESP_LOGI(TAG, "IPv4 Server ready..."); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index 2ff9526b58ce28..796e4ab7a3dfc8 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include namespace chip { @@ -373,7 +374,14 @@ struct ChipDeviceEvent final { ConnectivityChange IPv4; ConnectivityChange IPv6; - char address[INET6_ADDRSTRLEN]; + // WARNING: There used to be `char address[INET6_ADDRSTRLEN]` here and it is + // deprecated/removed since it was too large and only used for logging. + // Consider not relying on ipAddress field either since the platform + // layer *does not actually validate* that the actual internet is reachable + // before issuing this event *and* there may be multiple addresses + // (especially IPv6) so it's recommended to use `ChipDevicePlatformEvent` + // instead and do something that is better for your platform. + chip::Inet::IPAddress ipAddress; } InternetConnectivityChange; struct { diff --git a/src/inet/IPAddress.cpp b/src/inet/IPAddress.cpp index 6c7415412b10b5..f3c8cd9175eeba 100644 --- a/src/inet/IPAddress.cpp +++ b/src/inet/IPAddress.cpp @@ -57,19 +57,6 @@ bool IPAddress::operator!=(const IPAddress & other) const return Addr[0] != other.Addr[0] || Addr[1] != other.Addr[1] || Addr[2] != other.Addr[2] || Addr[3] != other.Addr[3]; } -IPAddress & IPAddress::operator=(const IPAddress & other) -{ - if (this != &other) - { - Addr[0] = other.Addr[0]; - Addr[1] = other.Addr[1]; - Addr[2] = other.Addr[2]; - Addr[3] = other.Addr[3]; - } - - return *this; -} - #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT IPAddress::IPAddress(const ip6_addr_t & ipv6Addr) diff --git a/src/inet/IPAddress.h b/src/inet/IPAddress.h index e71de199a5d105..b7a11f17b22467 100644 --- a/src/inet/IPAddress.h +++ b/src/inet/IPAddress.h @@ -120,6 +120,7 @@ union SockAddr * @details * The CHIP Inet Layer uses objects of this class to represent Internet * protocol addresses (independent of protocol version). + * */ class DLL_EXPORT IPAddress { @@ -141,8 +142,7 @@ class DLL_EXPORT IPAddress static constexpr uint16_t kMaxStringLength = OT_IP6_ADDRESS_STRING_SIZE; #endif - IPAddress() = default; - IPAddress(const IPAddress & other) = default; + IPAddress() = default; #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT explicit IPAddress(const ip6_addr_t & ipv6Addr); @@ -324,15 +324,6 @@ class DLL_EXPORT IPAddress */ bool operator!=(const IPAddress & other) const; - /** - * @brief Conventional assignment operator. - * - * @param[in] other The address to copy. - * - * @return A reference to this object. - */ - IPAddress & operator=(const IPAddress & other); - /** * @brief Emit the IP address in conventional text presentation format. * @@ -667,5 +658,7 @@ class DLL_EXPORT IPAddress static IPAddress Any; }; +static_assert(std::is_trivial::value, "IPAddress is not trivial"); + } // namespace Inet } // namespace chip diff --git a/src/inet/IPPrefix.cpp b/src/inet/IPPrefix.cpp index a9d443701d9ac8..fb921b916fdf56 100644 --- a/src/inet/IPPrefix.cpp +++ b/src/inet/IPPrefix.cpp @@ -49,17 +49,6 @@ bool IPPrefix::operator!=(const IPPrefix & other) const return IPAddr != other.IPAddr || Length != other.Length; } -IPPrefix & IPPrefix::operator=(const IPPrefix & other) -{ - if (this != &other) - { - IPAddr = other.IPAddr; - Length = other.Length; - } - - return *this; -} - bool IPPrefix::MatchAddress(const IPAddress & addr) const { uint8_t l = (Length <= 128) ? Length : 128; diff --git a/src/inet/IPPrefix.h b/src/inet/IPPrefix.h index ce58c1b3a700a3..74528ef4ed97a9 100644 --- a/src/inet/IPPrefix.h +++ b/src/inet/IPPrefix.h @@ -48,12 +48,6 @@ class IPPrefix IPPrefix() = default; IPPrefix(const IPAddress & ipAddress, uint8_t length) : IPAddr(ipAddress), Length(length) {} - /** - * Copy constructor for the IPPrefix class. - * - */ - IPPrefix(const IPPrefix & other) = default; - /** An IPv6 or IPv4 address. */ IPAddress IPAddr; @@ -107,15 +101,6 @@ class IPPrefix */ bool operator!=(const IPPrefix & other) const; - /** - * @brief Conventional assignment operator. - * - * @param[in] other the prefix to copy. - * - * @return a reference to this object. - */ - IPPrefix & operator=(const IPPrefix & other); - /** * @brief Test if an address matches the prefix. * diff --git a/src/platform/Ameba/ConnectivityManagerImpl.cpp b/src/platform/Ameba/ConnectivityManagerImpl.cpp index 1427fa939f96a5..ee294acb78d665 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.cpp +++ b/src/platform/Ameba/ConnectivityManagerImpl.cpp @@ -699,10 +699,11 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) // Alert other components of the state change. ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); - event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); - addr.ToString(event.InternetConnectivityChange.address); + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); + event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); + event.InternetConnectivityChange.ipAddress = addr; + PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) diff --git a/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp b/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp index 7c0a9bfd8d39e8..a279c808c4ccb5 100644 --- a/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp @@ -450,10 +450,11 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) // Alert other components of the state change. ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); - event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); - addr.ToString(event.InternetConnectivityChange.address, sizeof(event.InternetConnectivityChange.address)); + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); + event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); + event.InternetConnectivityChange.ipAddress = addr; + (void) PlatformMgr().PostEvent(&event); if (haveIPv4Conn != hadIPv4Conn) diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 8ebc260031e872..8af78d9bcc6bf0 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -1011,10 +1011,11 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) // Alert other components of the state change. ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); - event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); - addr.ToString(event.InternetConnectivityChange.address); + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); + event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); + event.InternetConnectivityChange.ipAddress = addr; + PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 2a2c5fcff050ba..e2044e11c8712c 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1181,13 +1181,15 @@ void ConnectivityManagerImpl::PostNetworkConnect() if ((it.GetAddress(addr) == CHIP_NO_ERROR) && addr.IsIPv4()) { ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_Established; - event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; - addr.ToString(event.InternetConnectivityChange.address); + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_Established; + event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.InternetConnectivityChange.ipAddress = addr; - ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, - event.InternetConnectivityChange.address); + char ipStrBuf[chip::Inet::IPAddress::kMaxStringLength] = { 0 }; + addr.ToString(ipStrBuf); + + ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, ipStrBuf); PlatformMgr().PostEventOrDie(&event); } diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 21817dab467e62..dc16c1c3da8754 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -149,15 +149,15 @@ void PlatformManagerImpl::WiFIIPChangeListener() continue; } + char ipStrBuf[chip::Inet::IPAddress::kMaxStringLength] = { 0 }; + inet_ntop(AF_INET, RTA_DATA(routeInfo), ipStrBuf, sizeof(ipStrBuf)); + ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", name, ipStrBuf); + ChipDeviceEvent event; event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_Established; event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; - inet_ntop(AF_INET, RTA_DATA(routeInfo), event.InternetConnectivityChange.address, - sizeof(event.InternetConnectivityChange.address)); - - ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", name, - event.InternetConnectivityChange.address); + VerifyOrDie(chip::Inet::IPAddress::FromString(ipStrBuf, event.InternetConnectivityChange.ipAddress)); CHIP_ERROR status = PlatformMgr().PostEvent(&event); if (status != CHIP_NO_ERROR) diff --git a/src/platform/P6/ConnectivityManagerImpl.cpp b/src/platform/P6/ConnectivityManagerImpl.cpp index 7b6590a359825a..22034d9f561b66 100644 --- a/src/platform/P6/ConnectivityManagerImpl.cpp +++ b/src/platform/P6/ConnectivityManagerImpl.cpp @@ -657,10 +657,10 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) // Alert other components of the state change. ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); - event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); - addr.ToString(event.InternetConnectivityChange.address); + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); + event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); + event.InternetConnectivityChange.ipAddress = addr; PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) diff --git a/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp b/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp index b96a3953180746..6eca69d3eb4866 100644 --- a/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/mbed/NetworkCommissioningWiFiDriver.cpp @@ -439,9 +439,10 @@ void WiFiDriverImpl::OnNetworkConnected() // Unexpected change, forward to the application mIp4Address = IPAddress::Any; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; - event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; + event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.InternetConnectivityChange.ipAddress = mIp4Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogError(DeviceLayer, "Unexpected loss of Ip4 address"); } @@ -451,9 +452,10 @@ void WiFiDriverImpl::OnNetworkConnected() // Unexpected change, forward to the application mIp6Address = IPAddress::Any; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; - event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; + event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.InternetConnectivityChange.ipAddress = mIp6Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogError(DeviceLayer, "Unexpected loss of Ip6 address"); } @@ -467,9 +469,10 @@ void WiFiDriverImpl::OnNetworkConnected() { mIp4Address = addr; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_Established; - event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_Established; + event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.InternetConnectivityChange.ipAddress = mIp4Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogProgress(DeviceLayer, "New Ip4 address set: %s", address.get_ip_address()); } @@ -482,9 +485,10 @@ void WiFiDriverImpl::OnNetworkConnected() // Unexpected change, forward to the application mIp6Address = IPAddress::Any; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; - event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; + event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.InternetConnectivityChange.ipAddress = mIp6Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogError(DeviceLayer, "Unexpected loss of Ip6 address"); } @@ -495,9 +499,10 @@ void WiFiDriverImpl::OnNetworkConnected() { mIp6Address = addr; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; - event.InternetConnectivityChange.IPv6 = kConnectivity_Established; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; + event.InternetConnectivityChange.IPv6 = kConnectivity_Established; + event.InternetConnectivityChange.ipAddress = mIp6Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogProgress(DeviceLayer, "New Ip6 address set %s", address.get_ip_address()); } @@ -509,9 +514,10 @@ void WiFiDriverImpl::OnNetworkConnected() { mIp6Address = addr; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; - event.InternetConnectivityChange.IPv6 = kConnectivity_Established; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; + event.InternetConnectivityChange.IPv6 = kConnectivity_Established; + event.InternetConnectivityChange.ipAddress = mIp6Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogProgress(DeviceLayer, "New Ip6 address set %s", address.get_ip_address()); } @@ -534,9 +540,10 @@ void WiFiDriverImpl::OnNetworkDisconnected() // Unexpected change, forward to the application mIp4Address = IPAddress::Any; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; - event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; + event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; + event.InternetConnectivityChange.ipAddress = mIp4Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogError(DeviceLayer, "Loss of Ip4 address"); } @@ -546,9 +553,10 @@ void WiFiDriverImpl::OnNetworkDisconnected() // Unexpected change, forward to the application mIp6Address = IPAddress::Any; ChipDeviceEvent event; - event.Type = DeviceEventType::kInternetConnectivityChange; - event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; - event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.Type = DeviceEventType::kInternetConnectivityChange; + event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; + event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; + event.InternetConnectivityChange.ipAddress = mIp6Address; ConnectivityMgrImpl().PostEvent(&event, true); ChipLogError(DeviceLayer, "Loss of Ip6 address"); }