Browse Source

bluetooth support

pull/5/head
Łukasz Nidecki 1 year ago
parent
commit
11f3db9147
  1. 47
      src/TTGO_T-Beam_LoRa_APRS.ino
  2. 1
      src/TTGO_T-Beam_LoRa_APRS_config.h

47
src/TTGO_T-Beam_LoRa_APRS.ino

@ -23,6 +23,10 @@
#include <axp20x.h>
#include <KISS_TO_TNC2.h>
#ifdef ENABLE_BLUETOOTH
#include "BluetoothSerial.h"
#endif
// I2C LINES
#define I2C_SDA 21
#define I2C_SCL 22
@ -108,6 +112,8 @@ void setup_data(void);
void displayInvalidGPS();
void handleKISSData(char character);
// SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device
HardwareSerial gpsSerial(1); // TTGO has HW serial
TinyGPSPlus gps; // The TinyGPS++ object
@ -124,6 +130,10 @@ BG_RF95 rf95(18, 26); // TTGO T-Beam has NSS @ Pin 18 and Interrupt IO @
#define OLED_RESET 4 // not used
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
#ifdef ENABLE_BLUETOOTH
BluetoothSerial SerialBT;
#endif
// + FUNCTIONS-----------------------------------------------------------+//
// This custom version of delay() ensures that the gps object
@ -226,7 +236,13 @@ void recalcGPS(){
#endif
#ifdef KISS_PROTOCOLL
Serial.print(encode_kiss(outString));
#else
#ifdef ENABLE_BLUETOOTH
if (SerialBT.connected()){
SerialBT.print(encode_kiss(outString));
}
#endif
#else
Serial.println(outString);
#endif
}
@ -356,6 +372,10 @@ void setup(){
rf95.setModemConfig(BG_RF95::Bw125Cr45Sf4096); // hard coded because of double definition
rf95.setTxPower(20); // was 5
delay(250);
#ifdef ENABLE_BLUETOOTH
SerialBT.begin(String("TTGO LORA APRS ") + CALLSIGN);
writedisplaytext("LoRa-APRS","","Init:","BT OK!","","",250);
#endif
writedisplaytext("LoRa-APRS","","Init:","FINISHED OK!"," =:-) ","",250);
writedisplaytext("","","","","","",0);
}
@ -372,13 +392,17 @@ void loop() {
#ifdef KISS_PROTOCOLL
while (Serial.available() > 0 ){
char character = Serial.read();
inTNCData.concat(character);
if (character == (char)FEND && inTNCData.length() > 3){
writedisplaytext("(KISSTX))","","","","","",1);
loraSend(lora_TXStart, lora_TXEnd, 60, 255, 1, 10, TXdbmW, TXFREQ, decode_kiss(inTNCData));
inTNCData = "";
}
handleKISSData(character);
}
#ifdef ENABLE_BLUETOOTH
if (SerialBT.connected()) {
while (SerialBT.available() > 0 ){
char character = SerialBT.read();
handleKISSData(character);
}
}
#endif
#endif
if (rf95.waitAvailableTimeout(100)) {
@ -489,6 +513,15 @@ void loop() {
}
}
void handleKISSData(char character) {
inTNCData.concat(character);
if (character == (char)FEND && inTNCData.length() > 3){
writedisplaytext("(KISSTX))","","","","","",1);
loraSend(lora_TXStart, lora_TXEnd, 60, 255, 1, 10, TXdbmW, TXFREQ, decode_kiss(inTNCData));
inTNCData = "";
}
}
void displayInvalidGPS() {
writedisplaytext(" " + Tcall, "(TX) at valid GPS", "LAT: not valid", "LON: not valid", "SPD: --- CRS: ---", "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V", 1);
#ifdef SHOW_GPS_DATA

1
src/TTGO_T-Beam_LoRa_APRS_config.h

@ -18,5 +18,6 @@
#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
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 !!!
Loading…
Cancel
Save