@ -6,6 +6,7 @@
String inTNCData = " " ;
QueueHandle_t tncToSendQueue = nullptr ;
QueueHandle_t tncReceivedQueue = nullptr ;
WiFiClient client ;
/**
* Handle incoming TNC KISS data character
@ -23,6 +24,12 @@ void handleKISSData(char character) {
SerialBT . print ( inTNCData ) ;
}
# endif
# ifdef ENABLE_WIFI
if ( client . connected ( ) ) {
client . print ( inTNCData ) ;
client . flush ( ) ;
}
# endif
# endif
auto * buffer = new String ( ) ;
buffer - > concat ( TNC2DataFrame ) ;
@ -34,31 +41,50 @@ void handleKISSData(char character) {
}
void taskTNC( void * parameter ) {
[[noreturn]] void taskTNC( void * parameter ) {
tncToSendQueue = xQueueCreate ( 4 , sizeof ( String * ) ) ;
tncReceivedQueue = xQueueCreate ( 4 , sizeof ( String * ) ) ;
String * loraReceivedFrameString = nullptr ;
client = tncServer . available ( ) ;
while ( true ) {
while ( Serial . available ( ) > 0 ) {
char character = Serial . read ( ) ;
handleKISSData ( character ) ;
}
# ifdef ENABLE_BLUETOOTH
if ( SerialBT . hasClient ( ) ) {
while ( SerialBT . available ( ) > 0 ) {
char character = SerialBT . read ( ) ;
handleKISSData ( character ) ;
if ( SerialBT . hasClient ( ) ) {
while ( SerialBT . available ( ) > 0 ) {
char character = SerialBT . read ( ) ;
handleKISSData ( character ) ;
}
}
# endif
# ifdef ENABLE_WIFI
if ( ! client . connected ( ) ) {
client = tncServer . available ( ) ;
}
if ( client . connected ( ) ) {
while ( client . available ( ) > 0 ) {
char character = client . read ( ) ;
handleKISSData ( character ) ;
}
}
}
# endif
if ( xQueueReceive ( tncReceivedQueue , & loraReceivedFrameString , ( 1 / portTICK_PERIOD_MS ) ) = = pdPASS ) {
Serial . print ( encode_kiss ( * loraReceivedFrameString ) ) ;
const String & kissEncoded = encode_kiss ( * loraReceivedFrameString ) ;
Serial . print ( kissEncoded ) ;
# ifdef ENABLE_BLUETOOTH
if ( SerialBT . hasClient ( ) ) {
SerialBT . print ( encode_kiss ( * loraReceivedFrameString ) ) ;
SerialBT . print ( kissEncoded ) ;
}
# endif
# ifdef ENABLE_WIFI
if ( client . connected ( ) ) {
client . print ( kissEncoded ) ;
client . flush ( ) ;
}
# endif
delete loraReceivedFrameString ;
}
vTaskDelay ( 50 / portTICK_PERIOD_MS ) ;