Implement Communication object file structure

This commit is contained in:
GHOSCHT 2022-02-01 23:20:04 +01:00
parent 98bd6db4b3
commit 591a8c27cd
No known key found for this signature in database
GPG key ID: A35BD466B8871994
6 changed files with 79 additions and 0 deletions

View file

@ -0,0 +1,11 @@
#include <Communicator.h>
Communicator::Communicator(__SIZE_TYPE__ bufferSize)
{
this->messageBuffer = new char[bufferSize];
}
char *Communicator::getBuffer()
{
return messageBuffer;
}

View file

@ -0,0 +1,12 @@
class Communicator
{
private:
char *messageBuffer;
public:
Communicator(__SIZE_TYPE__ bufferSize);
virtual void sendMessage(int *values);
virtual void sendMessage(char *message);
virtual char *receiveMessage();
char *getBuffer();
};

View file

@ -0,0 +1,17 @@
#include <I2CCommunicator.h>
#include <Wire.h>
I2CCommunicator::I2CCommunicator(int slaveAddr, __SIZE_TYPE__ bufferSize) : Communicator(bufferSize)
{
Wire.begin(slaveAddr);
//Wire.onReceive(receiveEvent);
}
void I2CCommunicator::sendMessage(int *values)
{
}
void I2CCommunicator::sendMessage(char *message)
{
Wire.println(message);
}

View file

@ -0,0 +1,11 @@
#include <Communicator.h>
class I2CCommunicator : public Communicator
{
private:
public:
I2CCommunicator(int slaveAddr, __SIZE_TYPE__ bufferSize);
void sendMessage(int *values);
void sendMessage(char *message);
char *receiveMessage();
};

View file

@ -0,0 +1,17 @@
#include <SerialCommunicator.h>
#include <HardwareSerial.h>
SerialCommunicator::SerialCommunicator(int baudRate, int timeout, __SIZE_TYPE__ bufferSize) : Communicator(bufferSize)
{
Serial.begin(baudRate);
Serial.setTimeout(timeout);
}
void SerialCommunicator::sendMessage(int *values)
{
}
void SerialCommunicator::sendMessage(char *message)
{
Serial.println(message);
}

View file

@ -0,0 +1,11 @@
#include <Communicator.h>
class SerialCommunicator : public Communicator
{
private:
public:
SerialCommunicator(int baudRate, int timeout, __SIZE_TYPE__ bufferSize);
void sendMessage(int *values);
void sendMessage(char *message);
char *receiveMessage();
};