base-station/Firmware/lib/StreamCommunicator/StreamCommunicator.cpp

31 lines
676 B
C++
Raw Normal View History

2022-04-09 20:07:19 +02:00
#include <StreamCommunicator.h>
StreamCommunicator::StreamCommunicator(Stream &s_out, __SIZE_TYPE__ bufferSize) :Communicator(bufferSize), stream(s_out)
2022-04-09 20:07:19 +02:00
{
}
void StreamCommunicator::sendMessage(int *values, __SIZE_TYPE__ numberOfValues)
{
char message[calculateMessageOutSize(numberOfValues)];
parseIDs(values, numberOfValues, message);
stream.println(message);
}
void StreamCommunicator::sendMessage(const char message[])
{
stream.println(message);
}
char *StreamCommunicator::receiveMessage()
{
if (stream.available())
{
clearBuffer();
stream.readBytesUntil('\n', getBuffer(), getBufferSize());
}
return getBuffer();
}