Skip to content

Commit 5853fe0

Browse files
Merge branch 'master' into include-refactoring
2 parents 9f19e5b + 5022993 commit 5853fe0

6 files changed

+30
-11
lines changed

Diff for: examples/ConnectionHandlerDemo/arduino_secrets.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
// Required for WiFiConnectionHandler
12
const char SECRET_SSID[] = "NETWORK NAME";
23
const char SECRET_PASS[] = "NETWORK PASSWORD";
34

5+
// Required for GSMConnectionHandler
46
const char SECRET_APN[] = "MOBILE PROVIDER APN ADDRESS";
5-
const char SECRET_PIN[] = "0000";
7+
const char SECRET_PIN[] = "0000"; // Required for NBConnectionHandler
68
const char SECRET_GSM_USER[] = "GSM USERNAME";
79
const char SECRET_GSM_PASS[] = "GSM PASSWORD";
810

11+
// Required for LoRaConnectionHandler
912
const char SECRET_APP_EUI[] = "APP_EUI";
1013
const char SECRET_APP_KEY[] = "APP_KEY";
1114

15+
// Required for EthernetConnectionHandler (without DHCP mode)
1216
const char SECRET_IP[] = "IP ADDRESS";
1317
const char SECRET_DNS[] = "DNS ADDRESS";
1418
const char SECRET_GATEWAY[] = "GATEWAY ADDRESS";

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name=Arduino_ConnectionHandler
22
version=0.8.1
33
author=Ubi de Feo, Cristian Maglie, Andrea Catozzi, Alexander Entinger et al.
4-
maintainer=Arduino.cc
4+
maintainer=Arduino <info@arduino.cc>
55
sentence=Arduino Library for network connection management (WiFi, GSM, NB, [Ethernet])
66
paragraph=Originally part of ArduinoIoTCloud
77
category=Communication

Diff for: src/Arduino_EthernetConnectionHandler.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,38 @@
2525
CTOR/DTOR
2626
******************************************************************************/
2727

28-
EthernetConnectionHandler::EthernetConnectionHandler(bool const keep_alive)
28+
EthernetConnectionHandler::EthernetConnectionHandler(unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive)
2929
: ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
3030
,_ip{INADDR_NONE}
3131
,_dns{INADDR_NONE}
3232
,_gateway{INADDR_NONE}
3333
,_netmask{INADDR_NONE}
34+
,_timeout{timeout}
35+
,_response_timeout{responseTimeout}
3436
{
3537

3638
}
3739

38-
EthernetConnectionHandler::EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, bool const keep_alive)
40+
EthernetConnectionHandler::EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive)
3941
: ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
4042
,_ip{ip}
4143
,_dns{dns}
4244
,_gateway{gateway}
4345
,_netmask{netmask}
46+
,_timeout{timeout}
47+
,_response_timeout{responseTimeout}
4448
{
4549

4650
}
4751

48-
EthernetConnectionHandler::EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, bool const keep_alive)
52+
EthernetConnectionHandler::EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive)
4953
: ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
5054
,_ip{INADDR_NONE}
5155
,_dns{INADDR_NONE}
5256
,_gateway{INADDR_NONE}
5357
,_netmask{INADDR_NONE}
58+
,_timeout{timeout}
59+
,_response_timeout{responseTimeout}
5460
{
5561
if(!_ip.fromString(ip)) {
5662
_ip = INADDR_NONE;
@@ -82,13 +88,15 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
8288
NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
8389
{
8490
if (_ip != INADDR_NONE) {
85-
if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, 15000, 4000) == 0) {
91+
if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, _timeout, _response_timeout) == 0) {
8692
Debug.print(DBG_ERROR, F("Failed to configure Ethernet, check cable connection"));
93+
Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout);
8794
return NetworkConnectionState::CONNECTING;
8895
}
8996
} else {
90-
if (Ethernet.begin(nullptr, 15000, 4000) == 0) {
97+
if (Ethernet.begin(nullptr, _timeout, _response_timeout) == 0) {
9198
Debug.print(DBG_ERROR, F("Waiting Ethernet configuration from DHCP server, check cable connection"));
99+
Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout);
92100
return NetworkConnectionState::CONNECTING;
93101
}
94102
}

Diff for: src/Arduino_EthernetConnectionHandler.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class EthernetConnectionHandler : public ConnectionHandler
4040
{
4141
public:
4242

43-
EthernetConnectionHandler(bool const keep_alive = true);
44-
EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, bool const keep_alive = true);
45-
EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, bool const keep_alive = true);
43+
EthernetConnectionHandler(unsigned long const timeout = 15000, unsigned long const responseTimeout = 4000, bool const keep_alive = true);
44+
EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, unsigned long const timeout = 15000, unsigned long const responseTimeout = 4000, bool const keep_alive = true);
45+
EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, unsigned long const timeout = 15000, unsigned long const responseTimeout = 4000, bool const keep_alive = true);
4646

4747

4848
virtual unsigned long getTime() override { return 0; }
@@ -65,6 +65,9 @@ class EthernetConnectionHandler : public ConnectionHandler
6565
IPAddress _gateway;
6666
IPAddress _netmask;
6767

68+
unsigned long _timeout;
69+
unsigned long _response_timeout;
70+
6871
EthernetUDP _eth_udp;
6972
EthernetClient _eth_client;
7073

Diff for: src/Arduino_LoRaConnectionHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ NetworkConnectionState LoRaConnectionHandler::update_handleInit()
107107
{
108108
Debug.print(DBG_ERROR, F("Something went wrong; are you indoor? Move near a window, then reset and retry."));
109109
return NetworkConnectionState::ERROR;
110-
}
110+
}
111111
// Set channelmask based on configuration
112112
if (_channelMask) {
113113
_modem.sendMask(_channelMask);

Diff for: src/Arduino_LoRaConnectionHandler.h

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <MKRWAN.h>
2929
#endif
3030

31+
#ifdef BOARD_HAS_LORA /* Only compile if the board has LoRa */
32+
3133
/******************************************************************************
3234
CLASS DECLARATION
3335
******************************************************************************/
@@ -76,4 +78,6 @@ class LoRaConnectionHandler : public ConnectionHandler
7678
LoRaModem _modem;
7779
};
7880

81+
#endif /* #ifdef BOARD_HAS_LORA */
82+
7983
#endif /* ARDUINO_LORA_CONNECTION_HANDLER_H_ */

0 commit comments

Comments
 (0)