mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
Fixes typo
Adds #endif comments
This commit is contained in:
parent
ddb0623983
commit
775ee36d0b
1 changed files with 8 additions and 8 deletions
|
@ -34,7 +34,7 @@ static String generateCellVoltageAutoConfigTopic(int cell_number, const char* ho
|
||||||
static void publish_cell_voltages(void) {
|
static void publish_cell_voltages(void) {
|
||||||
#ifdef HA_AUTODISCOVERY
|
#ifdef HA_AUTODISCOVERY
|
||||||
static bool mqtt_first_transmission = true;
|
static bool mqtt_first_transmission = true;
|
||||||
#endif
|
#endif // HA_AUTODISCOVERY
|
||||||
static JsonDocument doc;
|
static JsonDocument doc;
|
||||||
static const char* hostname = WiFi.getHostname();
|
static const char* hostname = WiFi.getHostname();
|
||||||
static String state_topic = String("battery-emulator_") + String(hostname) + "/spec_data";
|
static String state_topic = String("battery-emulator_") + String(hostname) + "/spec_data";
|
||||||
|
@ -91,7 +91,7 @@ static void publish_cell_voltages(void) {
|
||||||
if (!mqtt_publish(state_topic.c_str(), mqtt_msg, false)) {
|
if (!mqtt_publish(state_topic.c_str(), mqtt_msg, false)) {
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("Cell voltage MQTT msg could not be sent");
|
Serial.println("Cell voltage MQTT msg could not be sent");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
}
|
}
|
||||||
doc.clear();
|
doc.clear();
|
||||||
#ifdef HA_AUTODISCOVERY
|
#ifdef HA_AUTODISCOVERY
|
||||||
|
@ -99,7 +99,7 @@ static void publish_cell_voltages(void) {
|
||||||
#endif // HA_AUTODISCOVERY
|
#endif // HA_AUTODISCOVERY
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HA_AUTODISCOVER
|
#ifdef HA_AUTODISCOVERY
|
||||||
struct SensorConfig {
|
struct SensorConfig {
|
||||||
const char* object_id;
|
const char* object_id;
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -179,7 +179,7 @@ static void publish_common_info(void) {
|
||||||
if (!mqtt_publish(state_topic.c_str(), mqtt_msg, false)) {
|
if (!mqtt_publish(state_topic.c_str(), mqtt_msg, false)) {
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("Common info MQTT msg could not be sent");
|
Serial.println("Common info MQTT msg could not be sent");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
}
|
}
|
||||||
doc.clear();
|
doc.clear();
|
||||||
#ifdef HA_AUTODISCOVERY
|
#ifdef HA_AUTODISCOVERY
|
||||||
|
@ -192,7 +192,7 @@ static void reconnect() {
|
||||||
// attempt one reconnection
|
// attempt one reconnection
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.print("Attempting MQTT connection... ");
|
Serial.print("Attempting MQTT connection... ");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
const char* hostname = WiFi.getHostname();
|
const char* hostname = WiFi.getHostname();
|
||||||
char clientId[64]; // Adjust the size as needed
|
char clientId[64]; // Adjust the size as needed
|
||||||
snprintf(clientId, sizeof(clientId), "LilyGoClient-%s", hostname);
|
snprintf(clientId, sizeof(clientId), "LilyGoClient-%s", hostname);
|
||||||
|
@ -200,13 +200,13 @@ static void reconnect() {
|
||||||
if (client.connect(clientId, mqtt_user, mqtt_password)) {
|
if (client.connect(clientId, mqtt_user, mqtt_password)) {
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.print("failed, rc=");
|
Serial.print("failed, rc=");
|
||||||
Serial.print(client.state());
|
Serial.print(client.state());
|
||||||
Serial.println(" try again in 5 seconds");
|
Serial.println(" try again in 5 seconds");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
// Wait 5 seconds before retrying
|
// Wait 5 seconds before retrying
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ void init_mqtt(void) {
|
||||||
client.setServer(MQTT_SERVER, MQTT_PORT);
|
client.setServer(MQTT_SERVER, MQTT_PORT);
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("MQTT initialized");
|
Serial.println("MQTT initialized");
|
||||||
#endif
|
#endif // DEBUG_VIA_USB
|
||||||
|
|
||||||
previousMillisUpdateVal = millis();
|
previousMillisUpdateVal = millis();
|
||||||
reconnect();
|
reconnect();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue