mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
well I hope this fixes the build
This commit is contained in:
parent
c8de0d3af9
commit
dff9788b96
8 changed files with 19 additions and 13 deletions
|
@ -22,7 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Preferences settings; // Store user settings
|
Preferences settings; // Store user settings
|
||||||
|
const char* version_number = "5.2.0"; // The current software version, shown on webserver
|
||||||
// Interval settings
|
// Interval settings
|
||||||
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
|
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
|
||||||
const int interval10 = 10; // Interval for 10ms tasks
|
const int interval10 = 10; // Interval for 10ms tasks
|
||||||
|
@ -130,7 +130,9 @@ void setup() {
|
||||||
init_webserver();
|
init_webserver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef EVENTLOGGING
|
||||||
init_events();
|
init_events();
|
||||||
|
#endif
|
||||||
|
|
||||||
init_CAN();
|
init_CAN();
|
||||||
|
|
||||||
|
|
|
@ -36,5 +36,5 @@ const char* ssid = "REPLACE_WITH_YOUR_SSID"; // Maximum of 63 character
|
||||||
const char* password = "REPLACE_WITH_YOUR_PASSWORD"; // Minimum of 8 characters;
|
const char* password = "REPLACE_WITH_YOUR_PASSWORD"; // Minimum of 8 characters;
|
||||||
const char* ssidAP = "Battery Emulator"; // Maximum of 63 characters;
|
const char* ssidAP = "Battery Emulator"; // Maximum of 63 characters;
|
||||||
const char* passwordAP = "123456789"; // Minimum of 8 characters; set to NULL if you want the access point to be open
|
const char* passwordAP = "123456789"; // Minimum of 8 characters; set to NULL if you want the access point to be open
|
||||||
const char* versionNumber = "5.0.1"; // The current software version, shown on webserver
|
const uint8_t wifi_channel = 0; // set to 0 for automatic channel selection
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -75,4 +75,6 @@ extern volatile float CHARGER_END_A;
|
||||||
extern bool charger_HV_enabled;
|
extern bool charger_HV_enabled;
|
||||||
extern bool charger_aux12V_enabled;
|
extern bool charger_aux12V_enabled;
|
||||||
|
|
||||||
|
extern const uint8_t wifi_channel;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void publish_cell_voltages(void) {
|
||||||
"\"unit_of_measurement\": \"V\","
|
"\"unit_of_measurement\": \"V\","
|
||||||
"\"value_template\": \"{{ value_json.cell_voltages[%d] }}\""
|
"\"value_template\": \"{{ value_json.cell_voltages[%d] }}\""
|
||||||
"}",
|
"}",
|
||||||
i + 1, versionNumber, i + 1, i + 1, i);
|
i + 1, version_number, i + 1, i + 1, i);
|
||||||
// End each discovery topic with cell number and '/config'
|
// End each discovery topic with cell number and '/config'
|
||||||
String cell_topic = topic + String(i + 1) + "/config";
|
String cell_topic = topic + String(i + 1) + "/config";
|
||||||
mqtt_publish_retain(cell_topic.c_str());
|
mqtt_publish_retain(cell_topic.c_str());
|
||||||
|
@ -154,7 +154,7 @@ static void publish_common_info(void) {
|
||||||
"\"enabled_by_default\": true,"
|
"\"enabled_by_default\": true,"
|
||||||
"\"state_class\": \"measurement\""
|
"\"state_class\": \"measurement\""
|
||||||
"}",
|
"}",
|
||||||
config.name, state_topic, config.object_id, config.object_id, versionNumber, config.value_template, config.unit, config.device_class);
|
config.name, state_topic, config.object_id, config.object_id, version_number, config.value_template, config.unit, config.device_class);
|
||||||
mqtt_publish_retain(config.topic);
|
mqtt_publish_retain(config.topic);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#define MQTT_MSG_BUFFER_SIZE (1024)
|
#define MQTT_MSG_BUFFER_SIZE (1024)
|
||||||
|
|
||||||
|
extern const char* version_number; // The current software version, used for mqtt
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#ifndef UNIT_TEST
|
#ifndef UNIT_TEST
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
extern unsigned long time_seconds;
|
extern unsigned long previous_millis;
|
||||||
extern uint32_t previous_millis;
|
extern uint32_t time_seconds;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -60,7 +60,7 @@ void init_webserver() {
|
||||||
} else {
|
} else {
|
||||||
WiFi.mode(WIFI_STA); // Only Router connection
|
WiFi.mode(WIFI_STA); // Only Router connection
|
||||||
}
|
}
|
||||||
init_WiFi_STA(ssid, password, channel);
|
init_WiFi_STA(ssid, password, wifi_channel);
|
||||||
|
|
||||||
// Route for root / web page
|
// Route for root / web page
|
||||||
server.on("/", HTTP_GET,
|
server.on("/", HTTP_GET,
|
||||||
|
@ -301,7 +301,7 @@ void wifi_monitor() {
|
||||||
if (status != WL_CONNECTED && status != WL_IDLE_STATUS) {
|
if (status != WL_CONNECTED && status != WL_IDLE_STATUS) {
|
||||||
Serial.println(getConnectResultString(status));
|
Serial.println(getConnectResultString(status));
|
||||||
if(wifi_state == INIT) { //we haven't been connected yet, try the init logic
|
if(wifi_state == INIT) { //we haven't been connected yet, try the init logic
|
||||||
init_WiFi_STA(ssid, password, channel);
|
init_WiFi_STA(ssid, password, wifi_channel);
|
||||||
} else { //we were connected before, try the reconnect logic
|
} else { //we were connected before, try the reconnect logic
|
||||||
if (currentMillis - last_wifi_attempt_time > wifi_reconnect_interval) {
|
if (currentMillis - last_wifi_attempt_time > wifi_reconnect_interval) {
|
||||||
last_wifi_attempt_time = currentMillis;
|
last_wifi_attempt_time = currentMillis;
|
||||||
|
@ -324,11 +324,11 @@ void wifi_monitor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_WiFi_STA(const char* ssid, const char* password, const uint8_t channel) {
|
void init_WiFi_STA(const char* ssid, const char* password, const uint8_t wifi_channel) {
|
||||||
// Connect to Wi-Fi network with SSID and password
|
// Connect to Wi-Fi network with SSID and password
|
||||||
Serial.print("Connecting to ");
|
Serial.print("Connecting to ");
|
||||||
Serial.println(ssid);
|
Serial.println(ssid);
|
||||||
WiFi.begin(ssid, password, channel);
|
WiFi.begin(ssid, password, wifi_channel);
|
||||||
WiFi.setAutoReconnect(true); // Enable auto reconnect
|
WiFi.setAutoReconnect(true); // Enable auto reconnect
|
||||||
wl_status_t result = static_cast<wl_status_t>(WiFi.waitForConnectResult(INIT_WIFI_CONNECT_TIMEOUT));
|
wl_status_t result = static_cast<wl_status_t>(WiFi.waitForConnectResult(INIT_WIFI_CONNECT_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ String processor(const String& var) {
|
||||||
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
||||||
|
|
||||||
// Show version number
|
// Show version number
|
||||||
content += "<h4>Software version: " + String(versionNumber) + "</h4>";
|
content += "<h4>Software version: " + String(version_number) + "</h4>";
|
||||||
|
|
||||||
// Display LED color
|
// Display LED color
|
||||||
content += "<h4>LED color: ";
|
content += "<h4>LED color: ";
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "../mqtt/mqtt.h"
|
#include "../mqtt/mqtt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern const char* version_number; // The current software version, shown on webserver
|
||||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||||
|
@ -40,10 +41,9 @@ extern EVENTS_STRUCT_TYPE entries[EVENT_NOF_EVENTS];
|
||||||
|
|
||||||
extern const char* ssid;
|
extern const char* ssid;
|
||||||
extern const char* password;
|
extern const char* password;
|
||||||
extern const uint8_t channel;
|
extern const uint8_t wifi_channel;
|
||||||
extern const char* ssidAP;
|
extern const char* ssidAP;
|
||||||
extern const char* passwordAP;
|
extern const char* passwordAP;
|
||||||
extern const char* versionNumber;
|
|
||||||
|
|
||||||
// Common charger parameters
|
// Common charger parameters
|
||||||
extern float charger_stat_HVcur;
|
extern float charger_stat_HVcur;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue