diff --git a/libraries/lwIP_Ethernet/src/LwipIntfDev.h b/libraries/lwIP_Ethernet/src/LwipIntfDev.h index d90a15710..a6756f43c 100644 --- a/libraries/lwIP_Ethernet/src/LwipIntfDev.h +++ b/libraries/lwIP_Ethernet/src/LwipIntfDev.h @@ -427,18 +427,20 @@ bool LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu) { template void LwipIntfDev::end() { - if (_intrPin < 0) { - __removeEthernetPacketHandler(_phID); - } else { - detachInterrupt(_intrPin); - __removeEthernetGPIO(_intrPin); - } + if (_started) { + if (_intrPin < 0) { + __removeEthernetPacketHandler(_phID); + } else { + detachInterrupt(_intrPin); + __removeEthernetGPIO(_intrPin); + } - RawDev::end(); + RawDev::end(); - netif_remove(&_netif); + netif_remove(&_netif); - _started = false; + _started = false; + } } template