62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
|
#include <Communicator.h>
|
||
|
#include <cstring>
|
||
|
#include <WString.h>
|
||
|
|
||
|
Communicator::Communicator(__SIZE_TYPE__ bufferSize){
|
||
|
this->messageBuffer = new char[bufferSize];
|
||
|
this->bufferSize = bufferSize;
|
||
|
}
|
||
|
|
||
|
void Communicator::sendMessage(int *values, __SIZE_TYPE__ numberOfValues)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void Communicator::sendMessage(const char message[])
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
char *Communicator::receiveMessage()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
__SIZE_TYPE__ Communicator::calculateMessageOutSize(__SIZE_TYPE__ numberOfValues)
|
||
|
{
|
||
|
return numberOfValues + (numberOfValues - 1) + 1;
|
||
|
}
|
||
|
|
||
|
void Communicator::parseIDs(const int values[], __SIZE_TYPE__ numberOfValues, char *output)
|
||
|
{
|
||
|
String out = "";
|
||
|
__SIZE_TYPE__ outputSize = calculateMessageOutSize(numberOfValues);
|
||
|
__SIZE_TYPE__ outputCharPointer = 0;
|
||
|
|
||
|
for (__SIZE_TYPE__ i = 0; i < numberOfValues; i++)
|
||
|
{
|
||
|
out += values[i];
|
||
|
outputCharPointer++;
|
||
|
if (outputCharPointer < outputSize - 1)
|
||
|
{
|
||
|
out += ',';
|
||
|
outputCharPointer++;
|
||
|
}
|
||
|
}
|
||
|
strcpy(output, out.c_str());
|
||
|
}
|
||
|
|
||
|
char *Communicator::getBuffer()
|
||
|
{
|
||
|
return messageBuffer;
|
||
|
}
|
||
|
|
||
|
void Communicator::clearBuffer()
|
||
|
{
|
||
|
memset(getBuffer(), '\0', getBufferSize());
|
||
|
}
|
||
|
|
||
|
int Communicator::getBufferSize()
|
||
|
{
|
||
|
return this->bufferSize;
|
||
|
}
|