Skip to content

Commit

Permalink
Don't use stack static stack memory for the client ID. async-mqtt-cli…
Browse files Browse the repository at this point in the history
…ent doesn't make a copy.
  • Loading branch information
sidoh committed Mar 25, 2020
1 parent 36c3197 commit 089597a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/MQTT/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ void MqttClient::begin() {
mqttClient.setKeepAlive(60);

// Configure client
char nameBuffer[30];
sprintf_P(nameBuffer, PSTR("epaper-display-%u"), ESP_CHIP_ID());
sprintf_P(this->clientName, PSTR("epaper-display-%u"), ESP_CHIP_ID());
mqttClient.setClientId(this->clientName);

mqttClient.setClientId(nameBuffer);
if (this->username.length() > 0) {
mqttClient.setCredentials(this->username.c_str(), this->password.c_str());
}
Expand Down
1 change: 1 addition & 0 deletions lib/MQTT/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MqttClient {
String domain;
String username;
String password;
char clientName[30];

unsigned long lastConnectAttempt;
TVariableUpdateFn variableUpdateCallback;
Expand Down

0 comments on commit 089597a

Please sign in to comment.