mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-10-31 02:51:58 +01:00
tnc2 added
This commit is contained in:
1 parent
ee65f953d6
commit
5d04c56fd2
7 files changed
+79
-21
No files matched your search
@@ -68,7 +68,7 @@ ___________________________________________________________________*/
|
||||
#endif
|
||||
|
||||
|
||||
String versionDate = "2026-09-07";
|
||||
String versionDate = "2026-09-15";
|
||||
String versionNumber = "4.0.1";
|
||||
Configuration Config;
|
||||
WiFiClient aprsIsClient;
|
||||
|
||||
@@ -157,6 +157,7 @@ bool Configuration::writeFile() {
|
||||
data["tnc"]["enableSerial"] = tnc.enableSerial;
|
||||
data["tnc"]["acceptOwn"] = tnc.acceptOwn;
|
||||
data["tnc"]["aprsBridgeActive"] = tnc.aprsBridgeActive;
|
||||
data["tnc"]["kissProtocol"] = tnc.kissProtocol;
|
||||
|
||||
data["mqtt"]["active"] = mqtt.active;
|
||||
data["mqtt"]["server"] = mqtt.server;
|
||||
@@ -369,11 +370,13 @@ bool Configuration::readFile() {
|
||||
if (data["tnc"]["enableServer"].isNull() ||
|
||||
data["tnc"]["enableSerial"].isNull() ||
|
||||
data["tnc"]["acceptOwn"].isNull() ||
|
||||
data["tnc"]["aprsBridgeActive"].isNull()) needsRewrite = true;
|
||||
data["tnc"]["aprsBridgeActive"].isNull() ||
|
||||
data["tnc"]["kissProtocol"].isNull()) needsRewrite = true;
|
||||
tnc.enableServer = data["tnc"]["enableServer"] | false;
|
||||
tnc.enableSerial = data["tnc"]["enableSerial"] | false;
|
||||
tnc.acceptOwn = data["tnc"]["acceptOwn"] | false;
|
||||
tnc.aprsBridgeActive = data["tnc"]["aprsBridgeActive"] | false;
|
||||
tnc.kissProtocol = data["tnc"]["kissProtocol"] | true;
|
||||
|
||||
if (data["mqtt"]["active"].isNull() ||
|
||||
data["mqtt"]["server"].isNull() ||
|
||||
@@ -538,6 +541,7 @@ void Configuration::setDefaultValues() {
|
||||
tnc.enableSerial = false;
|
||||
tnc.acceptOwn = false;
|
||||
tnc.aprsBridgeActive = false;
|
||||
tnc.kissProtocol = true;
|
||||
|
||||
mqtt.active = false;
|
||||
mqtt.server = "";
|
||||
|
||||
+51
-17
@@ -78,7 +78,23 @@ namespace TNC_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void handleInputData(char character, int bufferIndex) {
|
||||
void processInputFrame(const String& frame, int bufferIndex, const String& protocolLabel) {
|
||||
if (bufferIndex != -1) {
|
||||
Utils::print("<--- Got from TNC (" + protocolLabel + ") : ");
|
||||
Utils::println(frame);
|
||||
}
|
||||
|
||||
String sender = frame.substring(0,frame.indexOf(">"));
|
||||
|
||||
if (Config.tnc.acceptOwn || sender != Config.callsign) {
|
||||
if (Config.loramodule.txActive) STATION_Utils::addToOutputPacketBuffer(frame);
|
||||
if (Config.tnc.aprsBridgeActive && Config.aprs_is.active && passcodeValid && aprsIsClient.connected()) APRS_IS_Utils::upload(frame);
|
||||
} else {
|
||||
Utils::println("Ignored own frame from " + protocolLabel);
|
||||
}
|
||||
}
|
||||
|
||||
void handleInputDataKISS(char character, int bufferIndex) {
|
||||
String* data = (bufferIndex == -1) ? &inputSerialBuffer : &inputServerBuffer[bufferIndex];
|
||||
if (data->length() == 0 && character != (char)FEND) return;
|
||||
|
||||
@@ -89,19 +105,7 @@ namespace TNC_Utils {
|
||||
const String& frame = decodeKISS(*data, isDataFrame);
|
||||
|
||||
if (isDataFrame) {
|
||||
if (bufferIndex != -1) {
|
||||
Utils::print("<--- Got from TNC : ");
|
||||
Utils::println(frame);
|
||||
}
|
||||
|
||||
String sender = frame.substring(0,frame.indexOf(">"));
|
||||
|
||||
if (Config.tnc.acceptOwn || sender != Config.callsign) {
|
||||
if (Config.loramodule.txActive) STATION_Utils::addToOutputPacketBuffer(frame);
|
||||
if (Config.tnc.aprsBridgeActive && Config.aprs_is.active && passcodeValid && aprsIsClient.connected()) APRS_IS_Utils::upload(frame);
|
||||
} else {
|
||||
Utils::println("Ignored own frame from KISS");
|
||||
}
|
||||
processInputFrame(frame, bufferIndex, "KISS");
|
||||
}
|
||||
data->clear();
|
||||
}
|
||||
@@ -111,6 +115,36 @@ namespace TNC_Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void handleInputDataTNC2(char character, int bufferIndex) {
|
||||
String* data = (bufferIndex == -1) ? &inputSerialBuffer : &inputServerBuffer[bufferIndex];
|
||||
|
||||
if (character == '\r') return;
|
||||
|
||||
if (character == '\n') {
|
||||
String frame = *data;
|
||||
frame.trim();
|
||||
data->clear();
|
||||
|
||||
if (frame.length() > 0 && frame.indexOf(':') != -1 && frame.indexOf('>') != -1) {
|
||||
processInputFrame(frame, bufferIndex, "TNC2");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
data->concat(character);
|
||||
if (data->length() > 255) {
|
||||
data->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void handleInputData(char character, int bufferIndex) {
|
||||
if (Config.tnc.kissProtocol) {
|
||||
handleInputDataKISS(character, bufferIndex);
|
||||
} else {
|
||||
handleInputDataTNC2(character, bufferIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void readFromClients() {
|
||||
for (int i = 0; i < MAX_CLIENTS; i++) {
|
||||
auto client = clients[i];
|
||||
@@ -138,13 +172,13 @@ namespace TNC_Utils {
|
||||
void sendToClients(const String& packet, bool stripBytes) {
|
||||
String cleanPacket = stripBytes ? packet.substring(3): packet;
|
||||
|
||||
const String kissEncoded = encodeKISS(cleanPacket);
|
||||
const String encoded = Config.tnc.kissProtocol ? encodeKISS(cleanPacket) : (cleanPacket + "\r\n");
|
||||
|
||||
for (int i = 0; i < MAX_CLIENTS; i++) {
|
||||
auto client = clients[i];
|
||||
if (client != nullptr) {
|
||||
if (client->connected()) {
|
||||
client->print(kissEncoded);
|
||||
client->print(encoded);
|
||||
client->flush();
|
||||
} else {
|
||||
delete client;
|
||||
@@ -158,7 +192,7 @@ namespace TNC_Utils {
|
||||
|
||||
void sendToSerial(const String& packet, bool stripBytes) {
|
||||
String cleanPacket = stripBytes ? packet.substring(3): packet;
|
||||
Serial.print(encodeKISS(cleanPacket));
|
||||
Serial.print(Config.tnc.kissProtocol ? encodeKISS(cleanPacket) : (cleanPacket + "\r\n"));
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -322,6 +322,7 @@ namespace WEB_Utils {
|
||||
Config.tnc.enableSerial = request->hasParam("tnc.enableSerial", true);
|
||||
Config.tnc.acceptOwn = request->hasParam("tnc.acceptOwn", true);
|
||||
Config.tnc.aprsBridgeActive = request->hasParam("tnc.aprsBridgeActive", true);
|
||||
Config.tnc.kissProtocol = getParamStringSafe("tnc.kissProtocol", Config.tnc.kissProtocol ? "KISS" : "TNC2") != "TNC2";
|
||||
|
||||
Config.mqtt.active = request->hasParam("mqtt.active", true);
|
||||
if (Config.mqtt.active) {
|
||||
|
||||
Reference in new issue
Block a user