Merge pull request #1476 from dalathegreat/improvement/even-more-common-image-settings

Improvement: Remove old method to compile, all is now Common Image
This commit is contained in:
Daniel Öster 2025-09-01 21:34:44 +03:00 committed by GitHub
commit 955688fec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
102 changed files with 370 additions and 655 deletions

View file

@ -44,10 +44,6 @@ jobs:
- name: Install PlatformIO Core - name: Install PlatformIO Core
run: pip install --upgrade platformio run: pip install --upgrade platformio
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
- name: Build image for Lilygo - name: Build image for Lilygo
run: pio run -e lilygo_2CAN_330 run: pio run -e lilygo_2CAN_330

View file

@ -44,10 +44,6 @@ jobs:
- name: Install PlatformIO Core - name: Install PlatformIO Core
run: pip install --upgrade platformio run: pip install --upgrade platformio
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
- name: Build image for Lilygo - name: Build image for Lilygo
run: pio run -e lilygo_330 run: pio run -e lilygo_330

View file

@ -44,10 +44,6 @@ jobs:
- name: Install PlatformIO Core - name: Install PlatformIO Core
run: pip install --upgrade platformio run: pip install --upgrade platformio
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
- name: Build image for Stark CMR - name: Build image for Stark CMR
run: pio run -e stark_330 run: pio run -e stark_330

View file

@ -13,7 +13,6 @@ jobs:
- name: Configure and build with CMake - name: Configure and build with CMake
run: | run: |
cp Software/USER_SECRETS.TEMPLATE.h Software/USER_SECRETS.h
cd test cd test
mkdir build mkdir build
cd build cd build

View file

@ -1,7 +1,6 @@
/* Do not change any code below this line unless you are sure what you are doing */ /* Do not change any code below this line unless you are sure what you are doing */
/* Only change battery specific settings in "USER_SETTINGS.h" */ /* Only change battery specific settings in "USER_SETTINGS.h" */
#include "HardwareSerial.h" #include "HardwareSerial.h"
#include "USER_SECRETS.h"
#include "USER_SETTINGS.h" #include "USER_SETTINGS.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_task_wdt.h" #include "esp_task_wdt.h"

View file

@ -1,22 +0,0 @@
/* This file should be renamed to USER_SECRETS.h to be able to use the software!
It contains all the credentials that should never be made public */
#ifndef COMMON_IMAGE
//Password to the access point generated by the Battery-Emulator
#define AP_PASSWORD "123456789" // Minimum of 8 characters; set to blank if you want the access point to be open
//Name and password of Wifi network you want the emulator to connect to
#define WIFI_SSID "REPLACE_WITH_YOUR_SSID" // Maximum of 63 characters
#define WIFI_PASSWORD "REPLACE_WITH_YOUR_PASSWORD" // Minimum of 8 characters
//Set WEBSERVER_AUTH_REQUIRED to true to require a password when accessing the webserver homepage. Improves cybersecurity.
#define WEBSERVER_AUTH_REQUIRED false
#define HTTP_USERNAME "admin" // Username for webserver authentication
#define HTTP_PASSWORD "admin" // Password for webserver authentication
//MQTT credentials
#define MQTT_SERVER "192.168.xxx.yyy" // MQTT server address
#define MQTT_PORT 1883 // MQTT server port
#define MQTT_USER "" // MQTT username, leave blank for no authentication
#define MQTT_PASSWORD "" // MQTT password, leave blank for no authentication
#endif

View file

@ -1,6 +1,5 @@
#include "USER_SETTINGS.h" #include "USER_SETTINGS.h"
#include <string> #include <string>
#include "USER_SECRETS.h"
#include "src/devboard/hal/hal.h" #include "src/devboard/hal/hal.h"
/* This file contains all the battery settings and limits */ /* This file contains all the battery settings and limits */
@ -21,25 +20,14 @@ volatile CAN_Configuration can_config = {
.shunt = CAN_NATIVE // (OPTIONAL) Which CAN is your shunt connected to? .shunt = CAN_NATIVE // (OPTIONAL) Which CAN is your shunt connected to?
}; };
#ifdef COMMON_IMAGE
std::string ssid; std::string ssid;
std::string password; std::string password;
std::string passwordAP; std::string passwordAP;
#else
std::string ssid = WIFI_SSID; // Set in USER_SECRETS.h
std::string password = WIFI_PASSWORD; // Set in USER_SECRETS.h
std::string passwordAP = AP_PASSWORD; // Set in USER_SECRETS.h
#endif
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
#ifdef COMMON_IMAGE
std::string http_username; std::string http_username;
std::string http_password; std::string http_password;
#else
std::string http_username = HTTP_USERNAME; // Set in USER_SECRETS.h
std::string http_password = HTTP_PASSWORD; // Set in USER_SECRETS.h
#endif
// Set your Static IP address. Only used incase WIFICONFIG is set in USER_SETTINGS.h // Set your Static IP address. Only used incase WIFICONFIG is set in USER_SETTINGS.h
IPAddress local_IP(192, 168, 10, 150); IPAddress local_IP(192, 168, 10, 150);
@ -47,13 +35,8 @@ IPAddress gateway(192, 168, 10, 1);
IPAddress subnet(255, 255, 255, 0); IPAddress subnet(255, 255, 255, 0);
// MQTT // MQTT
#ifdef COMMON_IMAGE
std::string mqtt_user; std::string mqtt_user;
std::string mqtt_password; std::string mqtt_password;
#else
std::string mqtt_user = MQTT_USER; // Set in USER_SECRETS.h
std::string mqtt_password = MQTT_PASSWORD; // Set in USER_SECRETS.h
#endif
const char* mqtt_topic_name = const char* mqtt_topic_name =
"BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX" "BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX"

View file

@ -6,8 +6,6 @@
/* This file is being transitioned towards COMMON_IMAGE. Use v8.16 if you are taking this software into use! */ /* This file is being transitioned towards COMMON_IMAGE. Use v8.16 if you are taking this software into use! */
//#define COMMON_IMAGE
/* Select hardware used for Battery-Emulator */ /* Select hardware used for Battery-Emulator */
//#define HW_LILYGO //#define HW_LILYGO
//#define HW_STARK //#define HW_STARK

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RS485Battery.h" #include "RS485Battery.h"
#if !defined(COMMON_IMAGE) && !defined(SELECTED_BATTERY_CLASS)
#error No battery selected! Choose one from the USER_SETTINGS.h file or build COMMON_IMAGE.
#endif
Battery* battery = nullptr; Battery* battery = nullptr;
Battery* battery2 = nullptr; Battery* battery2 = nullptr;
@ -149,11 +145,6 @@ const battery_chemistry_enum battery_chemistry_default = battery_chemistry_enum:
battery_chemistry_enum user_selected_battery_chemistry = battery_chemistry_default; battery_chemistry_enum user_selected_battery_chemistry = battery_chemistry_default;
#ifdef COMMON_IMAGE
#ifdef SELECTED_BATTERY_CLASS
#error "Compile time SELECTED_BATTERY_CLASS should not be defined with COMMON_IMAGE"
#endif
BatteryType user_selected_battery_type = BatteryType::NissanLeaf; BatteryType user_selected_battery_type = BatteryType::NissanLeaf;
bool user_selected_second_battery = false; bool user_selected_second_battery = false;
@ -287,39 +278,6 @@ void setup_battery() {
} }
} }
} }
#else // Battery selection has been made at build-time
void setup_battery() {
// Instantiate the battery only once just in case this function gets called multiple times.
if (battery == nullptr) {
#ifdef TESLA_MODEL_3Y_BATTERY
battery = new SELECTED_BATTERY_CLASS(user_selected_battery_chemistry);
#else
battery = new SELECTED_BATTERY_CLASS();
#endif
}
battery->setup();
#ifdef DOUBLE_BATTERY
if (battery2 == nullptr) {
#if defined(BMW_I3_BATTERY)
battery2 =
new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double, esp32hal->WUP_PIN2());
#elif defined(KIA_HYUNDAI_64_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer_extended.KiaHyundai64_2,
&datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double);
#elif defined(SANTA_FE_PHEV_BATTERY) || defined(TEST_FAKE_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, can_config.battery_double);
#else
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, nullptr, can_config.battery_double);
#endif
}
battery2->setup();
#endif
}
#endif
/* User-selected Tesla settings */ /* User-selected Tesla settings */
bool user_selected_tesla_digital_HVIL = false; bool user_selected_tesla_digital_HVIL = false;
@ -329,7 +287,7 @@ uint16_t user_selected_tesla_GTW_mapRegion = 2;
uint16_t user_selected_tesla_GTW_chassisType = 2; uint16_t user_selected_tesla_GTW_chassisType = 2;
uint16_t user_selected_tesla_GTW_packEnergy = 1; uint16_t user_selected_tesla_GTW_packEnergy = 1;
// Use 0V for user selected cell/pack voltage defaults (COMMON_IMAGE will replace with saved values from NVM) // Use 0V for user selected cell/pack voltage defaults (On boot will be replaced with saved values from NVM)
uint16_t user_selected_max_pack_voltage_dV = 0; uint16_t user_selected_max_pack_voltage_dV = 0;
uint16_t user_selected_min_pack_voltage_dV = 0; uint16_t user_selected_min_pack_voltage_dV = 0;
uint16_t user_selected_max_cell_voltage_mV = 0; uint16_t user_selected_max_cell_voltage_mV = 0;

View file

@ -6,10 +6,6 @@
#include "BMW-I3-HTML.h" #include "BMW-I3-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_I3_BATTERY
#define SELECTED_BATTERY_CLASS BmwI3Battery
#endif
class BmwI3Battery : public CanBattery { class BmwI3Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -37,7 +37,7 @@ uint8_t BmwIXBattery::increment_alive_counter(uint8_t counter) {
return counter; return counter;
} }
static byte increment_C0_counter(byte counter) { static uint8_t increment_C0_counter(uint8_t counter) {
counter++; counter++;
// Reset to 0xF0 if it exceeds 0xFE // Reset to 0xF0 if it exceeds 0xFE
if (counter > 0xFE) { if (counter > 0xFE) {
@ -459,10 +459,12 @@ void BmwIXBattery::setup(void) { // Performs one time setup at startup
void BmwIXBattery::HandleIncomingUserRequest(void) { void BmwIXBattery::HandleIncomingUserRequest(void) {
// Debug user request to open or close the contactors // Debug user request to open or close the contactors
logging.print("User request: contactor close: "); if (userRequestContactorClose) {
logging.print(userRequestContactorClose); logging.printf("User request: contactor close");
logging.print(" User request: contactor open: "); }
logging.println(userRequestContactorOpen); if (userRequestContactorOpen) {
logging.printf("User request: contactor open");
}
if ((userRequestContactorClose == false) && (userRequestContactorOpen == false)) { if ((userRequestContactorClose == false) && (userRequestContactorOpen == false)) {
// do nothing // do nothing
} else if ((userRequestContactorClose == true) && (userRequestContactorOpen == false)) { } else if ((userRequestContactorClose == true) && (userRequestContactorOpen == false)) {

View file

@ -4,10 +4,6 @@
#include "BMW-IX-HTML.h" #include "BMW-IX-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_IX_BATTERY
#define SELECTED_BATTERY_CLASS BmwIXBattery
#endif
class BmwIXBattery : public CanBattery { class BmwIXBattery : public CanBattery {
public: public:
BmwIXBattery() : renderer(*this) {} BmwIXBattery() : renderer(*this) {}

View file

@ -1,5 +1,6 @@
#include "BMW-PHEV-BATTERY.h" #include "BMW-PHEV-BATTERY.h"
#include <Arduino.h> #include <Arduino.h>
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"
@ -149,15 +150,6 @@ uint8_t BmwPhevBattery::increment_alive_counter(uint8_t counter) {
return counter; return counter;
} }
static byte increment_0C0_counter(byte counter) {
counter++;
// Reset to 0xF0 if it exceeds 0xFE
if (counter > 0xFE) {
counter = 0xF0;
}
return counter;
}
void BmwPhevBattery::processCellVoltages() { void BmwPhevBattery::processCellVoltages() {
const int startByte = 3; // Start reading at byte 3 const int startByte = 3; // Start reading at byte 3
const int numVoltages = 96; // Number of cell voltage values to process const int numVoltages = 96; // Number of cell voltage values to process
@ -469,7 +461,7 @@ void BmwPhevBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
#endif // DEBUG_LOG && UDS_LOG #endif // DEBUG_LOG && UDS_LOG
transmit_can_frame(&BMW_6F1_REQUEST_CONTINUE_MULTIFRAME); transmit_can_frame(&BMW_6F1_REQUEST_CONTINUE_MULTIFRAME);
gUDSContext.receivedInBatch = 0; // Reset batch count gUDSContext.receivedInBatch = 0; // Reset batch count
Serial.println("Sent FC for next batch of 3 frames."); logging.println("Sent FC for next batch of 3 frames.");
} }
break; break;
@ -513,18 +505,18 @@ void BmwPhevBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
battery_current = ((int32_t)((gUDSContext.UDS_buffer[3] << 24) | (gUDSContext.UDS_buffer[4] << 16) | battery_current = ((int32_t)((gUDSContext.UDS_buffer[3] << 24) | (gUDSContext.UDS_buffer[4] << 16) |
(gUDSContext.UDS_buffer[5] << 8) | gUDSContext.UDS_buffer[6])) * (gUDSContext.UDS_buffer[5] << 8) | gUDSContext.UDS_buffer[6])) *
0.1; 0.1;
logging.print("Received current/amps measurement data: "); logging.printf("Received current/amps measurement data: ");
logging.print(battery_current); logging.print(battery_current);
logging.print(" - "); logging.printf(" - ");
for (uint16_t i = 0; i < gUDSContext.UDS_bytesReceived; i++) { for (uint16_t i = 0; i < gUDSContext.UDS_bytesReceived; i++) {
// Optional leading zero for single-digit hex // Optional leading zero for single-digit hex
if (gUDSContext.UDS_buffer[i] < 0x10) { if (gUDSContext.UDS_buffer[i] < 0x10) {
logging.print("0"); logging.printf("0");
} }
logging.print(gUDSContext.UDS_buffer[i], HEX); logging.print(gUDSContext.UDS_buffer[i], HEX);
logging.print(" "); logging.printf(" ");
} }
logging.println(); // new line at the end logging.println(""); // new line at the end
} }
//Cell Min/Max //Cell Min/Max
@ -540,14 +532,14 @@ void BmwPhevBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
max_cell_voltage = (gUDSContext.UDS_buffer[11] << 8 | gUDSContext.UDS_buffer[12]) / 10; max_cell_voltage = (gUDSContext.UDS_buffer[11] << 8 | gUDSContext.UDS_buffer[12]) / 10;
} else { } else {
logging.println("Cell Min Max Invalid 65535 or 0..."); logging.println("Cell Min Max Invalid 65535 or 0...");
logging.print("Received data: "); logging.printf("Received data: ");
for (uint16_t i = 0; i < gUDSContext.UDS_bytesReceived; i++) { for (uint16_t i = 0; i < gUDSContext.UDS_bytesReceived; i++) {
// Optional leading zero for single-digit hex // Optional leading zero for single-digit hex
if (gUDSContext.UDS_buffer[i] < 0x10) { if (gUDSContext.UDS_buffer[i] < 0x10) {
logging.print("0"); logging.printf("0");
} }
logging.print(gUDSContext.UDS_buffer[i], HEX); logging.print(gUDSContext.UDS_buffer[i], HEX);
logging.print(" "); logging.printf(" ");
} }
logging.println(); // new line at the end logging.println(); // new line at the end
} }
@ -678,7 +670,7 @@ void BmwPhevBattery::transmit_can(unsigned long currentMillis) {
} }
void BmwPhevBattery::setup(void) { // Performs one time setup at startup void BmwPhevBattery::setup(void) { // Performs one time setup at startup
strncpy(datalayer.system.info.battery_protocol, "BMW PHEV Battery", 63); strncpy(datalayer.system.info.battery_protocol, Name, 63);
datalayer.system.info.battery_protocol[63] = '\0'; datalayer.system.info.battery_protocol[63] = '\0';
//Wakeup the SME //Wakeup the SME
wake_battery_via_canbus(); wake_battery_via_canbus();

View file

@ -3,10 +3,6 @@
#include "BMW-PHEV-HTML.h" #include "BMW-PHEV-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BMW_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS BmwPhevBattery
#endif
class BmwPhevBattery : public CanBattery { class BmwPhevBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);
@ -14,6 +10,8 @@ class BmwPhevBattery : public CanBattery {
virtual void update_values(); virtual void update_values();
virtual void transmit_can(unsigned long currentMillis); virtual void transmit_can(unsigned long currentMillis);
static constexpr const char* Name = "BMW PHEV Battery";
BatteryHtmlRenderer& get_status_renderer() { return renderer; } BatteryHtmlRenderer& get_status_renderer() { return renderer; }
private: private:

View file

@ -1,4 +1,5 @@
#include "BOLT-AMPERA-BATTERY.h" #include "BOLT-AMPERA-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"

View file

@ -3,10 +3,6 @@
#include "BOLT-AMPERA-HTML.h" #include "BOLT-AMPERA-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef BOLT_AMPERA_BATTERY
#define SELECTED_BATTERY_CLASS BoltAmperaBattery
#endif
class BoltAmperaBattery : public CanBattery { class BoltAmperaBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,4 +1,5 @@
#include "BYD-ATTO-3-BATTERY.h" #include "BYD-ATTO-3-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"

View file

@ -24,9 +24,6 @@ static const int RAMPDOWN_POWER_ALLOWED =
10000; // Power to start ramp down from, set a lower value to limit the power even further as SOC decreases 10000; // Power to start ramp down from, set a lower value to limit the power even further as SOC decreases
/* Do not modify the rows below */ /* Do not modify the rows below */
#ifdef BYD_ATTO_3_BATTERY
#define SELECTED_BATTERY_CLASS BydAttoBattery
#endif
class BydAttoBattery : public CanBattery { class BydAttoBattery : public CanBattery {
public: public:

View file

@ -3,10 +3,6 @@
#include "CELLPOWER-HTML.h" #include "CELLPOWER-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CELLPOWER_BMS
#define SELECTED_BATTERY_CLASS CellPowerBms
#endif
class CellPowerBms : public CanBattery { class CellPowerBms : public CanBattery {
public: public:
CellPowerBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} CellPowerBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -120,7 +120,7 @@ void ChademoBattery::process_vehicle_charging_session(CAN_frame rx_frame) {
uint8_t chargingrate = 0; uint8_t chargingrate = 0;
if (x100_chg_lim.ConstantOfChargingRateIndication > 0) { if (x100_chg_lim.ConstantOfChargingRateIndication > 0) {
chargingrate = x102_chg_session.StateOfCharge / x100_chg_lim.ConstantOfChargingRateIndication * 100; chargingrate = x102_chg_session.StateOfCharge / x100_chg_lim.ConstantOfChargingRateIndication * 100;
logging.print("Charge Rate (kW): "); logging.printf("Charge Rate (kW): ");
logging.println(chargingrate); logging.println(chargingrate);
} }
@ -220,9 +220,9 @@ void ChademoBattery::process_vehicle_charging_limits(CAN_frame rx_frame) {
if (get_measured_voltage() <= x200_discharge_limits.MinimumDischargeVoltage && CHADEMO_Status > CHADEMO_NEGOTIATE) { if (get_measured_voltage() <= x200_discharge_limits.MinimumDischargeVoltage && CHADEMO_Status > CHADEMO_NEGOTIATE) {
logging.println("x200 minimum discharge voltage met or exceeded, stopping."); logging.println("x200 minimum discharge voltage met or exceeded, stopping.");
logging.print("Measured: "); logging.printf("Measured: ");
logging.print(get_measured_voltage()); logging.print(get_measured_voltage());
logging.print("Minimum voltage: "); logging.printf("Minimum voltage: ");
logging.print(x200_discharge_limits.MinimumDischargeVoltage); logging.print(x200_discharge_limits.MinimumDischargeVoltage);
CHADEMO_Status = CHADEMO_STOP; CHADEMO_Status = CHADEMO_STOP;
} }
@ -240,9 +240,9 @@ void ChademoBattery::process_vehicle_discharge_estimate(CAN_frame rx_frame) {
if (currentMillis - previousMillis5000 >= INTERVAL_5_S) { if (currentMillis - previousMillis5000 >= INTERVAL_5_S) {
previousMillis5000 = currentMillis; previousMillis5000 = currentMillis;
logging.print("x201 availabile vehicle energy, completion time: "); logging.printf("x201 availabile vehicle energy, completion time: ");
logging.println(x201_discharge_estimate.AvailableVehicleEnergy); logging.println(x201_discharge_estimate.AvailableVehicleEnergy);
logging.print("x201 approx vehicle completion time: "); logging.printf("x201 approx vehicle completion time: ");
logging.println(x201_discharge_estimate.ApproxDischargeCompletionTime); logging.println(x201_discharge_estimate.ApproxDischargeCompletionTime);
} }
} }
@ -766,7 +766,7 @@ void ChademoBattery::handle_chademo_sequence() {
/* check whether contactors ready, because externally dependent upon inverter allow during discharge */ /* check whether contactors ready, because externally dependent upon inverter allow during discharge */
if (contactors_ready) { if (contactors_ready) {
logging.println("Contactors ready"); logging.println("Contactors ready");
logging.print("Voltage: "); logging.printf("Voltage: ");
logging.println(get_measured_voltage()); logging.println(get_measured_voltage());
/* transition to POWERFLOW state if discharge compatible on both sides */ /* transition to POWERFLOW state if discharge compatible on both sides */
if (x109_evse_state.discharge_compatible && x102_chg_session.s.status.StatusVehicleDischargeCompatible && if (x109_evse_state.discharge_compatible && x102_chg_session.s.status.StatusVehicleDischargeCompatible &&

View file

@ -7,10 +7,6 @@
#include "CHADEMO-BATTERY-HTML.h" #include "CHADEMO-BATTERY-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CHADEMO_BATTERY
#define SELECTED_BATTERY_CLASS ChademoBattery
#endif
class ChademoBattery : public CanBattery { class ChademoBattery : public CanBattery {
public: public:
ChademoBattery() { ChademoBattery() {

View file

@ -22,7 +22,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
#include "CHADEMO-BATTERY.h" #include "CHADEMO-BATTERY.h"
#include "src/devboard/utils/logging.h"
/* Initial frames received from ISA shunts provide invalid during initialization */ /* Initial frames received from ISA shunts provide invalid during initialization */
static int framecount = 0; static int framecount = 0;
@ -87,17 +86,6 @@ void ISA_handleFrame(CAN_frame* frame) {
case 0x510: case 0x510:
case 0x511: case 0x511:
logging.print(millis()); // Example printout, time, ID, length, data: 7553 1DB 8 FF C0 B9 EA 0 0 2 5D
logging.print(" ");
logging.print(frame->ID, HEX);
logging.print(" ");
logging.print(frame->DLC);
logging.print(" ");
for (int i = 0; i < frame->DLC; ++i) {
logging.print(frame->data.u8[i], HEX);
logging.print(" ");
}
logging.println("");
break; break;
case 0x521: case 0x521:
@ -245,7 +233,7 @@ void ISA_initialize() {
ISA_STOP(); ISA_STOP();
delay(500); delay(500);
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
logging.print("ISA Initialization "); logging.printf("ISA Initialization ");
logging.println(i); logging.println(i);
outframe.data.u8[0] = (0x20 + i); outframe.data.u8[0] = (0x20 + i);
@ -382,7 +370,7 @@ void ISA_initCurrent() {
} }
void ISA_getCONFIG(uint8_t i) { void ISA_getCONFIG(uint8_t i) {
logging.print("ISA Get Config "); logging.printf("ISA Get Config ");
logging.println(i); logging.println(i);
outframe.data.u8[0] = (0x60 + i); outframe.data.u8[0] = (0x60 + i);
@ -398,7 +386,7 @@ void ISA_getCONFIG(uint8_t i) {
} }
void ISA_getCAN_ID(uint8_t i) { void ISA_getCAN_ID(uint8_t i) {
logging.print("ISA Get CAN ID "); logging.printf("ISA Get CAN ID ");
logging.println(i); logging.println(i);
outframe.data.u8[0] = (0x50 + i); outframe.data.u8[0] = (0x50 + i);
@ -418,8 +406,8 @@ void ISA_getCAN_ID(uint8_t i) {
} }
void ISA_getINFO(uint8_t i) { void ISA_getINFO(uint8_t i) {
logging.print("ISA Get INFO "); logging.printf("ISA Get INFO ");
logging.println(i, HEX); logging.println(i);
outframe.data.u8[0] = (0x70 + i); outframe.data.u8[0] = (0x70 + i);
outframe.data.u8[1] = 0x00; outframe.data.u8[1] = 0x00;

View file

@ -1,4 +1,5 @@
#include "CMFA-EV-BATTERY.h" #include "CMFA-EV-BATTERY.h"
#include <cstring> //unit tests memcpy
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"

View file

@ -4,10 +4,6 @@
#include "CMFA-EV-HTML.h" #include "CMFA-EV-HTML.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef CMFA_EV_BATTERY
#define SELECTED_BATTERY_CLASS CmfaEvBattery
#endif
class CmfaEvBattery : public CanBattery { class CmfaEvBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -16,7 +16,7 @@ static uint16_t voltage_dV = 0;
static uint32_t remaining_capacity_mAh = 0; static uint32_t remaining_capacity_mAh = 0;
static uint16_t cellvoltages_mV[48] = {0}; static uint16_t cellvoltages_mV[48] = {0};
static uint16_t cellvoltage_min_mV = 3700; static uint16_t cellvoltage_min_mV = 3700;
static uint16_t cellvoltage_max_mV = 3700; static uint16_t cellvoltage_max_mV = 0;
static uint16_t cell_count = 0; static uint16_t cell_count = 0;
static uint16_t SOC = 0; static uint16_t SOC = 0;
static bool has_fault = false; static bool has_fault = false;
@ -109,12 +109,12 @@ uint32_t decode_uint32be(uint8_t data[8], uint8_t offset) {
} }
void dump_buff(const char* msg, uint8_t* buff, uint8_t len) { void dump_buff(const char* msg, uint8_t* buff, uint8_t len) {
logging.print("[DALY-BMS] "); logging.printf("[DALY-BMS] ");
logging.print(msg); logging.printf(msg);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
logging.print(buff[i] >> 4, HEX); logging.print(buff[i] >> 4, HEX);
logging.print(buff[i] & 0xf, HEX); logging.print(buff[i] & 0xf, HEX);
logging.print(" "); logging.printf(" ");
} }
logging.println(); logging.println();
} }

View file

@ -3,10 +3,6 @@
#include "RS485Battery.h" #include "RS485Battery.h"
#ifdef DALY_BMS
#define SELECTED_BATTERY_CLASS DalyBms
#endif
class DalyBms : public RS485Battery { class DalyBms : public RS485Battery {
public: public:
void setup(); void setup();

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "ECMP-HTML.h" #include "ECMP-HTML.h"
#ifdef STELLANTIS_ECMP_BATTERY
#define SELECTED_BATTERY_CLASS EcmpBattery
#endif
class EcmpBattery : public CanBattery { class EcmpBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,4 +1,5 @@
#include "FOXESS-BATTERY.h" #include "FOXESS-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"

View file

@ -2,10 +2,6 @@
#define FOXESS_BATTERY_H #define FOXESS_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef FOXESS_BATTERY
#define SELECTED_BATTERY_CLASS FoxessBattery
#endif
class FoxessBattery : public CanBattery { class FoxessBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,4 +1,5 @@
#include "GEELY-GEOMETRY-C-BATTERY.h" #include "GEELY-GEOMETRY-C-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "GEELY-GEOMETRY-C-HTML.h" #include "GEELY-GEOMETRY-C-HTML.h"
#ifdef GEELY_GEOMETRY_C_BATTERY
#define SELECTED_BATTERY_CLASS GeelyGeometryCBattery
#endif
class GeelyGeometryCBattery : public CanBattery { class GeelyGeometryCBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,6 +1,7 @@
#ifndef _GEELY_GEOMETRY_C_HTML_H #ifndef _GEELY_GEOMETRY_C_HTML_H
#define _GEELY_GEOMETRY_C_HTML_H #define _GEELY_GEOMETRY_C_HTML_H
#include <cstring> //For unit test
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"
#include "../devboard/webserver/BatteryHtmlRenderer.h" #include "../devboard/webserver/BatteryHtmlRenderer.h"

View file

@ -6,10 +6,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "HYUNDAI-IONIQ-28-BATTERY-HTML.h" #include "HYUNDAI-IONIQ-28-BATTERY-HTML.h"
#ifdef HYUNDAI_IONIQ_28_BATTERY
#define SELECTED_BATTERY_CLASS HyundaiIoniq28Battery
#endif
class HyundaiIoniq28Battery : public CanBattery { class HyundaiIoniq28Battery : public CanBattery {
public: public:
// Use the default constructor to create the first or single battery. // Use the default constructor to create the first or single battery.

View file

@ -1,4 +1,5 @@
#include "IMIEV-CZERO-ION-BATTERY.h" #include "IMIEV-CZERO-ION-BATTERY.h"
#include <cstring> //for unit tests
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
@ -76,17 +77,8 @@ void ImievCZeroIonBattery::
if (!BMU_Detected) { if (!BMU_Detected) {
logging.println("BMU not detected, check wiring!"); logging.println("BMU not detected, check wiring!");
//TODO: Raise event
} }
logging.println("Battery Values");
logging.print("BMU SOC: ");
logging.print(BMU_SOC);
logging.print(" BMU Current: ");
logging.print(BMU_Current);
logging.print(" BMU Battery Voltage: ");
logging.print(BMU_PackVoltage);
logging.print(" BMU_Power: ");
logging.print(BMU_Power);
} }
void ImievCZeroIonBattery::handle_incoming_can_frame(CAN_frame rx_frame) { void ImievCZeroIonBattery::handle_incoming_can_frame(CAN_frame rx_frame) {

View file

@ -2,10 +2,6 @@
#define IMIEV_CZERO_ION_BATTERY_H #define IMIEV_CZERO_ION_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef IMIEV_CZERO_ION_BATTERY
#define SELECTED_BATTERY_CLASS ImievCZeroIonBattery
#endif
class ImievCZeroIonBattery : public CanBattery { class ImievCZeroIonBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,4 +1,5 @@
#include "JAGUAR-IPACE-BATTERY.h" #include "JAGUAR-IPACE-BATTERY.h"
#include <cstring> //for unit tests
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
@ -57,9 +58,9 @@ CAN_frame ipace_keep_alive = {.FD = false,
.data = {0x9E, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};*/ .data = {0x9E, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};*/
static void print_units(const char* header, int value, const char* units) { static void print_units(const char* header, int value, const char* units) {
logging.print(header); logging.printf(header);
logging.print(value); logging.printf("%d", value);
logging.print(units); logging.printf(units);
} }
void JaguarIpaceBattery::update_values() { void JaguarIpaceBattery::update_values() {

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef JAGUAR_IPACE_BATTERY
#define SELECTED_BATTERY_CLASS JaguarIpaceBattery
#endif
class JaguarIpaceBattery : public CanBattery { class JaguarIpaceBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -5,10 +5,6 @@
#define ESTIMATE_SOC_FROM_CELLVOLTAGE #define ESTIMATE_SOC_FROM_CELLVOLTAGE
#ifdef KIA_HYUNDAI_64_FD_BATTERY
#define SELECTED_BATTERY_CLASS Kia64FDBattery
#endif
class Kia64FDBattery : public CanBattery { class Kia64FDBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -55,18 +55,6 @@ uint16_t KiaEGmpBattery::estimateSOC(uint16_t packVoltage, uint16_t cellCount, i
// Calculate average cell voltage in millivolts // Calculate average cell voltage in millivolts
uint16_t avgCellVoltage = compensatedPackVoltageMv / cellCount; uint16_t avgCellVoltage = compensatedPackVoltageMv / cellCount;
logging.print("Pack: ");
logging.print(packVoltage / 10.0);
logging.print("V, Current: ");
logging.print(currentAmps / 10.0);
logging.print("A, Drop: ");
logging.print(voltageDrop / 1000.0);
logging.print("V, Comp Pack: ");
logging.print(compensatedPackVoltageMv / 1000.0);
logging.print("V, Avg Cell: ");
logging.print(avgCellVoltage);
logging.println("mV");
// Use the cell voltage lookup table to estimate SOC // Use the cell voltage lookup table to estimate SOC
return estimateSOCFromCell(avgCellVoltage); return estimateSOCFromCell(avgCellVoltage);
} }
@ -182,65 +170,6 @@ void KiaEGmpBattery::update_values() {
if (leadAcidBatteryVoltage < 110) { if (leadAcidBatteryVoltage < 110) {
set_event(EVENT_12V_LOW, leadAcidBatteryVoltage); set_event(EVENT_12V_LOW, leadAcidBatteryVoltage);
} }
/* Safeties verified. Perform USB serial printout if configured to do so */
logging.println(); //sepatator
logging.println("Values from battery: ");
logging.print("SOC BMS: ");
logging.print((uint16_t)SOC_BMS / 10.0, 1);
logging.print("% | SOC Display: ");
logging.print((uint16_t)SOC_Display / 10.0, 1);
logging.print("% | SOH ");
logging.print((uint16_t)batterySOH / 10.0, 1);
logging.println("%");
logging.print((int16_t)batteryAmps / 10.0, 1);
logging.print(" Amps | ");
logging.print((uint16_t)batteryVoltage / 10.0, 1);
logging.print(" Volts | ");
logging.print((int16_t)datalayer.battery.status.active_power_W);
logging.println(" Watts");
logging.print("Allowed Charge ");
logging.print((uint16_t)allowedChargePower * 10);
logging.print(" W | Allowed Discharge ");
logging.print((uint16_t)allowedDischargePower * 10);
logging.println(" W");
logging.print("MaxCellVolt ");
logging.print(CellVoltMax_mV);
logging.print(" mV No ");
logging.print(CellVmaxNo);
logging.print(" | MinCellVolt ");
logging.print(CellVoltMin_mV);
logging.print(" mV No ");
logging.println(CellVminNo);
logging.print("TempHi ");
logging.print((int16_t)temperatureMax);
logging.print("°C TempLo ");
logging.print((int16_t)temperatureMin);
logging.print("°C WaterInlet ");
logging.print((int8_t)temperature_water_inlet);
logging.print("°C PowerRelay ");
logging.print((int8_t)powerRelayTemperature * 2);
logging.println("°C");
logging.print("Aux12volt: ");
logging.print((int16_t)leadAcidBatteryVoltage / 10.0, 1);
logging.println("V | ");
logging.print("BmsManagementMode ");
logging.print((uint8_t)batteryManagementMode, BIN);
if (bitRead((uint8_t)BMS_ign, 2) == 1) {
logging.print(" | BmsIgnition ON");
} else {
logging.print(" | BmsIgnition OFF");
}
if (bitRead((uint8_t)batteryRelay, 0) == 1) {
logging.print(" | PowerRelay ON");
} else {
logging.print(" | PowerRelay OFF");
}
logging.print(" | Inverter ");
logging.print(inverterVoltage);
logging.println(" Volts");
} }
// Getter implementations for HTML renderer // Getter implementations for HTML renderer
@ -321,14 +250,10 @@ void KiaEGmpBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE; datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
break; break;
case 0x7EC: case 0x7EC:
// print_canfd_frame(frame);
switch (rx_frame.data.u8[0]) { switch (rx_frame.data.u8[0]) {
case 0x10: //"PID Header" case 0x10: //"PID Header"
// logging.println ("Send ack");
poll_data_pid = rx_frame.data.u8[4]; poll_data_pid = rx_frame.data.u8[4];
// if (rx_frame.data.u8[4] == poll_data_pid) { transmit_can_frame(&EGMP_7E4_ack); //Send ack to BMS
transmit_can_frame(&EGMP_7E4_ack); //Send ack to BMS if the same frame is sent as polled
// }
break; break;
case 0x21: //First frame in PID group case 0x21: //First frame in PID group
if (poll_data_pid == 1) { if (poll_data_pid == 1) {

View file

@ -5,10 +5,6 @@
#define ESTIMATE_SOC_FROM_CELLVOLTAGE #define ESTIMATE_SOC_FROM_CELLVOLTAGE
#ifdef KIA_E_GMP_BATTERY
#define SELECTED_BATTERY_CLASS KiaEGmpBattery
#endif
class KiaEGmpBattery : public CanBattery { class KiaEGmpBattery : public CanBattery {
public: public:
KiaEGmpBattery() : renderer(*this) {} KiaEGmpBattery() : renderer(*this) {}

View file

@ -1,4 +1,5 @@
#include "KIA-HYUNDAI-64-BATTERY.h" #include "KIA-HYUNDAI-64-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"

View file

@ -5,10 +5,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "KIA-HYUNDAI-64-HTML.h" #include "KIA-HYUNDAI-64-HTML.h"
#ifdef KIA_HYUNDAI_64_BATTERY
#define SELECTED_BATTERY_CLASS KiaHyundai64Battery
#endif
class KiaHyundai64Battery : public CanBattery { class KiaHyundai64Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,6 +1,7 @@
#ifndef _KIA_HYUNDAI_64_HTML_H #ifndef _KIA_HYUNDAI_64_HTML_H
#define _KIA_HYUNDAI_64_HTML_H #define _KIA_HYUNDAI_64_HTML_H
#include <cstring> //For unit test
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"
#include "../devboard/webserver/BatteryHtmlRenderer.h" #include "../devboard/webserver/BatteryHtmlRenderer.h"

View file

@ -1,4 +1,5 @@
#include "KIA-HYUNDAI-HYBRID-BATTERY.h" #include "KIA-HYUNDAI-HYBRID-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"

View file

@ -2,10 +2,6 @@
#define KIA_HYUNDAI_HYBRID_BATTERY_H #define KIA_HYUNDAI_HYBRID_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef KIA_HYUNDAI_HYBRID_BATTERY
#define SELECTED_BATTERY_CLASS KiaHyundaiHybridBattery
#endif
class KiaHyundaiHybridBattery : public CanBattery { class KiaHyundaiHybridBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,6 +1,7 @@
#include "MEB-BATTERY.h" #include "MEB-BATTERY.h"
#include <Arduino.h> #include <Arduino.h>
#include <algorithm> // For std::min and std::max #include <algorithm> // For std::min and std::max
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../communication/can/obd.h" #include "../communication/can/obd.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
@ -1262,8 +1263,6 @@ void MebBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
handle_obd_frame(rx_frame); handle_obd_frame(rx_frame);
break; break;
default: default:
logging.printf("Unknown CAN frame received:\n");
dump_can_frame(rx_frame, MSG_RX);
break; break;
} }
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE; datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "MEB-HTML.h" #include "MEB-HTML.h"
#ifdef MEB_BATTERY
#define SELECTED_BATTERY_CLASS MebBattery
#endif
class MebBattery : public CanBattery { class MebBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,4 +1,5 @@
#include "MG-5-BATTERY.h" #include "MG-5-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
@ -112,7 +113,7 @@ void Mg5Battery::transmit_can(unsigned long currentMillis) {
} }
void Mg5Battery::setup(void) { // Performs one time setup at startup void Mg5Battery::setup(void) { // Performs one time setup at startup
strncpy(datalayer.system.info.battery_protocol, "MG 5 battery", 63); strncpy(datalayer.system.info.battery_protocol, Name, 63);
datalayer.system.info.battery_protocol[63] = '\0'; datalayer.system.info.battery_protocol[63] = '\0';
datalayer.system.status.battery_allows_contactor_closing = true; datalayer.system.status.battery_allows_contactor_closing = true;
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_DV; datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_DV;

View file

@ -2,10 +2,6 @@
#define MG_5_BATTERY_H #define MG_5_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef MG_5_BATTERY
#define SELECTED_BATTERY_CLASS Mg5Battery
#endif
class Mg5Battery : public CanBattery { class Mg5Battery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,10 +1,11 @@
#include "MG-HS-PHEV-BATTERY.h" #include "MG-HS-PHEV-BATTERY.h"
#include <cmath> //For unit test
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../communication/contactorcontrol/comm_contactorcontrol.h" #include "../communication/contactorcontrol/comm_contactorcontrol.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
#include "../devboard/utils/logging.h" #include "../devboard/utils/logging.h"
/* /*
MG HS PHEV 16.6kWh battery integration MG HS PHEV 16.6kWh battery integration

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef MG_HS_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS MgHsPHEVBattery
#endif
class MgHsPHEVBattery : public CanBattery { class MgHsPHEVBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,13 +1,13 @@
#include "NISSAN-LEAF-BATTERY.h" #include "NISSAN-LEAF-BATTERY.h"
#include <cstring> //For unit test
#include "../charger/CHARGERS.h"
#include "../charger/CanCharger.h"
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" //For "More battery info" webpage #include "../datalayer/datalayer_extended.h" //For "More battery info" webpage
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
#include "../devboard/utils/logging.h" #include "../devboard/utils/logging.h"
#include "../charger/CHARGERS.h"
#include "../charger/CanCharger.h"
uint16_t Temp_fromRAW_to_F(uint16_t temperature); uint16_t Temp_fromRAW_to_F(uint16_t temperature);
//Cryptographic functions //Cryptographic functions
void decodeChallengeData(unsigned int SeedInput, unsigned char* Crypt_Output_Buffer); void decodeChallengeData(unsigned int SeedInput, unsigned char* Crypt_Output_Buffer);

View file

@ -6,10 +6,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "NISSAN-LEAF-HTML.h" #include "NISSAN-LEAF-HTML.h"
#ifdef NISSAN_LEAF_BATTERY
#define SELECTED_BATTERY_CLASS NissanLeafBattery
#endif
class NissanLeafBattery : public CanBattery { class NissanLeafBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef ORION_BMS
#define SELECTED_BATTERY_CLASS OrionBms
#endif
class OrionBms : public CanBattery { class OrionBms : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef PYLON_BATTERY
#define SELECTED_BATTERY_CLASS PylonBattery
#endif
class PylonBattery : public CanBattery { class PylonBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,8 +1,8 @@
#include "RANGE-ROVER-PHEV-BATTERY.h" #include "RANGE-ROVER-PHEV-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
/* TODO /* TODO
- LOG files from vehicle needed to determine CAN content needed to send towards battery! - LOG files from vehicle needed to determine CAN content needed to send towards battery!
- BCCM_PMZ_A (0x18B 50ms) - BCCM_PMZ_A (0x18B 50ms)

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RANGE_ROVER_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS RangeRoverPhevBattery
#endif
class RangeRoverPhevBattery : public CanBattery { class RangeRoverPhevBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RELION_BATTERY
#define SELECTED_BATTERY_CLASS RelionBattery
#endif
class RelionBattery : public CanBattery { class RelionBattery : public CanBattery {
public: public:
RelionBattery() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} RelionBattery() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RENAULT_KANGOO_BATTERY
#define SELECTED_BATTERY_CLASS RenaultKangooBattery
#endif
class RenaultKangooBattery : public CanBattery { class RenaultKangooBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,5 +1,6 @@
#include "RENAULT-TWIZY.h" #include "RENAULT-TWIZY.h"
#include <cstdint> #include <cstdint>
#include <cstring> //For unit test
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"

View file

@ -2,10 +2,6 @@
#define RENAULT_TWIZY_BATTERY_H #define RENAULT_TWIZY_BATTERY_H
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RENAULT_TWIZY_BATTERY
#define SELECTED_BATTERY_CLASS RenaultTwizyBattery
#endif
class RenaultTwizyBattery : public CanBattery { class RenaultTwizyBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,10 +1,9 @@
#include "RENAULT-ZOE-GEN1-BATTERY.h" #include "RENAULT-ZOE-GEN1-BATTERY.h"
#include <cstring> //For unit test
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" #include "../datalayer/datalayer_extended.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
void transmit_can_frame(CAN_frame* tx_frame, int interface);
/* Information in this file is based of the OVMS V3 vehicle_renaultzoe.cpp component /* Information in this file is based of the OVMS V3 vehicle_renaultzoe.cpp component
https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/blob/master/vehicle/OVMS.V3/components/vehicle_renaultzoe/src/vehicle_renaultzoe.cpp https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/blob/master/vehicle/OVMS.V3/components/vehicle_renaultzoe/src/vehicle_renaultzoe.cpp
The Zoe BMS apparently does not send total pack voltage, so we use the polled 96x cellvoltages summed up as total voltage The Zoe BMS apparently does not send total pack voltage, so we use the polled 96x cellvoltages summed up as total voltage

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RENAULT-ZOE-GEN1-HTML.h" #include "RENAULT-ZOE-GEN1-HTML.h"
#ifdef RENAULT_ZOE_GEN1_BATTERY
#define SELECTED_BATTERY_CLASS RenaultZoeGen1Battery
#endif
class RenaultZoeGen1Battery : public CanBattery { class RenaultZoeGen1Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "RENAULT-ZOE-GEN2-HTML.h" #include "RENAULT-ZOE-GEN2-HTML.h"
#ifdef RENAULT_ZOE_GEN2_BATTERY
#define SELECTED_BATTERY_CLASS RenaultZoeGen2Battery
#endif
class RenaultZoeGen2Battery : public CanBattery { class RenaultZoeGen2Battery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -4,10 +4,6 @@
#include "../system_settings.h" #include "../system_settings.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef RJXZS_BMS
#define SELECTED_BATTERY_CLASS RjxzsBms
#endif
class RjxzsBms : public CanBattery { class RjxzsBms : public CanBattery {
public: public:
RjxzsBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {} RjxzsBms() : CanBattery(CAN_Speed::CAN_SPEED_250KBPS) {}

View file

@ -4,10 +4,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SAMSUNG_SDI_LV_BATTERY
#define SELECTED_BATTERY_CLASS SamsungSdiLVBattery
#endif
class SamsungSdiLVBattery : public CanBattery { class SamsungSdiLVBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,8 +1,8 @@
#include "SANTA-FE-PHEV-BATTERY.h" #include "SANTA-FE-PHEV-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
/* Credits go to maciek16c for these findings! /* Credits go to maciek16c for these findings!
https://github.com/maciek16c/hyundai-santa-fe-phev-battery https://github.com/maciek16c/hyundai-santa-fe-phev-battery
https://openinverter.org/forum/viewtopic.php?p=62256 https://openinverter.org/forum/viewtopic.php?p=62256

View file

@ -3,10 +3,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SANTA_FE_PHEV_BATTERY
#define SELECTED_BATTERY_CLASS SantaFePhevBattery
#endif
class SantaFePhevBattery : public CanBattery { class SantaFePhevBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,8 +1,8 @@
#include "SIMPBMS-BATTERY.h" #include "SIMPBMS-BATTERY.h"
#include <cstring> //For unit test
#include "../battery/BATTERIES.h" #include "../battery/BATTERIES.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
void SimpBmsBattery::update_values() { void SimpBmsBattery::update_values() {
datalayer.battery.status.real_soc = (SOC * 100); //increase SOC range from 0-100 -> 100.00 datalayer.battery.status.real_soc = (SOC * 100); //increase SOC range from 0-100 -> 100.00

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SIMPBMS_BATTERY
#define SELECTED_BATTERY_CLASS SimpBmsBattery
#endif
class SimpBmsBattery : public CanBattery { class SimpBmsBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,4 +1,5 @@
#include "SONO-BATTERY.h" #include "SONO-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#ifdef SONO_BATTERY
#define SELECTED_BATTERY_CLASS SonoBattery
#endif
class SonoBattery : public CanBattery { class SonoBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -4,11 +4,6 @@
CanShunt* shunt = nullptr; CanShunt* shunt = nullptr;
ShuntType user_selected_shunt_type = ShuntType::None; ShuntType user_selected_shunt_type = ShuntType::None;
#ifdef COMMON_IMAGE
#ifdef SELECTED_SHUNT_CLASS
#error "Compile time SELECTED_SHUNT_CLASS should not be defined with COMMON_IMAGE"
#endif
void setup_can_shunt() { void setup_can_shunt() {
if (shunt) { if (shunt) {
return; return;
@ -30,21 +25,6 @@ void setup_can_shunt() {
} }
} }
#else
void setup_can_shunt() {
if (shunt) {
return;
}
#if defined(SELECTED_SHUNT_CLASS)
shunt = new SELECTED_SHUNT_CLASS();
if (shunt) {
shunt->setup();
}
#endif
}
#endif
extern std::vector<ShuntType> supported_shunt_types() { extern std::vector<ShuntType> supported_shunt_types() {
std::vector<ShuntType> types; std::vector<ShuntType> types;

View file

@ -1,4 +1,5 @@
#include "TESLA-BATTERY.h" #include "TESLA-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" //For Advanced Battery Insights webpage #include "../datalayer/datalayer_extended.h" //For Advanced Battery Insights webpage
@ -995,52 +996,52 @@ void TeslaBattery::
} }
printFaultCodesIfActive(); printFaultCodesIfActive();
logging.print("BMS Contactors State: "); logging.printf("BMS Contactors State: ");
logging.print(getBMSContactorState(battery_contactor)); // Display what state the BMS thinks the contactors are in logging.printf(getBMSContactorState(battery_contactor)); // Display what state the BMS thinks the contactors are in
logging.print(", HVIL: "); logging.printf(", HVIL: ");
logging.print(getHvilStatusState(battery_hvil_status)); logging.printf(getHvilStatusState(battery_hvil_status));
logging.print(", NegativeState: "); logging.printf(", NegativeState: ");
logging.print(getContactorState(battery_packContNegativeState)); logging.printf(getContactorState(battery_packContNegativeState));
logging.print(", PositiveState: "); logging.printf(", PositiveState: ");
logging.println(getContactorState(battery_packContPositiveState)); logging.println(getContactorState(battery_packContPositiveState));
logging.print("HVP Contactors setState: "); logging.printf("HVP Contactors setState: ");
logging.print( logging.printf(
getContactorText(battery_packContactorSetState)); // Display what state the HVP has set the contactors to be in getContactorText(battery_packContactorSetState)); // Display what state the HVP has set the contactors to be in
logging.print(", Closing blocked: "); logging.printf(", Closing blocked: ");
logging.print(getNoYes(battery_packCtrsClosingBlocked)); logging.printf(getNoYes(battery_packCtrsClosingBlocked));
if (battery_packContactorSetState == 5) { if (battery_packContactorSetState == 5) {
logging.print(" (already CLOSED)"); logging.printf(" (already CLOSED)");
} }
logging.print(", Pyrotest: "); logging.printf(", Pyrotest: ");
logging.println(getNoYes(battery_pyroTestInProgress)); logging.println(getNoYes(battery_pyroTestInProgress));
logging.print("Battery values: "); logging.printf("Battery values: ");
logging.print("Real SOC: "); logging.printf("Real SOC: ");
logging.print(battery_soc_ui / 10.0, 1); logging.print(battery_soc_ui / 10.0, 1);
logging.print(", Battery voltage: "); logging.printf(", Battery voltage: ");
logging.print(battery_volts / 10.0, 1); logging.print(battery_volts / 10.0, 1);
logging.print("V"); logging.printf("V");
logging.print(", Battery HV current: "); logging.printf(", Battery HV current: ");
logging.print(battery_amps / 10.0, 1); logging.print(battery_amps / 10.0, 1);
logging.print("A"); logging.printf("A");
logging.print(", Fully charged?: "); logging.printf(", Fully charged?: ");
if (battery_full_charge_complete) if (battery_full_charge_complete)
logging.print("YES, "); logging.printf("YES, ");
else else
logging.print("NO, "); logging.printf("NO, ");
if (datalayer.battery.info.chemistry == battery_chemistry_enum::LFP) { if (datalayer.battery.info.chemistry == battery_chemistry_enum::LFP) {
logging.print("LFP chemistry detected!"); logging.printf("LFP chemistry detected!");
} }
logging.println(""); logging.println("");
logging.print("Cellstats, Max: "); logging.printf("Cellstats, Max: ");
logging.print(battery_cell_max_v); logging.print(battery_cell_max_v);
logging.print("mV (cell "); logging.printf("mV (cell ");
logging.print(battery_BrickVoltageMaxNum); logging.print(battery_BrickVoltageMaxNum);
logging.print("), Min: "); logging.printf("), Min: ");
logging.print(battery_cell_min_v); logging.print(battery_cell_min_v);
logging.print("mV (cell "); logging.printf("mV (cell ");
logging.print(battery_BrickVoltageMinNum); logging.print(battery_BrickVoltageMinNum);
logging.print("), Imbalance: "); logging.printf("), Imbalance: ");
logging.print(battery_cell_deviation_mV); logging.print(battery_cell_deviation_mV);
logging.println("mV."); logging.println("mV.");

View file

@ -4,13 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "TESLA-HTML.h" #include "TESLA-HTML.h"
#ifdef TESLA_MODEL_3Y_BATTERY
#define SELECTED_BATTERY_CLASS TeslaModel3YBattery
#endif
#ifdef TESLA_MODEL_SX_BATTERY
#define SELECTED_BATTERY_CLASS TeslaModelSXBattery
#endif
// 0x7FF gateway config, "Gen3" vehicles only, not applicable to Gen2 "classic" Model S and Model X // 0x7FF gateway config, "Gen3" vehicles only, not applicable to Gen2 "classic" Model S and Model X
// These are user configurable from the Webserver UI // These are user configurable from the Webserver UI
extern bool user_selected_tesla_digital_HVIL; extern bool user_selected_tesla_digital_HVIL;

View file

@ -3,12 +3,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../devboard/utils/logging.h" #include "../devboard/utils/logging.h"
static void print_units(const char* header, int value, const char* units) {
logging.print(header);
logging.print(value);
logging.print(units);
}
void TestFakeBattery:: void TestFakeBattery::
update_values() { /* This function puts fake values onto the parameters sent towards the inverter */ update_values() { /* This function puts fake values onto the parameters sent towards the inverter */

View file

@ -3,10 +3,6 @@
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "CanBattery.h" #include "CanBattery.h"
#ifdef TEST_FAKE_BATTERY
#define SELECTED_BATTERY_CLASS TestFakeBattery
#endif
class TestFakeBattery : public CanBattery { class TestFakeBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -1,10 +1,10 @@
#include "VOLVO-SPA-BATTERY.h" #include "VOLVO-SPA-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" //For "More battery info" webpage #include "../datalayer/datalayer_extended.h" //For "More battery info" webpage
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
#include "../devboard/utils/logging.h" #include "../devboard/utils/logging.h"
void VolvoSpaBattery:: void VolvoSpaBattery::
update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter

View file

@ -4,10 +4,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "VOLVO-SPA-HTML.h" #include "VOLVO-SPA-HTML.h"
#ifdef VOLVO_SPA_BATTERY
#define SELECTED_BATTERY_CLASS VolvoSpaBattery
#endif
class VolvoSpaBattery : public CanBattery { class VolvoSpaBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -1,10 +1,10 @@
#include "VOLVO-SPA-HYBRID-BATTERY.h" #include "VOLVO-SPA-HYBRID-BATTERY.h"
#include <cstring> //For unit test
#include "../communication/can/comm_can.h" #include "../communication/can/comm_can.h"
#include "../datalayer/datalayer.h" #include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h" //For "More battery info" webpage #include "../datalayer/datalayer_extended.h" //For "More battery info" webpage
#include "../devboard/utils/events.h" #include "../devboard/utils/events.h"
#include "../devboard/utils/logging.h" #include "../devboard/utils/logging.h"
void VolvoSpaHybridBattery:: void VolvoSpaHybridBattery::
update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter
uint8_t cnt = 0; uint8_t cnt = 0;

View file

@ -3,10 +3,6 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "VOLVO-SPA-HYBRID-HTML.h" #include "VOLVO-SPA-HYBRID-HTML.h"
#ifdef VOLVO_SPA_HYBRID_BATTERY
#define SELECTED_BATTERY_CLASS VolvoSpaHybridBattery
#endif
class VolvoSpaHybridBattery : public CanBattery { class VolvoSpaHybridBattery : public CanBattery {
public: public:
virtual void setup(void); virtual void setup(void);

View file

@ -30,16 +30,11 @@ extern const char* name_for_charger_type(ChargerType type) {
} }
void setup_charger() { void setup_charger() {
#ifdef COMMON_IMAGE
switch (user_selected_charger_type) { switch (user_selected_charger_type) {
case ChargerType::ChevyVolt: case ChargerType::ChevyVolt:
charger = new ChevyVoltCharger(); charger = new ChevyVoltCharger();
case ChargerType::NissanLeaf: case ChargerType::NissanLeaf:
charger = new NissanLeafCharger(); charger = new NissanLeafCharger();
} }
#else
#ifdef SELECTED_CHARGER_CLASS
charger = new SELECTED_CHARGER_CLASS();
#endif
#endif
} }

View file

@ -87,7 +87,6 @@ void init_stored_settings() {
datalayer.battery.settings.user_set_bms_reset_duration_ms = temp; datalayer.battery.settings.user_set_bms_reset_duration_ms = temp;
} }
#ifdef COMMON_IMAGE
user_selected_battery_type = (BatteryType)settings.getUInt("BATTTYPE", (int)BatteryType::None); user_selected_battery_type = (BatteryType)settings.getUInt("BATTTYPE", (int)BatteryType::None);
user_selected_battery_chemistry = user_selected_battery_chemistry =
(battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::NCA); (battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::NCA);
@ -168,8 +167,6 @@ void init_stored_settings() {
mqtt_user = settings.getString("MQTTUSER").c_str(); mqtt_user = settings.getString("MQTTUSER").c_str();
mqtt_password = settings.getString("MQTTPASSWORD").c_str(); mqtt_password = settings.getString("MQTTPASSWORD").c_str();
#endif
settings.end(); settings.end();
} }

View file

@ -4,7 +4,6 @@
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <src/communication/nvm/comm_nvm.h> #include <src/communication/nvm/comm_nvm.h>
#include <list> #include <list>
#include "../../../USER_SECRETS.h"
#include "../../../USER_SETTINGS.h" #include "../../../USER_SETTINGS.h"
#include "../../battery/BATTERIES.h" #include "../../battery/BATTERIES.h"
#include "../../communication/contactorcontrol/comm_contactorcontrol.h" #include "../../communication/contactorcontrol/comm_contactorcontrol.h"
@ -15,29 +14,11 @@
#include "mqtt.h" #include "mqtt.h"
#include "mqtt_client.h" #include "mqtt_client.h"
#ifdef MQTT bool mqtt_enabled = false;
const bool mqtt_enabled_default = true; bool ha_autodiscovery_enabled = false;
#else
const bool mqtt_enabled_default = false;
#endif
bool mqtt_enabled = mqtt_enabled_default;
#ifdef HA_AUTODISCOVERY
const bool ha_autodiscovery_enabled_default = true;
#else
const bool ha_autodiscovery_enabled_default = false;
#endif
bool ha_autodiscovery_enabled = ha_autodiscovery_enabled_default;
#ifdef COMMON_IMAGE
const int mqtt_port_default = 0; const int mqtt_port_default = 0;
const char* mqtt_server_default = ""; const char* mqtt_server_default = "";
#else
const int mqtt_port_default = MQTT_PORT;
const char* mqtt_server_default = MQTT_SERVER;
#endif
int mqtt_port = mqtt_port_default; int mqtt_port = mqtt_port_default;
std::string mqtt_server = mqtt_server_default; std::string mqtt_server = mqtt_server_default;
@ -626,7 +607,7 @@ bool init_mqtt(void) {
} }
if (mqtt_manual_topic_object_name) { if (mqtt_manual_topic_object_name) {
#ifdef COMMON_IMAGE
BatteryEmulatorSettingsStore settings; BatteryEmulatorSettingsStore settings;
topic_name = settings.getString("MQTTTOPIC", mqtt_topic_name); topic_name = settings.getString("MQTTTOPIC", mqtt_topic_name);
object_id_prefix = settings.getString("MQTTOBJIDPREFIX", mqtt_object_id_prefix); object_id_prefix = settings.getString("MQTTOBJIDPREFIX", mqtt_object_id_prefix);
@ -649,13 +630,6 @@ bool init_mqtt(void) {
device_id = ha_device_id; device_id = ha_device_id;
} }
#else
// Use custom topic name, object ID prefix, and device name from user settings
topic_name = mqtt_topic_name;
object_id_prefix = mqtt_object_id_prefix;
device_name = mqtt_device_name;
device_id = ha_device_id;
#endif
} else { } else {
// Use default naming based on WiFi hostname for topic, object ID prefix, and device name // Use default naming based on WiFi hostname for topic, object ID prefix, and device name
topic_name = "battery-emulator_" + String(WiFi.getHostname()); topic_name = "battery-emulator_" + String(WiFi.getHostname());

View file

@ -8,7 +8,6 @@
#ifndef UNIT_TEST #ifndef UNIT_TEST
// Real implementation for production // Real implementation for production
#include <Print.h>
class Logging : public Print { class Logging : public Print {
void add_timestamp(size_t size); void add_timestamp(size_t size);
@ -51,12 +50,61 @@ class Logging {
(void)fmt; (void)fmt;
} }
// Overloaded print methods for different data types
static void print(const char* str) { (void)str; }
static void print(char c) { (void)c; }
static void print(int8_t num) { (void)num; }
static void print(uint8_t num) { (void)num; }
static void print(int16_t num) { (void)num; }
static void print(uint16_t num) { (void)num; }
static void print(int32_t num) { (void)num; }
static void print(uint32_t num) { (void)num; }
static void print(int64_t num) { (void)num; }
static void print(uint64_t num) { (void)num; }
static void print(float num) { (void)num; }
static void print(double num) { (void)num; }
static void print(bool b) { (void)b; }
static void print(double num, int precision) {
(void)num;
(void)precision;
}
static void print(float num, int precision) {
(void)num;
(void)precision;
}
static void print(int32_t num, int base) {
(void)num;
(void)base;
}
static void print(uint32_t num, int base) {
(void)num;
(void)base;
}
static void println(const char* str) { (void)str; } static void println(const char* str) { (void)str; }
static void println(char c) { (void)c; }
static void println(int8_t num) { (void)num; }
static void println(uint8_t num) { (void)num; }
static void println(int16_t num) { (void)num; }
static void println(uint16_t num) { (void)num; }
static void println(int32_t num) { (void)num; }
static void println(uint32_t num) { (void)num; }
static void println(int64_t num) { (void)num; }
static void println(uint64_t num) { (void)num; }
static void println(float num) { (void)num; }
static void println(double num) { (void)num; }
static void println(bool b) { (void)b; }
static void println() {} // Empty println
Logging() {} Logging() {}
}; };
// Test macros - empty implementations // Test macros - empty implementations
#define DEBUG_PRINT(fmt, ...) ((void)0)
#define DEBUG_PRINTF(fmt, ...) ((void)0) #define DEBUG_PRINTF(fmt, ...) ((void)0)
#define DEBUG_PRINTLN(str) ((void)0) #define DEBUG_PRINTLN(str) ((void)0)

View file

@ -135,12 +135,6 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
return String(ssid.c_str()); return String(ssid.c_str());
} }
#ifndef COMMON_IMAGE
if (var == "COMMONIMAGEDIVCLASS") {
return "hidden";
}
#endif
if (var == "SAVEDCLASS") { if (var == "SAVEDCLASS") {
if (!settingsUpdated) { if (!settingsUpdated) {
return "hidden"; return "hidden";
@ -839,7 +833,7 @@ const char* getCANInterfaceName(CAN_Interface interface) {
<h4 style='color: white;'>SSID: <span id='SSID'>%SSID%</span><button onclick='editSSID()'>Edit</button></h4> <h4 style='color: white;'>SSID: <span id='SSID'>%SSID%</span><button onclick='editSSID()'>Edit</button></h4>
<h4 style='color: white;'>Password: ######## <span id='Password'></span> <button onclick='editPassword()'>Edit</button></h4> <h4 style='color: white;'>Password: ######## <span id='Password'></span> <button onclick='editPassword()'>Edit</button></h4>
<div style='background-color: #404E47; padding: 10px; margin-bottom: 10px;border-radius: 50px; class="%COMMONIMAGEDIVCLASS%"> <div style='background-color: #404E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>
<div style='max-width: 500px;'> <div style='max-width: 500px;'>
<form action='saveSettings' method='post' style='display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; align-items: center;'> <form action='saveSettings' method='post' style='display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; align-items: center;'>

View file

@ -2,7 +2,6 @@
#include <Preferences.h> #include <Preferences.h>
#include <ctime> #include <ctime>
#include <vector> #include <vector>
#include "../../../USER_SECRETS.h"
#include "../../battery/BATTERIES.h" #include "../../battery/BATTERIES.h"
#include "../../battery/Battery.h" #include "../../battery/Battery.h"
#include "../../charger/CHARGERS.h" #include "../../charger/CHARGERS.h"
@ -23,21 +22,10 @@
extern std::string http_username; extern std::string http_username;
extern std::string http_password; extern std::string http_password;
#ifdef WEBSERVER bool webserver_enabled =
const bool webserver_enabled_default = true; true; // Global flag to enable or disable the webserver //Old method to disable was with #ifdef WEBSERVER
#else
const bool webserver_enabled_default = false;
#endif
bool webserver_enabled = webserver_enabled_default; // Global flag to enable or disable the webserver bool webserver_auth = false;
#ifndef COMMON_IMAGE
const bool webserver_auth_default = WEBSERVER_AUTH_REQUIRED;
#else
const bool webserver_auth_default = false;
#endif
bool webserver_auth = webserver_auth_default;
// Create AsyncWebServer object on port 80 // Create AsyncWebServer object on port 80
AsyncWebServer server(80); AsyncWebServer server(80);
@ -401,7 +389,6 @@ void init_webserver() {
request->send(200, "text/html", "OK"); request->send(200, "text/html", "OK");
}); });
#ifdef COMMON_IMAGE
struct BoolSetting { struct BoolSetting {
const char* name; const char* name;
bool existingValue; bool existingValue;
@ -557,7 +544,6 @@ void init_webserver() {
settingsUpdated = settings.were_settings_updated(); settingsUpdated = settings.were_settings_updated();
request->redirect("/settings"); request->redirect("/settings");
}); });
#endif
// Route for editing SSID // Route for editing SSID
def_route_with_auth("/updateSSID", server, HTTP_GET, [](AsyncWebServerRequest* request) { def_route_with_auth("/updateSSID", server, HTTP_GET, [](AsyncWebServerRequest* request) {
@ -908,9 +894,6 @@ 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'>";
content += "<h4>Software: " + String(version_number); content += "<h4>Software: " + String(version_number);
#ifdef COMMON_IMAGE
content += " (Common image) ";
#endif
// Show hardware used: // Show hardware used:
#ifdef HW_LILYGO #ifdef HW_LILYGO
content += " Hardware: LilyGo T-CAN485"; content += " Hardware: LilyGo T-CAN485";

View file

@ -12,17 +12,7 @@ const bool wifi_enabled_default = false;
bool wifi_enabled = wifi_enabled_default; bool wifi_enabled = wifi_enabled_default;
#ifdef COMMON_IMAGE bool wifiap_enabled = true; //Old method was with ifdef
const bool wifiap_enabled_default = true;
#else
#ifdef WIFIAP
const bool wifiap_enabled_default = true;
#else
const bool wifiap_enabled_default = false;
#endif
#endif
bool wifiap_enabled = wifiap_enabled_default;
#ifdef MDNSRESPONDER #ifdef MDNSRESPONDER
const bool mdns_enabled_default = true; const bool mdns_enabled_default = true;

View file

@ -96,11 +96,6 @@ extern const char* name_for_inverter_type(InverterProtocolType type) {
return nullptr; return nullptr;
} }
#ifdef COMMON_IMAGE
#ifdef SELECTED_INVERTER_CLASS
#error "Compile time SELECTED_INVERTER_CLASS should not be defined with COMMON_IMAGE"
#endif
bool setup_inverter() { bool setup_inverter() {
if (inverter) { if (inverter) {
return true; return true;
@ -205,24 +200,3 @@ bool setup_inverter() {
return false; return false;
} }
#else
bool setup_inverter() {
if (inverter) {
// The inverter is setup only once.
return true;
}
#ifdef SELECTED_INVERTER_CLASS
inverter = new SELECTED_INVERTER_CLASS();
if (inverter) {
return inverter->setup();
}
return false;
#else
return true;
#endif
}
#endif

View file

@ -7,11 +7,6 @@ extern InverterProtocol* inverter;
#include "../../USER_SETTINGS.h" #include "../../USER_SETTINGS.h"
#include "AFORE-CAN.h" #include "AFORE-CAN.h"
#ifdef BYD_CAN_DEYE
#define BYD_CAN
#endif
#include "BYD-CAN.h" #include "BYD-CAN.h"
#include "BYD-MODBUS.h" #include "BYD-MODBUS.h"
#include "FERROAMP-CAN.h" #include "FERROAMP-CAN.h"

View file

@ -14,18 +14,18 @@ void KostalInverterProtocol::float2frame(uint8_t* arr, float value, uint8_t fram
} }
static void dbg_timestamp(void) { static void dbg_timestamp(void) {
logging.print("["); logging.printf("[");
logging.print(millis()); logging.print(millis());
logging.print(" ms] "); logging.printf(" ms] ");
} }
static void dbg_frame(uint8_t* frame, int len, const char* prefix) { static void dbg_frame(uint8_t* frame, int len, const char* prefix) {
dbg_timestamp(); dbg_timestamp();
logging.print(prefix); logging.print(prefix);
logging.print(": "); logging.printf(": ");
for (uint8_t i = 0; i < len; i++) { for (uint8_t i = 0; i < len; i++) {
if (frame[i] < 0x10) { if (frame[i] < 0x10) {
logging.print("0"); logging.printf("0");
} }
logging.print(frame[i], HEX); logging.print(frame[i], HEX);
logging.print(" "); logging.print(" ");

View file

@ -20,7 +20,6 @@ class KostalInverterProtocol : public Rs485InverterProtocol {
int baud_rate() { return 57600; } int baud_rate() { return 57600; }
void float2frame(uint8_t* arr, float value, uint8_t framepointer); void float2frame(uint8_t* arr, float value, uint8_t framepointer);
bool check_kostal_frame_crc(int len); bool check_kostal_frame_crc(int len);
// How many value updates we can go without inverter gets reported as missing \ // How many value updates we can go without inverter gets reported as missing \
// e.g. value set to 12, 12*5sec=60seconds without comm before event is raised // e.g. value set to 12, 12*5sec=60seconds without comm before event is raised
const int RS485_HEALTHY = 12; const int RS485_HEALTHY = 12;

View file

@ -137,17 +137,6 @@ void SmaTripowerInverter::map_can_frame_to_variable(CAN_frame rx_frame) {
} }
} }
void SmaTripowerInverter::pushFrame(CAN_frame* frame, std::function<void(void)> callback) {
if (listLength >= 20) {
return; //TODO: scream.
}
framesToSend[listLength] = {
.frame = frame,
.callback = callback,
};
listLength++;
}
void SmaTripowerInverter::transmit_can(unsigned long currentMillis) { void SmaTripowerInverter::transmit_can(unsigned long currentMillis) {
// Send CAN Message only if we're enabled by inverter // Send CAN Message only if we're enabled by inverter
@ -155,18 +144,6 @@ void SmaTripowerInverter::transmit_can(unsigned long currentMillis) {
return; return;
} }
if (listLength > 0 && currentMillis - previousMillis250ms >= INTERVAL_250_MS) {
previousMillis250ms = currentMillis;
// Send next frame.
Frame frame = framesToSend[0];
transmit_can_frame(frame.frame);
frame.callback();
for (int i = 0; i < listLength - 1; i++) {
framesToSend[i] = framesToSend[i + 1];
}
listLength--;
}
if (!pairing_completed) { if (!pairing_completed) {
return; return;
} }
@ -174,19 +151,19 @@ void SmaTripowerInverter::transmit_can(unsigned long currentMillis) {
// Send CAN Message every 2s // Send CAN Message every 2s
if (currentMillis - previousMillis2s >= INTERVAL_2_S) { if (currentMillis - previousMillis2s >= INTERVAL_2_S) {
previousMillis2s = currentMillis; previousMillis2s = currentMillis;
pushFrame(&SMA_358); transmit_can_frame(&SMA_358);
} }
// Send CAN Message every 10s // Send CAN Message every 10s
if (currentMillis - previousMillis10s >= INTERVAL_10_S) { if (currentMillis - previousMillis10s >= INTERVAL_10_S) {
previousMillis10s = currentMillis; previousMillis10s = currentMillis;
pushFrame(&SMA_518); transmit_can_frame(&SMA_518);
pushFrame(&SMA_4D8); transmit_can_frame(&SMA_4D8);
pushFrame(&SMA_3D8); transmit_can_frame(&SMA_3D8);
} }
// Send CAN Message every 60s (potentially SMA_458 is not required for stable operation) // Send CAN Message every 60s (potentially SMA_458 is not required for stable operation)
if (currentMillis - previousMillis60s >= INTERVAL_60_S) { if (currentMillis - previousMillis60s >= INTERVAL_60_S) {
previousMillis60s = currentMillis; previousMillis60s = currentMillis;
pushFrame(&SMA_458); transmit_can_frame(&SMA_458);
} }
} }
@ -195,18 +172,17 @@ void SmaTripowerInverter::completePairing() {
} }
void SmaTripowerInverter::transmit_can_init() { void SmaTripowerInverter::transmit_can_init() {
listLength = 0; // clear all frames
pushFrame(&SMA_558); //Pairing start - Vendor transmit_can_frame(&SMA_558); //Pairing start - Vendor
pushFrame(&SMA_598); //Serial transmit_can_frame(&SMA_598); //Serial
pushFrame(&SMA_5D8); //BYD transmit_can_frame(&SMA_5D8); //BYD
pushFrame(&SMA_618_0); //BATTERY transmit_can_frame(&SMA_618_0); //BATTERY
pushFrame(&SMA_618_1); //-Box Pr transmit_can_frame(&SMA_618_1); //-Box Pr
pushFrame(&SMA_618_2); //emium H transmit_can_frame(&SMA_618_2); //emium H
pushFrame(&SMA_618_3); //VS transmit_can_frame(&SMA_618_3); //VS
pushFrame(&SMA_358); transmit_can_frame(&SMA_358);
pushFrame(&SMA_3D8); transmit_can_frame(&SMA_3D8);
pushFrame(&SMA_458); transmit_can_frame(&SMA_458);
pushFrame(&SMA_4D8); transmit_can_frame(&SMA_4D8);
pushFrame(&SMA_518, [this]() { this->completePairing(); }); transmit_can_frame(&SMA_518);
} }

View file

@ -24,7 +24,6 @@ class SmaTripowerInverter : public SmaInverterBase {
const int THIRTY_MINUTES = 1200; const int THIRTY_MINUTES = 1200;
void transmit_can_init(); void transmit_can_init();
void pushFrame(CAN_frame* frame, std::function<void(void)> callback = []() {});
void completePairing(); void completePairing();
unsigned long previousMillis250ms = 0; // will store last time a 250ms CAN Message was send unsigned long previousMillis250ms = 0; // will store last time a 250ms CAN Message was send
@ -33,14 +32,6 @@ class SmaTripowerInverter : public SmaInverterBase {
unsigned long previousMillis10s = 0; // will store last time a 10s CAN Message was send unsigned long previousMillis10s = 0; // will store last time a 10s CAN Message was send
unsigned long previousMillis60s = 0; // will store last time a 60s CAN Message was send unsigned long previousMillis60s = 0; // will store last time a 60s CAN Message was send
typedef struct {
CAN_frame* frame;
std::function<void(void)> callback;
} Frame;
unsigned short listLength = 0;
Frame framesToSend[20];
uint32_t inverter_time = 0; uint32_t inverter_time = 0;
uint16_t inverter_voltage = 0; uint16_t inverter_voltage = 0;
int16_t inverter_current = 0; int16_t inverter_current = 0;

View file

@ -292,9 +292,8 @@ bool SofarInverter::setup() { // Performs one time setup at startup over CAN bu
init_frame(SOFAR_783, 0x783); init_frame(SOFAR_783, 0x783);
init_frame(SOFAR_784, 0x784); init_frame(SOFAR_784, 0x784);
String tempStr(datalayer.battery.settings.sofar_user_specified_battery_id); snprintf(datalayer.system.info.inverter_brand, sizeof(datalayer.system.info.inverter_brand), "%s",
strncpy(datalayer.system.info.inverter_brand, tempStr.c_str(), 7); datalayer.battery.settings.sofar_user_specified_battery_id);
datalayer.system.info.inverter_brand[7] = '\0';
return true; return true;
} }

View file

@ -28,7 +28,7 @@ monitor_speed = 115200
monitor_filters = default, time, log2file monitor_filters = default, time, log2file
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
framework = arduino framework = arduino
build_flags = -I include -DHW_LILYGO -DCOMMON_IMAGE build_flags = -I include -DHW_LILYGO
lib_deps = lib_deps =
[env:stark_330] [env:stark_330]
@ -38,17 +38,7 @@ monitor_speed = 115200
monitor_filters = default, time, log2file, esp32_exception_decoder monitor_filters = default, time, log2file, esp32_exception_decoder
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
framework = arduino framework = arduino
build_flags = -I include -DHW_STARK -DCOMMON_IMAGE build_flags = -I include -DHW_STARK
lib_deps =
[env:stark_330_debuglog]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.30/platform-espressif32.zip
board = esp32dev
monitor_speed = 115200
monitor_filters = default, time, log2file, esp32_exception_decoder
board_build.partitions = min_spiffs.csv
framework = arduino
build_flags = -I include -DHW_STARK -DCOMMON_IMAGE -DDEBUG_VIA_USB
lib_deps = lib_deps =
[env:lilygo_2CAN_330] [env:lilygo_2CAN_330]
@ -62,7 +52,6 @@ framework = arduino
build_flags = build_flags =
-I include -I include
-D HW_LILYGO2CAN -D HW_LILYGO2CAN
-D COMMON_IMAGE
-D BOARD_HAS_PSRAM -D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1 -D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1 ;1 is to use the USB port as a serial port -D ARDUINO_USB_CDC_ON_BOOT=1 ;1 is to use the USB port as a serial port

View file

@ -85,11 +85,80 @@ add_executable(tests
../Software/USER_SETTINGS.cpp ../Software/USER_SETTINGS.cpp
../Software/src/battery/BATTERIES.cpp ../Software/src/battery/BATTERIES.cpp
../Software/src/battery/Battery.cpp ../Software/src/battery/Battery.cpp
../Software/src/battery/BMW-I3-BATTERY.cpp
../Software/src/battery/BMW-I3-HTML.cpp
../Software/src/battery/BMW-IX-BATTERY.cpp
../Software/src/battery/BMW-IX-HTML.cpp
../Software/src/battery/BMW-PHEV-BATTERY.cpp
../Software/src/battery/BMW-SBOX.cpp
../Software/src/battery/BOLT-AMPERA-BATTERY.cpp
../Software/src/battery/BYD-ATTO-3-BATTERY.cpp
../Software/src/battery/CanBattery.cpp ../Software/src/battery/CanBattery.cpp
../Software/src/battery/CELLPOWER-BMS.cpp
../Software/src/battery/CHADEMO-BATTERY.cpp
../Software/src/battery/CHADEMO-SHUNTS.cpp
../Software/src/battery/CMFA-EV-BATTERY.cpp
../Software/src/battery/DALY-BMS.cpp
../Software/src/battery/ECMP-BATTERY.cpp
../Software/src/battery/FOXESS-BATTERY.cpp
../Software/src/battery/GEELY-GEOMETRY-C-BATTERY.cpp
../Software/src/battery/HYUNDAI-IONIQ-28-BATTERY-HTML.cpp
../Software/src/battery/HYUNDAI-IONIQ-28-BATTERY.cpp
../Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp
../Software/src/battery/JAGUAR-IPACE-BATTERY.cpp
../Software/src/battery/KIA-E-GMP-BATTERY.cpp
../Software/src/battery/KIA-E-GMP-HTML.cpp
../Software/src/battery/KIA-64FD-BATTERY.cpp
../Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp
../Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp
../Software/src/battery/MEB-BATTERY.cpp
../Software/src/battery/MG-5-BATTERY.cpp
../Software/src/battery/MG-HS-PHEV-BATTERY.cpp
../Software/src/battery/NISSAN-LEAF-BATTERY.cpp ../Software/src/battery/NISSAN-LEAF-BATTERY.cpp
../Software/src/inverter/INVERTERS.cpp ../Software/src/battery/ORION-BMS.cpp
../Software/src/battery/PYLON-BATTERY.cpp
../Software/src/battery/RANGE-ROVER-PHEV-BATTERY.cpp
../Software/src/battery/RELION-LV-BATTERY.cpp
../Software/src/battery/RENAULT-KANGOO-BATTERY.cpp
../Software/src/battery/RENAULT-TWIZY.cpp
../Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp
../Software/src/battery/RENAULT-ZOE-GEN2-BATTERY.cpp
../Software/src/battery/RJXZS-BMS.cpp
../Software/src/battery/SAMSUNG-SDI-LV-BATTERY.cpp
../Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp
../Software/src/battery/Shunts.cpp
../Software/src/battery/SIMPBMS-BATTERY.cpp
../Software/src/battery/SONO-BATTERY.cpp
../Software/src/battery/TESLA-BATTERY.cpp
../Software/src/battery/TEST-FAKE-BATTERY.cpp
../Software/src/battery/VOLVO-SPA-BATTERY.cpp
../Software/src/battery/VOLVO-SPA-HYBRID-BATTERY.cpp
../Software/src/inverter/AFORE-CAN.cpp
../Software/src/inverter/BYD-CAN.cpp
../Software/src/inverter/BYD-MODBUS.cpp ../Software/src/inverter/BYD-MODBUS.cpp
../Software/src/inverter/FERROAMP-CAN.cpp
../Software/src/inverter/FOXESS-CAN.cpp
../Software/src/inverter/GROWATT-HV-CAN.cpp
../Software/src/inverter/GROWATT-LV-CAN.cpp
../Software/src/inverter/GROWATT-WIT-CAN.cpp
../Software/src/inverter/INVERTERS.cpp
../Software/src/inverter/KOSTAL-RS485.cpp
../Software/src/inverter/ModbusInverterProtocol.cpp
../Software/src/inverter/PYLON-CAN.cpp
../Software/src/inverter/PYLON-LV-CAN.cpp
../Software/src/inverter/SCHNEIDER-CAN.cpp
../Software/src/inverter/SMA-BYD-H-CAN.cpp
../Software/src/inverter/SMA-BYD-HVS-CAN.cpp
../Software/src/inverter/SMA-LV-CAN.cpp
../Software/src/inverter/SMA-TRIPOWER-CAN.cpp
../Software/src/inverter/SOFAR-CAN.cpp
../Software/src/inverter/SOL-ARK-LV-CAN.cpp
../Software/src/inverter/SOLAX-CAN.cpp
../Software/src/inverter/SOLXPOW-CAN.cpp
../Software/src/inverter/SUNGROW-CAN.cpp
../Software/src/charger/CHARGERS.cpp ../Software/src/charger/CHARGERS.cpp
../Software/src/charger/CHEVY-VOLT-CHARGER.cpp
../Software/src/charger/NISSAN-LEAF-CHARGER.cpp
emul/can.cpp emul/can.cpp
emul/time.cpp emul/time.cpp
emul/serial.cpp emul/serial.cpp

View file

@ -15,4 +15,22 @@ int max(int a, int b) {
return (a > b) ? a : b; return (a > b) ? a : b;
} }
// Mock implementation for OBD
#include "../../Software/src/communication/can/obd.h"
void handle_obd_frame(CAN_frame& frame) {
(void)frame;
}
void transmit_obd_can_frame(unsigned int address, int interface, bool canFD) {
(void)interface;
}
void start_bms_reset() {}
#include "../../Software/src/communication/rs485/comm_rs485.h"
// Mock implementation
void register_receiver(Rs485Receiver* receiver) {
(void)receiver; // Silence unused parameter warning
}
ESPClass ESP; ESPClass ESP;

View file

@ -6,15 +6,97 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "HardwareSerial.h" #include "HardwareSerial.h"
#include "Logging.h" #include "Logging.h"
#include "Print.h" #include "Print.h"
#include "esp-hal-gpio.h" #include "esp-hal-gpio.h"
// Arduino base constants for print formatting
constexpr int BIN = 2;
constexpr int OCT = 8;
constexpr int DEC = 10;
constexpr int HEX = 16;
// Arduino type aliases
using byte = uint8_t;
#define boolean bool
// Arduino random functions
inline long random(long max) {
(void)max;
return 0; // Return a predictable value for testing
}
inline long random(long min, long max) {
(void)min;
(void)max;
return min; // Return the minimum value for predictability
}
// Also add randomSeed for completeness
inline void randomSeed(unsigned long seed) {
(void)seed;
}
inline uint16_t word(uint8_t highByte, uint8_t lowByte) {
return (static_cast<uint16_t>(highByte) << 8) | lowByte;
}
inline uint16_t word(uint16_t w) {
return w;
}
// Bit manipulation functions
inline uint8_t bitRead(uint8_t value, uint8_t bit) {
return (value >> bit) & 0x01;
}
inline void bitSet(uint8_t& value, uint8_t bit) {
value |= (1UL << bit);
}
inline void bitClear(uint8_t& value, uint8_t bit) {
value &= ~(1UL << bit);
}
inline void bitWrite(uint8_t& value, uint8_t bit, uint8_t bitvalue) {
if (bitvalue) {
bitSet(value, bit);
} else {
bitClear(value, bit);
}
}
// Byte extraction functions
inline uint8_t lowByte(uint16_t w) {
return static_cast<uint8_t>(w & 0xFF);
}
inline uint8_t highByte(uint16_t w) {
return static_cast<uint8_t>(w >> 8);
}
template <typename T>
inline const T& min(const T& a, const T& b) {
return (a < b) ? a : b;
}
template <typename T>
inline const T& max(const T& a, const T& b) {
return (a > b) ? a : b;
}
void pinMode(uint8_t pin, uint8_t mode); void pinMode(uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t val); void digitalWrite(uint8_t pin, uint8_t val);
int digitalRead(uint8_t pin); int digitalRead(uint8_t pin);
inline int analogRead(uint8_t pin) {
(void)pin;
return 0; // Return 0 for predictable tests
}
unsigned long micros(); unsigned long micros();
// Can be previously declared as a macro in stupid eModbus // Can be previously declared as a macro in stupid eModbus

View file

@ -35,17 +35,28 @@ enum SerialConfig {
class HardwareSerial : public Stream { class HardwareSerial : public Stream {
public: public:
int available() { return 0; } // Implement ALL pure virtual functions from base classes
int available() override { return 0; }
int read() override { return -1; }
int peek() override { return -1; }
void flush() override {} // Implement flush from Print
size_t write(uint8_t) override { return 0; } // Implement write from Print
// Your existing methods
uint32_t baudRate() { return 9600; } uint32_t baudRate() { return 9600; }
void begin(unsigned long baud, uint32_t config = SERIAL_8N1, int8_t rxPin = -1, int8_t txPin = -1, void begin(unsigned long baud, uint32_t config = SERIAL_8N1, int8_t rxPin = -1, int8_t txPin = -1,
bool invert = false, unsigned long timeout_ms = 20000UL, uint8_t rxfifo_full_thrhd = 120) {} bool invert = false, unsigned long timeout_ms = 20000UL, uint8_t rxfifo_full_thrhd = 120) {}
int read() { return 0; }
void setTxBufferSize(uint16_t size) {} void setTxBufferSize(uint16_t size) {}
void setRxBufferSize(uint16_t size) {} void setRxBufferSize(uint16_t size) {}
bool setRxFIFOFull(uint8_t fifoBytes) { return false; } bool setRxFIFOFull(uint8_t fifoBytes) { return false; }
size_t write(uint8_t) { return 0; }
};
// Add the buffer write method
size_t write(const uint8_t* buffer, size_t size) override {
(void)buffer;
(void)size;
return 0;
}
};
extern HardwareSerial Serial; extern HardwareSerial Serial;
extern HardwareSerial Serial1; extern HardwareSerial Serial1;
extern HardwareSerial Serial2; extern HardwareSerial Serial2;

Some files were not shown because too many files have changed in this diff Show more