base-station/Firmware/lib/StreamCommunicator/StreamCommunicator.cpp
2022-04-10 16:20:26 +02:00

27 lines
671 B
C++

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