@@ -78,10 +78,10 @@ bool MDNSResponder::_process(bool p_bUserContext) {
78
78
}
79
79
}
80
80
else {
81
- bResult = ((WiFi. isConnected () || // Either station is connected
82
- WiFi. softAPgetStationNum ()> 0 ) && // Or AP has stations connected
83
- ( _updateProbeStatus ()) && // Probing
84
- ( _checkServiceQueryCache ())); // Service query cache check
81
+ bResult = (m_netif != nullptr ) &&
82
+ (m_netif-> flags & NETIF_FLAG_UP) && // network interface is up and running
83
+ _updateProbeStatus () && // Probing
84
+ _checkServiceQueryCache (); // Service query cache check
85
85
}
86
86
return bResult;
87
87
}
@@ -91,53 +91,10 @@ bool MDNSResponder::_process(bool p_bUserContext) {
91
91
*/
92
92
bool MDNSResponder::_restart (void ) {
93
93
94
- // check m_IPAddress
95
- if (!m_IPAddress.isSet ()) {
96
-
97
- IPAddress sta = WiFi.localIP ();
98
- IPAddress ap = WiFi.softAPIP ();
99
-
100
- if (!sta.isSet () && !ap.isSet ()) {
101
-
102
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] internal interfaces (STA, AP) are not set (none was specified)\n " )));
103
- return false ;
104
- }
105
-
106
- if (sta.isSet ()) {
107
-
108
- if (ap.isSet ())
109
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] default interface STA selected over AP (none was specified)\n " )));
110
- else
111
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] default interface STA selected\n " )));
112
- m_IPAddress = sta;
113
-
114
- } else {
115
-
116
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] default interface AP selected (none was specified)\n " )));
117
- m_IPAddress = ap;
118
-
119
- }
120
-
121
- // continue to ensure interface is UP
122
- }
123
-
124
- // check existence of this IP address in the interface list
125
- bool found = false ;
126
- for (auto a: addrList)
127
- if (m_IPAddress == a.addr ()) {
128
- if (a.ifUp ()) {
129
- found = true ;
130
- break ;
131
- }
132
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] found interface for IP '%s' but it is not UP\n " ), m_IPAddress.toString ().c_str ()););
133
- }
134
- if (!found) {
135
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] interface defined by IP '%s' not found\n " ), m_IPAddress.toString ().c_str ()););
136
- return false ;
137
- }
138
-
139
- return ((_resetProbeStatus (true )) && // Stop and restart probing
140
- (_allocUDPContext ())); // Restart UDP
94
+ return ((m_netif != nullptr ) &&
95
+ (m_netif->flags & NETIF_FLAG_UP) && // network interface is up and running
96
+ (_resetProbeStatus (true )) && // Stop and restart probing
97
+ (_allocUDPContext ())); // Restart UDP
141
98
}
142
99
143
100
@@ -797,7 +754,7 @@ bool MDNSResponder::_processPTRAnswer(const MDNSResponder::stcMDNS_RRAnswerPTR*
797
754
if (p_pPTRAnswer->m_u32TTL ) { // Received update message
798
755
pSQAnswer->m_TTLServiceDomain .set (p_pPTRAnswer->m_u32TTL ); // Update TTL tag
799
756
DEBUG_EX_INFO (
800
- DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processPTRAnswer: Updated TTL(%lu ) for " ), p_pPTRAnswer->m_u32TTL );
757
+ DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processPTRAnswer: Updated TTL(%d ) for " ), ( int ) p_pPTRAnswer->m_u32TTL );
801
758
_printRRDomain (pSQAnswer->m_ServiceDomain );
802
759
DEBUG_OUTPUT.printf_P (PSTR (" \n " ));
803
760
);
@@ -851,7 +808,7 @@ bool MDNSResponder::_processSRVAnswer(const MDNSResponder::stcMDNS_RRAnswerSRV*
851
808
if (p_pSRVAnswer->m_u32TTL ) { // First or update message (TTL != 0)
852
809
pSQAnswer->m_TTLHostDomainAndPort .set (p_pSRVAnswer->m_u32TTL ); // Update TTL tag
853
810
DEBUG_EX_INFO (
854
- DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processSRVAnswer: Updated TTL(%lu ) for " ), p_pSRVAnswer->m_u32TTL );
811
+ DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processSRVAnswer: Updated TTL(%d ) for " ), ( int ) p_pSRVAnswer->m_u32TTL );
855
812
_printRRDomain (pSQAnswer->m_ServiceDomain );
856
813
DEBUG_OUTPUT.printf_P (PSTR (" host domain and port\n " ));
857
814
);
@@ -904,7 +861,7 @@ bool MDNSResponder::_processTXTAnswer(const MDNSResponder::stcMDNS_RRAnswerTXT*
904
861
if (p_pTXTAnswer->m_u32TTL ) { // First or update message
905
862
pSQAnswer->m_TTLTxts .set (p_pTXTAnswer->m_u32TTL ); // Update TTL tag
906
863
DEBUG_EX_INFO (
907
- DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processTXTAnswer: Updated TTL(%lu ) for " ), p_pTXTAnswer->m_u32TTL );
864
+ DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processTXTAnswer: Updated TTL(%d ) for " ), ( int ) p_pTXTAnswer->m_u32TTL );
908
865
_printRRDomain (pSQAnswer->m_ServiceDomain );
909
866
DEBUG_OUTPUT.printf_P (PSTR (" TXTs\n " ));
910
867
);
@@ -956,7 +913,7 @@ bool MDNSResponder::_processTXTAnswer(const MDNSResponder::stcMDNS_RRAnswerTXT*
956
913
if (p_pAAnswer->m_u32TTL ) { // Valid TTL -> Update answers TTL
957
914
pIP4Address->m_TTL .set (p_pAAnswer->m_u32TTL );
958
915
DEBUG_EX_INFO (
959
- DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processAAnswer: Updated TTL(%lu ) for " ), p_pAAnswer->m_u32TTL );
916
+ DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _processAAnswer: Updated TTL(%d ) for " ), ( int ) p_pAAnswer->m_u32TTL );
960
917
_printRRDomain (pSQAnswer->m_ServiceDomain );
961
918
DEBUG_OUTPUT.printf_P (PSTR (" IP4Address (%s)\n " ), pIP4Address->m_IPAddress .toString ().c_str ());
962
919
);
@@ -1123,7 +1080,7 @@ bool MDNSResponder::_updateProbeStatus(void) {
1123
1080
1124
1081
if (MDNS_ANNOUNCE_COUNT > m_HostProbeInformation.m_u8SentCount ) {
1125
1082
m_HostProbeInformation.m_Timeout .reset (MDNS_ANNOUNCE_DELAY);
1126
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _updateProbeStatus: Announcing host (%lu ).\n\n " ), m_HostProbeInformation.m_u8SentCount ););
1083
+ DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _updateProbeStatus: Announcing host (%d ).\n\n " ), m_HostProbeInformation.m_u8SentCount ););
1127
1084
}
1128
1085
else {
1129
1086
m_HostProbeInformation.m_Timeout .resetToNeverExpires ();
@@ -1171,7 +1128,7 @@ bool MDNSResponder::_updateProbeStatus(void) {
1171
1128
1172
1129
if (MDNS_ANNOUNCE_COUNT > pService->m_ProbeInformation .m_u8SentCount ) {
1173
1130
pService->m_ProbeInformation .m_Timeout .reset (MDNS_ANNOUNCE_DELAY);
1174
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s (%lu )\n\n " ), (pService->m_pcName ?: m_pcHostname), pService->m_pcService , pService->m_pcProtocol , pService->m_ProbeInformation .m_u8SentCount ););
1131
+ DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s (%d )\n\n " ), (pService->m_pcName ?: m_pcHostname), pService->m_pcService , pService->m_pcProtocol , pService->m_ProbeInformation .m_u8SentCount ););
1175
1132
}
1176
1133
else {
1177
1134
pService->m_ProbeInformation .m_Timeout .resetToNeverExpires ();
0 commit comments