fix: single point of truth for secure client network

This commit is contained in:
Florian Grandel
2021-12-22 02:53:35 +01:00
parent 59fd3ec598
commit 135e79e4da
4 changed files with 7 additions and 9 deletions

View File

@@ -34,7 +34,7 @@ char* currentDateTime(void);
static const char* theClientStatus[] = { "InPool", "Disconnected", "TryConnecting", "Connecting", "Active", "Asleep", "Awake",
"Lost" };
Client::Client(bool secure)
Client::Client()
{
_packetId = 0;
_snMsgId = 0;
@@ -45,8 +45,7 @@ Client::Client(bool secure)
_willTopic = nullptr;
_willMsg = nullptr;
_connectData = MQTTPacket_Connect_Initializer;
_network = new Network(secure);
_secureNetwork = secure;
_network = new Network();
_sensorNetype = true;
_connAck = nullptr;
_waitWillMsgFlg = false;
@@ -426,7 +425,7 @@ bool Client::isConnecting(void)
bool Client::isSecureNetwork(void)
{
return _secureNetwork;
return _network->isSecure();
}
bool Client::isSensorNetStable(void)

View File

@@ -179,8 +179,7 @@ class Client
friend class ClientList;
friend class ClientsPool;
public:
Client(bool secure = false);
Client(uint8_t maxInflightMessages, bool secure);
Client();
~Client();
Connect* getConnectData(void);

View File

@@ -238,11 +238,11 @@ int Network::_numOfInstance = 0;
SSL_CTX* Network::_ctx = 0;
SSL_SESSION* Network::_session = 0;
Network::Network(bool secure) :
Network::Network() :
TCPStack()
{
_ssl = 0;
_secureFlg = secure;
_secureFlg = false;
_busy = false;
_sslValid = false;
}

View File

@@ -68,7 +68,7 @@ private:
class Network: public TCPStack
{
public:
Network(bool secure);
Network();
virtual ~Network();
bool connect(const char* host, const char* port, const char* caPath, const char* caFile, const char* cert, const char* prvkey);