Skip to content

Commit

Permalink
Merge pull request #252 from fgrandel/bugfix/secure-flag
Browse files Browse the repository at this point in the history
fix: secure client networks no longer work with pre-allocated client list
  • Loading branch information
ty4tw authored Dec 26, 2021
2 parents 4508461 + 135e79e commit 27b5c76
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions MQTTSNGateway/src/MQTTSNGWClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -426,7 +425,7 @@ bool Client::isConnecting(void)

bool Client::isSecureNetwork(void)
{
return _secureNetwork;
return _network->isSecure();
}

bool Client::isSensorNetStable(void)
Expand Down
3 changes: 1 addition & 2 deletions MQTTSNGateway/src/MQTTSNGWClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions MQTTSNGateway/src/linux/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion MQTTSNGateway/src/linux/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TCPStack
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);
Expand Down

0 comments on commit 27b5c76

Please sign in to comment.