From 5df20e8ecd2d048723b9c8694cd6eae6ff322fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nidecki?= Date: Fri, 12 Feb 2021 21:44:06 +0100 Subject: [PATCH] KISS_DEBUG option for testing axp192 --- lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp | 8 +++----- lib/KISS_TO_TNC2/KISS_TO_TNC2.h | 3 ++- src/TTGO_T-Beam_LoRa_APRS.ino | 24 ++++++++++++++++++++++++ src/TTGO_T-Beam_LoRa_APRS_config.h | 1 + 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp b/lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp index 82f2596..1b915f1 100644 --- a/lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp +++ b/lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp @@ -7,8 +7,6 @@ String decode_address_ax25(const String& ax25Address, bool &isLast); bool validateKISSFrame(const String &kissFormattedFrame); -String encapsulateKISS(const String &ax25Frame); - String decapsulateKISS(const String& frame); /* @@ -64,14 +62,14 @@ String encode_kiss(const String& tnc2FormattedFrame) { ax25Frame += tnc2FormattedFrame.substring(tnc2FormattedFrame.indexOf(':')+1); } - String kissFrame = encapsulateKISS(ax25Frame); + String kissFrame = encapsulateKISS(ax25Frame, CMD_DATA); return kissFrame; } -String encapsulateKISS(const String &ax25Frame) { +String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd) { String kissFrame = ""; kissFrame += (char)FEND; // start of frame - kissFrame += (char)CMD_DATA; // TNC0, DATA + kissFrame += (char)(0x0f & TNCCmd); // TNC0, cmd for (int i = 0; i < ax25Frame.length(); ++i) { char currentChar = ax25Frame.charAt(i); if (currentChar == (char)FEND){ diff --git a/lib/KISS_TO_TNC2/KISS_TO_TNC2.h b/lib/KISS_TO_TNC2/KISS_TO_TNC2.h index 0fe9660..ecf447a 100644 --- a/lib/KISS_TO_TNC2/KISS_TO_TNC2.h +++ b/lib/KISS_TO_TNC2/KISS_TO_TNC2.h @@ -8,5 +8,6 @@ #define IS_LAST_ADDRESS_POSITION_MASK 0b1 String encode_kiss(const String& tnc2FormattedFrame); - String decode_kiss(const String& kissFormattedFrame); + +String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd); \ No newline at end of file diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 5a8626f..670808c 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -514,6 +514,30 @@ void loop() { displayInvalidGPS(); } } + #ifdef KISS_PROTOCOLL + #ifdef KISS_DEBUG + static auto last_debug_send_time = millis(); + if (millis() - last_debug_send_time > 1000*10) { + last_debug_send_time = millis(); + String debug_message = ""; + debug_message += "Bat V: " + String(axp.getBattVoltage()); + debug_message += ", "; + debug_message += "Bat IN A: " + String(axp.getBattChargeCurrent()); + debug_message += ", "; + debug_message += "Bat OUT A: " + String(axp.getBattDischargeCurrent()); + debug_message += ", "; + debug_message += "Bat %: " + String(axp.getBattPercentage()); + debug_message += ", "; + debug_message += "USB V: " + String(axp.getVbusVoltage()); + debug_message += ", "; + debug_message += "USB A: " + String(axp.getVbusCurrent()); + debug_message += ", "; + debug_message += "Temp C: " + String(axp.getTemp()); + + Serial.print(encapsulateKISS(debug_message, CMD_HARDWARE)); + } +#endif + #endif } void handleKISSData(char character) { diff --git a/src/TTGO_T-Beam_LoRa_APRS_config.h b/src/TTGO_T-Beam_LoRa_APRS_config.h index 595d4ad..34206a4 100644 --- a/src/TTGO_T-Beam_LoRa_APRS_config.h +++ b/src/TTGO_T-Beam_LoRa_APRS_config.h @@ -20,5 +20,6 @@ //#define SHOW_GPS_DATA // uncomment to show on serial port, received data from GPS and debug information #define ENABLE_BLUETOOTH //#define BLUETOOTH_PIN "0000" +#define KISS_DEBUG unsigned long max_time_to_nextTX = 180000L; // TRANSMIT INTERVAL set here MAXIMUM time in ms(!) for smart beaconing - minimum time is always 1 min = 60 secs = 60000L !!! \ No newline at end of file