Files
Rens Pastoor 11b391b8a1 sync
2025-05-27 22:41:46 +02:00

40 lines
1.2 KiB
C++
Executable File

#include <Arduino.h>
#ifndef SERIALPROCESS_H
#define SERIALPROCESS_H
class SerialProcess {
private:
uint8_t ndx; // Current index for the buffer
const char beginMarker = '#'; // Marker to indicate the start of a message
const char endMarker = ';'; // Marker to indicate the end of a message
char rc; // Character read from Serial
int address; // Device address
bool newData; // Flag for new data availability
static const uint8_t numChars = 255; // Maximum size of the buffer
char receivedChars[numChars]; // Buffer for incoming data
bool rcCheck;
public:
// Constructor
explicit SerialProcess(int addr);
// Store Serial Input (if available)
void SerialInput();
// Check if new data is available
bool isNewDataAvailable();
// Get the received data
char* getReceivedData();
// Process the received message
void getPayload(char* payload);
// Send message in the correct format
void sendMessage(int receiver, const char* payload);
void changeAddress(int addr);
};
#endif // SERIALPROCESS_H