Skip to content

Commit 089597a

Browse files
committed
Don't use stack static stack memory for the client ID. async-mqtt-client doesn't make a copy.
1 parent 36c3197 commit 089597a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/MQTT/MqttClient.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ void MqttClient::begin() {
7777
mqttClient.setKeepAlive(60);
7878

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

83-
mqttClient.setClientId(nameBuffer);
8483
if (this->username.length() > 0) {
8584
mqttClient.setCredentials(this->username.c_str(), this->password.c_str());
8685
}

lib/MQTT/MqttClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MqttClient {
4242
String domain;
4343
String username;
4444
String password;
45+
char clientName[30];
4546

4647
unsigned long lastConnectAttempt;
4748
TVariableUpdateFn variableUpdateCallback;

0 commit comments

Comments
 (0)