#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
