arduino-libraries / Arduino_ConnectionHandler

GNU General Public License v3.0
97 stars 36 forks source link

Add support for custom Ethernet timeouts #107

Closed manchoz closed 5 months ago

manchoz commented 11 months ago

This PR adds support for specifying custom timeouts on Ethernet connections.

Combined with the ArduinoIoTCloud library, this PR allows writing sketches that don't block for 15s in the loop() if the Ethernet cable is not connected or there is no link-layer connectivity.

To be used as:

EthernetConnectionHandler ArduinoIoTPreferredConnection(IP, DNS, GATEWAY, NETMASK, 1000);
  auto connStatus = ArduinoIoTPreferredConnection.check();

  if (connStatus == NetworkConnectionState::CONNECTED)
    ArduinoCloud.update();
github-actions[bot] commented 11 months ago

Memory usage change @ 36aa0080e9ecd699e8fc53157f9ea00e2c957639

Board flash % RAM for global variables %
arduino:esp32:nano_nora 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed:envie_m7 N/A N/A N/A N/A
arduino:mbed_edge:edge_control 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_giga:giga 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nicla:nicla_vision 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta :small_red_triangle: +160 - +160 +0.01 - +0.01 :small_red_triangle: +32 - +32 +0.01 - +0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 :small_red_triangle: +136 - +136 +0.01 - +0.01 :small_red_triangle: +32 - +32 +0.01 - +0.01
arduino:renesas_uno:unor4wifi 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
esp32:esp32:esp32 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
esp8266:esp8266:huzzah 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|`examples/ConnectionHandlerDemo`
flash|%|`examples/ConnectionHandlerDemo`
RAM for global variables|% -|-|-|-|- `arduino:esp32:nano_nora`|0|0.0|0|0.0 `arduino:mbed:envie_m7`|N/A|N/A|N/A|N/A `arduino:mbed_edge:edge_control`|0|0.0|0|0.0 `arduino:mbed_giga:giga`|0|0.0|0|0.0 `arduino:mbed_nano:nanorp2040connect`|0|0.0|0|0.0 `arduino:mbed_nicla:nicla_vision`|0|0.0|0|0.0 `arduino:mbed_opta:opta`|160|0.01|32|0.01 `arduino:mbed_portenta:envie_m7`|N/A|N/A|N/A|N/A `arduino:renesas_portenta:portenta_c33`|136|0.01|32|0.01 `arduino:renesas_uno:unor4wifi`|0|0.0|0|0.0 `arduino:samd:mkr1000`|0|0.0|0|0.0 `arduino:samd:mkrgsm1400`|0|0.0|0|0.0 `arduino:samd:mkrnb1500`|0|0.0|0|0.0 `arduino:samd:mkrwan1300`|0|0.0|0|0.0 `arduino:samd:mkrwan1310`|0|0.0|0|0.0 `arduino:samd:mkrwifi1010`|0|0.0|0|0.0 `arduino:samd:nano_33_iot`|0|0.0|0|0.0 `esp32:esp32:esp32`|0|0.0|0|0.0 `esp8266:esp8266:huzzah`|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/ConnectionHandlerDemo
flash,%,examples/ConnectionHandlerDemo
RAM for global variables,% arduino:esp32:nano_nora,0,0.0,0,0.0 arduino:mbed:envie_m7,N/A,N/A,N/A,N/A arduino:mbed_edge:edge_control,0,0.0,0,0.0 arduino:mbed_giga:giga,0,0.0,0,0.0 arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0 arduino:mbed_nicla:nicla_vision,0,0.0,0,0.0 arduino:mbed_opta:opta,160,0.01,32,0.01 arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A arduino:renesas_portenta:portenta_c33,136,0.01,32,0.01 arduino:renesas_uno:unor4wifi,0,0.0,0,0.0 arduino:samd:mkr1000,0,0.0,0,0.0 arduino:samd:mkrgsm1400,0,0.0,0,0.0 arduino:samd:mkrnb1500,0,0.0,0,0.0 arduino:samd:mkrwan1300,0,0.0,0,0.0 arduino:samd:mkrwan1310,0,0.0,0,0.0 arduino:samd:mkrwifi1010,0,0.0,0,0.0 arduino:samd:nano_33_iot,0,0.0,0,0.0 esp32:esp32:esp32,0,0.0,0,0.0 esp8266:esp8266:huzzah,0,0.0,0,0.0 ```