mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
compile fixes and MQTT clientId name
This commit is contained in:
parent
b5d9f1a4be
commit
e328bfd37b
1 changed files with 8 additions and 7 deletions
|
@ -16,9 +16,9 @@ char mqtt_msg[MQTT_MSG_BUFFER_SIZE];
|
|||
MyTimer publish_global_timer(5000); //publish timer
|
||||
MyTimer check_global_timer(800); // check timmer - low-priority MQTT checks, where responsiveness is not critical.
|
||||
|
||||
static const char* topic_name = "";
|
||||
static const char* object_id_prefix = "";
|
||||
static const char* device_name = "";
|
||||
static String topic_name = "";
|
||||
static String object_id_prefix = "";
|
||||
static String device_name = "";
|
||||
|
||||
// Tracking reconnection attempts and failures
|
||||
static unsigned long lastReconnectAttempt = 0;
|
||||
|
@ -314,7 +314,7 @@ static bool reconnect() {
|
|||
Serial.print("Attempting MQTT connection... ");
|
||||
#endif // DEBUG_VIA_USB
|
||||
char clientId[64]; // Adjust the size as needed
|
||||
snprintf(clientId, sizeof(clientId), "LilyGoClient-%s", topic_name);
|
||||
snprintf(clientId, sizeof(clientId), "BatteryEmulatorClient-%s", WiFi.getHostname());
|
||||
// Attempt to connect
|
||||
if (client.connect(clientId, mqtt_user, mqtt_password)) {
|
||||
connected_once = true;
|
||||
|
@ -349,9 +349,10 @@ void init_mqtt(void) {
|
|||
device_name = mqtt_device_name;
|
||||
#else
|
||||
// Use default naming based on WiFi hostname for topic, object ID prefix, and device name
|
||||
topic_name = String("battery-emulator_") + WiFi.getHostname();
|
||||
object_id_prefix = WiFi.getHostname() + String("_");
|
||||
device_name = "BatteryEmulator_" + String(hostname);
|
||||
topic_name = String("battery-emulator_") + String(WiFi.getHostname());
|
||||
object_id_prefix = String(WiFi.getHostname()) + String("_");
|
||||
device_name = "BatteryEmulator_" + String(WiFi.getHostname());
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue