|
|
|
@ -27,38 +27,43 @@ QueueHandle_t tncToSendQueue = nullptr; |
|
|
|
|
*/ |
|
|
|
|
void handleKISSData(char character, int bufferIndex) { |
|
|
|
|
String *inTNCData = &inTNCDataBuffers[bufferIndex]; |
|
|
|
|
if (inTNCData->length() == 0 && character != (char) FEND){ |
|
|
|
|
if (inTNCData->length() == 0 && character != (char) FEND) |
|
|
|
|
{ |
|
|
|
|
// kiss frame begins with C0
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
inTNCData->concat(character); |
|
|
|
|
if (character == (char) U_SABME && inTNCData->length() > 3) { |
|
|
|
|
if (character == (char) FEND && inTNCData->length() > 3)
|
|
|
|
|
{ |
|
|
|
|
bool isDataFrame = false; |
|
|
|
|
const String &TNC2DataFrame = decode_kiss_pkt(*inTNCData, isDataFrame); |
|
|
|
|
bool isPacketFrame = false; |
|
|
|
|
const String &TNC2DataFrame = decode_kiss_pkt(*inTNCData, isDataFrame, isPacketFrame); |
|
|
|
|
|
|
|
|
|
if (isDataFrame) { |
|
|
|
|
if (isDataFrame && isPacketFrame) { |
|
|
|
|
auto *buffer = new String(); |
|
|
|
|
buffer->concat(TNC2DataFrame); |
|
|
|
|
if (xQueueSend(tncToSendQueue, &buffer, (1000 / portTICK_PERIOD_MS)) != pdPASS) { |
|
|
|
|
if (xQueueSend(tncToSendQueue, &buffer, (1000 / portTICK_PERIOD_MS)) != pdPASS)
|
|
|
|
|
{ |
|
|
|
|
delete buffer; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
inTNCData->clear(); |
|
|
|
|
inTNCData->clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (character == (char) FEND && inTNCData->length() > 3) { |
|
|
|
|
else if (character == (char) FEND && inTNCData->length() > 3) |
|
|
|
|
{ |
|
|
|
|
bool isDataFrame = false; |
|
|
|
|
const String &TNC2DataFrame = decode_kiss(*inTNCData, isDataFrame); |
|
|
|
|
|
|
|
|
|
if (isDataFrame) { |
|
|
|
|
auto *buffer = new String(); |
|
|
|
|
buffer->concat(TNC2DataFrame); |
|
|
|
|
if (xQueueSend(tncToSendQueue, &buffer, (1000 / portTICK_PERIOD_MS)) != pdPASS) { |
|
|
|
|
if (xQueueSend(tncToSendQueue, &buffer, (1000 / portTICK_PERIOD_MS)) != pdPASS)
|
|
|
|
|
{ |
|
|
|
|
delete buffer; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
inTNCData->clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (inTNCData->length() > 255){ |
|
|
|
|
// just in case of garbage input reset data
|
|
|
|
|
inTNCData->clear(); |
|
|
|
|