From cc976a4a4aa0bfb816b23d6a0170900d0f053d9e Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sun, 12 May 2024 22:02:12 -0400 Subject: [PATCH] small code refactor --- src/LoRa_APRS_iGate.cpp | 8 ++------ src/tnc_utils.cpp | 11 ----------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 7060e7f..a0ee27a 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -183,13 +183,9 @@ void loop() { // Utils::checkWiFiInterval(); #ifdef ESP32_DIY_LoRa_A7670 - if (Config.aprs_is.active && !modemLoggedToAPRSIS) { - A7670_Utils::APRS_IS_connect(); - } + if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect(); #else - if (Config.aprs_is.active && !espClient.connected()) { - APRS_IS_Utils::connect(); - } + if (Config.aprs_is.active && !espClient.connected()) APRS_IS_Utils::connect(); #endif TNC_Utils::loop(); diff --git a/src/tnc_utils.cpp b/src/tnc_utils.cpp index 7297df2..fe8bb9a 100644 --- a/src/tnc_utils.cpp +++ b/src/tnc_utils.cpp @@ -31,16 +31,12 @@ namespace TNC_Utils { void checkNewClients() { WiFiClient new_client = tncServer.available(); - if (new_client.connected()) { for (int i = 0; i < MAX_CLIENTS; i++) { WiFiClient* client = clients[i]; - if (client == nullptr) { clients[i] = new WiFiClient(new_client); - Utils::println("New TNC client connected"); - break; } } @@ -49,13 +45,11 @@ namespace TNC_Utils { void handleInputData(char character, int bufferIndex) { String* data; - if (bufferIndex == -1) { data = &inputSerialBuffer; } else { data = &inputServerBuffer[bufferIndex]; } - if (data->length() == 0 && character != (char)FEND) { return; } @@ -80,7 +74,6 @@ namespace TNC_Utils { Utils::println("Ignored own frame from KISS"); } } - data->clear(); } @@ -130,14 +123,12 @@ namespace TNC_Utils { } } } - Utils::print("---> Sent to TNC : "); Utils::println(packet); } void sendToSerial(String packet) { packet = packet.substring(3); - Serial.print(encodeKISS(packet)); Serial.flush(); } @@ -145,10 +136,8 @@ namespace TNC_Utils { void loop() { if (Config.tnc.enableServer) { checkNewClients(); - readFromClients(); } - if (Config.tnc.enableSerial) { readFromSerial(); }