Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/CatM1ConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ unsigned long CatM1ConnectionHandler::getTime()
return 0;
}

int CatM1ConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
return GSM.ping(ip);
}

int CatM1ConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
return GSM.ping(hostname);
}

int CatM1ConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
return GSM.ping(host);
}


/******************************************************************************
PROTECTED MEMBER FUNCTIONS
******************************************************************************/
Expand Down Expand Up @@ -95,7 +108,7 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnecting()
}

DEBUG_INFO(F("Sending PING to outer space..."));
int const ping_result = GSM.ping("time.arduino.cc");
int const ping_result = ping("time.arduino.cc");
DEBUG_INFO(F("GSM.ping(): %d"), ping_result);
if (ping_result < 0)
{
Expand Down
4 changes: 3 additions & 1 deletion src/CatM1ConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class CatM1ConnectionHandler : public ConnectionHandler
CatM1ConnectionHandler();
CatM1ConnectionHandler(const char * pin, const char * apn, const char * login, const char * pass, RadioAccessTechnologyType rat = CATM1, uint32_t band = BAND_3 | BAND_20 | BAND_19, bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override;
virtual Client & getClient() override { return _gsm_client; };
virtual UDP & getUDP() override { return _gsm_udp; };


protected:

virtual NetworkConnectionState update_handleInit () override;
Expand Down
12 changes: 12 additions & 0 deletions src/CellularConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ unsigned long CellularConnectionHandler::getTime()
return _cellular.getCellularTime().getUNIXTimestamp();
}

int CellularConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
return 0;
}

int CellularConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
return 0;
}

int CellularConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
return 0;
}

UDP & CellularConnectionHandler::getUDP()
{
DEBUG_ERROR(F("CellularConnectionHandler has no UDP support"));
Expand Down
4 changes: 3 additions & 1 deletion src/CellularConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class CellularConnectionHandler : public ConnectionHandler
CellularConnectionHandler();
CellularConnectionHandler(const char * pin, const char * apn, const char * login, const char * pass, bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override;
virtual Client & getClient() override { return _gsm_client; };
virtual UDP & getUDP() override;


protected:

virtual NetworkConnectionState update_handleInit () override;
Expand Down
4 changes: 4 additions & 0 deletions src/ConnectionHandlerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class ConnectionHandler {
virtual UDP &getUDP() = 0;

virtual unsigned long getTime() = 0;

virtual int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) = 0;
virtual int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) = 0;
virtual int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) = 0;
#endif

NetworkConnectionState getStatus() __attribute__((deprecated)) {
Expand Down
31 changes: 30 additions & 1 deletion src/EthernetConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,35 @@ EthernetConnectionHandler::EthernetConnectionHandler(
_settings.eth.response_timeout = responseTimeout;
}

/******************************************************************************
PUBLIC MEMBER FUNCTIONS
******************************************************************************/

int EthernetConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
#if defined(ARDUINO_ARCH_ZEPHYR)
return 0;
#else
return Ethernet.ping(ip);
#endif // ARDUINO_ARCH_ZEPHYR
}

int EthernetConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
#if defined(ARDUINO_ARCH_ZEPHYR)
return 0;
#else
return Ethernet.ping(hostname);
#endif // ARDUINO_ARCH_ZEPHYR
}

int EthernetConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
#if defined(ARDUINO_ARCH_ZEPHYR)
return 0;
#else
return Ethernet.ping(host);
#endif // ARDUINO_ARCH_ZEPHYR
}


/******************************************************************************
PROTECTED MEMBER FUNCTIONS
******************************************************************************/
Expand Down Expand Up @@ -110,7 +139,7 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
return NetworkConnectionState::CONNECTED;
}

int ping_result = Ethernet.ping("time.arduino.cc");
int ping_result = ping("time.arduino.cc");
DEBUG_INFO(F("Ethernet.ping(): %d"), ping_result);
if (ping_result < 0)
{
Expand Down
4 changes: 4 additions & 0 deletions src/EthernetConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class EthernetConnectionHandler : public ConnectionHandler
unsigned long const responseTimeout = 4000,
bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override { return 0; }
virtual Client & getClient() override{ return _eth_client; }
virtual UDP & getUDP() override { return _eth_udp; }
Expand Down
16 changes: 14 additions & 2 deletions src/GSMConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ unsigned long GSMConnectionHandler::getTime()
return _gsm.getTime();
}

int GSMConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
return _gprs.ping(ip);
}

int GSMConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
return _gprs.ping(hostname);
}

int GSMConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
return _gprs.ping(host);
}

