Skip to content

Commit

Permalink
MQTT: Set username and password as local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kumajaya authored and azoitl committed Feb 26, 2024
1 parent d0e8235 commit 0fade00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/com/mqtt_paho/MQTTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ int CMQTTClient::initClient() {
mClientConnectionOptions.context = this;

if ("" != gMqttClientConfigFile) { //file was provided
std::string mUsername;
std::string mPassword;
CMQTTClientConfigFileParser::MQTTConfigFromFile result = CMQTTClientConfigFileParser::MQTTConfigFromFile(mUsername, mPassword);
std::string endpoint = mAddress;
if(CMQTTClientConfigFileParser::loadConfig(gMqttClientConfigFile, endpoint, result)) {
if (CMQTTClientConfigFileParser::loadConfig(gMqttClientConfigFile, mAddress, result)) {
mClientConnectionOptions.username = mUsername.c_str();
mClientConnectionOptions.password = mPassword.c_str();
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/com/mqtt_paho/MQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class CMQTTClient {

std::string mAddress;
std::string mClientId;
std::string mUsername;
std::string mPassword;

MQTTAsync mAsClient;
MQTTAsync_connectOptions mClientConnectionOptions;
Expand Down

0 comments on commit 0fade00

Please sign in to comment.