@@ -46,9 +46,6 @@ using namespace chip::DeviceLayer;
46
46
using namespace chip ::System;
47
47
48
48
DeviceCallbacksDelegate * appDelegate = nullptr ;
49
- #if CONFIG_ENABLE_OTA_REQUESTOR
50
- static bool isOTAInitialized = false ;
51
- #endif
52
49
53
50
void CommonDeviceCallbacks::DeviceEventCallback (const ChipDeviceEvent * event, intptr_t arg)
54
51
{
@@ -66,14 +63,15 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i
66
63
ESP_LOGI (TAG, " CHIPoBLE disconnected" );
67
64
break ;
68
65
69
- case DeviceEventType::kThreadConnectivityChange :
66
+ case DeviceEventType::kDnssdInitialized :
70
67
#if CONFIG_ENABLE_OTA_REQUESTOR
71
- if (event->ThreadConnectivityChange .Result == kConnectivity_Established && !isOTAInitialized)
68
+ OTAHelpers::Instance ().InitOTARequestor ();
69
+ #endif
70
+ appDelegate = DeviceCallbacksDelegate::Instance ().GetAppDelegate ();
71
+ if (appDelegate != nullptr )
72
72
{
73
- OTAHelpers::Instance ().InitOTARequestor ();
74
- isOTAInitialized = true ;
73
+ appDelegate->OnDnssdInitialized ();
75
74
}
76
- #endif
77
75
break ;
78
76
79
77
case DeviceEventType::kCommissioningComplete : {
@@ -136,13 +134,6 @@ void CommonDeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent *
136
134
appDelegate->OnIPv4ConnectivityEstablished ();
137
135
}
138
136
chip::app::DnssdServer::Instance ().StartServer ();
139
- #if CONFIG_ENABLE_OTA_REQUESTOR
140
- if (!isOTAInitialized)
141
- {
142
- OTAHelpers::Instance ().InitOTARequestor ();
143
- isOTAInitialized = true ;
144
- }
145
- #endif
146
137
}
147
138
else if (event->InternetConnectivityChange .IPv4 == kConnectivity_Lost )
148
139
{
@@ -156,14 +147,6 @@ void CommonDeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent *
156
147
{
157
148
ESP_LOGI (TAG, " IPv6 Server ready..." );
158
149
chip::app::DnssdServer::Instance ().StartServer ();
159
-
160
- #if CONFIG_ENABLE_OTA_REQUESTOR
161
- if (!isOTAInitialized)
162
- {
163
- OTAHelpers::Instance ().InitOTARequestor ();
164
- isOTAInitialized = true ;
165
- }
166
- #endif
167
150
}
168
151
else if (event->InternetConnectivityChange .IPv6 == kConnectivity_Lost )
169
152
{
0 commit comments