Pre-commit

This commit is contained in:
Cabooman 2024-02-03 22:31:18 +01:00
parent 13bfdcc33b
commit 5fef88504c
4 changed files with 11 additions and 12 deletions

View file

@ -947,11 +947,10 @@ void init_battery(void) {
#ifdef MQTT
void publish_battery_specifics(void) {
static bool first_execution = true;
if(first_execution == true) {
if (first_execution == true) {
first_execution = false;
// Discovery stuff
}
else {
} else {
// Publishing stuff
}
}

View file

@ -107,14 +107,14 @@ static void publish_cell_voltages(void) {
size_t msg_length = snprintf(mqtt_msg, sizeof(mqtt_msg), "{\n\"cell_voltages\":[");
for (size_t i = 0; i < nof_cellvoltages; ++i) {
msg_length +=
snprintf(mqtt_msg + msg_length, sizeof(mqtt_msg) - msg_length, "%s%d", (i == 0) ? "" : ", ", cellvoltages[i]);
msg_length +=
snprintf(mqtt_msg + msg_length, sizeof(mqtt_msg) - msg_length, "%s%d", (i == 0) ? "" : ", ", cellvoltages[i]);
}
snprintf(mqtt_msg + msg_length, sizeof(mqtt_msg) - msg_length, "]\n}\n");
// Publish and print error if not OK
if (mqtt_publish_retain("battery/spec_data") == false) {
Serial.println("Cell voltage MQTT msg could not be sent");
Serial.println("Cell voltage MQTT msg could not be sent");
}
}
}

View file

@ -41,12 +41,12 @@
extern uint16_t SOC;
extern uint16_t StateOfHealth;
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t cell_max_voltage; //mV, 0-4350
extern uint16_t cell_min_voltage; //mV, 0-4350
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t cell_max_voltage; //mV, 0-4350
extern uint16_t cell_min_voltage; //mV, 0-4350
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
extern const char* mqtt_user;
extern const char* mqtt_password;