Browse Source

Merge branch 'master_sq9mdd' into wifi-experimental

# Conflicts:
#	src/TTGO_T-Beam_LoRa_APRS.ino
#	src/TTGO_T-Beam_LoRa_APRS_config.h
pull/16/head
Łukasz Nidecki 10 months ago
parent
commit
0d478b5bc9
  1. 17
      README.md
  2. 12
      lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp
  3. 21
      platformio.ini
  4. 89
      src/TTGO_T-Beam_LoRa_APRS.ino
  5. 1
      src/TTGO_T-Beam_LoRa_APRS_config.h

17
README.md

@ -7,13 +7,15 @@ After connection with APRX based DIGI it can be used as KISS-TNC
![diagram](https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS/blob/master/img/digi-schemat.png)
## Contributors
* Initial work: OE1ACM, OE3CJB<br>
* Redesigned: SQ9MDD<br>
* KISS TNC Over Seriall or Bluetooth: SQ5RWU<br><br>
* Initial work: OE1ACM, OE3CJB
* Redesigned: SQ9MDD
* KISS TNC Over Seriall or Bluetooth: SQ5RWU
* Lora32 board support DJ1AN
## Supported boards
* TTGO T-beam v.0.7
* TTGO T-beam v.1.0
* Lora32 board
## User key functions:
@ -24,3 +26,12 @@ After connection with APRX based DIGI it can be used as KISS-TNC
### long press: on or off the GPS power supply
* if the "FIXED_BEACON_EN" option is enabled in the configuration, a beacon will be sent every set time interval
## Oled screens information
* ((TX)) - position frame sent automatically
* ((RX)) - informs about the received frame
* ((GPSOFF)) - GPS power-off information
* ((GPS ON)) - GPS power-on information
* ((MAN TX)) - information about sending a manually initialized GPS position frame
* ((FIX TX)) - information about the forced manual sending of a frame with the position saved in the configuration when GPS is off or no fix
* ((AUT TX)) - information about sending automatic positioning frame when GPS is turned off
* ((KISSTX)) - information about sending the frame sent by KISS

12
lib/KISS_TO_TNC2/KISS_TO_TNC2.cpp

@ -3,7 +3,7 @@
bool validateTNC2Frame(const String &tnc2FormattedFrame);
String encode_address_ax25(String tnc2Address);
String decode_address_ax25(const String& ax25Address, bool &isLast);
String decode_address_ax25(const String &ax25Address, bool &isLast, bool isRelay);
bool validateKISSFrame(const String &kissFormattedFrame);
@ -113,12 +113,12 @@ String decode_kiss(const String& kissFormattedFrame) {
if (validateKISSFrame(kissFormattedFrame)){
String ax25Frame = decapsulateKISS(kissFormattedFrame);
bool isLast = false;
String dst_addr = decode_address_ax25(ax25Frame.substring(0, 7), isLast);
String src_addr = decode_address_ax25(ax25Frame.substring(7, 14), isLast);
String dst_addr = decode_address_ax25(ax25Frame.substring(0, 7), isLast, false);
String src_addr = decode_address_ax25(ax25Frame.substring(7, 14), isLast, false);
TNC2Frame = src_addr + ">" + dst_addr;
int digi_info_index = 14;
while (!isLast && digi_info_index + 7 < ax25Frame.length()){
String digi_addr = decode_address_ax25(ax25Frame.substring(digi_info_index, digi_info_index+7), isLast);
String digi_addr = decode_address_ax25(ax25Frame.substring(digi_info_index, digi_info_index + 7), isLast, true);
TNC2Frame += ',' + digi_addr;
digi_info_index += 7;
}
@ -162,7 +162,7 @@ String encode_address_ax25(String tnc2Address) {
* @param ax25Address
* @return
*/
String decode_address_ax25(const String& ax25Address, bool &isLast) {
String decode_address_ax25(const String &ax25Address, bool &isLast, bool isRelay) {
String TNCAddress = "";
for (int i = 0; i < 6; ++i) {
uint8_t currentCharacter = ax25Address.charAt(i);
@ -181,7 +181,7 @@ String decode_address_ax25(const String& ax25Address, bool &isLast) {
TNCAddress += '-';
TNCAddress += ssid;
}
if (hasBeenDigipited){
if (isRelay && hasBeenDigipited){
TNCAddress += '*';
}
return TNCAddress;

21
platformio.ini

@ -8,10 +8,7 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = arduino
[env]
monitor_speed = 115200
build_flags = -Wl,--gc-sections,--relax
board_build.partitions = no_ota.csv
@ -33,3 +30,19 @@ lib_deps =
OneWire
#DallasTemperature
#adafruit/Adafruit BME280 Library@^2.1.2
[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = arduino
[env:ttgo-lora32-v2]
platform = espressif32
board = ttgo-lora32-v1
framework = arduino
[env:ttgo-lora32-v1]
platform = espressif32
board = ttgo-lora32-v1
framework = arduino

89
src/TTGO_T-Beam_LoRa_APRS.ino

@ -23,7 +23,7 @@
#include <axp20x.h>
#include "taskGPS.h"
#ifdef KISS_PROTOCOL
#include "taskTNC.h"
#include "taskTNC.h"
#endif
#ifdef ENABLE_WIFI
#include "taskWebServer.h"
@ -37,8 +37,6 @@
// DISPLAY address
#define SSD1306_ADDRESS 0x3C
//other global Variables
// LED for signalling
#ifdef T_BEAM_V1_0
const byte TXLED = 4; //pin number for LED on TX Tracker
@ -135,9 +133,8 @@ tWebServerCfg webServerCfg;
static const adc_atten_t atten = ADC_ATTEN_DB_6;
static const adc_unit_t unit = ADC_UNIT_1;
#ifdef T_BEAM_V1_0
AXP20X_Class axp;
AXP20X_Class axp;
#endif
// checkRX
@ -226,12 +223,11 @@ void prepareAPRSFrame(){
outString += Talt;
}
}else{
outString += aprsLonPreset;
outString += aprsSymbolTable;
outString += aprsLatPreset;
outString += aprsSymbolTable;
outString += aprsLonPreset;
outString += aprsSymbol;
}
outString += aprsComment;
if (showBattery) {
@ -249,7 +245,6 @@ void prepareAPRSFrame(){
void sendpacket(){
batt_read();
prepareAPRSFrame();
loraSend(txPower, TXFREQ, outString); //send the packet, data is in TXbuff from lora_TXStart to lora_TXEnd
}
@ -289,7 +284,6 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
axp.setChgLEDMode(AXP20X_LED_BLINK_4HZ);
#endif
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
@ -328,13 +322,6 @@ String getSatAndBatInfo() {
void displayInvalidGPS() {
writedisplaytext(" " + Tcall, "(TX) at valid GPS", "LAT: not valid", "LON: not valid", "SPD: --- CRS: ---", getSatAndBatInfo(), 1);
#ifdef SHOW_GPS_DATA
Serial.print("(TX) at valid GPS / LAT: not valid / Lon: not valid / SPD: --- / CRS: ---");
Serial.print(" / SAT: ");
Serial.print(String(gps.satellites.value()));
Serial.print(" / BAT: ");
Serial.println(String(BattVolts,1));
#endif
}
#if defined(KISS_PROTOCOL)
@ -382,7 +369,6 @@ void sendTelemetryFrame() {
sendToTNC(telemetryBase + telemetryUnitNames);
sendToTNC(telemetryBase + telemetryEquations);
sendToTNC(telemetryBase + telemetryData);
#else
#endif
}
#endif
@ -574,32 +560,31 @@ void loop() {
}
}
}
//delay(1500);
if(digitalRead(BUTTON)==LOW && key_up == false && millis() >= time_delay && t_lock == false){
t_lock = true;
if(gps_state == true){
gps_state = false;
#ifdef T_BEAM_V1_0
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // GPS OFF
#endif
writedisplaytext("((GPSOFF))","","","","","",1);
next_fixed_beacon = millis() + fix_beacon_interval;
}else{
gps_state = true;
#ifdef T_BEAM_V1_0
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
#endif
writedisplaytext("((GPS ON))","","","","","",1); // GPS ON
}
}
if(digitalRead(BUTTON)==LOW && key_up == false && millis() >= time_delay && t_lock == false){
t_lock = true;
if(gps_state == true){
gps_state = false;
#ifdef T_BEAM_V1_0
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // GPS OFF
#endif
writedisplaytext("((GPSOFF))","","","","","",1);
next_fixed_beacon = millis() + fix_beacon_interval;
}else{
gps_state = true;
#ifdef T_BEAM_V1_0
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
#endif
writedisplaytext("((GPS ON))","","","","","",1); // GPS ON
}
}
if(digitalRead(BUTTON)==HIGH && !key_up){
key_up = true;
t_lock = false;
}
if (fixed_beacon_enabled) {
if (millis() >= next_fixed_beacon && !gps_state) {
next_fixed_beacon = millis() + fix_beacon_interval;
@ -608,7 +593,6 @@ void loop() {
}
}
#ifdef KISS_PROTOCOL
String *TNC2DataFrame = nullptr;
if (tncToSendQueue) {
@ -621,7 +605,6 @@ void loop() {
}
#endif
if (rf95.waitAvailableTimeout(100)) {
#ifdef T_BEAM_V1_0
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
@ -630,6 +613,8 @@ void loop() {
loraReceivedLength = sizeof(lora_RXBUFF); // reset max length before receiving!
if (rf95.recvAPRS(lora_RXBUFF, &loraReceivedLength)) {
loraReceivedFrameString = "";
//int rssi = rf95.lastSNR();
//Serial.println(rssi);
for (int i=0 ; i < loraReceivedLength ; i++) {
loraReceivedFrameString += (char) lora_RXBUFF[i];
}
@ -653,28 +638,22 @@ void loop() {
}
average_speed_final = (average_speed[0]+average_speed[1]+average_speed[2]+average_speed[3]+average_speed[4])/5;
nextTX = (max_time_to_nextTX-min_time_to_nextTX)/(max_speed-min_speed)*(max_speed-average_speed_final)+min_time_to_nextTX;
if (nextTX < min_time_to_nextTX) {nextTX=min_time_to_nextTX;}
if (nextTX > max_time_to_nextTX) {nextTX=max_time_to_nextTX;}
average_course[point_avg_course] = gps.course.deg(); // calculate smart beaconing course
++point_avg_course;
if (point_avg_course>(ANGLE_AVGS-1)) {
point_avg_course=0;
avg_c_y = 0;
avg_c_x = 0;
for (int i=0;i<ANGLE_AVGS;i++) {
avg_c_y += sin(average_course[i]/180*3.1415);
avg_c_x += cos(average_course[i]/180*3.1415);
}
new_course = atan2f(avg_c_y,avg_c_x)*180/3.1415;
if (new_course < 0) {
new_course=360+new_course;
}
if ((old_course < ANGLE) && (new_course > (360-ANGLE))) {
if (abs(new_course-old_course-360)>=ANGLE) {
nextTX = 0;
@ -693,30 +672,13 @@ void loop() {
}
old_course = new_course;
}
if ((millis()<max_time_to_nextTX)&&(lastTX == 0)) {
nextTX = 0;
}
if ( (lastTX+nextTX) <= millis() ) {
if (gps.location.age() < 2000) {
writedisplaytext(" ((TX))","","LAT: "+LatShown,"LON: "+LongShown,"SPD: "+String(gps.speed.kmph(),1)+" CRS: "+String(gps.course.deg(),1),getSatAndBatInfo(),1);
sendpacket();
#ifdef SHOW_GPS_DATA
Serial.print("((TX)) / LAT: ");
Serial.print(LatShown);
Serial.print(" / LON: ");
Serial.print(LongShown);
Serial.print(" / SPD: ");
Serial.print(String(gps.speed.kmph(),1));
Serial.print(" / CRS: ");
Serial.print(String(gps.course.deg(),1));
Serial.print(" / SAT: ");
Serial.print(String(gps.satellites.value()));
Serial.print(" / BAT: ");
Serial.print(String(BattVolts,1));
//digitalWrite(TXLED, LOW);
#endif
} else {
if (millis() > time_to_refresh){
displayInvalidGPS();
@ -769,5 +731,4 @@ void loop() {
#endif
#endif
vTaskDelay(1);
}
// end of main loop
}

1
src/TTGO_T-Beam_LoRa_APRS_config.h

@ -21,7 +21,6 @@
#define SHOW_RX_TIME 2000 // show RX packet for milliseconds (5000 = 5secs)
#define TXFREQ 433.775 // Transmit frequency in MHz
#define TXdbmW 20 // Transmit power in dBm 17-50mW, 18-63mW, 19-80mW, 20-100mW
//#define SHOW_GPS_DATA // uncomment to show on serial port, received data from GPS and debug information
#define ENABLE_BLUETOOTH // bluetooth KISS interface enable
//#define BLUETOOTH_PIN "0000"
//#define ENABLE_TNC_SELF_TELEMETRY

Loading…
Cancel
Save