Skip to content

Commit 1444414

Browse files
pankorepull[bot]
authored andcommitted
[wifi] combine ipv4 and ipv6 event so that dns server will start only when ipv6 is ready (#27884)
1 parent 08fa1c9 commit 1444414

File tree

2 files changed

+24
-44
lines changed

2 files changed

+24
-44
lines changed

src/platform/Ameba/ConnectivityManagerImpl.cpp

+22-41
Original file line numberDiff line numberDiff line change
@@ -758,53 +758,23 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void)
758758
}
759759
}
760760

761-
void ConnectivityManagerImpl::OnStationIPv4AddressAvailable(void)
761+
void ConnectivityManagerImpl::OnStationIPv4v6AddressAvailable(void)
762762
{
763763
uint8_t * ip = LwIP_GetIP(&xnetif[0]);
764764
uint8_t * gw = LwIP_GetGW(&xnetif[0]);
765765
uint8_t * msk = LwIP_GetMASK(&xnetif[0]);
766-
#if CHIP_PROGRESS_LOGGING
767-
{
768-
ChipLogProgress(DeviceLayer, "\n\r\tIP => %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
769-
ChipLogProgress(DeviceLayer, "\n\r\tGW => %d.%d.%d.%d\n\r", gw[0], gw[1], gw[2], gw[3]);
770-
ChipLogProgress(DeviceLayer, "\n\r\tmsk => %d.%d.%d.%d\n\r", msk[0], msk[1], msk[2], msk[3]);
771-
}
772-
#endif // CHIP_PROGRESS_LOGGING
773-
774-
RefreshMessageLayer();
775-
776-
UpdateInternetConnectivityState();
777-
778-
ChipDeviceEvent event;
779-
event.Type = DeviceEventType::kInterfaceIpAddressChanged;
780-
event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned;
781-
PlatformMgr().PostEventOrDie(&event);
782-
}
783-
784-
void ConnectivityManagerImpl::OnStationIPv4AddressLost(void)
785-
{
786-
ChipLogProgress(DeviceLayer, "IPv4 address lost on WiFi station interface");
787-
788-
RefreshMessageLayer();
789-
790-
UpdateInternetConnectivityState();
791-
792-
ChipDeviceEvent event;
793-
event.Type = DeviceEventType::kInterfaceIpAddressChanged;
794-
event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost;
795-
PlatformMgr().PostEventOrDie(&event);
796-
}
797-
798-
void ConnectivityManagerImpl::OnIPv6AddressAvailable(void)
799-
{
800766
#if LWIP_VERSION_MAJOR > 2 || LWIP_VERSION_MINOR > 0
801767
#if LWIP_IPV6
802768
uint8_t * ipv6_0 = LwIP_GetIPv6_linklocal(&xnetif[0]);
803769
uint8_t * ipv6_1 = LwIP_GetIPv6_global(&xnetif[0]);
804770
#endif
805771
#endif // LWIP_VERSION_MAJOR > 2 || LWIP_VERSION_MINOR > 0
772+
806773
#if CHIP_PROGRESS_LOGGING
807774
{
775+
ChipLogProgress(DeviceLayer, "\n\r\tIP => %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
776+
ChipLogProgress(DeviceLayer, "\n\r\tGW => %d.%d.%d.%d\n\r", gw[0], gw[1], gw[2], gw[3]);
777+
ChipLogProgress(DeviceLayer, "\n\r\tmsk => %d.%d.%d.%d\n\r", msk[0], msk[1], msk[2], msk[3]);
808778
#if LWIP_VERSION_MAJOR > 2 || LWIP_VERSION_MINOR > 0
809779
#if LWIP_IPV6
810780
ChipLogProgress(DeviceLayer,
@@ -830,6 +800,20 @@ void ConnectivityManagerImpl::OnIPv6AddressAvailable(void)
830800
PlatformMgr().PostEventOrDie(&event);
831801
}
832802

803+
void ConnectivityManagerImpl::OnStationIPv4v6AddressLost(void)
804+
{
805+
ChipLogProgress(DeviceLayer, "IPv4 address lost on WiFi station interface");
806+
807+
RefreshMessageLayer();
808+
809+
UpdateInternetConnectivityState();
810+
811+
ChipDeviceEvent event;
812+
event.Type = DeviceEventType::kInterfaceIpAddressChanged;
813+
event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost;
814+
PlatformMgr().PostEventOrDie(&event);
815+
}
816+
833817
void ConnectivityManagerImpl::RefreshMessageLayer(void) {}
834818

835819
void ConnectivityManagerImpl::RtkWiFiStationConnectedHandler(char * buf, int buf_len, int flags, void * userdata)
@@ -859,17 +843,14 @@ void ConnectivityManagerImpl::RtkWiFiScanCompletedHandler(void)
859843
void ConnectivityManagerImpl::DHCPProcessThread(void * param)
860844
{
861845
matter_lwip_dhcp();
862-
PlatformMgr().LockChipStack();
863-
sInstance.OnStationIPv4AddressAvailable();
864-
PlatformMgr().UnlockChipStack();
865846
#if LWIP_VERSION_MAJOR > 2 || LWIP_VERSION_MINOR > 0
866847
#if LWIP_IPV6
867848
matter_lwip_dhcp6();
868-
PlatformMgr().LockChipStack();
869-
sInstance.OnIPv6AddressAvailable();
870-
PlatformMgr().UnlockChipStack();
871849
#endif
872850
#endif // LWIP_VERSION_MAJOR > 2 || LWIP_VERSION_MINOR > 0
851+
PlatformMgr().LockChipStack();
852+
sInstance.OnStationIPv4v6AddressAvailable();
853+
PlatformMgr().UnlockChipStack();
873854
vTaskDelete(NULL);
874855
}
875856

src/platform/Ameba/ConnectivityManagerImpl.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ class ConnectivityManagerImpl final : public ConnectivityManager,
141141
static void DriveAPState(::chip::System::Layer * aLayer, void * aAppState);
142142

143143
void UpdateInternetConnectivityState(void);
144-
void OnStationIPv4AddressAvailable(void);
145-
void OnStationIPv4AddressLost(void);
146-
void OnIPv6AddressAvailable(void);
144+
void OnStationIPv4v6AddressAvailable(void);
145+
void OnStationIPv4v6AddressLost(void);
147146

148147
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
149148

0 commit comments

Comments
 (0)