/******************************************************************************
PROTECTED MEMBER FUNCTIONS
******************************************************************************/
Expand Down Expand Up @@ -105,7 +117,7 @@ NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
}

DEBUG_INFO(F("Sending PING to outer space..."));
int const ping_result = _gprs.ping("time.arduino.cc");
int const ping_result = ping("time.arduino.cc");
DEBUG_INFO(F("GPRS.ping(): %d"), ping_result);
if (ping_result < 0)
{
Expand Down Expand Up @@ -144,7 +156,7 @@ NetworkConnectionState GSMConnectionHandler::update_handleDisconnected()
}
else
{
return NetworkConnectionState::CLOSED;
return NetworkConnectionState::CLOSED;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/GSMConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ class GSMConnectionHandler : public ConnectionHandler
GSMConnectionHandler();
GSMConnectionHandler(const char * pin, const char * apn, const char * login, const char * pass, bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override;
virtual Client & getClient() override { return _gsm_client; };
virtual UDP & getUDP() override { return _gsm_udp; };


protected:

virtual NetworkConnectionState update_handleInit () override;
Expand Down
12 changes: 12 additions & 0 deletions src/GenericConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ unsigned long GenericConnectionHandler::getTime() {
return _ch != nullptr ? _ch->getTime() : 0;
}

int GenericConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
return _ch != nullptr ? _ch->ping(ip, ttl, count) : 0;
}

int GenericConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
return _ch != nullptr ? _ch->ping(hostname, ttl, count) : 0;
}

int GenericConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
return _ch != nullptr ? _ch->ping(host, ttl, count) : 0;
}

Client & GenericConnectionHandler::getClient() {
return _ch->getClient(); // NOTE _ch may be nullptr
}
Expand Down
4 changes: 4 additions & 0 deletions src/GenericConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class GenericConnectionHandler : public ConnectionHandler
virtual int read() = 0;
virtual int write(const uint8_t *buf, size_t size) = 0;
#else
int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

unsigned long getTime() override;

/*
Expand Down
12 changes: 12 additions & 0 deletions src/NBConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ unsigned long NBConnectionHandler::getTime()
return _nb.getTime();
}

int NBConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
return 0;
}

int NBConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
return 0;
}

int NBConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
return 0;
}

/******************************************************************************
PRIVATE MEMBER FUNCTIONS
******************************************************************************/
Expand Down
6 changes: 4 additions & 2 deletions src/NBConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class NBConnectionHandler : public ConnectionHandler
NBConnectionHandler(char const * pin, char const * apn, bool const keep_alive = true);
NBConnectionHandler(char const * pin, char const * apn, char const * login, char const * pass, bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override;
virtual Client & getClient() override { return _nb_client; };
virtual UDP & getUDP() override { return _nb_udp; };

virtual UDP & getUDP() override { return _nb_udp; }

protected:

Expand Down
26 changes: 25 additions & 1 deletion src/WiFiConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ unsigned long WiFiConnectionHandler::getTime()
#endif
}

int WiFiConnectionHandler::ping(IPAddress ip, uint8_t ttl, uint8_t count) {
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH_ZEPHYR)
return WiFi.ping(ip);
#else
return 0;
#endif
}

int WiFiConnectionHandler::ping(const String &hostname, uint8_t ttl, uint8_t count) {
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH_ZEPHYR)
return WiFi.ping(hostname);
#else
return 0;
#endif
}

int WiFiConnectionHandler::ping(const char* host, uint8_t ttl, uint8_t count) {
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH_ZEPHYR)
return WiFi.ping(host);
#else
return 0;
#endif
}

/******************************************************************************
PROTECTED MEMBER FUNCTIONS
******************************************************************************/
Expand Down Expand Up @@ -134,7 +158,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
}

#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32)
int ping_result = WiFi.ping("time.arduino.cc");
int ping_result = ping("time.arduino.cc");
DEBUG_INFO(F("WiFi.ping(): %d"), ping_result);
if (ping_result < 0)
{
Expand Down
4 changes: 3 additions & 1 deletion src/WiFiConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ class WiFiConnectionHandler : public ConnectionHandler
WiFiConnectionHandler();
WiFiConnectionHandler(char const * ssid, char const * pass, bool const keep_alive = true);

int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1) override;
int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1) override;

virtual unsigned long getTime() override;
virtual Client & getClient() override { return _wifi_client; }
virtual UDP & getUDP() override { return _wifi_udp; }


protected:

virtual NetworkConnectionState update_handleInit () override;
Expand Down