This commit is contained in:
Lubos Petrovic
2020-12-07 11:53:12 +01:00
parent a7fff773b5
commit cfdd76df0a
19 changed files with 91 additions and 25 deletions

View File

@@ -69,6 +69,8 @@ void Board320_240::afterSetup() {
sdcardToggleRecording(); sdcardToggleRecording();
} }
} }
BoardInterface::afterSetup();
} }
/** /**

View File

@@ -18,7 +18,7 @@
class Board320_240 : public BoardInterface { class Board320_240 : public BoardInterface {
private: protected:
// TFT, SD SPI // TFT, SD SPI
TFT_eSPI tft = TFT_eSPI(); TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft); TFT_eSprite spr = TFT_eSprite(&tft);

View File

@@ -7,6 +7,8 @@
#include <EEPROM.h> #include <EEPROM.h>
#include <BLEDevice.h> #include <BLEDevice.h>
#include "BoardInterface.h" #include "BoardInterface.h"
#include "CommObd2Ble4.h";
#include "CommObd2Can.h";
#include "LiveData.h" #include "LiveData.h"
/** /**
@@ -185,6 +187,23 @@ void BoardInterface::loadSettings() {
} }
} }
/**
* After setup
*/
void BoardInterface::afterSetup() {
// Init Comm iterface
if (liveData->settings.commType == COMM_TYPE_OBD2BLE4) {
commInterface = new CommObd2Ble4();
} else
if (liveData->settings.commType == COMM_TYPE_OBD2CAN) {
commInterface = new CommObd2Ble4();
//commInterface = new CommObd2Can();
}
//commInterface->initComm(liveData, NULL);
commInterface->connectDevice();
}
/** /**
Custom commands Custom commands
*/ */

View File

