mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 02:39:57 +02:00
Pre-commit
This commit is contained in:
parent
13bfdcc33b
commit
5fef88504c
4 changed files with 11 additions and 12 deletions
|
@ -947,11 +947,10 @@ void init_battery(void) {
|
||||||
#ifdef MQTT
|
#ifdef MQTT
|
||||||
void publish_battery_specifics(void) {
|
void publish_battery_specifics(void) {
|
||||||
static bool first_execution = true;
|
static bool first_execution = true;
|
||||||
if(first_execution == true) {
|
if (first_execution == true) {
|
||||||
first_execution = false;
|
first_execution = false;
|
||||||
// Discovery stuff
|
// Discovery stuff
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Publishing stuff
|
// Publishing stuff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,14 +107,14 @@ static void publish_cell_voltages(void) {
|
||||||
|
|
||||||
size_t msg_length = snprintf(mqtt_msg, sizeof(mqtt_msg), "{\n\"cell_voltages\":[");
|
size_t msg_length = snprintf(mqtt_msg, sizeof(mqtt_msg), "{\n\"cell_voltages\":[");
|
||||||
for (size_t i = 0; i < nof_cellvoltages; ++i) {
|
for (size_t i = 0; i < nof_cellvoltages; ++i) {
|
||||||
msg_length +=
|
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, "%s%d", (i == 0) ? "" : ", ", cellvoltages[i]);
|
||||||
}
|
}
|
||||||
snprintf(mqtt_msg + msg_length, sizeof(mqtt_msg) - msg_length, "]\n}\n");
|
snprintf(mqtt_msg + msg_length, sizeof(mqtt_msg) - msg_length, "]\n}\n");
|
||||||
|
|
||||||
// Publish and print error if not OK
|
// Publish and print error if not OK
|
||||||
if (mqtt_publish_retain("battery/spec_data") == false) {
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
|
|
||||||
extern uint16_t SOC;
|
extern uint16_t SOC;
|
||||||
extern uint16_t StateOfHealth;
|
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_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 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_max_voltage; //mV, 0-4350
|
||||||
extern uint16_t cell_min_voltage; //mV, 0-4350
|
extern uint16_t cell_min_voltage; //mV, 0-4350
|
||||||
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
|
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_user;
|
||||||
extern const char* mqtt_password;
|
extern const char* mqtt_password;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue