small code refactor

This commit is contained in:
richonguzman 2024-05-12 22:02:12 -04:00
parent e6402409fc
commit cc976a4a4a
2 changed files with 2 additions and 17 deletions

View file

@ -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();

View file

@ -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();
}