Skip to content

Commit

Permalink
added getNewSSLClient method
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed Mar 14, 2024
1 parent 03c4e2c commit dc55eb6
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Arduino_ConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class ConnectionHandler {
virtual unsigned long getTime() = 0;
virtual Client &getClient() = 0;
virtual Client *getNewClient() = 0;
virtual Client *getNewSSLClient() = 0;
virtual UDP &getUDP() = 0;
#endif

Expand Down
5 changes: 5 additions & 0 deletions src/Arduino_EthernetConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Arduino_EthernetConnectionHandler.h"

#ifdef BOARD_HAS_ETHERNET /* Only compile if the board has ethernet */
#include "EthernetSSLClient.h"

/******************************************************************************
CTOR/DTOR
Expand Down Expand Up @@ -126,4 +127,8 @@ NetworkConnectionState EthernetConnectionHandler::update_handleDisconnected()
}
}

Client* EthernetConnectionHandler::getNewSSLClient() {
return new EthernetSSLClient();
}

#endif /* #ifdef BOARD_HAS_ETHERNET */
1 change: 1 addition & 0 deletions src/Arduino_EthernetConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class EthernetConnectionHandler : public ConnectionHandler
virtual unsigned long getTime() override { return 0; }
virtual Client & getClient() override{ return _eth_client; }
virtual Client *getNewClient() override { return new EthernetClient(); }
virtual Client *getNewSSLClient();
virtual UDP & getUDP() override { return _eth_udp; }


Expand Down
8 changes: 8 additions & 0 deletions src/Arduino_GSMConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,12 @@ NetworkConnectionState GSMConnectionHandler::update_handleDisconnected()
}
}

Client* GSMConnectionHandler::getNewSSLClient() {
#ifdef ARDUINO_SAMD_MKRGSM1400
return GSMSSLClient();
#else
return nullptr;
#endif
}

#endif /* #ifdef BOARD_HAS_GSM */
1 change: 1 addition & 0 deletions src/Arduino_GSMConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class GSMConnectionHandler : public ConnectionHandler
virtual unsigned long getTime() override;
virtual Client & getClient() override { return _gsm_client; };
virtual Client *getNewClient() override { return new GSMClient(); }
virtual Client *getNewSSLClient();
virtual UDP & getUDP() override { return _gsm_udp; };


Expand Down
4 changes: 4 additions & 0 deletions src/Arduino_NBConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ NetworkConnectionState NBConnectionHandler::update_handleDisconnected()
}
}

Client* NBConnectionHandler::getNewSSLClient() {
return new NBSSLClient();
}

#endif /* #ifdef BOARD_HAS_NB */
1 change: 1 addition & 0 deletions src/Arduino_NBConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class NBConnectionHandler : public ConnectionHandler
virtual unsigned long getTime() override;
virtual Client & getClient() override { return _nb_client; };
virtual Client *getNewClient() override { return new NBClient(); }
virtual Client *getNewSSLClient();
virtual UDP & getUDP() override { return _nb_udp; };


Expand Down
25 changes: 24 additions & 1 deletion src/Arduino_WiFiConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@
******************************************************************************/

#include "Arduino_WiFiConnectionHandler.h"

#ifdef BOARD_HAS_WIFI /* Only compile if the board has WiFi */
#if defined(BOARD_STM32H7)
#include <WiFiSSLClient.h>
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFiClientSecure.h>
#elif defined(ARDUINO_UNOR4_WIFI)
#include <WiFiSSLClient.h>
#elif defined(ARDUINO_PORTENTA_C33)
#include <SSLClient.h>
#elif defined(BOARD_HAS_SE050)
#include <WiFiSSLSE050Client.h>
#endif

#ifdef BOARD_HAS_OFFLOADED_ECCX08
#include <Arduino_SecureElement.h>
#include <WiFiSSLClient.h>
#endif

/******************************************************************************
CONSTANTS
Expand Down Expand Up @@ -170,4 +185,12 @@ NetworkConnectionState WiFiConnectionHandler::update_handleDisconnected()
}
}

Client* WiFiConnectionHandler::getNewSSLClient() {
#ifdef ARDUINO_ARCH_ESP32
return new WiFiClientSecure();
#else
return new WiFiSSLClient();
#endif
}

#endif /* #ifdef BOARD_HAS_WIFI */
1 change: 1 addition & 0 deletions src/Arduino_WiFiConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WiFiConnectionHandler : public ConnectionHandler
virtual unsigned long getTime() override;
virtual Client & getClient() override { return _wifi_client; }
virtual Client *getNewClient() override { return new WiFiClient(); }
virtual Client *getNewSSLClient();
virtual UDP & getUDP() override { return _wifi_udp; }


Expand Down

0 comments on commit dc55eb6

Please sign in to comment.