Fixes typo

Adds #endif comments
This commit is contained in:
Paul Brand 2024-08-28 08:46:30 +02:00
parent ddb0623983
commit 775ee36d0b

View file

@ -34,7 +34,7 @@ static String generateCellVoltageAutoConfigTopic(int cell_number, const char* ho
static void publish_cell_voltages(void) {
#ifdef HA_AUTODISCOVERY
static bool mqtt_first_transmission = true;
#endif
#endif // HA_AUTODISCOVERY
static JsonDocument doc;
static const char* hostname = WiFi.getHostname();
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)) {
#ifdef DEBUG_VIA_USB
Serial.println("Cell voltage MQTT msg could not be sent");
#endif
#endif // DEBUG_VIA_USB
}
doc.clear();
#ifdef HA_AUTODISCOVERY
@ -99,7 +99,7 @@ static void publish_cell_voltages(void) {
#endif // HA_AUTODISCOVERY
}
#ifdef HA_AUTODISCOVER
#ifdef HA_AUTODISCOVERY
struct SensorConfig {
const char* object_id;
const char* name;
@ -179,7 +179,7 @@ static void publish_common_info(void) {
if (!mqtt_publish(state_topic.c_str(), mqtt_msg, false)) {
#ifdef DEBUG_VIA_USB
Serial.println("Common info MQTT msg could not be sent");
#endif
#endif // DEBUG_VIA_USB
}
doc.clear();
#ifdef HA_AUTODISCOVERY
@ -192,7 +192,7 @@ static void reconnect() {
// attempt one reconnection
#ifdef DEBUG_VIA_USB
Serial.print("Attempting MQTT connection... ");
#endif
#endif // DEBUG_VIA_USB
const char* hostname = WiFi.getHostname();
char clientId[64]; // Adjust the size as needed
snprintf(clientId, sizeof(clientId), "LilyGoClient-%s", hostname);
@ -200,13 +200,13 @@ static void reconnect() {
if (client.connect(clientId, mqtt_user, mqtt_password)) {
#ifdef DEBUG_VIA_USB
Serial.println("connected");
#endif
#endif // DEBUG_VIA_USB
} else {
#ifdef DEBUG_VIA_USB
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
#endif
#endif // DEBUG_VIA_USB
// Wait 5 seconds before retrying
}
}
@ -215,7 +215,7 @@ void init_mqtt(void) {
client.setServer(MQTT_SERVER, MQTT_PORT);
#ifdef DEBUG_VIA_USB
Serial.println("MQTT initialized");
#endif
#endif // DEBUG_VIA_USB
previousMillisUpdateVal = millis();
reconnect();