Skip to content

Commit

Permalink
well I hope this fixes the build
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett Christensen committed Feb 9, 2024
1 parent c8de0d3 commit dff9788
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Software/Software.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

Preferences settings; // Store user settings

const char* version_number = "5.2.0"; // The current software version, shown on webserver
// Interval settings
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
const int interval10 = 10; // Interval for 10ms tasks
Expand Down Expand Up @@ -130,7 +130,9 @@ void setup() {
init_webserver();
#endif

#ifdef EVENTLOGGING
init_events();
#endif

init_CAN();

Expand Down
2 changes: 1 addition & 1 deletion Software/USER_SETTINGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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* 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* 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
2 changes: 2 additions & 0 deletions Software/USER_SETTINGS.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ extern volatile float CHARGER_END_A;
extern bool charger_HV_enabled;
extern bool charger_aux12V_enabled;

extern const uint8_t wifi_channel;

#endif
4 changes: 2 additions & 2 deletions Software/src/devboard/mqtt/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void publish_cell_voltages(void) {
"\"unit_of_measurement\": \"V\","
"\"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'
String cell_topic = topic + String(i + 1) + "/config";
mqtt_publish_retain(cell_topic.c_str());
Expand Down Expand Up @@ -154,7 +154,7 @@ static void publish_common_info(void) {
"\"enabled_by_default\": true,"
"\"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);
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions Software/src/devboard/mqtt/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

#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 StateOfHealth;
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
Expand Down
4 changes: 2 additions & 2 deletions Software/src/devboard/utils/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#ifndef UNIT_TEST
#include <Arduino.h>
extern unsigned long time_seconds;
extern uint32_t previous_millis;
extern unsigned long previous_millis;
extern uint32_t time_seconds;
#endif

#include <stdint.h>
Expand Down
10 changes: 5 additions & 5 deletions Software/src/devboard/webserver/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void init_webserver() {
} else {
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
server.on("/", HTTP_GET,
Expand Down Expand Up @@ -301,7 +301,7 @@ void wifi_monitor() {
if (status != WL_CONNECTED && status != WL_IDLE_STATUS) {
Serial.println(getConnectResultString(status));
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
if (currentMillis - last_wifi_attempt_time > wifi_reconnect_interval) {
last_wifi_attempt_time = currentMillis;
Expand All @@ -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
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password, channel);
WiFi.begin(ssid, password, wifi_channel);
WiFi.setAutoReconnect(true); // Enable auto reconnect
wl_status_t result = static_cast<wl_status_t>(WiFi.waitForConnectResult(INIT_WIFI_CONNECT_TIMEOUT));
}
Expand All @@ -354,7 +354,7 @@ String processor(const String& var) {
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";

// Show version number
content += "<h4>Software version: " + String(versionNumber) + "</h4>";
content += "<h4>Software version: " + String(version_number) + "</h4>";

// Display LED color
content += "<h4>LED color: ";
Expand Down
4 changes: 2 additions & 2 deletions Software/src/devboard/webserver/webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "../mqtt/mqtt.h"
#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 StateOfHealth; //SOH%, 0-100.00 (0-10000)
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
Expand All @@ -40,10 +41,9 @@ extern EVENTS_STRUCT_TYPE entries[EVENT_NOF_EVENTS];

extern const char* ssid;
extern const char* password;
extern const uint8_t channel;
extern const uint8_t wifi_channel;
extern const char* ssidAP;
extern const char* passwordAP;
extern const char* versionNumber;

// Common charger parameters
extern float charger_stat_HVcur;
Expand Down

0 comments on commit dff9788

Please sign in to comment.