@@ -166,8 +166,9 @@ nsapi_error_t LWIP::Interface::set_dhcp()
166
166
void LWIP::Interface::netif_link_irq (struct netif *netif)
167
167
{
168
168
LWIP::Interface *interface = our_if_from_netif (netif);
169
+ nsapi_connection_status_t connectedStatusPrev = interface->connected ;
169
170
170
- if (netif_is_link_up (&interface->netif )) {
171
+ if (netif_is_link_up (&interface->netif ) && interface-> connected == NSAPI_STATUS_CONNECTING ) {
171
172
nsapi_error_t dhcp_status = interface->set_dhcp ();
172
173
173
174
if (interface->blocking && dhcp_status == NSAPI_ERROR_OK) {
@@ -177,15 +178,25 @@ void LWIP::Interface::netif_link_irq(struct netif *netif)
177
178
}
178
179
} else {
179
180
osSemaphoreRelease (interface->unlinked );
181
+ if (netif_is_up (&interface->netif )) {
182
+ interface->connected = NSAPI_STATUS_CONNECTING;
183
+ }
180
184
netif_set_down (&interface->netif );
181
185
}
186
+
187
+ if (interface->client_callback && connectedStatusPrev != interface->connected
188
+ && interface->connected != NSAPI_STATUS_GLOBAL_UP /* advertised by netif_status_irq */
189
+ && interface->connected != NSAPI_STATUS_DISCONNECTED) /* advertised by bring_down */ {
190
+ interface->client_callback (NSAPI_EVENT_CONNECTION_STATUS_CHANGE, interface->connected );
191
+ }
182
192
}
183
193
184
194
void LWIP::Interface::netif_status_irq (struct netif *netif)
185
195
{
186
196
LWIP::Interface *interface = our_if_from_netif (netif);
197
+ nsapi_connection_status_t connectedStatusPrev = interface->connected ;
187
198
188
- if (netif_is_up (&interface->netif )) {
199
+ if (netif_is_up (&interface->netif ) && netif_is_link_up (&interface-> netif ) ) {
189
200
bool dns_addr_has_to_be_added = false ;
190
201
if (!(interface->has_addr_state & HAS_ANY_ADDR) && LWIP::get_ip_addr (true , netif)) {
191
202
if (interface->blocking ) {
@@ -212,19 +223,19 @@ void LWIP::Interface::netif_status_irq(struct netif *netif)
212
223
dns_addr_has_to_be_added = true ;
213
224
}
214
225
#endif
215
- if (dns_addr_has_to_be_added && !interface->blocking ) {
226
+ if (dns_addr_has_to_be_added && !interface->blocking ) {
216
227
add_dns_addr (&interface->netif );
217
228
}
218
229
219
-
220
230
if (interface->has_addr_state & HAS_ANY_ADDR) {
221
231
interface->connected = NSAPI_STATUS_GLOBAL_UP;
222
232
}
223
- } else {
233
+ } else if (! netif_is_up (&interface-> netif ) && netif_is_link_up (&interface-> netif )) {
224
234
interface->connected = NSAPI_STATUS_DISCONNECTED;
225
235
}
226
236
227
- if (interface->client_callback ) {
237
+ if (interface->client_callback && (connectedStatusPrev != interface->connected )
238
+ && interface->connected != NSAPI_STATUS_DISCONNECTED) /* advertised by bring_down */ {
228
239
interface->client_callback (NSAPI_EVENT_CONNECTION_STATUS_CHANGE, interface->connected );
229
240
}
230
241
}
@@ -632,5 +643,8 @@ nsapi_error_t LWIP::Interface::bringdown()
632
643
has_addr_state = 0 ;
633
644
634
645
connected = NSAPI_STATUS_DISCONNECTED;
646
+ if (client_callback) {
647
+ client_callback (NSAPI_EVENT_CONNECTION_STATUS_CHANGE, connected);
648
+ }
635
649
return 0 ;
636
650
}
0 commit comments