Files
JC3636W518EN/10-OBD-Display-2024/elmulator/examples/ESP32_Custom_ELMulator/OBDSerialComm.h
T
patriandClaude Opus 5.5 9cefb9ba75 Separate old OBD display project from vendor demo folder
- Move user sketches to 10-OBD-Display-2024/, one folder per sketch
- Keep 2-Program Example/Demo_Arduino vendor-only, single docs/ copy
- Remove duplicate screenshots/instructions and ELMulator zip
- Archive broken LVGL 9 attempt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 23:57:09 +02:00

90 lines
1.7 KiB
C++

#ifndef ELMulator_OBDSerialComm_h
#define ELMulator_OBDSerialComm_h
#include <Arduino.h>
#include "definitions.h"
#include <BluetoothSerial.h>
class OBDSerialComm
{
public:
enum STATUS
{
IDLE = 0,
READY = 1
};
// // Bluetooth is not built in, we are using a BT module via GPIO
// OBDSerialComm(uint32_t baudRate, uint8_t rxPin, uint8_t txPin);
OBDSerialComm();
~OBDSerialComm();
void init(const String &deviceName);
void writeEndOK();
void writeEndERROR();
/**
* Response for unsupported PID command or missing sensor, respond "NO DATA".
*/
void writeEndNoData();
/**
* Response for invalid AT command, or invalid PID or other bad input, respond "?"
*/
void writeEndUnknown();
void setToDefaults();
void readData(String &rxData);
void writeTo(uint8_t cChar);
void writeTo(char const *string);
void setEcho(bool echo);
void writeEnd();
bool isEchoEnable();
void setLineFeeds(bool status);
void setMemory(bool status);
void setWhiteSpaces(bool status);
void setHeaders(bool status);
void setStatus(STATUS status);
void writeEndPidTo(char const *string);
private:
uint32_t baudRate; // Serial Baud Rate
STATUS status; // Operation status
bool echoEnable; // echoEnable command after received
bool lineFeedEnable;
bool memoryEnabled;
bool whiteSpacesEnabled;
bool headersEnabled;
void setBaudRate(uint32_t rate);
long getBaudRate();
void addSpacesToResponse(const char *response, char string[]);
#ifndef BLUETOOTH_BUILTIN
HardwareSerial *serial; // lib to communicate with bluetooth
#else
BluetoothSerial *serial;
#endif
};
#endif