mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Pre-commit
This commit is contained in:
parent
620db2cc33
commit
12b83e7605
3 changed files with 4 additions and 9 deletions
|
@ -930,7 +930,6 @@ uint16_t Temp_fromRAW_to_F(uint16_t temperature) { //This function feels horrib
|
||||||
|
|
||||||
#ifdef MQTT
|
#ifdef MQTT
|
||||||
void publish_data(void) {
|
void publish_data(void) {
|
||||||
Serial.println("Publishing...");
|
|
||||||
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 < 97; ++i) {
|
for (size_t i = 0; i < 97; ++i) {
|
||||||
|
|
|
@ -28,12 +28,8 @@ static void publish_values(void) {
|
||||||
" \"cell_max_voltage\": %d,\n"
|
" \"cell_max_voltage\": %d,\n"
|
||||||
" \"cell_min_voltage\": %d\n"
|
" \"cell_min_voltage\": %d\n"
|
||||||
"}\n",
|
"}\n",
|
||||||
((float)SOC) / 100.0,
|
((float)SOC) / 100.0, ((float)StateOfHealth) / 100.0, ((float)((int16_t)temperature_min)) / 10.0,
|
||||||
((float)StateOfHealth) / 100.0,
|
((float)((int16_t)temperature_max)) / 10.0, cell_max_voltage, cell_min_voltage);
|
||||||
((float)((int16_t)temperature_min)) / 10.0,
|
|
||||||
((float)((int16_t)temperature_max)) / 10.0,
|
|
||||||
cell_max_voltage,
|
|
||||||
cell_min_voltage);
|
|
||||||
bool result = client.publish("battery_testing/info", mqtt_msg, true);
|
bool result = client.publish("battery_testing/info", mqtt_msg, true);
|
||||||
Serial.println(mqtt_msg); // Uncomment to print the payload on serial
|
Serial.println(mqtt_msg); // Uncomment to print the payload on serial
|
||||||
}
|
}
|
||||||
|
@ -98,6 +94,6 @@ void mqtt_loop(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mqtt_publish_retain(const char *topic) {
|
bool mqtt_publish_retain(const char* topic) {
|
||||||
return client.publish(topic, mqtt_msg, true);
|
return client.publish(topic, mqtt_msg, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,6 @@ extern char mqtt_msg[MSG_BUFFER_SIZE];
|
||||||
|
|
||||||
void init_mqtt(void);
|
void init_mqtt(void);
|
||||||
void mqtt_loop(void);
|
void mqtt_loop(void);
|
||||||
bool mqtt_publish_retain(const char *topic);
|
bool mqtt_publish_retain(const char* topic);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue