Merge branch 'master' into release
This commit is contained in:
1183
Board320_240.cpp
Normal file
1183
Board320_240.cpp
Normal file
File diff suppressed because it is too large
Load Diff
67
Board320_240.h
Normal file
67
Board320_240.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef BOARD320_240_H
|
||||
#define BOARD320_240_H
|
||||
|
||||
// TFT COMMON
|
||||
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
|
||||
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
|
||||
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
|
||||
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
|
||||
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
|
||||
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
|
||||
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||
#define SMOOTH_FONT
|
||||
#define GFXFF 1 // TFT FOnts
|
||||
|
||||
//
|
||||
#include <TFT_eSPI.h>
|
||||
#include "BoardInterface.h"
|
||||
|
||||
class Board320_240 : public BoardInterface {
|
||||
|
||||
private:
|
||||
// TFT, SD SPI
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
TFT_eSprite spr = TFT_eSprite(&tft);
|
||||
char tmpStr1[20];
|
||||
char tmpStr2[20];
|
||||
char tmpStr3[20];
|
||||
char tmpStr4[20];
|
||||
public:
|
||||
bool invertDisplay = false;
|
||||
byte pinButtonLeft = 0;
|
||||
byte pinButtonRight = 0;
|
||||
byte pinButtonMiddle = 0;
|
||||
byte pinSpeaker = 0;
|
||||
byte pinBrightness = 0;
|
||||
//
|
||||
void initBoard() override;
|
||||
void afterSetup() override;
|
||||
void mainLoop() override;
|
||||
bool skipAdapterScan() override;
|
||||
// Basic GUI
|
||||
void setBrightness(byte lcdBrightnessPerc) override;
|
||||
void displayMessage(const char* row1, const char* row2) override;
|
||||
void redrawScreen() override;
|
||||
// Custom screens
|
||||
void drawBigCell(int32_t x, int32_t y, int32_t w, int32_t h, const char* text, const char* desc, uint16_t bgColor, uint16_t fgColor);
|
||||
void drawSmallCell(int32_t x, int32_t y, int32_t w, int32_t h, const char* text, const char* desc, int16_t bgColor, int16_t fgColor);
|
||||
void showTires(int32_t x, int32_t y, int32_t w, int32_t h, const char* topleft, const char* topright, const char* bottomleft, const char* bottomright, uint16_t color);
|
||||
void drawSceneMain();
|
||||
void drawSceneSpeed();
|
||||
void drawSceneBatteryCells();
|
||||
void drawPreDrawnChargingGraphs(int zeroX, int zeroY, int mulX, int mulY);
|
||||
void drawSceneChargingGraph();
|
||||
void drawSceneSoc10Table();
|
||||
void drawSceneDebug();
|
||||
// Menu
|
||||
String menuItemCaption(int16_t menuItemId, String title);
|
||||
void showMenu() override;
|
||||
void hideMenu() override;
|
||||
void menuMove(bool forward);
|
||||
void menuItemClick();
|
||||
//
|
||||
void loadTestData();
|
||||
//
|
||||
};
|
||||
|
||||
#endif // BOARD320_240_H
|
||||
151
BoardInterface.cpp
Normal file
151
BoardInterface.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef BOARDINTERFACE_CPP
|
||||
#define BOARDINTERFACE_CPP
|
||||
|
||||
#include <EEPROM.h>
|
||||
#include <BLEDevice.h>
|
||||
#include "BoardInterface.h"
|
||||
#include "LiveData.h"
|
||||
|
||||
/**
|
||||
Set live data
|
||||
*/
|
||||
void BoardInterface::setLiveData(LiveData* pLiveData) {
|
||||
this->liveData = pLiveData;
|
||||
}
|
||||
|
||||
/**
|
||||
Attach car interface
|
||||
*/
|
||||
void BoardInterface::attachCar(CarInterface* pCarInterface) {
|
||||
this->carInterface = pCarInterface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Shutdown device
|
||||
*/
|
||||
void BoardInterface::shutdownDevice() {
|
||||
|
||||
Serial.println("Shutdown.");
|
||||
|
||||
this->displayMessage("Shutdown in 3 sec.", "");
|
||||
delay(3000);
|
||||
|
||||
setCpuFrequencyMhz(80);
|
||||
this->setBrightness(0);
|
||||
//WiFi.disconnect(true);
|
||||
//WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
//adc_power_off();
|
||||
//esp_wifi_stop();
|
||||
esp_bt_controller_disable();
|
||||
|
||||
delay(2000);
|
||||
//esp_sleep_enable_timer_wakeup(525600L * 60L * 1000000L); // minutes
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
/**
|
||||
Load settings from flash memory, upgrade structure if version differs
|
||||
*/
|
||||
void BoardInterface::saveSettings() {
|
||||
|
||||
// Flash to memory
|
||||
Serial.println("Settings saved to eeprom.");
|
||||
EEPROM.put(0, this->liveData->settings);
|
||||
EEPROM.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
Reset settings (factory reset)
|
||||
*/
|
||||
void BoardInterface::resetSettings() {
|
||||
|
||||
// Flash to memory
|
||||
Serial.println("Factory reset.");
|
||||
this->liveData->settings.initFlag = 1;
|
||||
EEPROM.put(0, this->liveData->settings);
|
||||
EEPROM.commit();
|
||||
|
||||
this->displayMessage("Settings erased", "Restarting in 5 seconds");
|
||||
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
/**
|
||||
Load setting from flash memory, upgrade structure if version differs
|
||||
*/
|
||||
void BoardInterface::loadSettings() {
|
||||
|
||||
String tmpStr;
|
||||
|
||||
// Init
|
||||
this->liveData->settings.initFlag = 183;
|
||||
this->liveData->settings.settingsVersion = 3;
|
||||
this->liveData->settings.carType = CAR_KIA_ENIRO_2020_64;
|
||||
|
||||
// Default OBD adapter MAC and UUID's
|
||||
tmpStr = "00:00:00:00:00:00"; // Pair via menu (middle button)
|
||||
tmpStr.toCharArray(this->liveData->settings.obdMacAddress, tmpStr.length() + 1);
|
||||
tmpStr = "000018f0-0000-1000-8000-00805f9b34fb"; // Default UUID's for VGate iCar Pro BLE4 adapter
|
||||
tmpStr.toCharArray(this->liveData->settings.serviceUUID, tmpStr.length() + 1);
|
||||
tmpStr = "00002af0-0000-1000-8000-00805f9b34fb";
|
||||
tmpStr.toCharArray(this->liveData->settings.charTxUUID, tmpStr.length() + 1);
|
||||
tmpStr = "00002af1-0000-1000-8000-00805f9b34fb";
|
||||
tmpStr.toCharArray(this->liveData->settings.charRxUUID, tmpStr.length() + 1);
|
||||
|
||||
this->liveData->settings.displayRotation = 1; // 1,3
|
||||
this->liveData->settings.distanceUnit = 'k';
|
||||
this->liveData->settings.temperatureUnit = 'c';
|
||||
this->liveData->settings.pressureUnit = 'b';
|
||||
this->liveData->settings.defaultScreen = 1;
|
||||
this->liveData->settings.lcdBrightness = 0;
|
||||
this->liveData->settings.debugScreen = 0;
|
||||
this->liveData->settings.predrawnChargingGraphs = 1;
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
tmpStr = "internet.t-mobile.cz";
|
||||
tmpStr.toCharArray(liveData->settings.gprsApn, tmpStr.length() + 1);
|
||||
tmpStr = "http://api.example.com";
|
||||
tmpStr.toCharArray(liveData->settings.remoteApiSrvr, tmpStr.length() + 1);
|
||||
tmpStr = "example";
|
||||
tmpStr.toCharArray(liveData->settings.remoteApiKey, tmpStr.length() + 1);
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
// Load settings and replace default values
|
||||
Serial.println("Reading settings from eeprom.");
|
||||
EEPROM.begin(sizeof(SETTINGS_STRUC));
|
||||
EEPROM.get(0, this->liveData->tmpSettings);
|
||||
|
||||
// Init flash with default settings
|
||||
if (this->liveData->tmpSettings.initFlag != 183) {
|
||||
Serial.println("Settings not found. Initialization.");
|
||||
this->saveSettings();
|
||||
} else {
|
||||
Serial.print("Loaded settings ver.: ");
|
||||
Serial.println(this->liveData->settings.settingsVersion);
|
||||
|
||||
// Upgrade structure
|
||||
if (this->liveData->settings.settingsVersion != this->liveData->tmpSettings.settingsVersion) {
|
||||
if (this->liveData->tmpSettings.settingsVersion == 1) {
|
||||
this->liveData->tmpSettings.settingsVersion = 2;
|
||||
this->liveData->tmpSettings.defaultScreen = this->liveData->settings.defaultScreen;
|
||||
this->liveData->tmpSettings.lcdBrightness = this->liveData->settings.lcdBrightness;
|
||||
this->liveData->tmpSettings.debugScreen = this->liveData->settings.debugScreen;
|
||||
}
|
||||
if (this->liveData->tmpSettings.settingsVersion == 2) {
|
||||
this->liveData->tmpSettings.settingsVersion = 3;
|
||||
this->liveData->tmpSettings.predrawnChargingGraphs = this->liveData->settings.predrawnChargingGraphs;
|
||||
}
|
||||
this->saveSettings();
|
||||
}
|
||||
|
||||
// Save version? No need to upgrade structure
|
||||
if (this->liveData->settings.settingsVersion == this->liveData->tmpSettings.settingsVersion) {
|
||||
this->liveData->settings = this->liveData->tmpSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOARDINTERFACE_CPP
|
||||
50
BoardInterface.h
Normal file
50
BoardInterface.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef BOARDINTERFACE_H
|
||||
#define BOARDINTERFACE_H
|
||||
|
||||
#include "LiveData.h"
|
||||
#include "CarInterface.h"
|
||||
|
||||
class BoardInterface {
|
||||
|
||||
private:
|
||||
public:
|
||||
// Screens, buttons
|
||||
byte displayScreen = SCREEN_AUTO;
|
||||
byte displayScreenAutoMode = 0;
|
||||
byte displayScreenSpeedHud = false;
|
||||
byte displayScreenCount = 7;
|
||||
bool btnLeftPressed = true;
|
||||
bool btnMiddlePressed = true;
|
||||
bool btnRightPressed = true;
|
||||
bool testDataMode = false;
|
||||
bool scanDevices = false;
|
||||
// Debug screen - next command with right button
|
||||
uint16_t debugCommandIndex = 0;
|
||||
String debugAtshRequest = "ATSH7E4";
|
||||
String debugCommandRequest = "220101";
|
||||
String debugLastString = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
|
||||
String debugPreviousString = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
|
||||
//
|
||||
LiveData* liveData;
|
||||
CarInterface* carInterface;
|
||||
void setLiveData(LiveData* pLiveData);
|
||||
void attachCar(CarInterface* pCarInterface);
|
||||
virtual void initBoard()=0;
|
||||
virtual void afterSetup()=0;
|
||||
virtual void mainLoop()=0;
|
||||
virtual bool skipAdapterScan() {return false;};
|
||||
// Graphics & GUI
|
||||
virtual void displayMessage(const char* row1, const char* row2)=0;
|
||||
virtual void setBrightness(byte lcdBrightnessPerc)=0;
|
||||
virtual void redrawScreen()=0;
|
||||
// Menu
|
||||
virtual void showMenu()=0;
|
||||
virtual void hideMenu()=0;
|
||||
// Common
|
||||
void shutdownDevice();
|
||||
void saveSettings();
|
||||
void resetSettings();
|
||||
void loadSettings();
|
||||
};
|
||||
|
||||
#endif // BOARDINTERFACE_H
|
||||
24
BoardM5stackCore.cpp
Normal file
24
BoardM5stackCore.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef BOARDM5STACKCORE_CPP
|
||||
#define BOARDM5STACKCORE_CPP
|
||||
|
||||
#include "BoardInterface.h"
|
||||
#include "Board320_240.h"
|
||||
#include "BoardM5stackCore.h"
|
||||
|
||||
/**
|
||||
Init board
|
||||
*/
|
||||
void BoardM5stackCore::initBoard() {
|
||||
|
||||
this->invertDisplay = true;
|
||||
this->pinButtonLeft = BUTTON_LEFT;
|
||||
this->pinButtonRight = BUTTON_RIGHT;
|
||||
this->pinButtonMiddle = BUTTON_MIDDLE;
|
||||
this->pinSpeaker = SPEAKER_PIN;
|
||||
this->pinBrightness = TFT_BL;
|
||||
|
||||
Board320_240::initBoard();
|
||||
|
||||
}
|
||||
|
||||
#endif // BOARDM5STACKCORE_CPP
|
||||
44
BoardM5stackCore.h
Normal file
44
BoardM5stackCore.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef BOARDM5STACKCORE_H
|
||||
#define BOARDM5STACKCORE_H
|
||||
|
||||
// Setup for m5stack core
|
||||
#define USER_SETUP_LOADED 1
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
#define USER_SETUP_LOADED 1
|
||||
#define ILI9341_DRIVER
|
||||
#define M5STACK
|
||||
#define TFT_MISO 19
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 14 // Chip select control pin
|
||||
#define TFT_DC 27 // Data Command control pin
|
||||
#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
#define TFT_BL 32 // LED back-light
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_READ_FREQUENCY 5000000
|
||||
#define SPEAKER_PIN 25
|
||||
|
||||
#define BUTTON_LEFT 37
|
||||
#define BUTTON_MIDDLE 38
|
||||
#define BUTTON_RIGHT 39
|
||||
|
||||
#define SD_CS 4
|
||||
#define SD_MOSI 23
|
||||
#define SD_MISO 19
|
||||
#define SD_SCLK 18
|
||||
|
||||
//
|
||||
#include "BoardInterface.h"
|
||||
#include "Board320_240.h"
|
||||
|
||||
class BoardM5stackCore : public Board320_240 {
|
||||
|
||||
private:
|
||||
public:
|
||||
void initBoard() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // BOARDM5STACKCORE_H
|
||||
22
BoardTtgoT4v13.cpp
Normal file
22
BoardTtgoT4v13.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef BOARDTTGOT4V13_CPP
|
||||
#define BOARDTTGOT4V13_CPP
|
||||
|
||||
#include "BoardInterface.h"
|
||||
#include "Board320_240.h"
|
||||
#include "BoardTtgoT4v13.h"
|
||||
|
||||
/**
|
||||
Init board
|
||||
*/
|
||||
void BoardTtgoT4v13::initBoard() {
|
||||
|
||||
this->pinButtonLeft = BUTTON_LEFT;
|
||||
this->pinButtonRight = BUTTON_RIGHT;
|
||||
this->pinButtonMiddle = BUTTON_MIDDLE;
|
||||
//this->pinSpeaker = SPEAKER_PIN;
|
||||
this->pinBrightness = TFT_BL;
|
||||
|
||||
Board320_240::initBoard();
|
||||
}
|
||||
|
||||
#endif // BOARDTTGOT4V13_CPP
|
||||
45
BoardTtgoT4v13.h
Normal file
45
BoardTtgoT4v13.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef BOARDTTGOT4V13_H
|
||||
#define BOARDTTGOT4V13_H
|
||||
|
||||
// Setup for TTGO T4 v13
|
||||
#define USER_SETUP_LOADED 1
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
#define ILI9341_DRIVER
|
||||
#define TFT_MISO 12
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 27
|
||||
#define TFT_DC 32
|
||||
#define TFT_RST 5
|
||||
//#define TFT_BACKLIGHT_ON HIGH
|
||||
#define TFT_BL 4
|
||||
|
||||
#define USE_HSPI_PORT
|
||||
//#define SPI_FREQUENCY 40000000 // Maximum for ILI9341
|
||||
#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V
|
||||
|
||||
#define SD_CS 13
|
||||
#define SD_MOSI 15
|
||||
#define SD_MISO 2
|
||||
#define SD_SCLK 14
|
||||
|
||||
#define BUTTON_LEFT 38
|
||||
#define BUTTON_MIDDLE 37
|
||||
#define BUTTON_RIGHT 39
|
||||
|
||||
//
|
||||
#include "BoardInterface.h"
|
||||
#include "Board320_240.h"
|
||||
|
||||
//
|
||||
class BoardTtgoT4v13 : public Board320_240 {
|
||||
|
||||
private:
|
||||
public:
|
||||
void initBoard() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // BOARDTTGOT4V13_H
|
||||
381
CarHyundaiIoniq.cpp
Normal file
381
CarHyundaiIoniq.cpp
Normal file
@@ -0,0 +1,381 @@
|
||||
#ifndef CARHYUNDAIIONIQ_CPP
|
||||
#define CARHYUNDAIIONIQ_CPP
|
||||
|
||||
#include "CarHyundaiIoniq.h"
|
||||
|
||||
#define commandQueueCountHyundaiIoniq 25
|
||||
#define commandQueueLoopFromHyundaiIoniq 8
|
||||
|
||||
/**
|
||||
activatethis->liveData->commandQueue
|
||||
*/
|
||||
void CarHyundaiIoniq::activateCommandQueue() {
|
||||
|
||||
String commandQueueHyundaiIoniq[commandQueueCountHyundaiIoniq] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
//"AT AL", // Allow Long (>7 byte) messages
|
||||
//"AT AR", // Automatically receive
|
||||
//"AT H1", // Headers on (debug only)
|
||||
//"AT D1", // Display of the DLC on
|
||||
//"AT CAF0", // Automatic formatting off
|
||||
"AT DP",
|
||||
"AT ST16",
|
||||
|
||||
// Loop from (HYUNDAI IONIQ)
|
||||
// BMS
|
||||
"ATSH7E4",
|
||||
"2101", // power kw, ...
|
||||
"2102", // cell voltages, screen 3 only
|
||||
"2103", // cell voltages, screen 3 only
|
||||
"2104", // cell voltages, screen 3 only
|
||||
"2105", // soh, soc, ..
|
||||
"2106", // cooling water temp
|
||||
|
||||
// VMCU
|
||||
"ATSH7E2",
|
||||
"2101", // speed, ...
|
||||
"2102", // aux, ...
|
||||
|
||||
//"ATSH7Df",
|
||||
//"2106",
|
||||
//"220106",
|
||||
|
||||
// Aircondition
|
||||
// IONIQ OK
|
||||
"ATSH7B3",
|
||||
"220100", // in/out temp
|
||||
"220102", // coolant temp1, 2
|
||||
|
||||
// BCM / TPMS
|
||||
// IONIQ OK
|
||||
"ATSH7A0",
|
||||
"22c00b", // tire pressure/temp
|
||||
|
||||
// CLUSTER MODULE
|
||||
// IONIQ OK
|
||||
"ATSH7C6",
|
||||
"22B002", // odo
|
||||
};
|
||||
|
||||
// 28kWh version
|
||||
this->liveData->params.batteryTotalAvailableKWh = 28;
|
||||
this->liveData->params.batModuleTempCount = 12;
|
||||
|
||||
// Empty and fill command queue
|
||||
for (int i = 0; i < 300; i++) {
|
||||
this->liveData->commandQueue[i] = "";
|
||||
}
|
||||
for (int i = 0; i < commandQueueCountHyundaiIoniq; i++) {
|
||||
this->liveData->commandQueue[i] = commandQueueHyundaiIoniq[i];
|
||||
}
|
||||
|
||||
this->liveData->commandQueueLoopFrom = commandQueueLoopFromHyundaiIoniq;
|
||||
this->liveData->commandQueueCount = commandQueueCountHyundaiIoniq;
|
||||
}
|
||||
|
||||
/**
|
||||
parseRowMerged
|
||||
*/
|
||||
void CarHyundaiIoniq::parseRowMerged() {
|
||||
|
||||
// VMCU 7E2
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (this->liveData->commandRequest.equals("2101")) {
|
||||
this->liveData->params.speedKmh = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (this->liveData->params.speedKmh < -99 || this->liveData->params.speedKmh > 200)
|
||||
this->liveData->params.speedKmh = 0;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("2102")) {
|
||||
this->liveData->params.auxPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
this->liveData->params.auxCurrentAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (this->liveData->commandRequest.equals("22B002")) {
|
||||
this->liveData->params.odoKm = float(strtol(this->liveData->responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (this->liveData->commandRequest.equals("220100")) {
|
||||
this->liveData->params.indoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.outdoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("220102") && this->liveData->responseRowMerged.substring(12, 14) == "00") {
|
||||
this->liveData->params.coolantTemp1C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.coolantTemp2C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (this->liveData->commandRequest.equals("2101")) {
|
||||
this->liveData->params.cumulativeEnergyChargedKWh = float(strtol(this->liveData->responseRowMerged.substring(80, 88).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyChargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyChargedKWhStart = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.cumulativeEnergyDischargedKWh = float(strtol(this->liveData->responseRowMerged.substring(88, 96).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyDischargedKWhStart = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.availableChargePower = float(strtol(this->liveData->responseRowMerged.substring(16, 20).c_str(), 0, 16)) / 100.0;
|
||||
this->liveData->params.availableDischargePower = float(strtol(this->liveData->responseRowMerged.substring(20, 24).c_str(), 0, 16)) / 100.0;
|
||||
this->liveData->params.isolationResistanceKOhm = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(118, 122).c_str(), 2, true);
|
||||
this->liveData->params.batFanStatus = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(58, 60).c_str(), 2, true);
|
||||
this->liveData->params.batFanFeedbackHz = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(60, 62).c_str(), 2, true);
|
||||
this->liveData->params.auxVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(62, 64).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batPowerAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(24, 28).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(28, 32).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.batPowerKw = (this->liveData->params.batPowerAmp * this->liveData->params.batVoltage) / 1000.0;
|
||||
if (this->liveData->params.batPowerKw < 1) // Reset charging start time
|
||||
this->liveData->params.chargingStartTime = this->liveData->params.currentTime;
|
||||
this->liveData->params.batPowerKwh100 = this->liveData->params.batPowerKw / this->liveData->params.speedKmh * 100;
|
||||
this->liveData->params.batCellMaxV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batCellMinV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(54, 56).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batModuleTempC[0] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[1] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[2] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[3] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[4] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
//this->liveData->params.batTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//this->liveData->params.batMaxC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 34).c_str(), 1, true);
|
||||
//this->liveData->params.batMinC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batInletC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(48, 50).c_str(), 1, true);
|
||||
if (this->liveData->params.speedKmh < 10 && this->liveData->params.batPowerKw >= 1 && this->liveData->params.socPerc > 0 && this->liveData->params.socPerc <= 100) {
|
||||
if ( this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] == -100 || this->liveData->params.batPowerKw < this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
if ( this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] == -100 || this->liveData->params.batPowerKw > this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
this->liveData->params.chargingGraphBatMinTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMinC;
|
||||
this->liveData->params.chargingGraphBatMaxTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMaxC;
|
||||
this->liveData->params.chargingGraphHeaterTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batHeaterC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("2102") && this->liveData->responseRowMerged.substring(10, 12) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("2103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[32 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("2104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[64 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("2105")) {
|
||||
this->liveData->params.socPercPrevious = this->liveData->params.socPerc;
|
||||
this->liveData->params.sohPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(54, 58).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.socPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(66, 68).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Remaining battery modules (tempC)
|
||||
this->liveData->params.batModuleTempC[5] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(22, 24).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[6] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(24, 26).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[7] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(26, 28).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[8] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(28, 30).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[9] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 32).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[10] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 34).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[11] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < this->liveData->params.batModuleTempCount; i++) {
|
||||
if (this->liveData->params.batModuleTempC[i] < this->liveData->params.batMinC)
|
||||
this->liveData->params.batMinC = this->liveData->params.batModuleTempC[i];
|
||||
if (this->liveData->params.batModuleTempC[i] > this->liveData->params.batMaxC)
|
||||
this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[i];
|
||||
}
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (this->liveData->params.socPercPrevious - this->liveData->params.socPerc > 0) {
|
||||
byte index = (int(this->liveData->params.socPerc) == 4) ? 0 : (int)(this->liveData->params.socPerc / 10) + 1;
|
||||
if ((int(this->liveData->params.socPerc) % 10 == 9 || int(this->liveData->params.socPerc) == 4) && this->liveData->params.soc10ced[index] == -1) {
|
||||
this->liveData->params.soc10ced[index] = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.soc10cec[index] = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.soc10odo[index] = this->liveData->params.odoKm;
|
||||
this->liveData->params.soc10time[index] = this->liveData->params.currentTime;
|
||||
}
|
||||
}
|
||||
this->liveData->params.batHeaterC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
this->liveData->params.cellVoltage[96 - 30 + i] = -1;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
// IONIQ FAILED
|
||||
if (this->liveData->commandRequest.equals("2106")) {
|
||||
this->liveData->params.coolingWaterTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (this->liveData->commandRequest.equals("22c00b")) {
|
||||
this->liveData->params.tireFrontLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireFrontRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
loadTestData
|
||||
*/
|
||||
void CarHyundaiIoniq::loadTestData() {
|
||||
|
||||
// VMCU ATSH7E2
|
||||
this->liveData->currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
this->liveData->commandRequest = "2101";
|
||||
this->liveData->responseRowMerged = "6101FFE0000009211222062F03000000001D7734";
|
||||
this->parseRowMerged();
|
||||
// 2102
|
||||
this->liveData->commandRequest = "2102";
|
||||
this->liveData->responseRowMerged = "6102FF80000001010000009315B2888D390B08618B683900000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// "ATSH7DF",
|
||||
this->liveData->currentAtshRequest = "ATSH7DF";
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
this->liveData->currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
this->liveData->commandRequest = "220100";
|
||||
this->liveData->responseRowMerged = "6201007E5007C8FF8A876A011010FFFF10FF10FFFFFFFFFFFFFFFFFF2EEF767D00FFFF00FFFF000000";
|
||||
this->parseRowMerged();
|
||||
// 220102
|
||||
this->liveData->commandRequest = "220102";
|
||||
this->liveData->responseRowMerged = "620102FF800000A3950000000000002600000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// BMS ATSH7E4
|
||||
this->liveData->currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
this->liveData->commandRequest = "2101";
|
||||
this->liveData->responseRowMerged = "6101FFFFFFFF5026482648A3FFC30D9E181717171718170019B50FB501000090000142230001425F0000771B00007486007815D809015C0000000003E800";
|
||||
this->parseRowMerged();
|
||||
// 220102
|
||||
this->liveData->commandRequest = "2102";
|
||||
this->liveData->responseRowMerged = "6102FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
this->parseRowMerged();
|
||||
// 220103
|
||||
this->liveData->commandRequest = "2103";
|
||||
this->liveData->responseRowMerged = "6103FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
this->parseRowMerged();
|
||||
// 220104
|
||||
this->liveData->commandRequest = "2104";
|
||||
this->liveData->responseRowMerged = "6104FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
this->parseRowMerged();
|
||||
// 220105
|
||||
this->liveData->commandRequest = "2105";
|
||||
this->liveData->responseRowMerged = "6105FFFFFFFF00000000001717171817171726482648000150181703E81A03E801520029000000000000000000000000";
|
||||
this->parseRowMerged();
|
||||
// 220106
|
||||
this->liveData->commandRequest = "2106";
|
||||
this->liveData->responseRowMerged = "7F2112"; // n/a on ioniq
|
||||
this->parseRowMerged();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
this->liveData->currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
this->liveData->commandRequest = "22c00b";
|
||||
this->liveData->responseRowMerged = "62C00BFFFF0000B9510100B9510100B84F0100B54F0100AAAAAAAA";
|
||||
this->parseRowMerged();
|
||||
|
||||
// ATSH7C6
|
||||
this->liveData->currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
this->liveData->commandRequest = "22b002";
|
||||
this->liveData->responseRowMerged = "62B002E000000000AD003D2D0000000000000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
/* this->liveData->params.batModule01TempC = 28;
|
||||
this->liveData->params.batModule02TempC = 29;
|
||||
this->liveData->params.batModule03TempC = 28;
|
||||
this->liveData->params.batModule04TempC = 30;
|
||||
//this->liveData->params.batTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//this->liveData->params.batMaxC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//this->liveData->params.batMinC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModule01TempC;
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModule02TempC < this->liveData->params.batMinC) ? this->liveData->params.batModule02TempC : this->liveData->params.batMinC ;
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModule03TempC < this->liveData->params.batMinC) ? this->liveData->params.batModule03TempC : this->liveData->params.batMinC ;
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModule04TempC < this->liveData->params.batMinC) ? this->liveData->params.batModule04TempC : this->liveData->params.batMinC ;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModule02TempC > this->liveData->params.batMaxC) ? this->liveData->params.batModule02TempC : this->liveData->params.batMaxC ;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModule03TempC > this->liveData->params.batMaxC) ? this->liveData->params.batModule03TempC : this->liveData->params.batMaxC ;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModule04TempC > this->liveData->params.batMaxC) ? this->liveData->params.batModule04TempC : this->liveData->params.batMaxC ;
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
//
|
||||
this->liveData->params.soc10ced[10] = 2200;
|
||||
this->liveData->params.soc10cec[10] = 2500;
|
||||
this->liveData->params.soc10odo[10] = 13000;
|
||||
this->liveData->params.soc10time[10] = 13000;
|
||||
this->liveData->params.soc10ced[9] = this->liveData->params.soc10ced[10] + 6.4;
|
||||
this->liveData->params.soc10cec[9] = this->liveData->params.soc10cec[10] + 0;
|
||||
this->liveData->params.soc10odo[9] = this->liveData->params.soc10odo[10] + 30;
|
||||
this->liveData->params.soc10time[9] = this->liveData->params.soc10time[10] + 900;
|
||||
this->liveData->params.soc10ced[8] = this->liveData->params.soc10ced[9] + 6.8;
|
||||
this->liveData->params.soc10cec[8] = this->liveData->params.soc10cec[9] + 0;
|
||||
this->liveData->params.soc10odo[8] = this->liveData->params.soc10odo[9] + 30;
|
||||
this->liveData->params.soc10time[8] = this->liveData->params.soc10time[9] + 900;
|
||||
this->liveData->params.soc10ced[7] = this->liveData->params.soc10ced[8] + 7.2;
|
||||
this->liveData->params.soc10cec[7] = this->liveData->params.soc10cec[8] + 0.6;
|
||||
this->liveData->params.soc10odo[7] = this->liveData->params.soc10odo[8] + 30;
|
||||
this->liveData->params.soc10time[7] = this->liveData->params.soc10time[8] + 900;
|
||||
this->liveData->params.soc10ced[6] = this->liveData->params.soc10ced[7] + 6.7;
|
||||
this->liveData->params.soc10cec[6] = this->liveData->params.soc10cec[7] + 0;
|
||||
this->liveData->params.soc10odo[6] = this->liveData->params.soc10odo[7] + 30;
|
||||
this->liveData->params.soc10time[6] = this->liveData->params.soc10time[7] + 900;
|
||||
this->liveData->params.soc10ced[5] = this->liveData->params.soc10ced[6] + 6.7;
|
||||
this->liveData->params.soc10cec[5] = this->liveData->params.soc10cec[6] + 0;
|
||||
this->liveData->params.soc10odo[5] = this->liveData->params.soc10odo[6] + 30;
|
||||
this->liveData->params.soc10time[5] = this->liveData->params.soc10time[6] + 900;
|
||||
this->liveData->params.soc10ced[4] = this->liveData->params.soc10ced[5] + 6.4;
|
||||
this->liveData->params.soc10cec[4] = this->liveData->params.soc10cec[5] + 0.3;
|
||||
this->liveData->params.soc10odo[4] = this->liveData->params.soc10odo[5] + 30;
|
||||
this->liveData->params.soc10time[4] = this->liveData->params.soc10time[5] + 900;
|
||||
this->liveData->params.soc10ced[3] = this->liveData->params.soc10ced[4] + 6.4;
|
||||
this->liveData->params.soc10cec[3] = this->liveData->params.soc10cec[4] + 0;
|
||||
this->liveData->params.soc10odo[3] = this->liveData->params.soc10odo[4] + 30;
|
||||
this->liveData->params.soc10time[3] = this->liveData->params.soc10time[4] + 900;
|
||||
this->liveData->params.soc10ced[2] = this->liveData->params.soc10ced[3] + 5.4;
|
||||
this->liveData->params.soc10cec[2] = this->liveData->params.soc10cec[3] + 0.1;
|
||||
this->liveData->params.soc10odo[2] = this->liveData->params.soc10odo[3] + 30;
|
||||
this->liveData->params.soc10time[2] = this->liveData->params.soc10time[3] + 900;
|
||||
this->liveData->params.soc10ced[1] = this->liveData->params.soc10ced[2] + 6.2;
|
||||
this->liveData->params.soc10cec[1] = this->liveData->params.soc10cec[2] + 0.1;
|
||||
this->liveData->params.soc10odo[1] = this->liveData->params.soc10odo[2] + 30;
|
||||
this->liveData->params.soc10time[1] = this->liveData->params.soc10time[2] + 900;
|
||||
this->liveData->params.soc10ced[0] = this->liveData->params.soc10ced[1] + 2.9;
|
||||
this->liveData->params.soc10cec[0] = this->liveData->params.soc10cec[1] + 0.5;
|
||||
this->liveData->params.soc10odo[0] = this->liveData->params.soc10odo[1] + 15;
|
||||
this->liveData->params.soc10time[0] = this->liveData->params.soc10time[1] + 900;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endif //CARHYUNDAIIONIQ_CPP
|
||||
16
CarHyundaiIoniq.h
Normal file
16
CarHyundaiIoniq.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CARHYUNDAIIONIQ_H
|
||||
#define CARHYUNDAIIONIQ_H
|
||||
|
||||
#include "CarInterface.h"
|
||||
|
||||
class CarHyundaiIoniq : public CarInterface {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void activateCommandQueue() override;
|
||||
void parseRowMerged() override;
|
||||
void loadTestData() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
23
CarInterface.cpp
Normal file
23
CarInterface.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef CARINTERFACE_CPP
|
||||
#define CARINTERFACE_CPP
|
||||
|
||||
#include "CarInterface.h"
|
||||
#include "LiveData.h"
|
||||
|
||||
void CarInterface::setLiveData(LiveData* pLiveData) {
|
||||
this->liveData = pLiveData;
|
||||
}
|
||||
|
||||
void CarInterface::activateCommandQueue() {
|
||||
|
||||
}
|
||||
|
||||
void CarInterface::parseRowMerged() {
|
||||
|
||||
}
|
||||
|
||||
void CarInterface::loadTestData() {
|
||||
|
||||
}
|
||||
|
||||
#endif // CARINTERFACE_CPP
|
||||
17
CarInterface.h
Normal file
17
CarInterface.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef CARINTERFACE_H
|
||||
#define CARINTERFACE_H
|
||||
|
||||
#include "LiveData.h"
|
||||
|
||||
class CarInterface {
|
||||
|
||||
private:
|
||||
public:
|
||||
LiveData* liveData;
|
||||
void setLiveData(LiveData* pLiveData);
|
||||
virtual void activateCommandQueue();
|
||||
virtual void parseRowMerged();
|
||||
virtual void loadTestData();
|
||||
};
|
||||
|
||||
#endif // CARINTERFACE_H
|
||||
520
CarKiaDebugObd2.cpp
Normal file
520
CarKiaDebugObd2.cpp
Normal file
@@ -0,0 +1,520 @@
|
||||
#ifndef CARKIADEBUGOBD2_CPP
|
||||
#define CARKIADEBUGOBD2_CPP
|
||||
|
||||
#include "CarKiaDebugObd2.h"
|
||||
|
||||
#define commandQueueCountDebugObd2Kia 256
|
||||
#define commandQueueLoopFromDebugObd2Kia 8
|
||||
|
||||
/**
|
||||
activateCommandQueue
|
||||
*/
|
||||
void CarKiaDebugObd2::activateCommandQueue() {
|
||||
|
||||
String commandQueueDebugObd2Kia[commandQueueCountDebugObd2Kia] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
"AT DP",
|
||||
"AT ST16",
|
||||
|
||||
// Loop from here
|
||||
|
||||
// Request ID Response ID ECU name Can bus Protocol Description
|
||||
// 725 72D WPS B Wireless phone charger
|
||||
//"ATSH725",
|
||||
//"2201", // All with negative resp. "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 736 73E VESS P Virtual Engine Sound system
|
||||
//"ATSH736",
|
||||
//"2201", // All with negative resp. "2202", "2203", "2101", "2102",
|
||||
//"220101", // All with 62 response "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 755 75D BSD Right Blind spot detection Right
|
||||
// "ATSH755",
|
||||
// "2201", // ALL with negative 7F2213, etc "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 770 778 IGPM All UDS Integrated Gateway and power control module
|
||||
"ATSH770",
|
||||
"22BC01", // 009 62BC01400000000001AAAAAAAA
|
||||
"22BC02", // 62BC0200000000
|
||||
"22BC03", // 00B 62BC03FDEE7C730A600000AAAA
|
||||
"22BC04", // 00B 62BC04B33F74EA0D002042AAAA
|
||||
"22BC05", // 00B 62BC05BF13200001000000AAAA
|
||||
"22BC06", // 00B 62BC06B48000002C000000AAAA
|
||||
"22BC07", // 00B 62BC070849DBC000101900AAAA
|
||||
//"22BC08", // ALL with NEGATIVE RESPONSE "22BC09", "22BC0A", "22BC0B", "22BC0C", "22BC0D", "22BC0E", "22BC0F",
|
||||
|
||||
// 783 78B AMP M Amplifier
|
||||
//"ATSH783",
|
||||
// "2201",// ALL with NEGATIVE RESPONSE "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 796 79E PGS C Parking Guide System
|
||||
//"ATSH796",
|
||||
//"2201", // ALL with NEGATIVE RESPONSE "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A0 7A8 BCM / TPMS B UDS Body control module 22 B0 01 to 22 B0 0E
|
||||
// C Tire Pressure Monitoring "At least 22 C0 01 to 22 C0 02 & 22 C0 0B to 22 C0 0F"
|
||||
"ATSH7A0",
|
||||
"22B001", // 016 62B00140C20000000000000000000001010000000001AAAAAAAAAA
|
||||
"22B002", // 009 62B002C00000000300AAAAAAAA
|
||||
"22B003", // 018 62B003BFCB8000A23D63B164F8F7F73DF80000A400A4A4A4AAAAAA
|
||||
"22B004", // 00B 62B0047402994E0E008800AAAA
|
||||
"22B005", // 00B 62B0052000100000000800AAAA
|
||||
"22B006", // 00B 62B0062000000000000000AAAA
|
||||
"22B007", // 00B 62B007002001E000040000AAAA
|
||||
"22B008", // 00B 62B00800510C2000880004AAAA
|
||||
"22B009", // 00B 62B009FEEEFEEE08000800AAAA
|
||||
"22B00A", // 00B 62B00AE3FEE3000040C500AAAA
|
||||
//"22B00B", // 7F2231
|
||||
"22B00C", // 00B 62B00C3F00000000000000AAAA
|
||||
"22B00D", // 00B 62B00DFCFCFC0000000000AAAA
|
||||
"22B00E", // 00B 62B00E0800000000000000AAAA
|
||||
//"22B00F", // 7F2231
|
||||
"22C001", // 01D 62C001000000002E2E02500706B5B50A098C3C0000000001FF01000101AAAAAAAAAA
|
||||
"22C002", // 017 62C002FFFF0000D2E149F3D2DBDACBD2E84EBBD2E84E93AAAAAAAA
|
||||
"22C003", // 021 62C00300000000444F303101002E2E02500706B5B50A098C3C0000000001FF0100AA
|
||||
"22C004", // 021 62C004000000004E41303101002E2E024B0005B5B508088C3C0100000001FF0100AA
|
||||
"22C005", // 021 62C005000000004E54504D0100302F02500000ABAB00008C3C0000030001FF0000AA
|
||||
"22C006", // 021 62C00600000000444F303201002E2E02500706B5AB0A098C3C0000000001010100AA
|
||||
"22C007", // 021 62C007000000004E41303201002E2E024B0005B5AB08088C3C0100000001010100AA
|
||||
"22C008", // 021 62C00800000000434E303101002E2E02500706B5B50A098C3C0000020001FF0100AA
|
||||
"22C009", // 021 62C00900000000303030360000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAA
|
||||
"22C00A", // 021 62C00A00000000303030370000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAA
|
||||
"22C00B", // 017 62C00BFFFF0000AF470100B4480100B5460100B3460100AAAAAAAA
|
||||
"22C00C", // 025 62C00CFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00D", // 025 62C00DFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00E", // 025 62C00EFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00F", // 025 62C00FFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
|
||||
// 7A1 7A9 DDM B Driver door module
|
||||
// "ATSH7A1",
|
||||
// "2201", // All with NO DATA "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A2 7AA ADM B Assist door module
|
||||
//"ATSH7A2",
|
||||
// "2201", // ALL with NO DATA "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A3 7AB PSM B UDS Power Seat Module
|
||||
// "ATSH7A3",
|
||||
// "22B401", // All with NO DATA "22B402", "22B403", "22B404", "22B405", "22B406", "22B407", "22B408", "22B409", "22B40A",
|
||||
|
||||
// 7A5 7AD SMK B UDS Smart Key
|
||||
"ATSH7A5",
|
||||
"22B001", // 7F2278 7F2231
|
||||
"22B002", // positive
|
||||
"22B003", // positive
|
||||
"22B004", // 7F2278 7F2231
|
||||
"22B005", // positive
|
||||
"22B006", // positive
|
||||
"22B007", // positive
|
||||
"22B008", // positive
|
||||
"22B009", // positive
|
||||
"22B00A", // positive
|
||||
|
||||
// 7B3 7BB AIRCON / ACU UDS Aircondition
|
||||
"ATSH7B3",
|
||||
"220100", // 026 6201007E5027C8FF7C6D6B05EFBCFFFFEFFF10FFFFFFFFFFFFBFFFFF52B3919900FFFF01FFFF000000 in/out temp
|
||||
// "220101", // 7F2231
|
||||
"220102", // 014 620102FFF80000B36B0101000101003C00016E12 coolant temp1, 2
|
||||
// "220103", // 7F2231
|
||||
|
||||
// 7B7 7BF BSD Left Blind spot detection Left
|
||||
"ATSH7B7",
|
||||
// "2201", // ALL NEGATIVE RESP "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7C4 7CC MFC Multi Function Camera
|
||||
"ATSH7C4",
|
||||
"220101", // 6201010E
|
||||
"220102", // 62010200000000
|
||||
|
||||
// 7C6 7CE CM C & M UDS Cluster Module
|
||||
"ATSH7C6",
|
||||
"22B001", // 008 62B00100000000000000000000
|
||||
"22B002", // 00F 62B002E0000000FFA200AD8F0000000000000000 odo
|
||||
"22B003", // 008 62B00398000000010000000000
|
||||
//"22B004", // NO DATA
|
||||
|
||||
// 7D0 7D8 AEB UDS? Autonomous Emergency Breaking
|
||||
// "ATSH7D0",
|
||||
// "2201", // ALL CODES WITH NEGATIVE RESPONSE
|
||||
// "2202", // "2203", // "2101", // "2102", // "220101", // "220102", // "22B001", // "22C001", // "22C101",
|
||||
|
||||
// 7D1 7D9 ABS / ESP + AHB UDS
|
||||
"ATSH7D1",
|
||||
"22C101", // 02A 62C1015FD7E7D0FFFF00FF04D0D400000000FF7EFF0030F5010000FFFF7F6307F207FE05FF00FF3FFFFFAAAAAAAAAAAA
|
||||
"22C102", // 01A 62C10237000000FFFFFFFFFFFF00FF05FFFFFF00FF5501FFFFFFAA
|
||||
"22C103", // 01A 62C103BE3000000DFFF0FCFE7FFF7FFFFFFFFFFF000005B50000AA
|
||||
|
||||
// 7D2 7DA AIRBAG SRS Sytem
|
||||
// "ATSH7D2",
|
||||
// "2101", // 7F2211
|
||||
// "2102", // 7F2211
|
||||
// "220101", // 7F2211
|
||||
// "220102", // 7F2211
|
||||
// "22B001", // 7F2211
|
||||
// "22C001", // 7F2211
|
||||
// "22C101", // 7F2211
|
||||
|
||||
// 7D4 7DC EPS Electric power steering
|
||||
"ATSH7D4",
|
||||
//"2101", // 7F2121
|
||||
//"2102", // 7F2121
|
||||
"220101", // 012 6201018387FD009DFFF90100000010101921AAAA
|
||||
"220102", // 008 6201020000000500AAAAAAAAAA
|
||||
// "22B001", // 7F2231
|
||||
// "22C001", // 7F2231
|
||||
// "22C101", // 7F2231
|
||||
|
||||
// 7DF UNKNOWN
|
||||
//"ATSH7DF",
|
||||
//"2106", // 013 7F2112 028 6106FFFF800000000000000300001C001C001C000600060006000F000000010000000000000000015801580158015700
|
||||
//"220106", // 01B 620106FFFFFFFF12001200307C7C00317C830000B4B3000A28EA00
|
||||
|
||||
// 7E2 7EA VMCU H & P KWP2000 Vehicle Motor Control Unit 21 01 to 21 02 & 1A 80++
|
||||
"ATSH7E2",
|
||||
"2101", // 018 6101FFF8000009285A3806480300000000C4693404080805000000 speed, ..
|
||||
"2102", // 027 6102F8FFFC000101000000851BB5780234FA0BAB8D1933E07F5B211C74000001010100000007000000 aux, ..
|
||||
//"2103", // 7F2112
|
||||
//"1A80", // Working VIN 1A 8A 8C 8D ..
|
||||
|
||||
// 7E3 7EB MCU H & P KWP2000 Motor Control Unit 21 01 to 21 06
|
||||
"ATSH7E3",
|
||||
"2101", // 01E 610100007FFF0C3C00BD8D0A3300B00900002D0252025033D500C3FF68FF00000000
|
||||
"2102", // 03A 610207FFFFFF00000D000D00260008080909000001004614CDABC2CD3F005581720085CAF5265D0DC1CD0000EC3400000000000000000000FF0000000000
|
||||
"2103", // 06E 610300007FFF0000000000000000000000000000000000005C010E02FDFD040400000000000000000000000048058D0C0200160000000000AA3F000005000000AE0102000000000000000000000000000000000000000000BB0B00000000000000000000680000000000E803000000
|
||||
"2104", // 060 6104000001FF000000000000D7425D03000000000000050000007A2B00000000000000003200000000000000000000000000000000000000000000000000000000000000010000000100010001000000030000000000000000006D0000008E1B00
|
||||
"2105", // 067 6105000001FF630200010000005900000C00630200010000000100000C006B0200020000003300250D0136010096BA03000100000C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
"2106", // 013 6106000000030000000000000000000000000300
|
||||
//"2107", // 7F2112
|
||||
|
||||
// 7E4 7EC BMS P UDS Battery Management System 22 01 01 to 22 01 06
|
||||
"ATSH7E4",
|
||||
"220101", // 03E 620101FFF7E7FF6B0000000003001C0E2F161414141513000012B930B9380000830003E1E30003C95B0001722C00015B5B0040D1660D016B0000000003E8 power kw, ..
|
||||
"220102", // 027 620102FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA cell voltages, screen 3 only
|
||||
"220103", // 027 620103FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA cell voltages, screen 3 only
|
||||
"220104", // 027 620104FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA
|
||||
"220105", // 02E 620105003FFF90000000000000000012836A0142684268000150126E03E8000000006E0000B9B900000F00000000AAAA soh, soc, .
|
||||
"220106", // 01B 620106FFFFFFFF12001200307C7C00007C030000B4B3000A28EA00 cooling water temp
|
||||
// "220107", // 7F2231
|
||||
|
||||
// 7E5 7ED OBC KWP2000 OnBoard Charger 21 01 to 21 03
|
||||
"ATSH7E5",
|
||||
"2101", // 01A 6101DFE0000001010001000000000E2F0533051D0078000000C800
|
||||
"2102", // 011 6102FE000000000403E8000001BF000028000000
|
||||
"2103", // 039 6103FFFFFDF80000000000000000000000000000000000000000000000000000000000000000007576767600000000000000000004000400030000000000
|
||||
"2104", // 022 6104FFF000000A280A280A280000E324006900000003000000000000000000000000
|
||||
"2105", // 046 61050000000081AA791E8013791E779C791E8BD37907874A79108D67791473777915727E7914753179156FAE7917768F79147650792876257930757E7914759379167545791D000000000000
|
||||
"2106", // 028 6106FFFF8000001C001C001C000600060006000E000000010000000000000000015801580158015800
|
||||
//"2107", // ret 7F2112
|
||||
|
||||
// 7E6 7EE ?? ?? 21 08 05 to 21 08 0F -> All negative response
|
||||
//"ATSH7E6",
|
||||
//"210805", // ret 7F2112
|
||||
//"210806", // ret 7F2112
|
||||
//"210807", // ret 7F2112
|
||||
};
|
||||
|
||||
// 39 or 64 kWh model?
|
||||
this->liveData->params.batteryTotalAvailableKWh = 64;
|
||||
|
||||
// Empty and fill command queue
|
||||
for (uint16_t i = 0; i < 300; i++) {
|
||||
this->liveData->commandQueue[i] = "";
|
||||
}
|
||||
for (uint16_t i = 0; i < commandQueueCountDebugObd2Kia; i++) {
|
||||
this->liveData->commandQueue[i] = commandQueueDebugObd2Kia[i];
|
||||
}
|
||||
|
||||
this->liveData->commandQueueLoopFrom = commandQueueLoopFromDebugObd2Kia;
|
||||
this->liveData->commandQueueCount = commandQueueCountDebugObd2Kia;
|
||||
}
|
||||
|
||||
/**
|
||||
parseRowMerged
|
||||
*/
|
||||
void CarKiaDebugObd2::parseRowMerged() {
|
||||
|
||||
// VMCU 7E2
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (this->liveData->commandRequest.equals("2101")) {
|
||||
this->liveData->params.speedKmh = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (this->liveData->params.speedKmh < -99 || this->liveData->params.speedKmh > 200)
|
||||
this->liveData->params.speedKmh = 0;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("2102")) {
|
||||
this->liveData->params.auxPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
this->liveData->params.auxCurrentAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (this->liveData->commandRequest.equals("22B002")) {
|
||||
this->liveData->params.odoKm = float(strtol(this->liveData->responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (this->liveData->commandRequest.equals("220100")) {
|
||||
this->liveData->params.indoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.outdoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("220102") && this->liveData->responseRowMerged.substring(12, 14) == "00") {
|
||||
this->liveData->params.coolantTemp1C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.coolantTemp2C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (this->liveData->commandRequest.equals("220101")) {
|
||||
this->liveData->params.cumulativeEnergyChargedKWh = float(strtol(this->liveData->responseRowMerged.substring(82, 90).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyChargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyChargedKWhStart = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.cumulativeEnergyDischargedKWh = float(strtol(this->liveData->responseRowMerged.substring(90, 98).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyDischargedKWhStart = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.auxVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(64, 66).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batPowerAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(26, 30).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 34).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.batPowerKw = (this->liveData->params.batPowerAmp * this->liveData->params.batVoltage) / 1000.0;
|
||||
this->liveData->params.batPowerKwh100 = this->liveData->params.batPowerKw / this->liveData->params.speedKmh * 100;
|
||||
this->liveData->params.batCellMaxV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(52, 54).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batCellMinV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(56, 58).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batModuleTempC[0] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[1] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[2] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[3] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
//this->liveData->params.batTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//this->liveData->params.batMaxC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//this->liveData->params.batMinC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[0];
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModuleTempC[1] < this->liveData->params.batMinC) ? this->liveData->params.batModuleTempC[1] : this->liveData->params.batMinC;
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModuleTempC[2] < this->liveData->params.batMinC) ? this->liveData->params.batModuleTempC[2] : this->liveData->params.batMinC;
|
||||
this->liveData->params.batMinC = (this->liveData->params.batModuleTempC[3] < this->liveData->params.batMinC) ? this->liveData->params.batModuleTempC[3] : this->liveData->params.batMinC;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModuleTempC[1] > this->liveData->params.batMaxC) ? this->liveData->params.batModuleTempC[1] : this->liveData->params.batMaxC;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModuleTempC[2] > this->liveData->params.batMaxC) ? this->liveData->params.batModuleTempC[2] : this->liveData->params.batMaxC;
|
||||
this->liveData->params.batMaxC = (this->liveData->params.batModuleTempC[3] > this->liveData->params.batMaxC) ? this->liveData->params.batModuleTempC[3] : this->liveData->params.batMaxC;
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
this->liveData->params.batInletC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
if (this->liveData->params.speedKmh < 10 && this->liveData->params.batPowerKw >= 1 && this->liveData->params.socPerc > 0 && this->liveData->params.socPerc <= 100) {
|
||||
if ( this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] == -100 || this->liveData->params.batPowerKw < this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
if ( this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] == -100 || this->liveData->params.batPowerKw > this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
this->liveData->params.chargingGraphBatMinTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMinC;
|
||||
this->liveData->params.chargingGraphBatMaxTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMaxC;
|
||||
this->liveData->params.chargingGraphHeaterTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batHeaterC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220102") && this->liveData->responseRowMerged.substring(12, 14) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[32 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[64 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220105")) {
|
||||
this->liveData->params.socPercPrevious = this->liveData->params.socPerc;
|
||||
this->liveData->params.sohPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(56, 60).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.socPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(68, 70).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (this->liveData->params.socPercPrevious - this->liveData->params.socPerc > 0) {
|
||||
byte index = (int(this->liveData->params.socPerc) == 4) ? 0 : (int)(this->liveData->params.socPerc / 10) + 1;
|
||||
if ((int(this->liveData->params.socPerc) % 10 == 9 || int(this->liveData->params.socPerc) == 4) && this->liveData->params.soc10ced[index] == -1) {
|
||||
struct tm now;
|
||||
getLocalTime(&now, 0);
|
||||
time_t time_now_epoch = mktime(&now);
|
||||
this->liveData->params.soc10ced[index] = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.soc10cec[index] = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.soc10odo[index] = this->liveData->params.odoKm;
|
||||
this->liveData->params.soc10time[index] = time_now_epoch;
|
||||
}
|
||||
}
|
||||
this->liveData->params.batHeaterC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(52, 54).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
this->liveData->params.cellVoltage[96 - 30 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220106")) {
|
||||
this->liveData->params.coolingWaterTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (this->liveData->commandRequest.equals("22c00b")) {
|
||||
this->liveData->params.tireFrontLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireFrontRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
loadTestData
|
||||
*/
|
||||
void CarKiaDebugObd2::loadTestData() {
|
||||
|
||||
// VMCU ATSH7E2
|
||||
this->liveData->currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
this->liveData->commandRequest = "2101";
|
||||
this->liveData->responseRowMerged = "6101FFF8000009285A3B0648030000B4179D763404080805000000";
|
||||
this->parseRowMerged();
|
||||
// 2102
|
||||
this->liveData->commandRequest = "2102";
|
||||
this->liveData->responseRowMerged = "6102F8FFFC000101000000840FBF83BD33270680953033757F59291C76000001010100000007000000";
|
||||
this->liveData->responseRowMerged = "6102F8FFFC000101000000931CC77F4C39040BE09BA7385D8158832175000001010100000007000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// "ATSH7DF",
|
||||
this->liveData->currentAtshRequest = "ATSH7DF";
|
||||
// 2106
|
||||
this->liveData->commandRequest = "2106";
|
||||
this->liveData->responseRowMerged = "6106FFFF800000000000000200001B001C001C000600060006000E000000010000000000000000013D013D013E013E00";
|
||||
this->parseRowMerged();
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
this->liveData->currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
this->liveData->commandRequest = "220100";
|
||||
this->liveData->responseRowMerged = "6201007E5027C8FF7F765D05B95AFFFF5AFF11FFFFFFFFFFFF6AFFFF2DF0757630FFFF00FFFF000000";
|
||||
this->liveData->responseRowMerged = "6201007E5027C8FF867C58121010FFFF10FF8EFFFFFFFFFFFF10FFFF0DF0617900FFFF01FFFF000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// BMS ATSH7E4
|
||||
this->liveData->currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
this->liveData->commandRequest = "220101";
|
||||
this->liveData->responseRowMerged = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
|
||||
this->liveData->responseRowMerged = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
|
||||
this->parseRowMerged();
|
||||
// 220102
|
||||
this->liveData->commandRequest = "220102";
|
||||
this->liveData->responseRowMerged = "620102FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220103
|
||||
this->liveData->commandRequest = "220103";
|
||||
this->liveData->responseRowMerged = "620103FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCACBCACACFCCCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220104
|
||||
this->liveData->commandRequest = "220104";
|
||||
this->liveData->responseRowMerged = "620104FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220105
|
||||
this->liveData->commandRequest = "220105";
|
||||
this->liveData->responseRowMerged = "620105003fff9000000000000000000F8A86012B4946500101500DAC03E800000000AC0000C7C701000F00000000AAAA";
|
||||
this->liveData->responseRowMerged = "620105003FFF90000000000000000014918E012927465000015013BB03E800000000BB0000CBCB01001300000000AAAA";
|
||||
this->parseRowMerged();
|
||||
// 220106
|
||||
this->liveData->commandRequest = "220106";
|
||||
this->liveData->responseRowMerged = "620106FFFFFFFF14001A00240000003A7C86B4B30000000928EA00";
|
||||
this->parseRowMerged();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
this->liveData->currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
this->liveData->commandRequest = "22c00b";
|
||||
this->liveData->responseRowMerged = "62C00BFFFF0000B93D0100B43E0100B43D0100BB3C0100AAAAAAAA";
|
||||
this->parseRowMerged();
|
||||
|
||||
// ATSH7C6
|
||||
this->liveData->currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
this->liveData->commandRequest = "22b002";
|
||||
this->liveData->responseRowMerged = "62B002E0000000FFB400330B0000000000000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
this->liveData->params.batModuleTempC[0] = 28;
|
||||
this->liveData->params.batModuleTempC[1] = 29;
|
||||
this->liveData->params.batModuleTempC[2] = 28;
|
||||
this->liveData->params.batModuleTempC[3] = 30;
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < this->liveData->params.batModuleTempCount; i++) {
|
||||
if (this->liveData->params.batModuleTempC[i] < this->liveData->params.batMinC)
|
||||
this->liveData->params.batMinC = this->liveData->params.batModuleTempC[i];
|
||||
if (this->liveData->params.batModuleTempC[i] > this->liveData->params.batMaxC)
|
||||
this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[i];
|
||||
}
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
//
|
||||
this->liveData->params.soc10ced[10] = 2200;
|
||||
this->liveData->params.soc10cec[10] = 2500;
|
||||
this->liveData->params.soc10odo[10] = 13000;
|
||||
this->liveData->params.soc10time[10] = 13000;
|
||||
this->liveData->params.soc10ced[9] = this->liveData->params.soc10ced[10] + 6.4;
|
||||
this->liveData->params.soc10cec[9] = this->liveData->params.soc10cec[10] + 0;
|
||||
this->liveData->params.soc10odo[9] = this->liveData->params.soc10odo[10] + 30;
|
||||
this->liveData->params.soc10time[9] = this->liveData->params.soc10time[10] + 900;
|
||||
this->liveData->params.soc10ced[8] = this->liveData->params.soc10ced[9] + 6.8;
|
||||
this->liveData->params.soc10cec[8] = this->liveData->params.soc10cec[9] + 0;
|
||||
this->liveData->params.soc10odo[8] = this->liveData->params.soc10odo[9] + 30;
|
||||
this->liveData->params.soc10time[8] = this->liveData->params.soc10time[9] + 900;
|
||||
this->liveData->params.soc10ced[7] = this->liveData->params.soc10ced[8] + 7.2;
|
||||
this->liveData->params.soc10cec[7] = this->liveData->params.soc10cec[8] + 0.6;
|
||||
this->liveData->params.soc10odo[7] = this->liveData->params.soc10odo[8] + 30;
|
||||
this->liveData->params.soc10time[7] = this->liveData->params.soc10time[8] + 900;
|
||||
this->liveData->params.soc10ced[6] = this->liveData->params.soc10ced[7] + 6.7;
|
||||
this->liveData->params.soc10cec[6] = this->liveData->params.soc10cec[7] + 0;
|
||||
this->liveData->params.soc10odo[6] = this->liveData->params.soc10odo[7] + 30;
|
||||
this->liveData->params.soc10time[6] = this->liveData->params.soc10time[7] + 900;
|
||||
this->liveData->params.soc10ced[5] = this->liveData->params.soc10ced[6] + 6.7;
|
||||
this->liveData->params.soc10cec[5] = this->liveData->params.soc10cec[6] + 0;
|
||||
this->liveData->params.soc10odo[5] = this->liveData->params.soc10odo[6] + 30;
|
||||
this->liveData->params.soc10time[5] = this->liveData->params.soc10time[6] + 900;
|
||||
this->liveData->params.soc10ced[4] = this->liveData->params.soc10ced[5] + 6.4;
|
||||
this->liveData->params.soc10cec[4] = this->liveData->params.soc10cec[5] + 0.3;
|
||||
this->liveData->params.soc10odo[4] = this->liveData->params.soc10odo[5] + 30;
|
||||
this->liveData->params.soc10time[4] = this->liveData->params.soc10time[5] + 900;
|
||||
this->liveData->params.soc10ced[3] = this->liveData->params.soc10ced[4] + 6.4;
|
||||
this->liveData->params.soc10cec[3] = this->liveData->params.soc10cec[4] + 0;
|
||||
this->liveData->params.soc10odo[3] = this->liveData->params.soc10odo[4] + 30;
|
||||
this->liveData->params.soc10time[3] = this->liveData->params.soc10time[4] + 900;
|
||||
this->liveData->params.soc10ced[2] = this->liveData->params.soc10ced[3] + 5.4;
|
||||
this->liveData->params.soc10cec[2] = this->liveData->params.soc10cec[3] + 0.1;
|
||||
this->liveData->params.soc10odo[2] = this->liveData->params.soc10odo[3] + 30;
|
||||
this->liveData->params.soc10time[2] = this->liveData->params.soc10time[3] + 900;
|
||||
this->liveData->params.soc10ced[1] = this->liveData->params.soc10ced[2] + 6.2;
|
||||
this->liveData->params.soc10cec[1] = this->liveData->params.soc10cec[2] + 0.1;
|
||||
this->liveData->params.soc10odo[1] = this->liveData->params.soc10odo[2] + 30;
|
||||
this->liveData->params.soc10time[1] = this->liveData->params.soc10time[2] + 900;
|
||||
this->liveData->params.soc10ced[0] = this->liveData->params.soc10ced[1] + 2.9;
|
||||
this->liveData->params.soc10cec[0] = this->liveData->params.soc10cec[1] + 0.5;
|
||||
this->liveData->params.soc10odo[0] = this->liveData->params.soc10odo[1] + 15;
|
||||
this->liveData->params.soc10time[0] = this->liveData->params.soc10time[1] + 900;
|
||||
|
||||
}
|
||||
|
||||
#endif // CARKIADEBUGOBD2_CPP
|
||||
16
CarKiaDebugObd2.h
Normal file
16
CarKiaDebugObd2.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CARKIADEBUGOBD2_H
|
||||
#define CARKIADEBUGOBD2_H
|
||||
|
||||
#include "CarInterface.h"
|
||||
|
||||
class CarKiaDebugObd2 : public CarInterface {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void activateCommandQueue() override;
|
||||
void parseRowMerged() override;
|
||||
void loadTestData() override;
|
||||
};
|
||||
|
||||
#endif // CARKIADEBUGOBD2_H
|
||||
446
CarKiaEniro.cpp
Normal file
446
CarKiaEniro.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
#ifndef CARKIAENIRO_CPP
|
||||
#define CARKIAENIRO_CPP
|
||||
|
||||
/*
|
||||
* eNiro/Kona chargings limits depending on battery temperature (min.value of 01-04 battery module)
|
||||
>= 35°C BMS allows max 180A
|
||||
>= 25°C without limit (200A)
|
||||
>= 15°C BMS allows max 120A
|
||||
>= 5°C BMS allows max 90A
|
||||
>= 1°C BMS allows max 60A
|
||||
<= 0°C BMS allows max 40A
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
#include <WString.h>
|
||||
#include <String.h>
|
||||
#include <sys/time.h>
|
||||
#include "LiveData.h"
|
||||
#include "CarKiaEniro.h"
|
||||
|
||||
#define commandQueueCountKiaENiro 30
|
||||
#define commandQueueLoopFromKiaENiro 10
|
||||
|
||||
/**
|
||||
* activateCommandQueue
|
||||
*/
|
||||
void CarKiaEniro::activateCommandQueue() {
|
||||
|
||||
String commandQueueKiaENiro[commandQueueCountKiaENiro] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
//"AT AL", // Allow Long (>7 byte) messages
|
||||
//"AT AR", // Automatically receive
|
||||
//"AT H1", // Headers on (debug only)
|
||||
//"AT D1", // Display of the DLC on
|
||||
//"AT CAF0", // Automatic formatting off
|
||||
////"AT AT0", // disabled adaptive timing
|
||||
"AT DP",
|
||||
"AT ST16", // reduced timeout to 1, orig.16
|
||||
|
||||
// Loop from (KIA ENIRO)
|
||||
|
||||
// ABS / ESP + AHB
|
||||
"ATSH7D1",
|
||||
"22C101", // brake, park/drive mode
|
||||
|
||||
// IGPM
|
||||
"ATSH770",
|
||||
"22BC03", // low beam
|
||||
"22BC06", // brake light
|
||||
|
||||
// VMCU
|
||||
"ATSH7E2",
|
||||
"2101", // speed, ...
|
||||
"2102", // aux, ...
|
||||
|
||||
// BMS
|
||||
"ATSH7E4",
|
||||
"220101", // power kw, ...
|
||||
"220102", // cell voltages
|
||||
"220103", // cell voltages
|
||||
"220104", // cell voltages
|
||||
"220105", // soh, soc, ..
|
||||
"220106", // cooling water temp
|
||||
|
||||
// Aircondition
|
||||
"ATSH7B3",
|
||||
"220100", // in/out temp
|
||||
"220102", // coolant temp1, 2
|
||||
|
||||
// BCM / TPMS
|
||||
"ATSH7A0",
|
||||
"22c00b", // tire pressure/temp
|
||||
|
||||
// CLUSTER MODULE
|
||||
"ATSH7C6",
|
||||
"22B002", // odo
|
||||
|
||||
};
|
||||
|
||||
// 39 or 64 kWh model?
|
||||
this->liveData->params.batModuleTempCount = 4;
|
||||
this->liveData->params.batteryTotalAvailableKWh = 64;
|
||||
// =(I18*0,615)*(1+(I18*0,0008)) soc to kwh niro ev 2020
|
||||
if (this->liveData->settings.carType == CAR_KIA_ENIRO_2020_39 || this->liveData->settings.carType == CAR_HYUNDAI_KONA_2020_39) {
|
||||
this->liveData->params.batteryTotalAvailableKWh = 39.2;
|
||||
}
|
||||
|
||||
// Empty and fill command queue
|
||||
for (int i = 0; i < 300; i++) {
|
||||
this->liveData->commandQueue[i] = "";
|
||||
}
|
||||
for (int i = 0; i < commandQueueCountKiaENiro; i++) {
|
||||
this->liveData->commandQueue[i] = commandQueueKiaENiro[i];
|
||||
}
|
||||
|
||||
this->liveData->commandQueueLoopFrom = commandQueueLoopFromKiaENiro;
|
||||
this->liveData->commandQueueCount = commandQueueCountKiaENiro;
|
||||
}
|
||||
|
||||
/**
|
||||
* parseRowMerged
|
||||
*/
|
||||
void CarKiaEniro::parseRowMerged() {
|
||||
|
||||
bool tempByte;
|
||||
|
||||
// ABS / ESP + AHB 7D1
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7D1")) {
|
||||
if (this->liveData->commandRequest.equals("22C101")) {
|
||||
uint8_t driveMode = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(22, 24).c_str(), 1, false);
|
||||
this->liveData->params.forwardDriveMode = (driveMode == 4);
|
||||
this->liveData->params.reverseDriveMode = (driveMode == 2);
|
||||
this->liveData->params.parkModeOrNeutral = (driveMode == 1);
|
||||
}
|
||||
}
|
||||
|
||||
// IGPM
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH770")) {
|
||||
if (this->liveData->commandRequest.equals("22BC03")) {
|
||||
tempByte = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false);
|
||||
this->liveData->params.ignitionOnPrevious = this->liveData->params.ignitionOn;
|
||||
this->liveData->params.ignitionOn = (bitRead(tempByte, 5) == 1);
|
||||
if (this->liveData->params.ignitionOnPrevious && !this->liveData->params.ignitionOn)
|
||||
this->liveData->params.automaticShutdownTimer = this->liveData->params.currentTime;
|
||||
|
||||
this->liveData->params.lightInfo = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(18, 20).c_str(), 1, false);
|
||||
this->liveData->params.headLights = (bitRead(this->liveData->params.lightInfo, 5) == 1);
|
||||
this->liveData->params.dayLights = (bitRead(this->liveData->params.lightInfo, 3) == 1);
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("22BC06")) {
|
||||
this->liveData->params.brakeLightInfo = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
this->liveData->params.brakeLights = (bitRead(this->liveData->params.brakeLightInfo, 5) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VMCU 7E2
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (this->liveData->commandRequest.equals("2101")) {
|
||||
this->liveData->params.speedKmh = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (this->liveData->params.speedKmh < -99 || this->liveData->params.speedKmh > 200)
|
||||
this->liveData->params.speedKmh = 0;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("2102")) {
|
||||
this->liveData->params.auxPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
this->liveData->params.auxCurrentAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (this->liveData->commandRequest.equals("22B002")) {
|
||||
this->liveData->params.odoKm = float(strtol(this->liveData->responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (this->liveData->commandRequest.equals("220100")) {
|
||||
this->liveData->params.indoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.outdoorTemperature = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (this->liveData->commandRequest.equals("220102") && this->liveData->responseRowMerged.substring(12, 14) == "00") {
|
||||
this->liveData->params.coolantTemp1C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
this->liveData->params.coolantTemp2C = (this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (this->liveData->commandRequest.equals("220101")) {
|
||||
this->liveData->params.cumulativeEnergyChargedKWh = float(strtol(this->liveData->responseRowMerged.substring(82, 90).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyChargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyChargedKWhStart = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.cumulativeEnergyDischargedKWh = float(strtol(this->liveData->responseRowMerged.substring(90, 98).c_str(), 0, 16)) / 10.0;
|
||||
if (this->liveData->params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
this->liveData->params.cumulativeEnergyDischargedKWhStart = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.availableChargePower = float(strtol(this->liveData->responseRowMerged.substring(16, 20).c_str(), 0, 16)) / 100.0;
|
||||
this->liveData->params.availableDischargePower = float(strtol(this->liveData->responseRowMerged.substring(20, 24).c_str(), 0, 16)) / 100.0;
|
||||
//this->liveData->params.isolationResistanceKOhm = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(118, 122).c_str(), 2, true);
|
||||
this->liveData->params.batFanStatus = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(60, 62).c_str(), 2, true);
|
||||
this->liveData->params.batFanFeedbackHz = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(62, 64).c_str(), 2, true);
|
||||
this->liveData->params.auxVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(64, 66).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batPowerAmp = - this->liveData->hexToDec(this->liveData->responseRowMerged.substring(26, 30).c_str(), 2, true) / 10.0;
|
||||
this->liveData->params.batVoltage = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 34).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.batPowerKw = (this->liveData->params.batPowerAmp * this->liveData->params.batVoltage) / 1000.0;
|
||||
if (this->liveData->params.batPowerKw < 0) // Reset charging start time
|
||||
this->liveData->params.chargingStartTime = this->liveData->params.currentTime;
|
||||
this->liveData->params.batPowerKwh100 = this->liveData->params.batPowerKw / this->liveData->params.speedKmh * 100;
|
||||
this->liveData->params.batCellMaxV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(52, 54).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batCellMinV = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(56, 58).c_str(), 1, false) / 50.0;
|
||||
this->liveData->params.batModuleTempC[0] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[1] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[2] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
this->liveData->params.batModuleTempC[3] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
this->liveData->params.motorRpm = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(112, 116).c_str(), 2, false);
|
||||
//this->liveData->params.batTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//this->liveData->params.batMaxC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//this->liveData->params.batMinC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < this->liveData->params.batModuleTempCount; i++) {
|
||||
if (this->liveData->params.batModuleTempC[i] < this->liveData->params.batMinC)
|
||||
this->liveData->params.batMinC = this->liveData->params.batModuleTempC[i];
|
||||
if (this->liveData->params.batModuleTempC[i] > this->liveData->params.batMaxC)
|
||||
this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[i];
|
||||
}
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
this->liveData->params.batInletC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
if (this->liveData->params.speedKmh < 10 && this->liveData->params.batPowerKw >= 1 && this->liveData->params.socPerc > 0 && this->liveData->params.socPerc <= 100) {
|
||||
if ( this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] < 0 || this->liveData->params.batPowerKw < this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMinKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
if ( this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] < 0 || this->liveData->params.batPowerKw > this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)])
|
||||
this->liveData->params.chargingGraphMaxKw[int(this->liveData->params.socPerc)] = this->liveData->params.batPowerKw;
|
||||
this->liveData->params.chargingGraphBatMinTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMinC;
|
||||
this->liveData->params.chargingGraphBatMaxTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batMaxC;
|
||||
this->liveData->params.chargingGraphHeaterTempC[int(this->liveData->params.socPerc)] = this->liveData->params.batHeaterC;
|
||||
this->liveData->params.chargingGraphWaterCoolantTempC[int(this->liveData->params.socPerc)] = this->liveData->params.coolingWaterTempC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220102") && this->liveData->responseRowMerged.substring(12, 14) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[32 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this->liveData->params.cellVoltage[64 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220105")) {
|
||||
this->liveData->params.socPercPrevious = this->liveData->params.socPerc;
|
||||
this->liveData->params.sohPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(56, 60).c_str(), 2, false) / 10.0;
|
||||
this->liveData->params.socPerc = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(68, 70).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (this->liveData->params.socPercPrevious - this->liveData->params.socPerc > 0) {
|
||||
byte index = (int(this->liveData->params.socPerc) == 4) ? 0 : (int)(this->liveData->params.socPerc / 10) + 1;
|
||||
if ((int(this->liveData->params.socPerc) % 10 == 9 || int(this->liveData->params.socPerc) == 4) && this->liveData->params.soc10ced[index] == -1) {
|
||||
this->liveData->params.soc10ced[index] = this->liveData->params.cumulativeEnergyDischargedKWh;
|
||||
this->liveData->params.soc10cec[index] = this->liveData->params.cumulativeEnergyChargedKWh;
|
||||
this->liveData->params.soc10odo[index] = this->liveData->params.odoKm;
|
||||
this->liveData->params.soc10time[index] = this->liveData->params.currentTime;
|
||||
}
|
||||
}
|
||||
this->liveData->params.bmsUnknownTempA = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 32).c_str(), 1, true);
|
||||
this->liveData->params.batHeaterC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(52, 54).c_str(), 1, true);
|
||||
this->liveData->params.bmsUnknownTempB = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(82, 84).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
this->liveData->params.cellVoltage[96 - 30 + i] = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (this->liveData->commandRequest.equals("220106")) {
|
||||
this->liveData->params.coolingWaterTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
this->liveData->params.bmsUnknownTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(18, 20).c_str(), 1, true);
|
||||
this->liveData->params.bmsUnknownTempD = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(46, 48).c_str(), 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (this->liveData->currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (this->liveData->commandRequest.equals("22c00b")) {
|
||||
this->liveData->params.tireFrontLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearRightPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireRearLeftPressureBar = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
this->liveData->params.tireFrontLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireFrontRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearRightTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
this->liveData->params.tireRearLeftTempC = this->liveData->hexToDec(this->liveData->responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loadTestData
|
||||
*/
|
||||
void CarKiaEniro::loadTestData() {
|
||||
|
||||
// IGPM
|
||||
this->liveData->currentAtshRequest = "ATSH770";
|
||||
// 22BC03
|
||||
this->liveData->commandRequest = "22BC03";
|
||||
this->liveData->responseRowMerged = "62BC03FDEE7C730A600000AAAA";
|
||||
this->parseRowMerged();
|
||||
|
||||
// ABS / ESP + AHB ATSH7D1
|
||||
this->liveData->currentAtshRequest = "ATSH7D1";
|
||||
// 2101
|
||||
this->liveData->commandRequest = "22C101";
|
||||
this->liveData->responseRowMerged = "62C1015FD7E7D0FFFF00FF04D0D400000000FF7EFF0030F5010000FFFF7F6307F207FE05FF00FF3FFFFFAAAAAAAAAAAA";
|
||||
this->parseRowMerged();
|
||||
|
||||
// VMCU ATSH7E2
|
||||
this->liveData->currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
this->liveData->commandRequest = "2101";
|
||||
this->liveData->responseRowMerged = "6101FFF8000009285A3B0648030000B4179D763404080805000000";
|
||||
this->parseRowMerged();
|
||||
// 2102
|
||||
this->liveData->commandRequest = "2102";
|
||||
this->liveData->responseRowMerged = "6102F8FFFC000101000000840FBF83BD33270680953033757F59291C76000001010100000007000000";
|
||||
this->liveData->responseRowMerged = "6102F8FFFC000101000000931CC77F4C39040BE09BA7385D8158832175000001010100000007000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// "ATSH7DF",
|
||||
this->liveData->currentAtshRequest = "ATSH7DF";
|
||||
// 2106
|
||||
this->liveData->commandRequest = "2106";
|
||||
this->liveData->responseRowMerged = "6106FFFF800000000000000200001B001C001C000600060006000E000000010000000000000000013D013D013E013E00";
|
||||
this->parseRowMerged();
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
this->liveData->currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
this->liveData->commandRequest = "220100";
|
||||
this->liveData->responseRowMerged = "6201007E5027C8FF7F765D05B95AFFFF5AFF11FFFFFFFFFFFF6AFFFF2DF0757630FFFF00FFFF000000";
|
||||
this->liveData->responseRowMerged = "6201007E5027C8FF867C58121010FFFF10FF8EFFFFFFFFFFFF10FFFF0DF0617900FFFF01FFFF000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
// BMS ATSH7E4
|
||||
this->liveData->currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
this->liveData->commandRequest = "220101";
|
||||
this->liveData->responseRowMerged = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
|
||||
this->liveData->responseRowMerged = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
|
||||
this->parseRowMerged();
|
||||
// 220102
|
||||
this->liveData->commandRequest = "220102";
|
||||
this->liveData->responseRowMerged = "620102FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220103
|
||||
this->liveData->commandRequest = "220103";
|
||||
this->liveData->responseRowMerged = "620103FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCACBCACACFCCCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220104
|
||||
this->liveData->commandRequest = "220104";
|
||||
this->liveData->responseRowMerged = "620104FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
this->parseRowMerged();
|
||||
// 220105
|
||||
this->liveData->commandRequest = "220105";
|
||||
this->liveData->responseRowMerged = "620105003fff9000000000000000000F8A86012B4946500101500DAC03E800000000AC0000C7C701000F00000000AAAA";
|
||||
this->liveData->responseRowMerged = "620105003FFF90000000000000000014918E012927465000015013BB03E800000000BB0000CBCB01001300000000AAAA";
|
||||
this->parseRowMerged();
|
||||
// 220106
|
||||
this->liveData->commandRequest = "220106";
|
||||
this->liveData->responseRowMerged = "620106FFFFFFFF14001A00240000003A7C86B4B30000000928EA00";
|
||||
this->parseRowMerged();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
this->liveData->currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
this->liveData->commandRequest = "22c00b";
|
||||
this->liveData->responseRowMerged = "62C00BFFFF0000B93D0100B43E0100B43D0100BB3C0100AAAAAAAA";
|
||||
this->parseRowMerged();
|
||||
|
||||
// ATSH7C6
|
||||
this->liveData->currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
this->liveData->commandRequest = "22b002";
|
||||
this->liveData->responseRowMerged = "62B002E0000000FFB400330B0000000000000000";
|
||||
this->parseRowMerged();
|
||||
|
||||
this->liveData->params.batModuleTempC[0] = 28;
|
||||
this->liveData->params.batModuleTempC[1] = 29;
|
||||
this->liveData->params.batModuleTempC[2] = 28;
|
||||
this->liveData->params.batModuleTempC[3] = 30;
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
this->liveData->params.batMinC = this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < this->liveData->params.batModuleTempCount; i++) {
|
||||
if (this->liveData->params.batModuleTempC[i] < this->liveData->params.batMinC)
|
||||
this->liveData->params.batMinC = this->liveData->params.batModuleTempC[i];
|
||||
if (this->liveData->params.batModuleTempC[i] > this->liveData->params.batMaxC)
|
||||
this->liveData->params.batMaxC = this->liveData->params.batModuleTempC[i];
|
||||
}
|
||||
this->liveData->params.batTempC = this->liveData->params.batMinC;
|
||||
|
||||
|
||||
//
|
||||
this->liveData->params.soc10ced[10] = 2200;
|
||||
this->liveData->params.soc10cec[10] = 2500;
|
||||
this->liveData->params.soc10odo[10] = 13000;
|
||||
this->liveData->params.soc10time[10] = 13000;
|
||||
this->liveData->params.soc10ced[9] = this->liveData->params.soc10ced[10] + 6.4;
|
||||
this->liveData->params.soc10cec[9] = this->liveData->params.soc10cec[10] + 0;
|
||||
this->liveData->params.soc10odo[9] = this->liveData->params.soc10odo[10] + 30;
|
||||
this->liveData->params.soc10time[9] = this->liveData->params.soc10time[10] + 900;
|
||||
this->liveData->params.soc10ced[8] = this->liveData->params.soc10ced[9] + 6.8;
|
||||
this->liveData->params.soc10cec[8] = this->liveData->params.soc10cec[9] + 0;
|
||||
this->liveData->params.soc10odo[8] = this->liveData->params.soc10odo[9] + 30;
|
||||
this->liveData->params.soc10time[8] = this->liveData->params.soc10time[9] + 900;
|
||||
this->liveData->params.soc10ced[7] = this->liveData->params.soc10ced[8] + 7.2;
|
||||
this->liveData->params.soc10cec[7] = this->liveData->params.soc10cec[8] + 0.6;
|
||||
this->liveData->params.soc10odo[7] = this->liveData->params.soc10odo[8] + 30;
|
||||
this->liveData->params.soc10time[7] = this->liveData->params.soc10time[8] + 900;
|
||||
this->liveData->params.soc10ced[6] = this->liveData->params.soc10ced[7] + 6.7;
|
||||
this->liveData->params.soc10cec[6] = this->liveData->params.soc10cec[7] + 0;
|
||||
this->liveData->params.soc10odo[6] = this->liveData->params.soc10odo[7] + 30;
|
||||
this->liveData->params.soc10time[6] = this->liveData->params.soc10time[7] + 900;
|
||||
this->liveData->params.soc10ced[5] = this->liveData->params.soc10ced[6] + 6.7;
|
||||
this->liveData->params.soc10cec[5] = this->liveData->params.soc10cec[6] + 0;
|
||||
this->liveData->params.soc10odo[5] = this->liveData->params.soc10odo[6] + 30;
|
||||
this->liveData->params.soc10time[5] = this->liveData->params.soc10time[6] + 900;
|
||||
this->liveData->params.soc10ced[4] = this->liveData->params.soc10ced[5] + 6.4;
|
||||
this->liveData->params.soc10cec[4] = this->liveData->params.soc10cec[5] + 0.3;
|
||||
this->liveData->params.soc10odo[4] = this->liveData->params.soc10odo[5] + 30;
|
||||
this->liveData->params.soc10time[4] = this->liveData->params.soc10time[5] + 900;
|
||||
this->liveData->params.soc10ced[3] = this->liveData->params.soc10ced[4] + 6.4;
|
||||
this->liveData->params.soc10cec[3] = this->liveData->params.soc10cec[4] + 0;
|
||||
this->liveData->params.soc10odo[3] = this->liveData->params.soc10odo[4] + 30;
|
||||
this->liveData->params.soc10time[3] = this->liveData->params.soc10time[4] + 900;
|
||||
this->liveData->params.soc10ced[2] = this->liveData->params.soc10ced[3] + 5.4;
|
||||
this->liveData->params.soc10cec[2] = this->liveData->params.soc10cec[3] + 0.1;
|
||||
this->liveData->params.soc10odo[2] = this->liveData->params.soc10odo[3] + 30;
|
||||
this->liveData->params.soc10time[2] = this->liveData->params.soc10time[3] + 900;
|
||||
this->liveData->params.soc10ced[1] = this->liveData->params.soc10ced[2] + 6.2;
|
||||
this->liveData->params.soc10cec[1] = this->liveData->params.soc10cec[2] + 0.1;
|
||||
this->liveData->params.soc10odo[1] = this->liveData->params.soc10odo[2] + 30;
|
||||
this->liveData->params.soc10time[1] = this->liveData->params.soc10time[2] + 900;
|
||||
this->liveData->params.soc10ced[0] = this->liveData->params.soc10ced[1] + 2.9;
|
||||
this->liveData->params.soc10cec[0] = this->liveData->params.soc10cec[1] + 0.5;
|
||||
this->liveData->params.soc10odo[0] = this->liveData->params.soc10odo[1] + 15;
|
||||
this->liveData->params.soc10time[0] = this->liveData->params.soc10time[1] + 900;
|
||||
|
||||
}
|
||||
|
||||
#endif // CARKIAENIRO_CPP
|
||||
16
CarKiaEniro.h
Normal file
16
CarKiaEniro.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CARKIAENIRO_H
|
||||
#define CARKIAENIRO_H
|
||||
|
||||
#include "CarInterface.h"
|
||||
|
||||
class CarKiaEniro : public CarInterface {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void activateCommandQueue() override;
|
||||
void parseRowMerged() override;
|
||||
void loadTestData() override;
|
||||
};
|
||||
|
||||
#endif // CARKIAENIRO_H
|
||||
34
INSTALLATION.md
Normal file
34
INSTALLATION.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# INSTALLATION
|
||||
|
||||
## Quick installation from binary files with ESP32 flash tool
|
||||
|
||||
M5STACK (Many thanks to DimZen)
|
||||
|
||||
https://docs.google.com/document/d/17vJmeveNfN0exQy9wKC-5igU8zzNjsuOn1DPuPV_yJA/edit?usp=sharing
|
||||
|
||||
TTGO-T4 (older)
|
||||
|
||||
https://docs.google.com/document/d/1nEezrtXY-8X6mQ1hiZVWDjBVse1sXQg1SlnizaRmJwU/edit?usp=sharing
|
||||
|
||||
## Installation from sources
|
||||
- install arduino IDE + ESP32 support
|
||||
- https://github.com/Bodmer/TFT_eSPI - display library
|
||||
- Configure TFT eSPI
|
||||
W:\Documents\Arduino\libraries\TFT_eSP\User_Setup_Select.h
|
||||
```
|
||||
// Comment
|
||||
//#include <User_Setup.h> // Default setup is root library folder
|
||||
// And uncomment
|
||||
#include <User_Setups/Setup22_TTGO_T4_v1.3.h> // Setup file for ESP32 and TTGO T4 version 1.3
|
||||
```
|
||||
|
||||
My configuration
|
||||
- Board ESP32 Dev module
|
||||
- Upload speed 921600
|
||||
- CPU freq: 240MHz (Wifi/BT)
|
||||
- Flash freq: 80MHz
|
||||
- Flash mode: QIO
|
||||
- Flash size 4MB (32mb)
|
||||
- Partion scheme: default 4MB with spiffs
|
||||
- Core debug level: none
|
||||
- PSRAM: disable
|
||||
158
LiveData.cpp
Normal file
158
LiveData.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
#ifndef LIVEDATA_CPP
|
||||
#define LIVEDATA_CPP
|
||||
|
||||
#include "LiveData.h"
|
||||
#include "menu.h"
|
||||
|
||||
/**
|
||||
Init params with default values
|
||||
*/
|
||||
void LiveData::initParams() {
|
||||
|
||||
this->params.automaticShutdownTimer = 0;
|
||||
#ifdef SIM800L_ENABLED
|
||||
this->params.lastDataSent = 0;
|
||||
this->params.sim800l_enabled = false;
|
||||
#endif //SIM800L_ENABLED
|
||||
this->params.ignitionOn = false;
|
||||
this->params.ignitionOnPrevious = false;
|
||||
this->params.chargingStartTime = this->params.currentTime = 0;
|
||||
this->params.lightInfo = 0;
|
||||
this->params.headLights = false;
|
||||
this->params.dayLights = false;
|
||||
this->params.brakeLights = false;
|
||||
this->params.brakeLightInfo = 0;
|
||||
this->params.forwardDriveMode = false;
|
||||
this->params.reverseDriveMode = false;
|
||||
this->params.parkModeOrNeutral = false;
|
||||
this->params.espState = 0;
|
||||
this->params.speedKmh = -1;
|
||||
this->params.motorRpm = -1;
|
||||
this->params.odoKm = -1;
|
||||
this->params.socPerc = -1;
|
||||
this->params.socPercPrevious = -1;
|
||||
this->params.sohPerc = -1;
|
||||
this->params.cumulativeEnergyChargedKWh = -1;
|
||||
this->params.cumulativeEnergyChargedKWhStart = -1;
|
||||
this->params.cumulativeEnergyDischargedKWh = -1;
|
||||
this->params.cumulativeEnergyDischargedKWhStart = -1;
|
||||
this->params.availableChargePower = -1;
|
||||
this->params.availableDischargePower = -1;
|
||||
this->params.isolationResistanceKOhm = -1;
|
||||
this->params.batPowerAmp = -1;
|
||||
this->params.batPowerKw = -1;
|
||||
this->params.batPowerKwh100 = -1;
|
||||
this->params.batVoltage = -1;
|
||||
this->params.batCellMinV = -1;
|
||||
this->params.batCellMaxV = -1;
|
||||
this->params.batTempC = -1;
|
||||
this->params.batHeaterC = -1;
|
||||
this->params.batInletC = -1;
|
||||
this->params.batFanStatus = -1;
|
||||
this->params.batFanFeedbackHz = -1;
|
||||
this->params.batMinC = -1;
|
||||
this->params.batMaxC = -1;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
this->params.batModuleTempC[i] = 0;
|
||||
}
|
||||
this->params.batModuleTempC[0] = -1;
|
||||
this->params.batModuleTempC[1] = -1;
|
||||
this->params.batModuleTempC[2] = -1;
|
||||
this->params.batModuleTempC[3] = -1;
|
||||
this->params.coolingWaterTempC = -1;
|
||||
this->params.coolantTemp1C = -1;
|
||||
this->params.coolantTemp2C = -1;
|
||||
this->params.bmsUnknownTempA = -1;
|
||||
this->params.bmsUnknownTempB = -1;
|
||||
this->params.bmsUnknownTempC = -1;
|
||||
this->params.bmsUnknownTempD = -1;
|
||||
this->params.auxPerc = -1;
|
||||
this->params.auxCurrentAmp = -1;
|
||||
this->params.auxVoltage = -1;
|
||||
this->params.indoorTemperature = -1;
|
||||
this->params.outdoorTemperature = -1;
|
||||
this->params.tireFrontLeftTempC = -1;
|
||||
this->params.tireFrontLeftPressureBar = -1;
|
||||
this->params.tireFrontRightTempC = -1;
|
||||
this->params.tireFrontRightPressureBar = -1;
|
||||
this->params.tireRearLeftTempC = -1;
|
||||
this->params.tireRearLeftPressureBar = -1;
|
||||
this->params.tireRearRightTempC = -1;
|
||||
this->params.tireRearRightPressureBar = -1;
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
this->params.soc10ced[i] = this->params.soc10cec[i] = this->params.soc10odo[i] = -1;
|
||||
this->params.soc10time[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < 98; i++) {
|
||||
this->params.cellVoltage[i] = 0;
|
||||
}
|
||||
this->params.cellCount = 0;
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
this->params.chargingGraphMinKw[i] = -1;
|
||||
this->params.chargingGraphMaxKw[i] = -1;
|
||||
this->params.chargingGraphBatMinTempC[i] = -100;
|
||||
this->params.chargingGraphBatMaxTempC[i] = -100;
|
||||
this->params.chargingGraphHeaterTempC[i] = -100;
|
||||
this->params.chargingGraphWaterCoolantTempC[i] = -100;
|
||||
}
|
||||
|
||||
// Menu
|
||||
this->menuItems = menuItemsSource;
|
||||
}
|
||||
|
||||
/**
|
||||
Hex to dec (1-2 byte values, signed/unsigned)
|
||||
For 4 byte change int to long and add part for signed numbers
|
||||
*/
|
||||
float LiveData::hexToDec(String hexString, byte bytes, bool signedNum) {
|
||||
|
||||
unsigned int decValue = 0;
|
||||
unsigned int nextInt;
|
||||
|
||||
for (int i = 0; i < hexString.length(); i++) {
|
||||
nextInt = int(hexString.charAt(i));
|
||||
if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
|
||||
if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
|
||||
if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
|
||||
nextInt = constrain(nextInt, 0, 15);
|
||||
decValue = (decValue * 16) + nextInt;
|
||||
}
|
||||
|
||||
// Unsigned - do nothing
|
||||
if (!signedNum) {
|
||||
return decValue;
|
||||
}
|
||||
// Signed for 1, 2 bytes
|
||||
if (bytes == 1) {
|
||||
return (decValue > 127 ? (float)decValue - 256.0 : decValue);
|
||||
}
|
||||
return (decValue > 32767 ? (float)decValue - 65536.0 : decValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert km to km or miles
|
||||
*/
|
||||
float LiveData::km2distance(float inKm) {
|
||||
return (this->settings.distanceUnit == 'k') ? inKm : inKm / 1.609344;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert celsius to celsius or farenheit
|
||||
*/
|
||||
float LiveData::celsius2temperature(float inCelsius) {
|
||||
return (this->settings.temperatureUnit == 'c') ? inCelsius : (inCelsius * 1.8) + 32;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert bar to bar or psi
|
||||
*/
|
||||
float LiveData::bar2pressure(float inBar) {
|
||||
return (this->settings.pressureUnit == 'b') ? inBar : inBar * 14.503773800722;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
#endif // LIVEDATA_CPP
|
||||
@@ -1,4 +1,15 @@
|
||||
|
||||
#ifndef LIVEDATA_H
|
||||
#define LIVEDATA_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
#include <WString.h>
|
||||
#include <String.h>
|
||||
#include <sys/time.h>
|
||||
#include <BLEDevice.h>
|
||||
#include "config.h"
|
||||
|
||||
// SUPPORTED CARS
|
||||
#define CAR_KIA_ENIRO_2020_64 0
|
||||
#define CAR_HYUNDAI_KONA_2020_64 1
|
||||
@@ -18,22 +29,15 @@
|
||||
#define SCREEN_SOC10 6
|
||||
#define SCREEN_DEBUG 7
|
||||
|
||||
// Commands loop
|
||||
uint16_t commandQueueCount;
|
||||
uint16_t commandQueueLoopFrom;
|
||||
String commandQueue[300];
|
||||
String responseRow;
|
||||
String responseRowMerged;
|
||||
uint16_t commandQueueIndex;
|
||||
bool canSendNextAtCommand = false;
|
||||
String commandRequest = "";
|
||||
String currentAtshRequest = "";
|
||||
|
||||
// Structure with realtime values
|
||||
typedef struct {
|
||||
time_t currentTime;
|
||||
time_t chargingStartTime;
|
||||
time_t automatickShutdownTimer;
|
||||
time_t automaticShutdownTimer;
|
||||
#ifdef SIM800L_ENABLED
|
||||
time_t lastDataSent;
|
||||
bool sim800l_enabled;
|
||||
#endif //SIM800L_ENABLED
|
||||
bool ignitionOn;
|
||||
bool ignitionOnPrevious;
|
||||
bool forwardDriveMode;
|
||||
@@ -122,7 +126,7 @@ typedef struct {
|
||||
// Setting stored to flash
|
||||
typedef struct {
|
||||
byte initFlag; // 183 value
|
||||
byte settingsVersion; // current 4
|
||||
byte settingsVersion; // current 3
|
||||
uint16_t carType; // 0 - Kia eNiro 2020, 1 - Hyundai Kona 2020, 2 - Hyudai Ioniq 2018
|
||||
char obdMacAddress[20];
|
||||
char serviceUUID[40];
|
||||
@@ -137,41 +141,60 @@ typedef struct {
|
||||
byte lcdBrightness; // 0 - auto, 1 .. 100%
|
||||
byte debugScreen; // 0 - off, 1 - on
|
||||
byte predrawnChargingGraphs; // 0 - off, 1 - on
|
||||
byte wifiEnable; // 0 off 1 on used for NTP datetime sync
|
||||
char wifiSsid[32];
|
||||
char wifiPassword[32];
|
||||
byte sdcardAutoRecord; // 0 off 1 on
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
char gprsApn[64];
|
||||
char remoteApiSrvr[64];
|
||||
char remoteApiKey[13];
|
||||
#endif //SIM800L_ENABLED
|
||||
} SETTINGS_STRUC;
|
||||
|
||||
PARAMS_STRUC params; // Realtime sensor values
|
||||
SETTINGS_STRUC settings, tmpSettings; // Settings stored into flash
|
||||
|
||||
/**
|
||||
Hex to dec (1-2 byte values, signed/unsigned)
|
||||
For 4 byte change int to long and add part for signed numbers
|
||||
*/
|
||||
float hexToDec(String hexString, byte bytes = 2, bool signedNum = true) {
|
||||
//
|
||||
class LiveData {
|
||||
private:
|
||||
public:
|
||||
// Command loop
|
||||
uint16_t commandQueueCount;
|
||||
uint16_t commandQueueLoopFrom;
|
||||
String commandQueue[300];
|
||||
String responseRow;
|
||||
String responseRowMerged;
|
||||
uint16_t commandQueueIndex;
|
||||
bool canSendNextAtCommand = false;
|
||||
String commandRequest = "";
|
||||
String currentAtshRequest = "";
|
||||
// Menu
|
||||
bool menuVisible = false;
|
||||
uint8_t menuItemsCount = 78;
|
||||
uint16_t menuCurrent = 0;
|
||||
uint8_t menuItemSelected = 0;
|
||||
uint8_t menuItemOffset = 0;
|
||||
uint16_t scanningDeviceIndex = 0;
|
||||
MENU_ITEM* menuItems;
|
||||
|
||||
unsigned int decValue = 0;
|
||||
unsigned int nextInt;
|
||||
// Bluetooth4
|
||||
boolean bleConnect = true;
|
||||
boolean bleConnected = false;
|
||||
BLEAddress *pServerAddress;
|
||||
BLERemoteCharacteristic* pRemoteCharacteristic;
|
||||
BLERemoteCharacteristic* pRemoteCharacteristicWrite;
|
||||
BLEAdvertisedDevice* foundMyBleDevice;
|
||||
BLEClient* pClient;
|
||||
BLEScan* pBLEScan;
|
||||
|
||||
for (int i = 0; i < hexString.length(); i++) {
|
||||
nextInt = int(hexString.charAt(i));
|
||||
if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
|
||||
if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
|
||||
if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
|
||||
nextInt = constrain(nextInt, 0, 15);
|
||||
decValue = (decValue * 16) + nextInt;
|
||||
}
|
||||
// Params
|
||||
PARAMS_STRUC params; // Realtime sensor values
|
||||
// Settings
|
||||
SETTINGS_STRUC settings, tmpSettings; // Settings stored into flash
|
||||
|
||||
// Unsigned - do nothing
|
||||
if (!signedNum) {
|
||||
return decValue;
|
||||
}
|
||||
// Signed for 1, 2 bytes
|
||||
if (bytes == 1) {
|
||||
return (decValue > 127 ? (float)decValue - 256.0 : decValue);
|
||||
}
|
||||
return (decValue > 32767 ? (float)decValue - 65536.0 : decValue);
|
||||
}
|
||||
//
|
||||
void initParams();
|
||||
float hexToDec(String hexString, byte bytes = 2, bool signedNum = true);
|
||||
float km2distance(float inKm);
|
||||
float celsius2temperature(float inCelsius);
|
||||
float bar2pressure(float inBar);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
#endif // LIVEDATA_H
|
||||
118
README.md
118
README.md
@@ -1,4 +1,4 @@
|
||||
# KIA ENIRO DASHBOARD
|
||||
# evDash (older nama enirodashboard)
|
||||
|
||||
Supported devices
|
||||
1. LILYGO TTGO T4 v1.3
|
||||
@@ -34,13 +34,14 @@ Others
|
||||
|
||||
## Quick installation with ESP32 flash tool
|
||||
|
||||
M5STACK (Many thanks to DimZen)
|
||||
See INSTALLATION.md
|
||||
|
||||
https://docs.google.com/document/d/17vJmeveNfN0exQy9wKC-5igU8zzNjsuOn1DPuPV_yJA/edit?usp=sharing
|
||||
## RELEASE NOTES
|
||||
see. RELEASENOTES.md file
|
||||
|
||||
TTGO-T4 (older)
|
||||
## Installation from sources
|
||||
|
||||
https://docs.google.com/document/d/1nEezrtXY-8X6mQ1hiZVWDjBVse1sXQg1SlnizaRmJwU/edit?usp=sharing
|
||||
See INSTALLATION.md
|
||||
|
||||
## Screens and shortcuts
|
||||
- Middle button - menu
|
||||
@@ -56,110 +57,7 @@ Screen list
|
||||
- no6. consumption table. Can be used to measure available battery capacity!
|
||||
- no7. debug screen (default off in the menu)
|
||||
|
||||

|
||||
|
||||

|
||||
[](https://www.youtube.com/watch?v=Jg5VP2P58Yg&)
|
||||
|
||||
[](https://www.youtube.com/watch?v=Jg5VP2P58Yg&)
|
||||
|
||||
### v1.8.3 2020-11-28
|
||||
- Automatic shutdown when car goes off
|
||||
- Fixed M5stack speaker noise
|
||||
- Fixed menu, added scroll support
|
||||
|
||||
### v1.8.2 2020-11-25
|
||||
- Removed screen flickering. (via Sprites, esp32 with SRAM is now required!)
|
||||
- Code cleaning. Removed force no/yes redraw mode. Not required with sprites
|
||||
- Arrow for current (based on bat.temperature) pre-drawn charging graph
|
||||
|
||||
### v1.8.1 2020-11-23
|
||||
- Pre-drawn charging graphs (based on coldgates)
|
||||
- Show version in menu
|
||||
|
||||
### v1.8.0 2020-11-20
|
||||
- Support for new device m5stack core1 iot development kit
|
||||
- TTGO T4 is still supported device!
|
||||
|
||||
### v1.7.5 2020-11-17
|
||||
- Settings: Debug screen off/on
|
||||
- Settings: LCD brightness (auto, 20, 50, 100%)
|
||||
- Speed screen: added motor rpm, brake lights indicator
|
||||
- Soc% to kWh is now calibrated for NiroEV/KonaEV 2020
|
||||
- eNiroDashboard speed improvements
|
||||
|
||||
### v1.7.4 2020-11-12
|
||||
- Added default screen option to settings
|
||||
- Initial config for Renault ZOE 22kWh
|
||||
- ODB response analyzer. Please help community to decode unknown values like BMS valves, heater ON switch,...
|
||||
https://docs.google.com/spreadsheets/d/1eT2R8hmsD1hC__9LtnkZ3eDjLcdib9JR-3Myc97jy8M/edit?usp=sharing
|
||||
|
||||
### v1.7.3 2020-11-11
|
||||
- Headlights reminder (if drive mode & headlights are off)
|
||||
|
||||
### v1.7.2 2020-11-10
|
||||
- improved charging graph
|
||||
|
||||
### v1.7.1 2020-10-20
|
||||
- added new screen 1 - auto mode
|
||||
- automatically shows screen 3 - speed when speed is >5kph
|
||||
- screen 5 chargin graph when power kw > 1kW
|
||||
- added bat.fan status and fan feedback in Hz for Ioniq
|
||||
|
||||
### v1.7 2020-09-16
|
||||
- added support for 39.2kWh Hyundai Kona and Kia e-Niro
|
||||
- added initial support for Hyundai Ioniq 28kWh (not working yet)
|
||||
|
||||
### v1.6 2020-06-30
|
||||
- fixed ble device pairing
|
||||
- added command to set protocol ISO 15765-4 CAN (11 bit ID, 500 kbit/s) - some vgate adapters freezes during "init at command" phase
|
||||
|
||||
### v1.5 2020-06-03
|
||||
- added support for different units (miles, fahrenheits, psi)
|
||||
|
||||
### v1.4 2020-05-29
|
||||
- added menu
|
||||
- Pairing with VGATE iCar Pro BLE4 adapter via menu!
|
||||
- Installation with flash tool. You don't have to install Arduino and compile sources :)
|
||||
- New screen 5. Conpumption... Can be used to measure available battery capacity!
|
||||
- Load/Save settings
|
||||
- Flip screen vertical option
|
||||
- Several different improvements
|
||||
|
||||
### v1.1 2020-04-12
|
||||
- added new screens (switch via left button)
|
||||
- screen 0. (blank screen, lcd off)
|
||||
- screen 1. (default) summary info
|
||||
- screen 2. speed kmh + kwh/100km (or kw for discharge)
|
||||
- screen 3. battery cells + battery module temperatures
|
||||
- screen 4. charging graph
|
||||
- added low batery temperature detection for slow charging on 50kW DC (15°C) and UFC >70kW (25°C).
|
||||
|
||||
### v1.0 2020-03-23
|
||||
- first release
|
||||
- basic dashboard
|
||||
|
||||
## About T4
|
||||
ESP32-TTGO-T4
|
||||
https://github.com/fdufnews/ESP32-TTGO-T4
|
||||
|
||||
## Installation from sources
|
||||
- install arduino IDE + ESP32 support
|
||||
- https://github.com/Bodmer/TFT_eSPI - display library
|
||||
- Configure TFT eSPI
|
||||
W:\Documents\Arduino\libraries\TFT_eSP\User_Setup_Select.h
|
||||
```
|
||||
// Comment
|
||||
//#include <User_Setup.h> // Default setup is root library folder
|
||||
// And uncomment
|
||||
#include <User_Setups/Setup22_TTGO_T4_v1.3.h> // Setup file for ESP32 and TTGO T4 version 1.3
|
||||
```
|
||||
|
||||
My configuration
|
||||
- Board ESP32 Dev module
|
||||
- Upload speed 921600
|
||||
- CPU freq: 240MHz (Wifi/BT)
|
||||
- Flash freq: 80MHz
|
||||
- Flash mode: QIO
|
||||
- Flash size 4MB (32mb)
|
||||
- Partion scheme: default 4MB with spiffs
|
||||
- Core debug level: none
|
||||
- PSRAM: disable
|
||||
|
||||
85
RELEASENOTES.md
Normal file
85
RELEASENOTES.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# RELEASE NOTES
|
||||
|
||||
### v2.0.0 2020-12-02
|
||||
- Project renamed from eNiroDashboard to evDash
|
||||
|
||||
### v1.9.0 2020-11-30
|
||||
- Refactoring (classes)
|
||||
- SIM800L (m5stack) code from https://github.com/kolaCZek
|
||||
|
||||
### v1.8.3 2020-11-28
|
||||
- Automatic shutdown when car goes off
|
||||
- Fixed M5stack speaker noise
|
||||
- Fixed menu, added scroll support
|
||||
|
||||
### v1.8.2 2020-11-25
|
||||
- Removed screen flickering. (via Sprites, esp32 with SRAM is now required!)
|
||||
- Code cleaning. Removed force no/yes redraw mode. Not required with sprites
|
||||
- Arrow for current (based on bat.temperature) pre-drawn charging graph
|
||||
|
||||
### v1.8.1 2020-11-23
|
||||
- Pre-drawn charging graphs (based on coldgates)
|
||||
- Show version in menu
|
||||
|
||||
### v1.8.0 2020-11-20
|
||||
- Support for new device m5stack core1 iot development kit
|
||||
- TTGO T4 is still supported device!
|
||||
|
||||
### v1.7.5 2020-11-17
|
||||
- Settings: Debug screen off/on
|
||||
- Settings: LCD brightness (auto, 20, 50, 100%)
|
||||
- Speed screen: added motor rpm, brake lights indicator
|
||||
- Soc% to kWh is now calibrated for NiroEV/KonaEV 2020
|
||||
- eNiroDashboard speed improvements
|
||||
|
||||
### v1.7.4 2020-11-12
|
||||
- Added default screen option to settings
|
||||
- Initial config for Renault ZOE 22kWh
|
||||
- ODB response analyzer. Please help community to decode unknown values like BMS valves, heater ON switch,...
|
||||
https://docs.google.com/spreadsheets/d/1eT2R8hmsD1hC__9LtnkZ3eDjLcdib9JR-3Myc97jy8M/edit?usp=sharing
|
||||
|
||||
### v1.7.3 2020-11-11
|
||||
- Headlights reminder (if drive mode & headlights are off)
|
||||
|
||||
### v1.7.2 2020-11-10
|
||||
- improved charging graph
|
||||
|
||||
### v1.7.1 2020-10-20
|
||||
- added new screen 1 - auto mode
|
||||
- automatically shows screen 3 - speed when speed is >5kph
|
||||
- screen 5 chargin graph when power kw > 1kW
|
||||
- added bat.fan status and fan feedback in Hz for Ioniq
|
||||
|
||||
### v1.7 2020-09-16
|
||||
- added support for 39.2kWh Hyundai Kona and Kia e-Niro
|
||||
- added initial support for Hyundai Ioniq 28kWh (not working yet)
|
||||
|
||||
### v1.6 2020-06-30
|
||||
- fixed ble device pairing
|
||||
- added command to set protocol ISO 15765-4 CAN (11 bit ID, 500 kbit/s) - some vgate adapters freezes during "init at command" phase
|
||||
|
||||
### v1.5 2020-06-03
|
||||
- added support for different units (miles, fahrenheits, psi)
|
||||
|
||||
### v1.4 2020-05-29
|
||||
- added menu
|
||||
- Pairing with VGATE iCar Pro BLE4 adapter via menu!
|
||||
- Installation with flash tool. You don't have to install Arduino and compile sources :)
|
||||
- New screen 5. Conpumption... Can be used to measure available battery capacity!
|
||||
- Load/Save settings
|
||||
- Flip screen vertical option
|
||||
- Several different improvements
|
||||
|
||||
### v1.1 2020-04-12
|
||||
- added new screens (switch via left button)
|
||||
- screen 0. (blank screen, lcd off)
|
||||
- screen 1. (default) summary info
|
||||
- screen 2. speed kmh + kwh/100km (or kw for discharge)
|
||||
- screen 3. battery cells + battery module temperatures
|
||||
- screen 4. charging graph
|
||||
- added low batery temperature detection for slow charging on 50kW DC (15°C) and UFC >70kW (25°C).
|
||||
|
||||
### v1.0 2020-03-23
|
||||
- first release
|
||||
- basic dashboard
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
|
||||
rem slow GUI performance via arduino-cli yet
|
||||
|
||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_TTGO_T4=1 -v enirodashboard.ino
|
||||
rem arduino-cli upload -b esp32:esp32:esp32 -v -p COM6
|
||||
arduino-cli compile -v -b esp32:esp32:esp32wrover --build-properties build.extra_flags=-BOARD_TTGO_T4=1 -v evDash.ino
|
||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_TTGO_T4=1 -v evDash.ino
|
||||
rem rduino-cli upload -b esp32:esp32:esp32 -v -p COM6
|
||||
|
||||
rem arduino-cli compile -v -b esp32:esp32:m5stack-core-esp32 --build-properties build.extra_flags=-BOARD_M5STACK=1 enirodashboard.ino
|
||||
rem arduino-cli compile -v -b esp32:esp32:m5stack-core-esp32 --build-properties build.extra_flags=-BOARD_M5STACK=1 evDash.ino
|
||||
rem arduino-cli upload -v -b esp32:esp32:m5stack-core-esp32 -p COM9
|
||||
|
||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_M5STACK=1 -v enirodashboard.ino
|
||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_M5STACK=1 -v evDash.ino
|
||||
rem arduino-cli upload -b esp32:esp32:esp32 -v -p COM9
|
||||
|
||||
pause
|
||||
@@ -1,518 +0,0 @@
|
||||
|
||||
#define commandQueueCountDebugObd2Kia 256
|
||||
#define commandQueueLoopFromDebugObd2Kia 8
|
||||
|
||||
String commandQueueDebugObd2Kia[commandQueueCountDebugObd2Kia] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
"AT DP",
|
||||
"AT ST16",
|
||||
|
||||
// Loop from here
|
||||
|
||||
// Request ID Response ID ECU name Can bus Protocol Description
|
||||
// 725 72D WPS B Wireless phone charger
|
||||
//"ATSH725",
|
||||
//"2201", // All with negative resp. "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 736 73E VESS P Virtual Engine Sound system
|
||||
//"ATSH736",
|
||||
//"2201", // All with negative resp. "2202", "2203", "2101", "2102",
|
||||
//"220101", // All with 62 response "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 755 75D BSD Right Blind spot detection Right
|
||||
// "ATSH755",
|
||||
// "2201", // ALL with negative 7F2213, etc "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 770 778 IGPM All UDS Integrated Gateway and power control module
|
||||
"ATSH770",
|
||||
"22BC01", // 009 62BC01400000000001AAAAAAAA
|
||||
"22BC02", // 62BC0200000000
|
||||
"22BC03", // 00B 62BC03FDEE7C730A600000AAAA
|
||||
"22BC04", // 00B 62BC04B33F74EA0D002042AAAA
|
||||
"22BC05", // 00B 62BC05BF13200001000000AAAA
|
||||
"22BC06", // 00B 62BC06B48000002C000000AAAA
|
||||
"22BC07", // 00B 62BC070849DBC000101900AAAA
|
||||
//"22BC08", // ALL with NEGATIVE RESPONSE "22BC09", "22BC0A", "22BC0B", "22BC0C", "22BC0D", "22BC0E", "22BC0F",
|
||||
|
||||
// 783 78B AMP M Amplifier
|
||||
//"ATSH783",
|
||||
// "2201",// ALL with NEGATIVE RESPONSE "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 796 79E PGS C Parking Guide System
|
||||
//"ATSH796",
|
||||
//"2201", // ALL with NEGATIVE RESPONSE "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A0 7A8 BCM / TPMS B UDS Body control module 22 B0 01 to 22 B0 0E
|
||||
// C Tire Pressure Monitoring "At least 22 C0 01 to 22 C0 02 & 22 C0 0B to 22 C0 0F"
|
||||
"ATSH7A0",
|
||||
"22B001", // 016 62B00140C20000000000000000000001010000000001AAAAAAAAAA
|
||||
"22B002", // 009 62B002C00000000300AAAAAAAA
|
||||
"22B003", // 018 62B003BFCB8000A23D63B164F8F7F73DF80000A400A4A4A4AAAAAA
|
||||
"22B004", // 00B 62B0047402994E0E008800AAAA
|
||||
"22B005", // 00B 62B0052000100000000800AAAA
|
||||
"22B006", // 00B 62B0062000000000000000AAAA
|
||||
"22B007", // 00B 62B007002001E000040000AAAA
|
||||
"22B008", // 00B 62B00800510C2000880004AAAA
|
||||
"22B009", // 00B 62B009FEEEFEEE08000800AAAA
|
||||
"22B00A", // 00B 62B00AE3FEE3000040C500AAAA
|
||||
//"22B00B", // 7F2231
|
||||
"22B00C", // 00B 62B00C3F00000000000000AAAA
|
||||
"22B00D", // 00B 62B00DFCFCFC0000000000AAAA
|
||||
"22B00E", // 00B 62B00E0800000000000000AAAA
|
||||
//"22B00F", // 7F2231
|
||||
"22C001", // 01D 62C001000000002E2E02500706B5B50A098C3C0000000001FF01000101AAAAAAAAAA
|
||||
"22C002", // 017 62C002FFFF0000D2E149F3D2DBDACBD2E84EBBD2E84E93AAAAAAAA
|
||||
"22C003", // 021 62C00300000000444F303101002E2E02500706B5B50A098C3C0000000001FF0100AA
|
||||
"22C004", // 021 62C004000000004E41303101002E2E024B0005B5B508088C3C0100000001FF0100AA
|
||||
"22C005", // 021 62C005000000004E54504D0100302F02500000ABAB00008C3C0000030001FF0000AA
|
||||
"22C006", // 021 62C00600000000444F303201002E2E02500706B5AB0A098C3C0000000001010100AA
|
||||
"22C007", // 021 62C007000000004E41303201002E2E024B0005B5AB08088C3C0100000001010100AA
|
||||
"22C008", // 021 62C00800000000434E303101002E2E02500706B5B50A098C3C0000020001FF0100AA
|
||||
"22C009", // 021 62C00900000000303030360000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAA
|
||||
"22C00A", // 021 62C00A00000000303030370000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAA
|
||||
"22C00B", // 017 62C00BFFFF0000AF470100B4480100B5460100B3460100AAAAAAAA
|
||||
"22C00C", // 025 62C00CFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00D", // 025 62C00DFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00E", // 025 62C00EFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
"22C00F", // 025 62C00FFFFF03000000000000FFFF0000000000000000FFFF0000000000000000FFFF000000AAAAAAAA
|
||||
|
||||
// 7A1 7A9 DDM B Driver door module
|
||||
// "ATSH7A1",
|
||||
// "2201", // All with NO DATA "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A2 7AA ADM B Assist door module
|
||||
//"ATSH7A2",
|
||||
// "2201", // ALL with NO DATA "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7A3 7AB PSM B UDS Power Seat Module
|
||||
// "ATSH7A3",
|
||||
// "22B401", // All with NO DATA "22B402", "22B403", "22B404", "22B405", "22B406", "22B407", "22B408", "22B409", "22B40A",
|
||||
|
||||
// 7A5 7AD SMK B UDS Smart Key
|
||||
"ATSH7A5",
|
||||
"22B001", // 7F2278 7F2231
|
||||
"22B002", // positive
|
||||
"22B003", // positive
|
||||
"22B004", // 7F2278 7F2231
|
||||
"22B005", // positive
|
||||
"22B006", // positive
|
||||
"22B007", // positive
|
||||
"22B008", // positive
|
||||
"22B009", // positive
|
||||
"22B00A", // positive
|
||||
|
||||
// 7B3 7BB AIRCON / ACU UDS Aircondition
|
||||
"ATSH7B3",
|
||||
"220100", // 026 6201007E5027C8FF7C6D6B05EFBCFFFFEFFF10FFFFFFFFFFFFBFFFFF52B3919900FFFF01FFFF000000 in/out temp
|
||||
// "220101", // 7F2231
|
||||
"220102", // 014 620102FFF80000B36B0101000101003C00016E12 coolant temp1, 2
|
||||
// "220103", // 7F2231
|
||||
|
||||
// 7B7 7BF BSD Left Blind spot detection Left
|
||||
"ATSH7B7",
|
||||
// "2201", // ALL NEGATIVE RESP "2202", "2203", "2101", "2102", "220101", "220102", "22B001", "22C001", "22C101",
|
||||
|
||||
// 7C4 7CC MFC Multi Function Camera
|
||||
"ATSH7C4",
|
||||
"220101", // 6201010E
|
||||
"220102", // 62010200000000
|
||||
|
||||
// 7C6 7CE CM C & M UDS Cluster Module
|
||||
"ATSH7C6",
|
||||
"22B001", // 008 62B00100000000000000000000
|
||||
"22B002", // 00F 62B002E0000000FFA200AD8F0000000000000000 odo
|
||||
"22B003", // 008 62B00398000000010000000000
|
||||
//"22B004", // NO DATA
|
||||
|
||||
// 7D0 7D8 AEB UDS? Autonomous Emergency Breaking
|
||||
// "ATSH7D0",
|
||||
// "2201", // ALL CODES WITH NEGATIVE RESPONSE
|
||||
// "2202", // "2203", // "2101", // "2102", // "220101", // "220102", // "22B001", // "22C001", // "22C101",
|
||||
|
||||
// 7D1 7D9 ABS / ESP + AHB UDS
|
||||
"ATSH7D1",
|
||||
"22C101", // 02A 62C1015FD7E7D0FFFF00FF04D0D400000000FF7EFF0030F5010000FFFF7F6307F207FE05FF00FF3FFFFFAAAAAAAAAAAA
|
||||
"22C102", // 01A 62C10237000000FFFFFFFFFFFF00FF05FFFFFF00FF5501FFFFFFAA
|
||||
"22C103", // 01A 62C103BE3000000DFFF0FCFE7FFF7FFFFFFFFFFF000005B50000AA
|
||||
|
||||
// 7D2 7DA AIRBAG SRS Sytem
|
||||
// "ATSH7D2",
|
||||
// "2101", // 7F2211
|
||||
// "2102", // 7F2211
|
||||
// "220101", // 7F2211
|
||||
// "220102", // 7F2211
|
||||
// "22B001", // 7F2211
|
||||
// "22C001", // 7F2211
|
||||
// "22C101", // 7F2211
|
||||
|
||||
// 7D4 7DC EPS Electric power steering
|
||||
"ATSH7D4",
|
||||
//"2101", // 7F2121
|
||||
//"2102", // 7F2121
|
||||
"220101", // 012 6201018387FD009DFFF90100000010101921AAAA
|
||||
"220102", // 008 6201020000000500AAAAAAAAAA
|
||||
// "22B001", // 7F2231
|
||||
// "22C001", // 7F2231
|
||||
// "22C101", // 7F2231
|
||||
|
||||
// 7DF UNKNOWN
|
||||
//"ATSH7DF",
|
||||
//"2106", // 013 7F2112 028 6106FFFF800000000000000300001C001C001C000600060006000F000000010000000000000000015801580158015700
|
||||
//"220106", // 01B 620106FFFFFFFF12001200307C7C00317C830000B4B3000A28EA00
|
||||
|
||||
// 7E2 7EA VMCU H & P KWP2000 Vehicle Motor Control Unit 21 01 to 21 02 & 1A 80++
|
||||
"ATSH7E2",
|
||||
"2101", // 018 6101FFF8000009285A3806480300000000C4693404080805000000 speed, ...
|
||||
"2102", // 027 6102F8FFFC000101000000851BB5780234FA0BAB8D1933E07F5B211C74000001010100000007000000 aux, ...
|
||||
//"2103", // 7F2112
|
||||
//"1A80", // Working VIN 1A 8A 8C 8D ...
|
||||
|
||||
// 7E3 7EB MCU H & P KWP2000 Motor Control Unit 21 01 to 21 06
|
||||
"ATSH7E3",
|
||||
"2101", // 01E 610100007FFF0C3C00BD8D0A3300B00900002D0252025033D500C3FF68FF00000000
|
||||
"2102", // 03A 610207FFFFFF00000D000D00260008080909000001004614CDABC2CD3F005581720085CAF5265D0DC1CD0000EC3400000000000000000000FF0000000000
|
||||
"2103", // 06E 610300007FFF0000000000000000000000000000000000005C010E02FDFD040400000000000000000000000048058D0C0200160000000000AA3F000005000000AE0102000000000000000000000000000000000000000000BB0B00000000000000000000680000000000E803000000
|
||||
"2104", // 060 6104000001FF000000000000D7425D03000000000000050000007A2B00000000000000003200000000000000000000000000000000000000000000000000000000000000010000000100010001000000030000000000000000006D0000008E1B00
|
||||
"2105", // 067 6105000001FF630200010000005900000C00630200010000000100000C006B0200020000003300250D0136010096BA03000100000C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
"2106", // 013 6106000000030000000000000000000000000300
|
||||
//"2107", // 7F2112
|
||||
|
||||
// 7E4 7EC BMS P UDS Battery Management System 22 01 01 to 22 01 06
|
||||
"ATSH7E4",
|
||||
"220101", // 03E 620101FFF7E7FF6B0000000003001C0E2F161414141513000012B930B9380000830003E1E30003C95B0001722C00015B5B0040D1660D016B0000000003E8 power kw, ...
|
||||
"220102", // 027 620102FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA cell voltages, screen 3 only
|
||||
"220103", // 027 620103FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA cell voltages, screen 3 only
|
||||
"220104", // 027 620104FFFFFFFFB9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9B9AAAA
|
||||
"220105", // 02E 620105003FFF90000000000000000012836A0142684268000150126E03E8000000006E0000B9B900000F00000000AAAA soh, soc, ..
|
||||
"220106", // 01B 620106FFFFFFFF12001200307C7C00007C030000B4B3000A28EA00 cooling water temp
|
||||
// "220107", // 7F2231
|
||||
|
||||
// 7E5 7ED OBC KWP2000 OnBoard Charger 21 01 to 21 03
|
||||
"ATSH7E5",
|
||||
"2101", // 01A 6101DFE0000001010001000000000E2F0533051D0078000000C800
|
||||
"2102", // 011 6102FE000000000403E8000001BF000028000000
|
||||
"2103", // 039 6103FFFFFDF80000000000000000000000000000000000000000000000000000000000000000007576767600000000000000000004000400030000000000
|
||||
"2104", // 022 6104FFF000000A280A280A280000E324006900000003000000000000000000000000
|
||||
"2105", // 046 61050000000081AA791E8013791E779C791E8BD37907874A79108D67791473777915727E7914753179156FAE7917768F79147650792876257930757E7914759379167545791D000000000000
|
||||
"2106", // 028 6106FFFF8000001C001C001C000600060006000E000000010000000000000000015801580158015800
|
||||
//"2107", // ret 7F2112
|
||||
|
||||
// 7E6 7EE ?? ?? 21 08 05 to 21 08 0F -> All negative response
|
||||
//"ATSH7E6",
|
||||
//"210805", // ret 7F2112
|
||||
//"210806", // ret 7F2112
|
||||
//"210807", // ret 7F2112
|
||||
};
|
||||
|
||||
/**
|
||||
Init command queue
|
||||
*/
|
||||
bool activateCommandQueueForDebugObd2Kia() {
|
||||
|
||||
// 39 or 64 kWh model?
|
||||
params.batteryTotalAvailableKWh = 64;
|
||||
|
||||
// Empty and fill command queue
|
||||
for (uint16_t i = 0; i < 300; i++) {
|
||||
commandQueue[i] = "";
|
||||
}
|
||||
for (uint16_t i = 0; i < commandQueueCountDebugObd2Kia; i++) {
|
||||
commandQueue[i] = commandQueueDebugObd2Kia[i];
|
||||
}
|
||||
|
||||
commandQueueLoopFrom = commandQueueLoopFromDebugObd2Kia;
|
||||
commandQueueCount = commandQueueCountDebugObd2Kia;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse merged row
|
||||
*/
|
||||
bool parseRowMergedDebugObd2Kia() {
|
||||
|
||||
// VMCU 7E2
|
||||
if (currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (commandRequest.equals("2101")) {
|
||||
params.speedKmh = hexToDec(responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (params.speedKmh < -99 || params.speedKmh > 200)
|
||||
params.speedKmh = 0;
|
||||
}
|
||||
if (commandRequest.equals("2102")) {
|
||||
params.auxPerc = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
params.auxCurrentAmp = - hexToDec(responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (commandRequest.equals("22B002")) {
|
||||
params.odoKm = float(strtol(responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (commandRequest.equals("220100")) {
|
||||
params.indoorTemperature = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
params.outdoorTemperature = (hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (commandRequest.equals("220102") && responseRowMerged.substring(12, 14) == "00") {
|
||||
params.coolantTemp1C = (hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
params.coolantTemp2C = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (commandRequest.equals("220101")) {
|
||||
params.cumulativeEnergyChargedKWh = float(strtol(responseRowMerged.substring(82, 90).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyChargedKWhStart == -1)
|
||||
params.cumulativeEnergyChargedKWhStart = params.cumulativeEnergyChargedKWh;
|
||||
params.cumulativeEnergyDischargedKWh = float(strtol(responseRowMerged.substring(90, 98).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
params.cumulativeEnergyDischargedKWhStart = params.cumulativeEnergyDischargedKWh;
|
||||
params.auxVoltage = hexToDec(responseRowMerged.substring(64, 66).c_str(), 2, true) / 10.0;
|
||||
params.batPowerAmp = - hexToDec(responseRowMerged.substring(26, 30).c_str(), 2, true) / 10.0;
|
||||
params.batVoltage = hexToDec(responseRowMerged.substring(30, 34).c_str(), 2, false) / 10.0;
|
||||
params.batPowerKw = (params.batPowerAmp * params.batVoltage) / 1000.0;
|
||||
params.batPowerKwh100 = params.batPowerKw / params.speedKmh * 100;
|
||||
params.batCellMaxV = hexToDec(responseRowMerged.substring(52, 54).c_str(), 1, false) / 50.0;
|
||||
params.batCellMinV = hexToDec(responseRowMerged.substring(56, 58).c_str(), 1, false) / 50.0;
|
||||
params.batModuleTempC[0] = hexToDec(responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
params.batModuleTempC[1] = hexToDec(responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
params.batModuleTempC[2] = hexToDec(responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
params.batModuleTempC[3] = hexToDec(responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
//params.batTempC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//params.batMaxC = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//params.batMinC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batMinC = params.batMaxC = params.batModuleTempC[0];
|
||||
params.batMinC = (params.batModuleTempC[1] < params.batMinC) ? params.batModuleTempC[1] : params.batMinC;
|
||||
params.batMinC = (params.batModuleTempC[2] < params.batMinC) ? params.batModuleTempC[2] : params.batMinC;
|
||||
params.batMinC = (params.batModuleTempC[3] < params.batMinC) ? params.batModuleTempC[3] : params.batMinC;
|
||||
params.batMaxC = (params.batModuleTempC[1] > params.batMaxC) ? params.batModuleTempC[1] : params.batMaxC;
|
||||
params.batMaxC = (params.batModuleTempC[2] > params.batMaxC) ? params.batModuleTempC[2] : params.batMaxC;
|
||||
params.batMaxC = (params.batModuleTempC[3] > params.batMaxC) ? params.batModuleTempC[3] : params.batMaxC;
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
params.batInletC = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
if (params.speedKmh < 10 && params.batPowerKw >= 1 && params.socPerc > 0 && params.socPerc <= 100) {
|
||||
if ( params.chargingGraphMinKw[int(params.socPerc)] == -100 || params.batPowerKw < params.chargingGraphMinKw[int(params.socPerc)])
|
||||
params.chargingGraphMinKw[int(params.socPerc)] = params.batPowerKw;
|
||||
if ( params.chargingGraphMaxKw[int(params.socPerc)] == -100 || params.batPowerKw > params.chargingGraphMaxKw[int(params.socPerc)])
|
||||
params.chargingGraphMaxKw[int(params.socPerc)] = params.batPowerKw;
|
||||
params.chargingGraphBatMinTempC[int(params.socPerc)] = params.batMinC;
|
||||
params.chargingGraphBatMaxTempC[int(params.socPerc)] = params.batMaxC;
|
||||
params.chargingGraphHeaterTempC[int(params.socPerc)] = params.batHeaterC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220102") && responseRowMerged.substring(12, 14) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[32 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[64 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220105")) {
|
||||
params.socPercPrevious = params.socPerc;
|
||||
params.sohPerc = hexToDec(responseRowMerged.substring(56, 60).c_str(), 2, false) / 10.0;
|
||||
params.socPerc = hexToDec(responseRowMerged.substring(68, 70).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (params.socPercPrevious - params.socPerc > 0) {
|
||||
byte index = (int(params.socPerc) == 4) ? 0 : (int)(params.socPerc / 10) + 1;
|
||||
if ((int(params.socPerc) % 10 == 9 || int(params.socPerc) == 4) && params.soc10ced[index] == -1) {
|
||||
struct tm now;
|
||||
getLocalTime(&now, 0);
|
||||
time_t time_now_epoch = mktime(&now);
|
||||
params.soc10ced[index] = params.cumulativeEnergyDischargedKWh;
|
||||
params.soc10cec[index] = params.cumulativeEnergyChargedKWh;
|
||||
params.soc10odo[index] = params.odoKm;
|
||||
params.soc10time[index] = time_now_epoch;
|
||||
}
|
||||
}
|
||||
params.batHeaterC = hexToDec(responseRowMerged.substring(52, 54).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
params.cellVoltage[96 - 30 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220106")) {
|
||||
params.coolingWaterTempC = hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (commandRequest.equals("22c00b")) {
|
||||
params.tireFrontLeftPressureBar = hexToDec(responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontRightPressureBar = hexToDec(responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearRightPressureBar = hexToDec(responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearLeftPressureBar = hexToDec(responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontLeftTempC = hexToDec(responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireFrontRightTempC = hexToDec(responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearRightTempC = hexToDec(responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearLeftTempC = hexToDec(responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Test data
|
||||
*/
|
||||
bool testDataDebugObd2Kia() {
|
||||
|
||||
// VMCU ATSH7E2
|
||||
currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
commandRequest = "2101";
|
||||
responseRowMerged = "6101FFF8000009285A3B0648030000B4179D763404080805000000";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 2102
|
||||
commandRequest = "2102";
|
||||
responseRowMerged = "6102F8FFFC000101000000840FBF83BD33270680953033757F59291C76000001010100000007000000";
|
||||
responseRowMerged = "6102F8FFFC000101000000931CC77F4C39040BE09BA7385D8158832175000001010100000007000000";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
// "ATSH7DF",
|
||||
currentAtshRequest = "ATSH7DF";
|
||||
// 2106
|
||||
commandRequest = "2106";
|
||||
responseRowMerged = "6106FFFF800000000000000200001B001C001C000600060006000E000000010000000000000000013D013D013E013E00";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
commandRequest = "220100";
|
||||
responseRowMerged = "6201007E5027C8FF7F765D05B95AFFFF5AFF11FFFFFFFFFFFF6AFFFF2DF0757630FFFF00FFFF000000";
|
||||
responseRowMerged = "6201007E5027C8FF867C58121010FFFF10FF8EFFFFFFFFFFFF10FFFF0DF0617900FFFF01FFFF000000";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
// BMS ATSH7E4
|
||||
currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
commandRequest = "220101";
|
||||
responseRowMerged = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
|
||||
responseRowMerged = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 220102
|
||||
commandRequest = "220102";
|
||||
responseRowMerged = "620102FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 220103
|
||||
commandRequest = "220103";
|
||||
responseRowMerged = "620103FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCACBCACACFCCCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 220104
|
||||
commandRequest = "220104";
|
||||
responseRowMerged = "620104FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 220105
|
||||
commandRequest = "220105";
|
||||
responseRowMerged = "620105003fff9000000000000000000F8A86012B4946500101500DAC03E800000000AC0000C7C701000F00000000AAAA";
|
||||
responseRowMerged = "620105003FFF90000000000000000014918E012927465000015013BB03E800000000BB0000CBCB01001300000000AAAA";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
// 220106
|
||||
commandRequest = "220106";
|
||||
responseRowMerged = "620106FFFFFFFF14001A00240000003A7C86B4B30000000928EA00";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
commandRequest = "22c00b";
|
||||
responseRowMerged = "62C00BFFFF0000B93D0100B43E0100B43D0100BB3C0100AAAAAAAA";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
// ATSH7C6
|
||||
currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
commandRequest = "22b002";
|
||||
responseRowMerged = "62B002E0000000FFB400330B0000000000000000";
|
||||
parseRowMergedDebugObd2Kia();
|
||||
|
||||
params.batModuleTempC[0] = 28;
|
||||
params.batModuleTempC[1] = 29;
|
||||
params.batModuleTempC[2] = 28;
|
||||
params.batModuleTempC[3] = 30;
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batMinC = params.batMaxC = params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < params.batModuleTempCount; i++) {
|
||||
if (params.batModuleTempC[i] < params.batMinC)
|
||||
params.batMinC = params.batModuleTempC[i];
|
||||
if (params.batModuleTempC[i] > params.batMaxC)
|
||||
params.batMaxC = params.batModuleTempC[i];
|
||||
}
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
//
|
||||
params.soc10ced[10] = 2200;
|
||||
params.soc10cec[10] = 2500;
|
||||
params.soc10odo[10] = 13000;
|
||||
params.soc10time[10] = 13000;
|
||||
params.soc10ced[9] = params.soc10ced[10] + 6.4;
|
||||
params.soc10cec[9] = params.soc10cec[10] + 0;
|
||||
params.soc10odo[9] = params.soc10odo[10] + 30;
|
||||
params.soc10time[9] = params.soc10time[10] + 900;
|
||||
params.soc10ced[8] = params.soc10ced[9] + 6.8;
|
||||
params.soc10cec[8] = params.soc10cec[9] + 0;
|
||||
params.soc10odo[8] = params.soc10odo[9] + 30;
|
||||
params.soc10time[8] = params.soc10time[9] + 900;
|
||||
params.soc10ced[7] = params.soc10ced[8] + 7.2;
|
||||
params.soc10cec[7] = params.soc10cec[8] + 0.6;
|
||||
params.soc10odo[7] = params.soc10odo[8] + 30;
|
||||
params.soc10time[7] = params.soc10time[8] + 900;
|
||||
params.soc10ced[6] = params.soc10ced[7] + 6.7;
|
||||
params.soc10cec[6] = params.soc10cec[7] + 0;
|
||||
params.soc10odo[6] = params.soc10odo[7] + 30;
|
||||
params.soc10time[6] = params.soc10time[7] + 900;
|
||||
params.soc10ced[5] = params.soc10ced[6] + 6.7;
|
||||
params.soc10cec[5] = params.soc10cec[6] + 0;
|
||||
params.soc10odo[5] = params.soc10odo[6] + 30;
|
||||
params.soc10time[5] = params.soc10time[6] + 900;
|
||||
params.soc10ced[4] = params.soc10ced[5] + 6.4;
|
||||
params.soc10cec[4] = params.soc10cec[5] + 0.3;
|
||||
params.soc10odo[4] = params.soc10odo[5] + 30;
|
||||
params.soc10time[4] = params.soc10time[5] + 900;
|
||||
params.soc10ced[3] = params.soc10ced[4] + 6.4;
|
||||
params.soc10cec[3] = params.soc10cec[4] + 0;
|
||||
params.soc10odo[3] = params.soc10odo[4] + 30;
|
||||
params.soc10time[3] = params.soc10time[4] + 900;
|
||||
params.soc10ced[2] = params.soc10ced[3] + 5.4;
|
||||
params.soc10cec[2] = params.soc10cec[3] + 0.1;
|
||||
params.soc10odo[2] = params.soc10odo[3] + 30;
|
||||
params.soc10time[2] = params.soc10time[3] + 900;
|
||||
params.soc10ced[1] = params.soc10ced[2] + 6.2;
|
||||
params.soc10cec[1] = params.soc10cec[2] + 0.1;
|
||||
params.soc10odo[1] = params.soc10odo[2] + 30;
|
||||
params.soc10time[1] = params.soc10time[2] + 900;
|
||||
params.soc10ced[0] = params.soc10ced[1] + 2.9;
|
||||
params.soc10cec[0] = params.soc10cec[1] + 0.5;
|
||||
params.soc10odo[0] = params.soc10odo[1] + 15;
|
||||
params.soc10time[0] = params.soc10time[1] + 900;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
#define commandQueueCountHyundaiIoniq 25
|
||||
#define commandQueueLoopFromHyundaiIoniq 8
|
||||
String commandQueueHyundaiIoniq[commandQueueCountHyundaiIoniq] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
//"AT AL", // Allow Long (>7 byte) messages
|
||||
//"AT AR", // Automatically receive
|
||||
//"AT H1", // Headers on (debug only)
|
||||
//"AT D1", // Display of the DLC on
|
||||
//"AT CAF0", // Automatic formatting off
|
||||
"AT DP",
|
||||
"AT ST16",
|
||||
|
||||
// Loop from (HYUNDAI IONIQ)
|
||||
// BMS
|
||||
"ATSH7E4",
|
||||
"2101", // power kw, ...
|
||||
"2102", // cell voltages, screen 3 only
|
||||
"2103", // cell voltages, screen 3 only
|
||||
"2104", // cell voltages, screen 3 only
|
||||
"2105", // soh, soc, ..
|
||||
"2106", // cooling water temp
|
||||
|
||||
// VMCU
|
||||
"ATSH7E2",
|
||||
"2101", // speed, ...
|
||||
"2102", // aux, ...
|
||||
|
||||
//"ATSH7Df",
|
||||
//"2106",
|
||||
//"220106",
|
||||
|
||||
// Aircondition
|
||||
// IONIQ OK
|
||||
"ATSH7B3",
|
||||
"220100", // in/out temp
|
||||
"220102", // coolant temp1, 2
|
||||
|
||||
// BCM / TPMS
|
||||
// IONIQ OK
|
||||
"ATSH7A0",
|
||||
"22c00b", // tire pressure/temp
|
||||
|
||||
// CLUSTER MODULE
|
||||
// IONIQ OK
|
||||
"ATSH7C6",
|
||||
"22B002", // odo
|
||||
};
|
||||
|
||||
/**
|
||||
Init command queue
|
||||
*/
|
||||
bool activateCommandQueueForHyundaiIoniq() {
|
||||
|
||||
// 28kWh version
|
||||
params.batteryTotalAvailableKWh = 28;
|
||||
params.batModuleTempCount = 12;
|
||||
|
||||
// Empty and fill command queue
|
||||
for (int i = 0; i < 300; i++) {
|
||||
commandQueue[i] = "";
|
||||
}
|
||||
for (int i = 0; i < commandQueueCountHyundaiIoniq; i++) {
|
||||
commandQueue[i] = commandQueueHyundaiIoniq[i];
|
||||
}
|
||||
|
||||
commandQueueLoopFrom = commandQueueLoopFromHyundaiIoniq;
|
||||
commandQueueCount = commandQueueCountHyundaiIoniq;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse merged row
|
||||
*/
|
||||
bool parseRowMergedHyundaiIoniq() {
|
||||
|
||||
// VMCU 7E2
|
||||
if (currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (commandRequest.equals("2101")) {
|
||||
params.speedKmh = hexToDec(responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (params.speedKmh < -99 || params.speedKmh > 200)
|
||||
params.speedKmh = 0;
|
||||
}
|
||||
if (commandRequest.equals("2102")) {
|
||||
params.auxPerc = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
params.auxCurrentAmp = - hexToDec(responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (commandRequest.equals("22B002")) {
|
||||
params.odoKm = float(strtol(responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (commandRequest.equals("220100")) {
|
||||
params.indoorTemperature = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
params.outdoorTemperature = (hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (commandRequest.equals("220102") && responseRowMerged.substring(12, 14) == "00") {
|
||||
params.coolantTemp1C = (hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
params.coolantTemp2C = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (commandRequest.equals("2101")) {
|
||||
params.cumulativeEnergyChargedKWh = float(strtol(responseRowMerged.substring(80, 88).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyChargedKWhStart == -1)
|
||||
params.cumulativeEnergyChargedKWhStart = params.cumulativeEnergyChargedKWh;
|
||||
params.cumulativeEnergyDischargedKWh = float(strtol(responseRowMerged.substring(88, 96).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
params.cumulativeEnergyDischargedKWhStart = params.cumulativeEnergyDischargedKWh;
|
||||
params.availableChargePower = float(strtol(responseRowMerged.substring(16, 20).c_str(), 0, 16)) / 100.0;
|
||||
params.availableDischargePower = float(strtol(responseRowMerged.substring(20, 24).c_str(), 0, 16)) / 100.0;
|
||||
params.isolationResistanceKOhm = hexToDec(responseRowMerged.substring(118, 122).c_str(), 2, true);
|
||||
params.batFanStatus = hexToDec(responseRowMerged.substring(58, 60).c_str(), 2, true);
|
||||
params.batFanFeedbackHz = hexToDec(responseRowMerged.substring(60, 62).c_str(), 2, true);
|
||||
params.auxVoltage = hexToDec(responseRowMerged.substring(62, 64).c_str(), 2, true) / 10.0;
|
||||
params.batPowerAmp = - hexToDec(responseRowMerged.substring(24, 28).c_str(), 2, true) / 10.0;
|
||||
params.batVoltage = hexToDec(responseRowMerged.substring(28, 32).c_str(), 2, false) / 10.0;
|
||||
params.batPowerKw = (params.batPowerAmp * params.batVoltage) / 1000.0;
|
||||
if (params.batPowerKw < 1) // Reset charging start time
|
||||
params.chargingStartTime = params.currentTime;
|
||||
params.batPowerKwh100 = params.batPowerKw / params.speedKmh * 100;
|
||||
params.batCellMaxV = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, false) / 50.0;
|
||||
params.batCellMinV = hexToDec(responseRowMerged.substring(54, 56).c_str(), 1, false) / 50.0;
|
||||
params.batModuleTempC[0] = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
params.batModuleTempC[1] = hexToDec(responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
params.batModuleTempC[2] = hexToDec(responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
params.batModuleTempC[3] = hexToDec(responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
params.batModuleTempC[4] = hexToDec(responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
//params.batTempC = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//params.batMaxC = hexToDec(responseRowMerged.substring(32, 34).c_str(), 1, true);
|
||||
//params.batMinC = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batInletC = hexToDec(responseRowMerged.substring(48, 50).c_str(), 1, true);
|
||||
if (params.speedKmh < 10 && params.batPowerKw >= 1 && params.socPerc > 0 && params.socPerc <= 100) {
|
||||
if ( params.chargingGraphMinKw[int(params.socPerc)] == -100 || params.batPowerKw < params.chargingGraphMinKw[int(params.socPerc)])
|
||||
params.chargingGraphMinKw[int(params.socPerc)] = params.batPowerKw;
|
||||
if ( params.chargingGraphMaxKw[int(params.socPerc)] == -100 || params.batPowerKw > params.chargingGraphMaxKw[int(params.socPerc)])
|
||||
params.chargingGraphMaxKw[int(params.socPerc)] = params.batPowerKw;
|
||||
params.chargingGraphBatMinTempC[int(params.socPerc)] = params.batMinC;
|
||||
params.chargingGraphBatMaxTempC[int(params.socPerc)] = params.batMaxC;
|
||||
params.chargingGraphHeaterTempC[int(params.socPerc)] = params.batHeaterC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("2102") && responseRowMerged.substring(10, 12) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[i] = hexToDec(responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("2103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[32 + i] = hexToDec(responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("2104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[64 + i] = hexToDec(responseRowMerged.substring(12 + (i * 2), 12 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("2105")) {
|
||||
params.socPercPrevious = params.socPerc;
|
||||
params.sohPerc = hexToDec(responseRowMerged.substring(54, 58).c_str(), 2, false) / 10.0;
|
||||
params.socPerc = hexToDec(responseRowMerged.substring(66, 68).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Remaining battery modules (tempC)
|
||||
params.batModuleTempC[5] = hexToDec(responseRowMerged.substring(22, 24).c_str(), 1, true);
|
||||
params.batModuleTempC[6] = hexToDec(responseRowMerged.substring(24, 26).c_str(), 1, true);
|
||||
params.batModuleTempC[7] = hexToDec(responseRowMerged.substring(26, 28).c_str(), 1, true);
|
||||
params.batModuleTempC[8] = hexToDec(responseRowMerged.substring(28, 30).c_str(), 1, true);
|
||||
params.batModuleTempC[9] = hexToDec(responseRowMerged.substring(30, 32).c_str(), 1, true);
|
||||
params.batModuleTempC[10] = hexToDec(responseRowMerged.substring(32, 34).c_str(), 1, true);
|
||||
params.batModuleTempC[11] = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
|
||||
params.batMinC = params.batMaxC = params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < params.batModuleTempCount; i++) {
|
||||
if (params.batModuleTempC[i] < params.batMinC)
|
||||
params.batMinC = params.batModuleTempC[i];
|
||||
if (params.batModuleTempC[i] > params.batMaxC)
|
||||
params.batMaxC = params.batModuleTempC[i];
|
||||
}
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (params.socPercPrevious - params.socPerc > 0) {
|
||||
byte index = (int(params.socPerc) == 4) ? 0 : (int)(params.socPerc / 10) + 1;
|
||||
if ((int(params.socPerc) % 10 == 9 || int(params.socPerc) == 4) && params.soc10ced[index] == -1) {
|
||||
params.soc10ced[index] = params.cumulativeEnergyDischargedKWh;
|
||||
params.soc10cec[index] = params.cumulativeEnergyChargedKWh;
|
||||
params.soc10odo[index] = params.odoKm;
|
||||
params.soc10time[index] = params.currentTime;
|
||||
}
|
||||
}
|
||||
params.batHeaterC = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
params.cellVoltage[96 - 30 + i] = -1;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
// IONIQ FAILED
|
||||
if (commandRequest.equals("2106")) {
|
||||
params.coolingWaterTempC = hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (commandRequest.equals("22c00b")) {
|
||||
params.tireFrontLeftPressureBar = hexToDec(responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontRightPressureBar = hexToDec(responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearRightPressureBar = hexToDec(responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearLeftPressureBar = hexToDec(responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontLeftTempC = hexToDec(responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireFrontRightTempC = hexToDec(responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearRightTempC = hexToDec(responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearLeftTempC = hexToDec(responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Test data
|
||||
*/
|
||||
bool testDataHyundaiIoniq() {
|
||||
|
||||
// VMCU ATSH7E2
|
||||
currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
commandRequest = "2101";
|
||||
responseRowMerged = "6101FFE0000009211222062F03000000001D7734";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 2102
|
||||
commandRequest = "2102";
|
||||
responseRowMerged = "6102FF80000001010000009315B2888D390B08618B683900000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
|
||||
// "ATSH7DF",
|
||||
currentAtshRequest = "ATSH7DF";
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
commandRequest = "220100";
|
||||
responseRowMerged = "6201007E5007C8FF8A876A011010FFFF10FF10FFFFFFFFFFFFFFFFFF2EEF767D00FFFF00FFFF000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220102
|
||||
commandRequest = "220102";
|
||||
responseRowMerged = "620102FF800000A3950000000000002600000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
|
||||
// BMS ATSH7E4
|
||||
currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
commandRequest = "2101";
|
||||
responseRowMerged = "6101FFFFFFFF5026482648A3FFC30D9E181717171718170019B50FB501000090000142230001425F0000771B00007486007815D809015C0000000003E800";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220102
|
||||
commandRequest = "2102";
|
||||
responseRowMerged = "6102FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220103
|
||||
commandRequest = "2103";
|
||||
responseRowMerged = "6103FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220104
|
||||
commandRequest = "2104";
|
||||
responseRowMerged = "6104FFFFFFFFB5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220105
|
||||
commandRequest = "2105";
|
||||
responseRowMerged = "6105FFFFFFFF00000000001717171817171726482648000150181703E81A03E801520029000000000000000000000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
// 220106
|
||||
commandRequest = "2106";
|
||||
responseRowMerged = "7F2112"; // n/a on ioniq
|
||||
parseRowMergedHyundaiIoniq();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
commandRequest = "22c00b";
|
||||
responseRowMerged = "62C00BFFFF0000B9510100B9510100B84F0100B54F0100AAAAAAAA";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
|
||||
// ATSH7C6
|
||||
currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
commandRequest = "22b002";
|
||||
responseRowMerged = "62B002E000000000AD003D2D0000000000000000";
|
||||
parseRowMergedHyundaiIoniq();
|
||||
|
||||
/* params.batModule01TempC = 28;
|
||||
params.batModule02TempC = 29;
|
||||
params.batModule03TempC = 28;
|
||||
params.batModule04TempC = 30;
|
||||
//params.batTempC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//params.batMaxC = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//params.batMinC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batMinC = params.batMaxC = params.batModule01TempC;
|
||||
params.batMinC = (params.batModule02TempC < params.batMinC) ? params.batModule02TempC : params.batMinC ;
|
||||
params.batMinC = (params.batModule03TempC < params.batMinC) ? params.batModule03TempC : params.batMinC ;
|
||||
params.batMinC = (params.batModule04TempC < params.batMinC) ? params.batModule04TempC : params.batMinC ;
|
||||
params.batMaxC = (params.batModule02TempC > params.batMaxC) ? params.batModule02TempC : params.batMaxC ;
|
||||
params.batMaxC = (params.batModule03TempC > params.batMaxC) ? params.batModule03TempC : params.batMaxC ;
|
||||
params.batMaxC = (params.batModule04TempC > params.batMaxC) ? params.batModule04TempC : params.batMaxC ;
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
//
|
||||
params.soc10ced[10] = 2200;
|
||||
params.soc10cec[10] = 2500;
|
||||
params.soc10odo[10] = 13000;
|
||||
params.soc10time[10] = 13000;
|
||||
params.soc10ced[9] = params.soc10ced[10] + 6.4;
|
||||
params.soc10cec[9] = params.soc10cec[10] + 0;
|
||||
params.soc10odo[9] = params.soc10odo[10] + 30;
|
||||
params.soc10time[9] = params.soc10time[10] + 900;
|
||||
params.soc10ced[8] = params.soc10ced[9] + 6.8;
|
||||
params.soc10cec[8] = params.soc10cec[9] + 0;
|
||||
params.soc10odo[8] = params.soc10odo[9] + 30;
|
||||
params.soc10time[8] = params.soc10time[9] + 900;
|
||||
params.soc10ced[7] = params.soc10ced[8] + 7.2;
|
||||
params.soc10cec[7] = params.soc10cec[8] + 0.6;
|
||||
params.soc10odo[7] = params.soc10odo[8] + 30;
|
||||
params.soc10time[7] = params.soc10time[8] + 900;
|
||||
params.soc10ced[6] = params.soc10ced[7] + 6.7;
|
||||
params.soc10cec[6] = params.soc10cec[7] + 0;
|
||||
params.soc10odo[6] = params.soc10odo[7] + 30;
|
||||
params.soc10time[6] = params.soc10time[7] + 900;
|
||||
params.soc10ced[5] = params.soc10ced[6] + 6.7;
|
||||
params.soc10cec[5] = params.soc10cec[6] + 0;
|
||||
params.soc10odo[5] = params.soc10odo[6] + 30;
|
||||
params.soc10time[5] = params.soc10time[6] + 900;
|
||||
params.soc10ced[4] = params.soc10ced[5] + 6.4;
|
||||
params.soc10cec[4] = params.soc10cec[5] + 0.3;
|
||||
params.soc10odo[4] = params.soc10odo[5] + 30;
|
||||
params.soc10time[4] = params.soc10time[5] + 900;
|
||||
params.soc10ced[3] = params.soc10ced[4] + 6.4;
|
||||
params.soc10cec[3] = params.soc10cec[4] + 0;
|
||||
params.soc10odo[3] = params.soc10odo[4] + 30;
|
||||
params.soc10time[3] = params.soc10time[4] + 900;
|
||||
params.soc10ced[2] = params.soc10ced[3] + 5.4;
|
||||
params.soc10cec[2] = params.soc10cec[3] + 0.1;
|
||||
params.soc10odo[2] = params.soc10odo[3] + 30;
|
||||
params.soc10time[2] = params.soc10time[3] + 900;
|
||||
params.soc10ced[1] = params.soc10ced[2] + 6.2;
|
||||
params.soc10cec[1] = params.soc10cec[2] + 0.1;
|
||||
params.soc10odo[1] = params.soc10odo[2] + 30;
|
||||
params.soc10time[1] = params.soc10time[2] + 900;
|
||||
params.soc10ced[0] = params.soc10ced[1] + 2.9;
|
||||
params.soc10cec[0] = params.soc10cec[1] + 0.5;
|
||||
params.soc10odo[0] = params.soc10odo[1] + 15;
|
||||
params.soc10time[0] = params.soc10time[1] + 900;
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
430
car_kia_eniro.h
430
car_kia_eniro.h
@@ -1,430 +0,0 @@
|
||||
|
||||
#define commandQueueCountKiaENiro 30
|
||||
#define commandQueueLoopFromKiaENiro 10
|
||||
|
||||
String commandQueueKiaENiro[commandQueueCountKiaENiro] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
//"AT AL", // Allow Long (>7 byte) messages
|
||||
//"AT AR", // Automatically receive
|
||||
//"AT H1", // Headers on (debug only)
|
||||
//"AT D1", // Display of the DLC on
|
||||
//"AT CAF0", // Automatic formatting off
|
||||
////"AT AT0", // disabled adaptive timing
|
||||
"AT DP",
|
||||
"AT ST16", // reduced timeout to 1, orig.16
|
||||
|
||||
// Loop from (KIA ENIRO)
|
||||
|
||||
// ABS / ESP + AHB
|
||||
"ATSH7D1",
|
||||
"22C101", // brake, park/drive mode
|
||||
|
||||
// IGPM
|
||||
"ATSH770",
|
||||
"22BC03", // low beam
|
||||
"22BC06", // brake light
|
||||
|
||||
// VMCU
|
||||
"ATSH7E2",
|
||||
"2101", // speed, ...
|
||||
"2102", // aux, ...
|
||||
|
||||
// BMS
|
||||
"ATSH7E4",
|
||||
"220101", // power kw, ...
|
||||
"220102", // cell voltages
|
||||
"220103", // cell voltages
|
||||
"220104", // cell voltages
|
||||
"220105", // soh, soc, ..
|
||||
"220106", // cooling water temp
|
||||
|
||||
// Aircondition
|
||||
"ATSH7B3",
|
||||
"220100", // in/out temp
|
||||
"220102", // coolant temp1, 2
|
||||
|
||||
// BCM / TPMS
|
||||
"ATSH7A0",
|
||||
"22c00b", // tire pressure/temp
|
||||
|
||||
// CLUSTER MODULE
|
||||
"ATSH7C6",
|
||||
"22B002", // odo
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
Init command queue
|
||||
*/
|
||||
bool activateCommandQueueForKiaENiro() {
|
||||
|
||||
// 39 or 64 kWh model?
|
||||
params.batModuleTempCount = 4;
|
||||
params.batteryTotalAvailableKWh = 64;
|
||||
// =(I18*0,615)*(1+(I18*0,0008)) soc to kwh niro ev 2020
|
||||
if (settings.carType == CAR_KIA_ENIRO_2020_39 || settings.carType == CAR_HYUNDAI_KONA_2020_39) {
|
||||
params.batteryTotalAvailableKWh = 39.2;
|
||||
}
|
||||
|
||||
// Empty and fill command queue
|
||||
for (int i = 0; i < 300; i++) {
|
||||
commandQueue[i] = "";
|
||||
}
|
||||
for (int i = 0; i < commandQueueCountKiaENiro; i++) {
|
||||
commandQueue[i] = commandQueueKiaENiro[i];
|
||||
}
|
||||
|
||||
commandQueueLoopFrom = commandQueueLoopFromKiaENiro;
|
||||
commandQueueCount = commandQueueCountKiaENiro;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse merged row
|
||||
*/
|
||||
bool parseRowMergedKiaENiro() {
|
||||
|
||||
bool tempByte;
|
||||
|
||||
// ABS / ESP + AHB 7D1
|
||||
if (currentAtshRequest.equals("ATSH7D1")) {
|
||||
if (commandRequest.equals("22C101")) {
|
||||
uint8_t driveMode = hexToDec(responseRowMerged.substring(22, 24).c_str(), 1, false);
|
||||
params.forwardDriveMode = (driveMode == 4);
|
||||
params.reverseDriveMode = (driveMode == 2);
|
||||
params.parkModeOrNeutral = (driveMode == 1);
|
||||
}
|
||||
}
|
||||
|
||||
// IGPM
|
||||
if (currentAtshRequest.equals("ATSH770")) {
|
||||
if (commandRequest.equals("22BC03")) {
|
||||
tempByte = hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false);
|
||||
params.ignitionOnPrevious = params.ignitionOn;
|
||||
params.ignitionOn = (bitRead(tempByte, 5) == 1);
|
||||
if (params.ignitionOnPrevious && !params.ignitionOn)
|
||||
params.automatickShutdownTimer = params.currentTime;
|
||||
|
||||
params.lightInfo = hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false);
|
||||
params.headLights = (bitRead(params.lightInfo, 5) == 1);
|
||||
params.dayLights = (bitRead(params.lightInfo, 3) == 1);
|
||||
}
|
||||
if (commandRequest.equals("22BC06")) {
|
||||
params.brakeLightInfo = hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
params.brakeLights = (bitRead(params.brakeLightInfo, 5) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VMCU 7E2
|
||||
if (currentAtshRequest.equals("ATSH7E2")) {
|
||||
if (commandRequest.equals("2101")) {
|
||||
params.speedKmh = hexToDec(responseRowMerged.substring(32, 36).c_str(), 2, false) * 0.0155; // / 100.0 *1.609 = real to gps is 1.750
|
||||
if (params.speedKmh < -99 || params.speedKmh > 200)
|
||||
params.speedKmh = 0;
|
||||
}
|
||||
if (commandRequest.equals("2102")) {
|
||||
params.auxPerc = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, false);
|
||||
params.auxCurrentAmp = - hexToDec(responseRowMerged.substring(46, 50).c_str(), 2, true) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Cluster module 7c6
|
||||
if (currentAtshRequest.equals("ATSH7C6")) {
|
||||
if (commandRequest.equals("22B002")) {
|
||||
params.odoKm = float(strtol(responseRowMerged.substring(18, 24).c_str(), 0, 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Aircon 7b3
|
||||
if (currentAtshRequest.equals("ATSH7B3")) {
|
||||
if (commandRequest.equals("220100")) {
|
||||
params.indoorTemperature = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
params.outdoorTemperature = (hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
if (commandRequest.equals("220102") && responseRowMerged.substring(12, 14) == "00") {
|
||||
params.coolantTemp1C = (hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false) / 2) - 40;
|
||||
params.coolantTemp2C = (hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false) / 2) - 40;
|
||||
}
|
||||
}
|
||||
|
||||
// BMS 7e4
|
||||
if (currentAtshRequest.equals("ATSH7E4")) {
|
||||
if (commandRequest.equals("220101")) {
|
||||
params.cumulativeEnergyChargedKWh = float(strtol(responseRowMerged.substring(82, 90).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyChargedKWhStart == -1)
|
||||
params.cumulativeEnergyChargedKWhStart = params.cumulativeEnergyChargedKWh;
|
||||
params.cumulativeEnergyDischargedKWh = float(strtol(responseRowMerged.substring(90, 98).c_str(), 0, 16)) / 10.0;
|
||||
if (params.cumulativeEnergyDischargedKWhStart == -1)
|
||||
params.cumulativeEnergyDischargedKWhStart = params.cumulativeEnergyDischargedKWh;
|
||||
params.availableChargePower = float(strtol(responseRowMerged.substring(16, 20).c_str(), 0, 16)) / 100.0;
|
||||
params.availableDischargePower = float(strtol(responseRowMerged.substring(20, 24).c_str(), 0, 16)) / 100.0;
|
||||
//params.isolationResistanceKOhm = hexToDec(responseRowMerged.substring(118, 122).c_str(), 2, true);
|
||||
params.batFanStatus = hexToDec(responseRowMerged.substring(60, 62).c_str(), 2, true);
|
||||
params.batFanFeedbackHz = hexToDec(responseRowMerged.substring(62, 64).c_str(), 2, true);
|
||||
params.auxVoltage = hexToDec(responseRowMerged.substring(64, 66).c_str(), 2, true) / 10.0;
|
||||
params.batPowerAmp = - hexToDec(responseRowMerged.substring(26, 30).c_str(), 2, true) / 10.0;
|
||||
params.batVoltage = hexToDec(responseRowMerged.substring(30, 34).c_str(), 2, false) / 10.0;
|
||||
params.batPowerKw = (params.batPowerAmp * params.batVoltage) / 1000.0;
|
||||
if (params.batPowerKw < 0) // Reset charging start time
|
||||
params.chargingStartTime = params.currentTime;
|
||||
params.batPowerKwh100 = params.batPowerKw / params.speedKmh * 100;
|
||||
params.batCellMaxV = hexToDec(responseRowMerged.substring(52, 54).c_str(), 1, false) / 50.0;
|
||||
params.batCellMinV = hexToDec(responseRowMerged.substring(56, 58).c_str(), 1, false) / 50.0;
|
||||
params.batModuleTempC[0] = hexToDec(responseRowMerged.substring(38, 40).c_str(), 1, true);
|
||||
params.batModuleTempC[1] = hexToDec(responseRowMerged.substring(40, 42).c_str(), 1, true);
|
||||
params.batModuleTempC[2] = hexToDec(responseRowMerged.substring(42, 44).c_str(), 1, true);
|
||||
params.batModuleTempC[3] = hexToDec(responseRowMerged.substring(44, 46).c_str(), 1, true);
|
||||
params.motorRpm = hexToDec(responseRowMerged.substring(112, 116).c_str(), 2, false);
|
||||
//params.batTempC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
//params.batMaxC = hexToDec(responseRowMerged.substring(34, 36).c_str(), 1, true);
|
||||
//params.batMinC = hexToDec(responseRowMerged.substring(36, 38).c_str(), 1, true);
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batMinC = params.batMaxC = params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < params.batModuleTempCount; i++) {
|
||||
if (params.batModuleTempC[i] < params.batMinC)
|
||||
params.batMinC = params.batModuleTempC[i];
|
||||
if (params.batModuleTempC[i] > params.batMaxC)
|
||||
params.batMaxC = params.batModuleTempC[i];
|
||||
}
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
params.batInletC = hexToDec(responseRowMerged.substring(50, 52).c_str(), 1, true);
|
||||
if (params.speedKmh < 10 && params.batPowerKw >= 1 && params.socPerc > 0 && params.socPerc <= 100) {
|
||||
if ( params.chargingGraphMinKw[int(params.socPerc)] < 0 || params.batPowerKw < params.chargingGraphMinKw[int(params.socPerc)])
|
||||
params.chargingGraphMinKw[int(params.socPerc)] = params.batPowerKw;
|
||||
if ( params.chargingGraphMaxKw[int(params.socPerc)] < 0 || params.batPowerKw > params.chargingGraphMaxKw[int(params.socPerc)])
|
||||
params.chargingGraphMaxKw[int(params.socPerc)] = params.batPowerKw;
|
||||
params.chargingGraphBatMinTempC[int(params.socPerc)] = params.batMinC;
|
||||
params.chargingGraphBatMaxTempC[int(params.socPerc)] = params.batMaxC;
|
||||
params.chargingGraphHeaterTempC[int(params.socPerc)] = params.batHeaterC;
|
||||
params.chargingGraphWaterCoolantTempC[int(params.socPerc)] = params.coolingWaterTempC;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220102") && responseRowMerged.substring(12, 14) == "FF") {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220103")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[32 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220104")) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
params.cellVoltage[64 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220105")) {
|
||||
params.socPercPrevious = params.socPerc;
|
||||
params.sohPerc = hexToDec(responseRowMerged.substring(56, 60).c_str(), 2, false) / 10.0;
|
||||
params.socPerc = hexToDec(responseRowMerged.substring(68, 70).c_str(), 1, false) / 2.0;
|
||||
|
||||
// Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%)
|
||||
if (params.socPercPrevious - params.socPerc > 0) {
|
||||
byte index = (int(params.socPerc) == 4) ? 0 : (int)(params.socPerc / 10) + 1;
|
||||
if ((int(params.socPerc) % 10 == 9 || int(params.socPerc) == 4) && params.soc10ced[index] == -1) {
|
||||
params.soc10ced[index] = params.cumulativeEnergyDischargedKWh;
|
||||
params.soc10cec[index] = params.cumulativeEnergyChargedKWh;
|
||||
params.soc10odo[index] = params.odoKm;
|
||||
params.soc10time[index] = params.currentTime;
|
||||
}
|
||||
}
|
||||
params.bmsUnknownTempA = hexToDec(responseRowMerged.substring(30, 32).c_str(), 1, true);
|
||||
params.batHeaterC = hexToDec(responseRowMerged.substring(52, 54).c_str(), 1, true);
|
||||
params.bmsUnknownTempB = hexToDec(responseRowMerged.substring(82, 84).c_str(), 1, true);
|
||||
//
|
||||
for (int i = 30; i < 32; i++) { // ai/aj position
|
||||
params.cellVoltage[96 - 30 + i] = hexToDec(responseRowMerged.substring(14 + (i * 2), 14 + (i * 2) + 2).c_str(), 1, false) / 50;
|
||||
}
|
||||
}
|
||||
// BMS 7e4
|
||||
if (commandRequest.equals("220106")) {
|
||||
params.coolingWaterTempC = hexToDec(responseRowMerged.substring(14, 16).c_str(), 1, false);
|
||||
params.bmsUnknownTempC = hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, true);
|
||||
params.bmsUnknownTempD = hexToDec(responseRowMerged.substring(46, 48).c_str(), 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
// TPMS 7a0
|
||||
if (currentAtshRequest.equals("ATSH7A0")) {
|
||||
if (commandRequest.equals("22c00b")) {
|
||||
params.tireFrontLeftPressureBar = hexToDec(responseRowMerged.substring(14, 16).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontRightPressureBar = hexToDec(responseRowMerged.substring(22, 24).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearRightPressureBar = hexToDec(responseRowMerged.substring(30, 32).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireRearLeftPressureBar = hexToDec(responseRowMerged.substring(38, 40).c_str(), 2, false) / 72.51886900361; // === OK Valid *0.2 / 14.503773800722
|
||||
params.tireFrontLeftTempC = hexToDec(responseRowMerged.substring(16, 18).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireFrontRightTempC = hexToDec(responseRowMerged.substring(24, 26).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearRightTempC = hexToDec(responseRowMerged.substring(32, 34).c_str(), 2, false) - 50; // === OK Valid
|
||||
params.tireRearLeftTempC = hexToDec(responseRowMerged.substring(40, 42).c_str(), 2, false) - 50; // === OK Valid
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Test data
|
||||
*/
|
||||
bool testDataKiaENiro() {
|
||||
|
||||
|
||||
// IGPM
|
||||
currentAtshRequest = "ATSH770";
|
||||
// 22BC03
|
||||
commandRequest = "22BC03";
|
||||
responseRowMerged = "62BC03FDEE7C730A600000AAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// ABS / ESP + AHB ATSH7D1
|
||||
currentAtshRequest = "ATSH7D1";
|
||||
// 2101
|
||||
commandRequest = "22C101";
|
||||
responseRowMerged = "62C1015FD7E7D0FFFF00FF04D0D400000000FF7EFF0030F5010000FFFF7F6307F207FE05FF00FF3FFFFFAAAAAAAAAAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// VMCU ATSH7E2
|
||||
currentAtshRequest = "ATSH7E2";
|
||||
// 2101
|
||||
commandRequest = "2101";
|
||||
responseRowMerged = "6101FFF8000009285A3B0648030000B4179D763404080805000000";
|
||||
parseRowMergedKiaENiro();
|
||||
// 2102
|
||||
commandRequest = "2102";
|
||||
responseRowMerged = "6102F8FFFC000101000000840FBF83BD33270680953033757F59291C76000001010100000007000000";
|
||||
responseRowMerged = "6102F8FFFC000101000000931CC77F4C39040BE09BA7385D8158832175000001010100000007000000";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// "ATSH7DF",
|
||||
currentAtshRequest = "ATSH7DF";
|
||||
// 2106
|
||||
commandRequest = "2106";
|
||||
responseRowMerged = "6106FFFF800000000000000200001B001C001C000600060006000E000000010000000000000000013D013D013E013E00";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// AIRCON / ACU ATSH7B3
|
||||
currentAtshRequest = "ATSH7B3";
|
||||
// 220100
|
||||
commandRequest = "220100";
|
||||
responseRowMerged = "6201007E5027C8FF7F765D05B95AFFFF5AFF11FFFFFFFFFFFF6AFFFF2DF0757630FFFF00FFFF000000";
|
||||
responseRowMerged = "6201007E5027C8FF867C58121010FFFF10FF8EFFFFFFFFFFFF10FFFF0DF0617900FFFF01FFFF000000";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// BMS ATSH7E4
|
||||
currentAtshRequest = "ATSH7E4";
|
||||
// 220101
|
||||
commandRequest = "220101";
|
||||
responseRowMerged = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
|
||||
responseRowMerged = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
|
||||
parseRowMergedKiaENiro();
|
||||
// 220102
|
||||
commandRequest = "220102";
|
||||
responseRowMerged = "620102FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
// 220103
|
||||
commandRequest = "220103";
|
||||
responseRowMerged = "620103FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCACBCACACFCCCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
// 220104
|
||||
commandRequest = "220104";
|
||||
responseRowMerged = "620104FFFFFFFFCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBAAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
// 220105
|
||||
commandRequest = "220105";
|
||||
responseRowMerged = "620105003fff9000000000000000000F8A86012B4946500101500DAC03E800000000AC0000C7C701000F00000000AAAA";
|
||||
responseRowMerged = "620105003FFF90000000000000000014918E012927465000015013BB03E800000000BB0000CBCB01001300000000AAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
// 220106
|
||||
commandRequest = "220106";
|
||||
responseRowMerged = "620106FFFFFFFF14001A00240000003A7C86B4B30000000928EA00";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// BCM / TPMS ATSH7A0
|
||||
currentAtshRequest = "ATSH7A0";
|
||||
// 22c00b
|
||||
commandRequest = "22c00b";
|
||||
responseRowMerged = "62C00BFFFF0000B93D0100B43E0100B43D0100BB3C0100AAAAAAAA";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
// ATSH7C6
|
||||
currentAtshRequest = "ATSH7C6";
|
||||
// 22b002
|
||||
commandRequest = "22b002";
|
||||
responseRowMerged = "62B002E0000000FFB400330B0000000000000000";
|
||||
parseRowMergedKiaENiro();
|
||||
|
||||
params.batModuleTempC[0] = 28;
|
||||
params.batModuleTempC[1] = 29;
|
||||
params.batModuleTempC[2] = 28;
|
||||
params.batModuleTempC[3] = 30;
|
||||
|
||||
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
|
||||
params.batMinC = params.batMaxC = params.batModuleTempC[0];
|
||||
for (uint16_t i = 1; i < params.batModuleTempCount; i++) {
|
||||
if (params.batModuleTempC[i] < params.batMinC)
|
||||
params.batMinC = params.batModuleTempC[i];
|
||||
if (params.batModuleTempC[i] > params.batMaxC)
|
||||
params.batMaxC = params.batModuleTempC[i];
|
||||
}
|
||||
params.batTempC = params.batMinC;
|
||||
|
||||
|
||||
//
|
||||
params.soc10ced[10] = 2200;
|
||||
params.soc10cec[10] = 2500;
|
||||
params.soc10odo[10] = 13000;
|
||||
params.soc10time[10] = 13000;
|
||||
params.soc10ced[9] = params.soc10ced[10] + 6.4;
|
||||
params.soc10cec[9] = params.soc10cec[10] + 0;
|
||||
params.soc10odo[9] = params.soc10odo[10] + 30;
|
||||
params.soc10time[9] = params.soc10time[10] + 900;
|
||||
params.soc10ced[8] = params.soc10ced[9] + 6.8;
|
||||
params.soc10cec[8] = params.soc10cec[9] + 0;
|
||||
params.soc10odo[8] = params.soc10odo[9] + 30;
|
||||
params.soc10time[8] = params.soc10time[9] + 900;
|
||||
params.soc10ced[7] = params.soc10ced[8] + 7.2;
|
||||
params.soc10cec[7] = params.soc10cec[8] + 0.6;
|
||||
params.soc10odo[7] = params.soc10odo[8] + 30;
|
||||
params.soc10time[7] = params.soc10time[8] + 900;
|
||||
params.soc10ced[6] = params.soc10ced[7] + 6.7;
|
||||
params.soc10cec[6] = params.soc10cec[7] + 0;
|
||||
params.soc10odo[6] = params.soc10odo[7] + 30;
|
||||
params.soc10time[6] = params.soc10time[7] + 900;
|
||||
params.soc10ced[5] = params.soc10ced[6] + 6.7;
|
||||
params.soc10cec[5] = params.soc10cec[6] + 0;
|
||||
params.soc10odo[5] = params.soc10odo[6] + 30;
|
||||
params.soc10time[5] = params.soc10time[6] + 900;
|
||||
params.soc10ced[4] = params.soc10ced[5] + 6.4;
|
||||
params.soc10cec[4] = params.soc10cec[5] + 0.3;
|
||||
params.soc10odo[4] = params.soc10odo[5] + 30;
|
||||
params.soc10time[4] = params.soc10time[5] + 900;
|
||||
params.soc10ced[3] = params.soc10ced[4] + 6.4;
|
||||
params.soc10cec[3] = params.soc10cec[4] + 0;
|
||||
params.soc10odo[3] = params.soc10odo[4] + 30;
|
||||
params.soc10time[3] = params.soc10time[4] + 900;
|
||||
params.soc10ced[2] = params.soc10ced[3] + 5.4;
|
||||
params.soc10cec[2] = params.soc10cec[3] + 0.1;
|
||||
params.soc10odo[2] = params.soc10odo[3] + 30;
|
||||
params.soc10time[2] = params.soc10time[3] + 900;
|
||||
params.soc10ced[1] = params.soc10ced[2] + 6.2;
|
||||
params.soc10cec[1] = params.soc10cec[2] + 0.1;
|
||||
params.soc10odo[1] = params.soc10odo[2] + 30;
|
||||
params.soc10time[1] = params.soc10time[2] + 900;
|
||||
params.soc10ced[0] = params.soc10ced[1] + 2.9;
|
||||
params.soc10cec[0] = params.soc10cec[1] + 0.5;
|
||||
params.soc10odo[0] = params.soc10odo[1] + 15;
|
||||
params.soc10time[0] = params.soc10time[1] + 900;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
|
||||
#define commandQueueCountRenaultZoe 10
|
||||
#define commandQueueLoopFromRenaultZoe 8
|
||||
|
||||
String commandQueueRenaultZoe[commandQueueCountRenaultZoe] = {
|
||||
"AT Z", // Reset all
|
||||
"AT I", // Print the version ID
|
||||
"AT E0", // Echo off
|
||||
"AT L0", // Linefeeds off
|
||||
"AT S0", // Printing of spaces on
|
||||
"AT SP 6", // Select protocol to ISO 15765-4 CAN (11 bit ID, 500 kbit/s)
|
||||
//"AT AL", // Allow Long (>7 byte) messages
|
||||
//"AT AR", // Automatically receive
|
||||
//"AT H1", // Headers on (debug only)
|
||||
//"AT D1", // Display of the DLC on
|
||||
//"AT CAF0", // Automatic formatting off
|
||||
"AT DP",
|
||||
"AT ST16",
|
||||
|
||||
// Loop from (KIA ENIRO) // TODO
|
||||
// BMS
|
||||
"ATSH7E4",
|
||||
"220101", // power kw, ...
|
||||
};
|
||||
|
||||
/**
|
||||
Init command queue
|
||||
*/
|
||||
bool activateCommandQueueForRenaultZoe() {
|
||||
|
||||
params.batModuleTempCount = 4;
|
||||
params.batteryTotalAvailableKWh = 22;
|
||||
|
||||
// Empty and fill command queue
|
||||
for (int i = 0; i < 300; i++) {
|
||||
commandQueue[i] = "";
|
||||
}
|
||||
for (int i = 0; i < commandQueueCountRenaultZoe; i++) {
|
||||
commandQueue[i] = commandQueueRenaultZoe[i];
|
||||
}
|
||||
|
||||
commandQueueLoopFrom = commandQueueLoopFromRenaultZoe;
|
||||
commandQueueCount = commandQueueCountRenaultZoe;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse merged row
|
||||
*/
|
||||
bool parseRowMergedRenaultZoe() {
|
||||
|
||||
// TODO
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Test data
|
||||
*/
|
||||
bool testDataRenaultZoe() {
|
||||
|
||||
// TODO
|
||||
|
||||
return true;
|
||||
}
|
||||
115
config.h
115
config.h
@@ -1,92 +1,10 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// SELECT HARDWARE !!!!
|
||||
////////////////////////////////////////////////////////////
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define BOARD_TTGO_T4
|
||||
//#define BOARD_M5STACK_CORE
|
||||
#include <BLEDevice.h>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#define USER_SETUP_LOADED 1
|
||||
#define SPI_FREQUENCY 27000000
|
||||
//#define SPI_READ_FREQUENCY 20000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// BOARD LILYGO TTGO T4 v1.3
|
||||
/////////////////////////////////////////////////////////////
|
||||
#ifdef BOARD_TTGO_T4
|
||||
|
||||
#define ILI9341_DRIVER
|
||||
#define TFT_MISO 12
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 27
|
||||
#define TFT_DC 32
|
||||
#define TFT_RST 5
|
||||
//#define TFT_BACKLIGHT_ON HIGH
|
||||
#define TFT_BL 4
|
||||
|
||||
#define USE_HSPI_PORT
|
||||
//#define SPI_FREQUENCY 40000000 // Maximum for ILI9341
|
||||
#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V
|
||||
|
||||
#define SD_CS 13
|
||||
#define SD_MOSI 15
|
||||
#define SD_MISO 2
|
||||
#define SD_SCLK 14
|
||||
|
||||
#define BUTTON_LEFT 38
|
||||
#define BUTTON_MIDDLE 37
|
||||
#define BUTTON_RIGHT 39
|
||||
|
||||
#endif // BOARD_TTGO_T4
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// BOARD M5STACK CORE IOT (M5-K001)
|
||||
/////////////////////////////////////////////////////////////
|
||||
#ifdef BOARD_M5STACK_CORE
|
||||
|
||||
#define USER_SETUP_LOADED 1
|
||||
#define ILI9341_DRIVER
|
||||
#define M5STACK
|
||||
#define TFT_MISO 19
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 14 // Chip select control pin
|
||||
#define TFT_DC 27 // Data Command control pin
|
||||
#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
#define TFT_BL 32 // LED back-light
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_READ_FREQUENCY 5000000
|
||||
#define SPEAKER_PIN 25
|
||||
#define INVERT_DISPLAY
|
||||
|
||||
#define BUTTON_LEFT 37
|
||||
#define BUTTON_MIDDLE 38
|
||||
#define BUTTON_RIGHT 39
|
||||
|
||||
#define SD_CS 4
|
||||
#define SD_MOSI 23
|
||||
#define SD_MISO 19
|
||||
#define SD_SCLK 18
|
||||
|
||||
#endif // BOARD_M5STACK_CORE
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
// TFT COMMON
|
||||
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
|
||||
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
|
||||
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
|
||||
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
|
||||
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
|
||||
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
|
||||
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||
#define SMOOTH_FONT
|
||||
#define GFXFF 1 // TFT FOnts
|
||||
#define APP_VERSION "v2.0.0"
|
||||
#define APP_RELEASE_DATE "2020-12-02"
|
||||
|
||||
// TFT COLORS FOR TTGO
|
||||
#define TFT_BLACK 0x0000 /* 0, 0, 0 */
|
||||
@@ -126,3 +44,26 @@
|
||||
#define TFT_GRAPH_COLDGATE15_24 0x0008
|
||||
#define TFT_GRAPH_OPTIMAL25 0x0200
|
||||
#define TFT_GRAPH_RAPIDGATE35 0x8300
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// SIM800L
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
#define SIM800L_RX 16
|
||||
#define SIM800L_TX 17
|
||||
#define SIM800L_RST 5
|
||||
#define SIM800L_TIMER 120
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
// MENU ITEM
|
||||
typedef struct {
|
||||
int16_t id;
|
||||
int16_t parentId;
|
||||
int16_t targetParentId;
|
||||
char title[50];
|
||||
char obdMacAddress[20];
|
||||
char serviceUUID[40];
|
||||
} MENU_ITEM;
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
||||
BIN
dist/m5stack_core1/evDash.ino.bin
vendored
Normal file
BIN
dist/m5stack_core1/evDash.ino.bin
vendored
Normal file
Binary file not shown.
BIN
dist/ttgo_t4_v13/evDash.ino.bin
vendored
Normal file
BIN
dist/ttgo_t4_v13/evDash.ino.bin
vendored
Normal file
Binary file not shown.
668
evDash.ino
Normal file
668
evDash.ino
Normal file
@@ -0,0 +1,668 @@
|
||||
/*
|
||||
* 2020-12-02
|
||||
* Project renamed from eNiroDashboard to evDash
|
||||
*
|
||||
!! working only with OBD BLE 4.0 adapters
|
||||
!! Supported adapter is Vgate ICar Pro (must be BLE4.0 version)
|
||||
!! Not working with standard BLUETOOTH 3 adapters
|
||||
|
||||
Required libraries
|
||||
- esp32 board support
|
||||
- tft_espi
|
||||
- ArduinoJson
|
||||
|
||||
SIM800L m5stack (https://github.com/kolaCZek)
|
||||
- SIM800L.h, SoftwareSerial.h
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// SELECT HARDWARE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Boards
|
||||
#define BOARD_TTGO_T4
|
||||
//#define BOARD_M5STACK_CORE
|
||||
|
||||
//#define SIM800L_ENABLED
|
||||
//#define SD_ENABLED
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#include <SPI.h>
|
||||
#include <BLEDevice.h>
|
||||
#include "BoardInterface.h"
|
||||
|
||||
#ifdef BOARD_TTGO_T4
|
||||
#include "BoardTtgoT4v13.h"
|
||||
#endif // BOARD_TTGO_T4
|
||||
#ifdef BOARD_M5STACK_CORE
|
||||
#include "BoardM5stackCore.h"
|
||||
#endif // BOARD_M5STACK_CORE
|
||||
|
||||
#ifdef SD_ENABLED
|
||||
#include <mySD.h>
|
||||
//#include <SD.h>
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "config.h"
|
||||
#include "LiveData.h"
|
||||
#include "CarInterface.h"
|
||||
#include "CarKiaEniro.h"
|
||||
#include "CarHyundaiIoniq.h"
|
||||
#include "CarKiaDebugObd2.h"
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
#include <ArduinoJson.h>
|
||||
#include <SoftwareSerial.h>
|
||||
#include "SIM800L.h"
|
||||
|
||||
SIM800L* sim800l;
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
// PLEASE CHANGE THIS SETTING for your BLE4
|
||||
uint32_t PIN = 1234;
|
||||
|
||||
// Temporary variables
|
||||
char ch;
|
||||
String line;
|
||||
|
||||
// Board, Car, Livedata (params, settings)
|
||||
BoardInterface* board;
|
||||
CarInterface* car;
|
||||
LiveData* liveData;
|
||||
|
||||
/**
|
||||
Do next AT command from queue
|
||||
*/
|
||||
bool doNextAtCommand() {
|
||||
|
||||
// Restart loop with AT commands
|
||||
if (liveData->commandQueueIndex >= liveData->commandQueueCount) {
|
||||
liveData->commandQueueIndex = liveData->commandQueueLoopFrom;
|
||||
board->redrawScreen();
|
||||
}
|
||||
|
||||
// Send AT command to obd
|
||||
liveData->commandRequest = liveData->commandQueue[liveData->commandQueueIndex];
|
||||
if (liveData->commandRequest.startsWith("ATSH")) {
|
||||
liveData->currentAtshRequest = liveData->commandRequest;
|
||||
}
|
||||
|
||||
Serial.print(">>> ");
|
||||
Serial.println(liveData->commandRequest);
|
||||
String tmpStr = liveData->commandRequest + "\r";
|
||||
liveData->pRemoteCharacteristicWrite->writeValue(tmpStr.c_str(), tmpStr.length());
|
||||
liveData->commandQueueIndex++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse result from OBD, create single line liveData->responseRowMerged
|
||||
*/
|
||||
bool parseRow() {
|
||||
|
||||
// Simple 1 line responses
|
||||
Serial.print("");
|
||||
Serial.println(liveData->responseRow);
|
||||
|
||||
// Merge 0:xxxx 1:yyyy 2:zzzz to single xxxxyyyyzzzz string
|
||||
if (liveData->responseRow.length() >= 2 && liveData->responseRow.charAt(1) == ':') {
|
||||
if (liveData->responseRow.charAt(0) == '0') {
|
||||
liveData->responseRowMerged = "";
|
||||
}
|
||||
liveData->responseRowMerged += liveData->responseRow.substring(2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse merged row (after merge completed)
|
||||
*/
|
||||
bool parseRowMerged() {
|
||||
|
||||
Serial.print("merged:");
|
||||
Serial.println(liveData->responseRowMerged);
|
||||
|
||||
// Catch output for debug screen
|
||||
if (board->displayScreen == SCREEN_DEBUG) {
|
||||
if (board->debugCommandIndex == liveData->commandQueueIndex) {
|
||||
board->debugAtshRequest = liveData->currentAtshRequest;
|
||||
board->debugCommandRequest = liveData->commandRequest;
|
||||
board->debugLastString = liveData->responseRowMerged;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse by selected car interface
|
||||
car->parseRowMerged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
BLE callbacks
|
||||
*/
|
||||
class MyClientCallback : public BLEClientCallbacks {
|
||||
|
||||
/**
|
||||
On BLE connect
|
||||
*/
|
||||
void onConnect(BLEClient* pclient) {
|
||||
Serial.println("onConnect");
|
||||
}
|
||||
|
||||
/**
|
||||
On BLE disconnect
|
||||
*/
|
||||
void onDisconnect(BLEClient* pclient) {
|
||||
//connected = false;
|
||||
Serial.println("onDisconnect");
|
||||
board->displayMessage("BLE disconnected", "");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Scan for BLE servers and find the first one that advertises the service we are looking for.
|
||||
*/
|
||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||
|
||||
/**
|
||||
Called for each advertising BLE server.
|
||||
*/
|
||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||
|
||||
Serial.print("BLE advertised device found: ");
|
||||
Serial.println(advertisedDevice.toString().c_str());
|
||||
Serial.println(advertisedDevice.getAddress().toString().c_str());
|
||||
|
||||
// Add to device list (max. 9 devices allowed yet)
|
||||
String tmpStr;
|
||||
|
||||
if (liveData->scanningDeviceIndex < 10/* && advertisedDevice.haveServiceUUID()*/) {
|
||||
for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) {
|
||||
if (liveData->menuItems[i].id == 10001 + liveData->scanningDeviceIndex) {
|
||||
tmpStr = advertisedDevice.toString().c_str();
|
||||
tmpStr.replace("Name: ", "");
|
||||
tmpStr.replace("Address: ", "");
|
||||
tmpStr.toCharArray(liveData->menuItems[i].title, 48);
|
||||
tmpStr = advertisedDevice.getAddress().toString().c_str();
|
||||
tmpStr.toCharArray(liveData->menuItems[i].obdMacAddress, 18);
|
||||
}
|
||||
}
|
||||
liveData->scanningDeviceIndex++;
|
||||
}
|
||||
/*
|
||||
if (advertisedDevice.getServiceDataUUID().toString() != "<NULL>") {
|
||||
Serial.print("ServiceDataUUID: ");
|
||||
Serial.println(advertisedDevice.getServiceDataUUID().toString().c_str());
|
||||
if (advertisedDevice.getServiceUUID().toString() != "<NULL>") {
|
||||
Serial.print("ServiceUUID: ");
|
||||
Serial.println(advertisedDevice.getServiceUUID().toString().c_str());
|
||||
}
|
||||
}*/
|
||||
|
||||
if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(BLEUUID(liveData->settings.serviceUUID)) &&
|
||||
(strcmp(advertisedDevice.getAddress().toString().c_str(), liveData->settings.obdMacAddress) == 0)) {
|
||||
Serial.println("Stop scanning. Found my BLE device.");
|
||||
BLEDevice::getScan()->stop();
|
||||
liveData->foundMyBleDevice = new BLEAdvertisedDevice(advertisedDevice);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
BLE Security
|
||||
*/
|
||||
class MySecurity : public BLESecurityCallbacks {
|
||||
|
||||
uint32_t onPassKeyRequest() {
|
||||
Serial.printf("Pairing password: %d \r\n", PIN);
|
||||
return PIN;
|
||||
}
|
||||
|
||||
void onPassKeyNotify(uint32_t pass_key) {
|
||||
Serial.printf("onPassKeyNotify\r\n");
|
||||
}
|
||||
|
||||
bool onConfirmPIN(uint32_t pass_key) {
|
||||
Serial.printf("onConfirmPIN\r\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool onSecurityRequest() {
|
||||
Serial.printf("onSecurityRequest\r\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void onAuthenticationComplete(esp_ble_auth_cmpl_t auth_cmpl) {
|
||||
if (auth_cmpl.success) {
|
||||
Serial.printf("onAuthenticationComplete\r\n");
|
||||
} else {
|
||||
Serial.println("Auth failure. Incorrect PIN?");
|
||||
liveData->bleConnect = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Ble notification callback
|
||||
*/
|
||||
static void notifyCallback (BLERemoteCharacteristic * pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) {
|
||||
|
||||
char ch;
|
||||
|
||||
// Parse multi line response to single lines
|
||||
liveData->responseRow = "";
|
||||
for (int i = 0; i <= length; i++) {
|
||||
ch = pData[i];
|
||||
if (ch == '\r' || ch == '\n' || ch == '\0') {
|
||||
if (liveData->responseRow != "")
|
||||
parseRow();
|
||||
liveData->responseRow = "";
|
||||
} else {
|
||||
liveData->responseRow += ch;
|
||||
if (liveData->responseRow == ">") {
|
||||
if (liveData->responseRowMerged != "") {
|
||||
parseRowMerged();
|
||||
}
|
||||
liveData->responseRowMerged = "";
|
||||
liveData->canSendNextAtCommand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Do connect BLE with server (OBD device)
|
||||
*/
|
||||
bool connectToServer(BLEAddress pAddress) {
|
||||
|
||||
board->displayMessage(" > Connecting device", "");
|
||||
|
||||
Serial.print("liveData->bleConnect ");
|
||||
Serial.println(pAddress.toString().c_str());
|
||||
board->displayMessage(" > Connecting device - init", pAddress.toString().c_str());
|
||||
|
||||
BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT);
|
||||
BLEDevice::setSecurityCallbacks(new MySecurity());
|
||||
|
||||
BLESecurity *pSecurity = new BLESecurity();
|
||||
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND); //
|
||||
pSecurity->setCapability(ESP_IO_CAP_KBDISP);
|
||||
pSecurity->setRespEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
|
||||
|
||||
board->displayMessage(" > Connecting device", pAddress.toString().c_str());
|
||||
liveData->pClient = BLEDevice::createClient();
|
||||
liveData->pClient->setClientCallbacks(new MyClientCallback());
|
||||
if (liveData->pClient->connect(pAddress, BLE_ADDR_TYPE_RANDOM) ) Serial.println("liveData->bleConnected");
|
||||
Serial.println(" - liveData->bleConnected to server");
|
||||
|
||||
// Remote service
|
||||
board->displayMessage(" > Connecting device", "Connecting service...");
|
||||
BLERemoteService* pRemoteService = liveData->pClient->getService(BLEUUID(liveData->settings.serviceUUID));
|
||||
if (pRemoteService == nullptr)
|
||||
{
|
||||
Serial.print("Failed to find our service UUID: ");
|
||||
Serial.println(liveData->settings.serviceUUID);
|
||||
board->displayMessage(" > Connecting device", "Unable to find service");
|
||||
return false;
|
||||
}
|
||||
Serial.println(" - Found our service");
|
||||
|
||||
// Get characteristics
|
||||
board->displayMessage(" > Connecting device", "Connecting TxUUID...");
|
||||
liveData->pRemoteCharacteristic = pRemoteService->getCharacteristic(BLEUUID(liveData->settings.charTxUUID));
|
||||
if (liveData->pRemoteCharacteristic == nullptr) {
|
||||
Serial.print("Failed to find our characteristic UUID: ");
|
||||
Serial.println(liveData->settings.charTxUUID);//.toString().c_str());
|
||||
board->displayMessage(" > Connecting device", "Unable to find TxUUID");
|
||||
return false;
|
||||
}
|
||||
Serial.println(" - Found our characteristic");
|
||||
|
||||
// Get characteristics
|
||||
board->displayMessage(" > Connecting device", "Connecting RxUUID...");
|
||||
liveData->pRemoteCharacteristicWrite = pRemoteService->getCharacteristic(BLEUUID(liveData->settings.charRxUUID));
|
||||
if (liveData->pRemoteCharacteristicWrite == nullptr) {
|
||||
Serial.print("Failed to find our characteristic UUID: ");
|
||||
Serial.println(liveData->settings.charRxUUID);//.toString().c_str());
|
||||
board->displayMessage(" > Connecting device", "Unable to find RxUUID");
|
||||
return false;
|
||||
}
|
||||
Serial.println(" - Found our characteristic write");
|
||||
|
||||
board->displayMessage(" > Connecting device", "Register callbacks...");
|
||||
// Read the value of the characteristic.
|
||||
if (liveData->pRemoteCharacteristic->canNotify()) {
|
||||
Serial.println(" - canNotify");
|
||||
//liveData->pRemoteCharacteristic->registerForNotify(notifyCallback);
|
||||
if (liveData->pRemoteCharacteristic->canIndicate()) {
|
||||
Serial.println(" - canIndicate");
|
||||
const uint8_t indicationOn[] = {0x2, 0x0};
|
||||
//const uint8_t indicationOff[] = {0x0,0x0};
|
||||
liveData->pRemoteCharacteristic->getDescriptor(BLEUUID((uint16_t)0x2902))->writeValue((uint8_t*)indicationOn, 2, true);
|
||||
//liveData->pRemoteCharacteristic->getDescriptor(BLEUUID((uint16_t)0x2902))->writeValue((uint8_t*)notifyOff,2,true);
|
||||
liveData->pRemoteCharacteristic->registerForNotify(notifyCallback, false);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
board->displayMessage(" > Connecting device", "Done...");
|
||||
if (liveData->pRemoteCharacteristicWrite->canWrite()) {
|
||||
Serial.println(" - canWrite");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Start ble scan
|
||||
*/
|
||||
void startBleScan() {
|
||||
|
||||
liveData->foundMyBleDevice = NULL;
|
||||
liveData->scanningDeviceIndex = 0;
|
||||
board->displayMessage(" > Scanning BLE4 devices", "40 seconds");
|
||||
|
||||
// Start scanning
|
||||
Serial.println("Scanning BLE devices...");
|
||||
Serial.print("Looking for ");
|
||||
Serial.println(liveData->settings.obdMacAddress);
|
||||
BLEScanResults foundDevices = liveData->pBLEScan->start(40, false);
|
||||
Serial.print("Devices found: ");
|
||||
Serial.println(foundDevices.getCount());
|
||||
Serial.println("Scan done!");
|
||||
liveData->pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
|
||||
|
||||
char tmpStr1[20];
|
||||
sprintf(tmpStr1, "Found %d devices", foundDevices.getCount());
|
||||
board->displayMessage(" > Scanning BLE4 devices", tmpStr1);
|
||||
|
||||
// Scan devices from menu, show list of devices
|
||||
if (liveData->menuItemSelected == 2) {
|
||||
Serial.println("Display menu with devices");
|
||||
liveData->menuVisible = true;
|
||||
liveData->menuCurrent = 9999;
|
||||
liveData->menuItemSelected = 0;
|
||||
board->showMenu();
|
||||
} else {
|
||||
// Redraw screen
|
||||
if (liveData->foundMyBleDevice == NULL) {
|
||||
board->displayMessage("Device not found", "Middle button - menu");
|
||||
} else {
|
||||
board->redrawScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
SIM800L
|
||||
*/
|
||||
#ifdef SIM800L_ENABLED
|
||||
bool sim800lSetup() {
|
||||
Serial.println("Setting SIM800L module");
|
||||
SoftwareSerial* serial = new SoftwareSerial(SIM800L_RX, SIM800L_TX);
|
||||
serial->begin(9600);
|
||||
sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512);
|
||||
|
||||
bool sim800l_ready = sim800l->isReady();
|
||||
for (uint8_t i = 0; i < 5 && !sim800l_ready; i++) {
|
||||
Serial.println("Problem to initialize SIM800L module, retry in 1 sec");
|
||||
delay(1000);
|
||||
sim800l_ready = sim800l->isReady();
|
||||
}
|
||||
|
||||
if(!sim800l_ready) {
|
||||
Serial.println("Problem to initialize SIM800L module");
|
||||
} else {
|
||||
Serial.println("SIM800L module initialized");
|
||||
|
||||
Serial.print("Setting GPRS APN to: ");
|
||||
Serial.println(liveData->settings.gprsApn);
|
||||
|
||||
bool sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||
for(uint8_t i = 0; i < 5 && !sim800l_gprs; i++) {
|
||||
Serial.println("Problem to set GPRS connection, retry in 1 sec");
|
||||
delay(1000);
|
||||
sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||
}
|
||||
|
||||
if(sim800l_gprs) {
|
||||
liveData->params.sim800l_enabled = true;
|
||||
Serial.println("GPRS OK");
|
||||
} else {
|
||||
Serial.println("Problem to set GPRS");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sendDataViaGPRS() {
|
||||
Serial.println("Sending data via GPRS");
|
||||
|
||||
NetworkRegistration network = sim800l->getRegistrationStatus();
|
||||
if (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
|
||||
Serial.println("SIM800L module not connected to network!");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool connected = sim800l->connectGPRS();
|
||||
for (uint8_t i = 0; i < 5 && !connected; i++) {
|
||||
delay(1000);
|
||||
connected = sim800l->connectGPRS();
|
||||
}
|
||||
|
||||
if (!connected) {
|
||||
Serial.println("GPRS not connected! Reseting SIM800L module!");
|
||||
sim800l->reset();
|
||||
sim800lSetup();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Serial.println("Start HTTP POST...");
|
||||
|
||||
StaticJsonDocument<250> jsonData;
|
||||
|
||||
jsonData["akey"] = liveData->settings.remoteApiKey;
|
||||
jsonData["soc"] = liveData->params.socPerc;
|
||||
jsonData["soh"] = liveData->params.sohPerc;
|
||||
jsonData["batK"] = liveData->params.batPowerKw;
|
||||
jsonData["batA"] = liveData->params.batPowerAmp;
|
||||
jsonData["batV"] = liveData->params.batVoltage;
|
||||
jsonData["auxV"] = liveData->params.auxVoltage;
|
||||
jsonData["MinC"] = liveData->params.batMinC;
|
||||
jsonData["MaxC"] = liveData->params.batMaxC;
|
||||
jsonData["InlC"] = liveData->params.batInletC;
|
||||
jsonData["fan"] = liveData->params.batFanStatus;
|
||||
jsonData["cumCh"] = liveData->params.cumulativeEnergyChargedKWh;
|
||||
jsonData["cumD"] = liveData->params.cumulativeEnergyDischargedKWh;
|
||||
|
||||
char payload[200];
|
||||
serializeJson(jsonData, payload);
|
||||
|
||||
Serial.print("Sending payload: ");
|
||||
Serial.println(payload);
|
||||
|
||||
Serial.print("Remote API server: ");
|
||||
Serial.println(liveData->settings.remoteApiSrvr);
|
||||
|
||||
uint16_t rc = sim800l->doPost(liveData->settings.remoteApiSrvr, "application/json", payload, 10000, 10000);
|
||||
if(rc == 200) {
|
||||
Serial.println(F("HTTP POST successful"));
|
||||
} else {
|
||||
// Failed...
|
||||
Serial.print(F("HTTP POST error: "));
|
||||
Serial.println(rc);
|
||||
}
|
||||
|
||||
sim800l->disconnectGPRS();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
/**
|
||||
Setup device
|
||||
*/
|
||||
void setup(void) {
|
||||
|
||||
// Serial console, init structures
|
||||
Serial.begin(115200);
|
||||
Serial.println("");
|
||||
Serial.println("Booting device...");
|
||||
|
||||
// Init settings/params, board library
|
||||
liveData = new LiveData();
|
||||
liveData->initParams();
|
||||
|
||||
#ifdef BOARD_TTGO_T4
|
||||
board = new BoardTtgoT4v13();
|
||||
#endif // BOARD_TTGO_T4
|
||||
#ifdef BOARD_M5STACK_CORE
|
||||
board = new BoardM5stackCore();
|
||||
#endif // BOARD_M5STACK_CORE
|
||||
board->setLiveData(liveData);
|
||||
board->loadSettings();
|
||||
board->initBoard();
|
||||
|
||||
// Car interface
|
||||
if (liveData->settings.carType == CAR_KIA_ENIRO_2020_64 || liveData->settings.carType == CAR_HYUNDAI_KONA_2020_64 ||
|
||||
liveData->settings.carType == CAR_KIA_ENIRO_2020_39 || liveData->settings.carType == CAR_HYUNDAI_KONA_2020_39) {
|
||||
car = new CarKiaEniro();
|
||||
} else if (liveData->settings.carType == CAR_HYUNDAI_IONIQ_2018) {
|
||||
car = new CarHyundaiIoniq();
|
||||
} else {
|
||||
// if (liveData->settings.carType == CAR_DEBUG_OBD2_KIA)
|
||||
car = new CarKiaDebugObd2();
|
||||
}
|
||||
car->setLiveData(liveData);
|
||||
car->activateCommandQueue();
|
||||
board->attachCar(car);
|
||||
board->debugCommandIndex = liveData->commandQueueLoopFrom;
|
||||
|
||||
// Redraw screen
|
||||
board->redrawScreen();
|
||||
|
||||
// Init time library
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 1589011873;
|
||||
settimeofday(&tv, NULL);
|
||||
struct tm now;
|
||||
getLocalTime(&now, 0);
|
||||
liveData->params.chargingStartTime = liveData->params.currentTime = mktime(&now);
|
||||
|
||||
// Hold right button
|
||||
board->afterSetup();
|
||||
|
||||
#ifdef SD_ENABLED
|
||||
// Init SDCARD
|
||||
/*if (!SD.begin(SD_CS, SD_MOSI, SD_MISO, SD_SCLK)) {
|
||||
Serial.println("SDCARD initialization failed!");
|
||||
} else {
|
||||
Serial.println("SDCARD initialization done.");
|
||||
}
|
||||
/*spiSD.begin(SD_SCLK,SD_MISO,SD_MOSI,SD_CS);
|
||||
if(!SD.begin( SD_CS, spiSD, 27000000)){
|
||||
Serial.println("SDCARD initialization failed!");
|
||||
} else {
|
||||
Serial.println("SDCARD initialization done.");
|
||||
}*/
|
||||
#endif
|
||||
|
||||
// Start BLE connection
|
||||
line = "";
|
||||
Serial.println("Start BLE with PIN auth");
|
||||
BLEDevice::init("");
|
||||
|
||||
// Retrieve a Scanner and set the callback we want to use to be informed when we have detected a new device.
|
||||
// Specify that we want active scanning and start the scan to run for 10 seconds.
|
||||
Serial.println("Setup BLE scan");
|
||||
liveData->pBLEScan = BLEDevice::getScan();
|
||||
liveData->pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||
liveData->pBLEScan->setInterval(1349);
|
||||
liveData->pBLEScan->setWindow(449);
|
||||
liveData->pBLEScan->setActiveScan(true);
|
||||
|
||||
// Skip BLE scan if middle button pressed
|
||||
if (!board->skipAdapterScan()) {
|
||||
startBleScan();
|
||||
}
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
sim800lSetup();
|
||||
#endif //SIM800L_ENABLED
|
||||
|
||||
// End
|
||||
Serial.println("Device setup completed");
|
||||
}
|
||||
|
||||
/**
|
||||
Loop
|
||||
*/
|
||||
void loop() {
|
||||
|
||||
// Connect BLE device
|
||||
if (liveData->bleConnect == true && liveData->foundMyBleDevice != NULL) {
|
||||
liveData->pServerAddress = new BLEAddress(liveData->settings.obdMacAddress);
|
||||
if (connectToServer(*liveData->pServerAddress)) {
|
||||
|
||||
liveData->bleConnected = true;
|
||||
liveData->bleConnect = false;
|
||||
|
||||
Serial.println("We are now connected to the BLE device.");
|
||||
|
||||
// Print message
|
||||
board->displayMessage(" > Processing init AT cmds", "");
|
||||
|
||||
// Serve first command (ATZ)
|
||||
doNextAtCommand();
|
||||
} else {
|
||||
Serial.println("We have failed to connect to the server; there is nothing more we will do.");
|
||||
}
|
||||
}
|
||||
|
||||
// Send command from TTY to OBD2
|
||||
if (liveData->bleConnected) {
|
||||
if (Serial.available()) {
|
||||
ch = Serial.read();
|
||||
line = line + ch;
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
Serial.println(line);
|
||||
liveData->pRemoteCharacteristicWrite->writeValue(line.c_str(), line.length());
|
||||
line = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Can send next command from queue to OBD
|
||||
if (liveData->canSendNextAtCommand) {
|
||||
liveData->canSendNextAtCommand = false;
|
||||
doNextAtCommand();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SIM800L_ENABLED
|
||||
if(liveData->params.lastDataSent + SIM800L_TIMER < liveData->params.currentTime && liveData->params.sim800l_enabled) {
|
||||
sendDataViaGPRS();
|
||||
liveData->params.lastDataSent = liveData->params.currentTime;
|
||||
}
|
||||
#endif // SIM800L_ENABLED
|
||||
|
||||
board->mainLoop();
|
||||
|
||||
// currentTime & 1ms delay
|
||||
struct tm now;
|
||||
getLocalTime(&now, 0);
|
||||
liveData->params.currentTime = mktime(&now);
|
||||
// Shutdown when car is off
|
||||
if (liveData->params.automaticShutdownTimer != 0 && liveData->params.currentTime - liveData->params.automaticShutdownTimer > 5)
|
||||
board->shutdownDevice();
|
||||
if (board->scanDevices) {
|
||||
board->scanDevices = false;
|
||||
startBleScan();
|
||||
}
|
||||
}
|
||||
22
menu.h
22
menu.h
@@ -1,20 +1,8 @@
|
||||
// Menu id/parent/title
|
||||
typedef struct {
|
||||
int16_t id;
|
||||
int16_t parentId;
|
||||
int16_t targetParentId;
|
||||
char title[50];
|
||||
char obdMacAddress[20];
|
||||
char serviceUUID[40];
|
||||
} MENU_ITEM;
|
||||
|
||||
#define menuItemsCount 79
|
||||
bool menuVisible = false;
|
||||
uint16_t menuCurrent = 0;
|
||||
uint8_t menuItemSelected = 0;
|
||||
uint8_t menuItemOffset = 0;
|
||||
uint16_t scanningDeviceIndex = 0;
|
||||
MENU_ITEM menuItems[menuItemsCount] = {
|
||||
|
||||
#include "config.h";
|
||||
|
||||
MENU_ITEM menuItemsSource[78] = {
|
||||
|
||||
{0, 0, 0, "<- exit menu"},
|
||||
{1, 0, -1, "Vehicle type"},
|
||||
@@ -32,7 +20,7 @@ MENU_ITEM menuItems[menuItemsCount] = {
|
||||
{103, 1, -1, "Hyundai Ioniq 2018 28kWh"},
|
||||
{104, 1, -1, "Kia eNiro 2020 39kWh"},
|
||||
{105, 1, -1, "Hyundai Kona 2020 39kWh"},
|
||||
{106, 1, -1, "Renault Zoe 22kWh (DEV)"},
|
||||
//{106, 1, -1, "Renault Zoe 22kWh (DEV)"},
|
||||
{107, 1, -1, "Debug OBD2 Kia"},
|
||||
|
||||
{300, 3, 0, "<- parent menu"},
|
||||
|
||||
Reference in New Issue
Block a user