@@ -4,10 +4,14 @@
#include <FS.h> #include <FS.h>
#include "LiveData.h" #include "LiveData.h"
#include "CarInterface.h" #include "CarInterface.h"
#include "CommInterface.h"
class BoardInterface { class BoardInterface {
private: protected:
LiveData* liveData;
CarInterface* carInterface;
CommInterface* commInterface;
public: public:
// Screens, buttons // Screens, buttons
byte displayScreen = SCREEN_AUTO; byte displayScreen = SCREEN_AUTO;
@@ -27,8 +31,6 @@ class BoardInterface {
String debugLastString = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8"; String debugLastString = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8";
String debugPreviousString = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8"; String debugPreviousString = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8";
// //
LiveData* liveData;
CarInterface* carInterface;
void setLiveData(LiveData* pLiveData); void setLiveData(LiveData* pLiveData);
void attachCar(CarInterface* pCarInterface); void attachCar(CarInterface* pCarInterface);
virtual void initBoard()=0; virtual void initBoard()=0;

View File

@@ -37,7 +37,7 @@
class BoardM5stackCore : public Board320_240 { class BoardM5stackCore : public Board320_240 {
private: protected:
public: public:
void initBoard() override; void initBoard() override;
void mainLoop() override; void mainLoop() override;

View File

@@ -36,7 +36,7 @@
// //
class BoardTtgoT4v13 : public Board320_240 { class BoardTtgoT4v13 : public Board320_240 {
private: protected:
public: public:
void initBoard() override; void initBoard() override;

View File

@@ -5,7 +5,7 @@
class CarHyundaiIoniq : public CarInterface { class CarHyundaiIoniq : public CarInterface {
private: protected:
public: public:
void activateCommandQueue() override; void activateCommandQueue() override;

View File

@@ -5,7 +5,7 @@
class CarInterface { class CarInterface {
private: protected:
public: public:
LiveData* liveData; LiveData* liveData;
void setLiveData(LiveData* pLiveData); void setLiveData(LiveData* pLiveData);

View File

@@ -5,7 +5,7 @@
class CarKiaDebugObd2 : public CarInterface { class CarKiaDebugObd2 : public CarInterface {
private: protected:
public: public:
void activateCommandQueue() override; void activateCommandQueue() override;

View File

@@ -5,7 +5,7 @@
class CarKiaEniro : public CarInterface { class CarKiaEniro : public CarInterface {
private: protected:
public: public:
void activateCommandQueue() override; void activateCommandQueue() override;

View File

@@ -5,7 +5,7 @@
class CarRenaultZoe : public CarInterface { class CarRenaultZoe : public CarInterface {
private: protected:
public: public:
void activateCommandQueue() override; void activateCommandQueue() override;

View File

@@ -2,6 +2,12 @@
#define COMMINTERFACE_CPP #define COMMINTERFACE_CPP
#include "CommInterface.h" #include "CommInterface.h"
//#include "BoardInterface.h"
#include "LiveData.h" #include "LiveData.h"
void CommInterface::initComm(LiveData* pLiveData/*, BoardInterface* pBoard*/) {
liveData = pLiveData;
//board = pBoard;
}
#endif // COMMINTERFACE_CPP #endif // COMMINTERFACE_CPP

View File

@@ -2,11 +2,18 @@
#define COMMINTERFACE_H #define COMMINTERFACE_H
#include "LiveData.h" #include "LiveData.h"
//#include "BoardInterface.h"
class CommInterface { class CommInterface {
private: protected:
LiveData* liveData;
//BoardInterface* board;
public: public:
void initComm(LiveData* pLiveData/*, BoardInterface* pBoard**/);
virtual void connectDevice() = 0;
virtual void disconnectDevice() = 0;
virtual void scanDevices() = 0;
}; };
#endif // COMMINTERFACE_H #endif // COMMINTERFACE_H

View File

@@ -1,7 +1,29 @@
#ifndef COMMOBD2BLE4_CPP #ifndef COMMOBD2BLE4_CPP
#define COMMOBD2BLE4_CPP #define COMMOBD2BLE4_CPP
#include "CommInterface.h" #include <BLEDevice.h>
#include "CommObd2Ble4.h"
#include "LiveData.h" #include "LiveData.h"
/**
* Connect ble4 adapter
*/
void CommObd2Ble4::connectDevice() {
Serial.println("COMM connectDevice");
}
/**
* Disconnect device
*/
void CommObd2Ble4::disconnectDevice() {
Serial.println("COMM disconnectDevice");
}
/**
* Scan device list
*/
void CommObd2Ble4::scanDevices() {
Serial.println("COMM scanDevices");
}
#endif // COMMOBD2BLE4_CPP #endif // COMMOBD2BLE4_CPP

View File

@@ -2,11 +2,16 @@
#define COMMOBD2BLE4_H #define COMMOBD2BLE4_H
#include "LiveData.h" #include "LiveData.h"
#include "CommInterface.h"
class CommObd2Ble4 : public CommInterface { class CommObd2Ble4 : public CommInterface {
private: protected:
uint32_t PIN = 1234;
public: public:
void connectDevice() override;
void disconnectDevice() override;
void scanDevices() override;
}; };
#endif // COMMOBD2BLE4_H #endif // COMMOBD2BLE4_H

View File

@@ -5,7 +5,7 @@
class CommObd2Can : public CommInterface { class CommObd2Can : public CommInterface {
private: protected:
public: public:
}; };

View File

@@ -19,6 +19,10 @@
#define CAR_RENAULT_ZOE 5 #define CAR_RENAULT_ZOE 5
#define CAR_DEBUG_OBD2_KIA 999 #define CAR_DEBUG_OBD2_KIA 999
//
#define COMM_TYPE_OBD2BLE4 0
#define COMM_TYPE_OBD2CAN 1
// SCREENS // SCREENS
#define SCREEN_BLANK 0 #define SCREEN_BLANK 0
#define SCREEN_AUTO 1 #define SCREEN_AUTO 1
@@ -179,7 +183,7 @@ typedef struct {
// //
class LiveData { class LiveData {
private: protected:
public: public:
// Command loop // Command loop
uint16_t commandQueueCount; uint16_t commandQueueCount;

Binary file not shown.

View File

@@ -39,7 +39,6 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SPI.h> #include <SPI.h>
#include <BLEDevice.h>
#include "BoardInterface.h" #include "BoardInterface.h"
#ifdef BOARD_TTGO_T4 #ifdef BOARD_TTGO_T4
@@ -49,6 +48,7 @@
#include "BoardM5stackCore.h" #include "BoardM5stackCore.h"
#endif // BOARD_M5STACK_CORE #endif // BOARD_M5STACK_CORE
#include <BLEDevice.h>
#include <sys/time.h> #include <sys/time.h>
#include "config.h" #include "config.h"
#include "LiveData.h" #include "LiveData.h"
@@ -66,9 +66,6 @@
SIM800L* sim800l; SIM800L* sim800l;
#endif //SIM800L_ENABLED #endif //SIM800L_ENABLED
// PLEASE CHANGE THIS SETTING for your BLE4
uint32_t PIN = 1234;
// Temporary variables // Temporary variables
char ch; char ch;
String line; String line;
@@ -218,6 +215,8 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
} }
}; };
uint32_t PIN = 1234;
/** /**
BLE Security BLE Security
*/ */
@@ -637,11 +636,11 @@ void loop() {
} }
} }
// Can send next command from queue to OBD // Can send next command from queue to OBD
if (liveData->canSendNextAtCommand) { if (liveData->canSendNextAtCommand) {
liveData->canSendNextAtCommand = false; liveData->canSendNextAtCommand = false;
doNextAtCommand(); doNextAtCommand();
} }
#ifdef SIM800L_ENABLED #ifdef SIM800L_ENABLED
if (liveData->params.lastDataSent + SIM800L_TIMER < liveData->params.currentTime && liveData->params.sim800l_enabled) { if (liveData->params.lastDataSent + SIM800L_TIMER < liveData->params.currentTime && liveData->params.sim800l_enabled) {