Skip to content

Commit

Permalink
small code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed May 13, 2024
1 parent e640240 commit cc976a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
8 changes: 2 additions & 6 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 0 additions & 11 deletions src/tnc_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
Expand All @@ -80,7 +74,6 @@ namespace TNC_Utils {
Utils::println("Ignored own frame from KISS");
}
}

data->clear();
}

Expand Down Expand Up @@ -130,25 +123,21 @@ 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();
}

void loop() {
if (Config.tnc.enableServer) {
checkNewClients();

readFromClients();
}

if (Config.tnc.enableSerial) {
readFromSerial();
}
Expand Down

0 comments on commit cc976a4

Please sign in to comment.