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
|
@ -71,7 +71,7 @@ uint16_t stat_batt_power = 0; // Power going in/out of battery
|
|||
uint16_t cell_max_voltage = 3700; // Stores the highest cell voltage value in the system
|
||||
uint16_t cell_min_voltage = 3700; // Stores the minimum cell voltage value in the system
|
||||
uint16_t cellvoltages[120]; // Stores all cell voltages
|
||||
uint8_t nof_cellvoltages = 0; // Total number of cell voltages, set by each battery.
|
||||
uint8_t nof_cellvoltages = 0; // Total number of cell voltages, set by each battery.
|
||||
bool LFP_Chemistry = false;
|
||||
|
||||
// Common charger parameters
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue