Ready for decode_kiss and encode_kiss
parent
651d34b044
commit
e50f6476c3
|
@ -1,31 +1,26 @@
|
|||
// http://en.wikipedia.org/wiki/KISS_(TNC)#Special_Characters
|
||||
// http://k4kpk.com/notes-on-aprs-kiss-and-setting-up-a-tnc-x-igate-and-digipeater
|
||||
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef KISS_H
|
||||
#define KISS_H
|
||||
#define KISS_H
|
||||
#define DCD_ON 0x03 // starting decode
|
||||
|
||||
#define FEND 0xC0
|
||||
#define FESC 0xDB
|
||||
#define TFEND 0xDC
|
||||
#define TFESC 0xDD
|
||||
#define FEND 0xC0 // frame END
|
||||
#define FESC 0xDB // frame Escape
|
||||
#define TFEND 0xDC // Transposed Frame End
|
||||
#define TFESC 0xDD // Transposed Frame Escape
|
||||
|
||||
#define CMD_UNKNOWN 0xFE
|
||||
#define CMD_DATA 0x00
|
||||
#define CMD_HARDWARE 0x06
|
||||
#define CMD_UNKNOWN 0xFE
|
||||
#define CMD_DATA 0x00
|
||||
#define CMD_HARDWARE 0x06
|
||||
|
||||
#define HW_RSSI 0x21
|
||||
|
||||
#define CMD_ERROR 0x90
|
||||
#define ERROR_INITRADIO 0x01
|
||||
#define ERROR_TXFAILED 0x02
|
||||
#define ERROR_QUEUE_FULL 0x04
|
||||
#define HW_RSSI 0x21
|
||||
|
||||
size_t frameLength;
|
||||
bool inFrame = false;
|
||||
bool escape = false;
|
||||
bool SERIAL_READING = false;
|
||||
uint8_t command = CMD_UNKNOWN;
|
||||
uint32_t lastSerialRead = 0;
|
||||
uint32_t serialReadTimeout = 25;
|
||||
|
||||
#endif
|
||||
#define CMD_ERROR 0x90
|
||||
#define ERROR_INITRADIO 0x01
|
||||
#define ERROR_TXFAILED 0x02
|
||||
#define ERROR_QUEUE_FULL 0x04
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <Adafruit_SPITFT_Macros.h>
|
||||
#include <gfxfont.h>
|
||||
#include <axp20x.h>
|
||||
#include "KISS.h"
|
||||
|
||||
// I2C LINES
|
||||
#define I2C_SDA 21
|
||||
|
@ -283,17 +284,21 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
|
|||
smartDelay(warten);
|
||||
}
|
||||
|
||||
//void blinker(int counter) {
|
||||
// for (int i = 0; i < (counter-1); i++) {
|
||||
// digitalWrite(TXLED, HIGH); // turn blue LED ON
|
||||
// smartDelay(150);
|
||||
// digitalWrite(TXLED, LOW); // turn blue LED OFF
|
||||
// smartDelay(100);
|
||||
// }
|
||||
// digitalWrite(TXLED, HIGH); // turn blue LED ON
|
||||
// smartDelay(150);
|
||||
// digitalWrite(TXLED, LOW); // turn blue LED OFF
|
||||
//}
|
||||
void encode_address(){
|
||||
|
||||
}
|
||||
|
||||
void decode_address(){
|
||||
|
||||
}
|
||||
|
||||
void encode_kiss(){
|
||||
|
||||
}
|
||||
|
||||
void decode_kiss(){
|
||||
|
||||
}
|
||||
|
||||
// + SETUP --------------------------------------------------------------+//
|
||||
|
||||
|
@ -310,9 +315,9 @@ void setup(){
|
|||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
|
||||
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
|
||||
Serial.println("LoRa-APRS / Init / AXP192 Begin PASS");
|
||||
//Serial.println("LoRa-APRS / Init / AXP192 Begin PASS");
|
||||
} else {
|
||||
Serial.println("LoRa-APRS / Init / AXP192 Begin FAIL");
|
||||
//Serial.println("LoRa-APRS / Init / AXP192 Begin FAIL");
|
||||
}
|
||||
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
|
@ -327,20 +332,20 @@ void setup(){
|
|||
}
|
||||
|
||||
writedisplaytext("LoRa-APRS","","Init:","Display OK!","","",1000);
|
||||
Serial.println("LoRa-APRS / Init / Display OK! ");
|
||||
//Serial.println("LoRa-APRS / Init / Display OK! ");
|
||||
Tcall = CALLSIGN;
|
||||
//LongFixed = LONGITUDE_PRESET;
|
||||
//LatFixed = LATIDUDE_PRESET;
|
||||
TxSymbol = APRS_SYMBOL;
|
||||
Serial.println("LoRa-APRS / Call="+Tcall+" / TxSymbol="+TxSymbol);
|
||||
//Serial.println("LoRa-APRS / Call="+Tcall+" / TxSymbol="+TxSymbol);
|
||||
//int start_button_pressed = millis();
|
||||
writedisplaytext("LoRa-APRS","","Init:","Mode","TRACKER","",1000);
|
||||
Serial.println("LoRa-APRS / Init / Mode / TRACKER");
|
||||
//Serial.println("LoRa-APRS / Init / Mode / TRACKER");
|
||||
//blinker(1);
|
||||
|
||||
if (!rf95.init()) {
|
||||
writedisplaytext("LoRa-APRS","","Init:","RF95 FAILED!",":-(","",250);
|
||||
Serial.println("LoRa-APRS / Init / RF95 FAILED!");
|
||||
//Serial.println("LoRa-APRS / Init / RF95 FAILED!");
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
|
@ -350,36 +355,42 @@ void setup(){
|
|||
// digitalWrite(TXLED, HIGH);
|
||||
writedisplaytext("LoRa-APRS","","Init:","RF95 OK!","","",250);
|
||||
// digitalWrite(TXLED, LOW);
|
||||
Serial.println("LoRa-APRS / Init / RF95 OK!");
|
||||
//Serial.println("LoRa-APRS / Init / RF95 OK!");
|
||||
ss.begin(GPSBaud, SERIAL_8N1, TXPin, RXPin); //Startup HW serial for GPS
|
||||
writedisplaytext("LoRa-APRS","","Init:","GPS Serial OK!","","",250);
|
||||
Serial.println("LoRa-APRS / Init / GPS Serial OK!");
|
||||
//Serial.println("LoRa-APRS / Init / GPS Serial OK!");
|
||||
writedisplaytext(" "+Tcall,"","Init:","Waiting for GPS","","",250);
|
||||
Serial.println("LoRa-APRS / Init / Waiting for GPS");
|
||||
//Serial.println("LoRa-APRS / Init / Waiting for GPS");
|
||||
while (millis() < 5000 && gps.charsProcessed() < 10) {}
|
||||
if (millis() > 5000 && gps.charsProcessed() < 10) {
|
||||
writedisplaytext(" "+Tcall,"","Init:","ERROR!","No GPS data!","Please restart TTGO",0);
|
||||
Serial.println("LoRa-APRS / Init / GPS ERROR - no GPS data - please RESTART TTGO");
|
||||
//Serial.println("LoRa-APRS / Init / GPS ERROR - no GPS data - please RESTART TTGO");
|
||||
while (true) {
|
||||
//blinker(1);
|
||||
}
|
||||
}
|
||||
writedisplaytext(" "+Tcall,"","Init:","Data from GPS OK!","","",250);
|
||||
Serial.println("LoRa-APRS / Init / Data from GPS OK!");
|
||||
//Serial.println("LoRa-APRS / Init / Data from GPS OK!");
|
||||
writedisplaytext("LoRa-APRS","","Init:","ADC OK!","BAT: "+String(axp.getBattVoltage()/1000,1),"",250);
|
||||
Serial.print("LoRa-APRS / Init / ADC OK! / BAT: ");
|
||||
Serial.println(String(axp.getBattVoltage()/1000,1));
|
||||
//Serial.print("LoRa-APRS / Init / ADC OK! / BAT: ");
|
||||
//Serial.println(String(axp.getBattVoltage()/1000,1));
|
||||
rf95.setFrequency(433.775);
|
||||
rf95.setModemConfig(BG_RF95::Bw125Cr45Sf4096); // hard coded because of double definition
|
||||
rf95.setTxPower(5);
|
||||
rf95.setTxPower(20); // was 5
|
||||
delay(250);
|
||||
Serial.print("LoRa-APRS / Init");
|
||||
//Serial.print("LoRa-APRS / Init");
|
||||
writedisplaytext("LoRa-APRS","","Init:","FINISHED OK!"," =:-) ","",250);
|
||||
Serial.println("LoRa-APRS / Init / FINISHED OK! / =:-)");
|
||||
//Serial.println("LoRa-APRS / Init / FINISHED OK! / =:-)");
|
||||
writedisplaytext("","","","","","",0);
|
||||
//blinker(5);
|
||||
|
||||
#ifdef KISS_PROTOCOLL
|
||||
//Serial.write(DCD_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// +---------------------------------------------------------------------+//
|
||||
// + MAINLOOP -----------------------------------------------------------+//
|
||||
// +---------------------------------------------------------------------+//
|
||||
|
@ -392,11 +403,17 @@ void loop() {
|
|||
while (Serial.available() > 0 ){
|
||||
char character = Serial.read();
|
||||
content.concat(character);
|
||||
}
|
||||
}
|
||||
|
||||
if(content != ""){
|
||||
//Serial.println(content);
|
||||
//loraSend(lora_TXStart, lora_TXEnd, 60, 255, 1, 10, TXdbmW, TXFREQ, content);
|
||||
#ifdef TEXT_PROTOCOLL
|
||||
loraSend(lora_TXStart, lora_TXEnd, 60, 255, 1, 10, TXdbmW, TXFREQ, content);
|
||||
#endif
|
||||
#ifdef KISS_PROTOCOLL
|
||||
decode_kiss();
|
||||
loraSend(lora_TXStart, lora_TXEnd, 60, 255, 1, 10, TXdbmW, TXFREQ, content);
|
||||
#endif
|
||||
content = "";
|
||||
}
|
||||
|
||||
|
@ -407,9 +424,13 @@ void loop() {
|
|||
InputString = "";
|
||||
for ( int i=0 ; i < len ; i++) {
|
||||
InputString += (char) lora_RXBUFF[i];
|
||||
}
|
||||
Serial.println(InputString);
|
||||
//blinker(3);
|
||||
}
|
||||
#ifdef TEXT_PROTOCOLL
|
||||
Serial.println(InputString);
|
||||
#endif
|
||||
#ifdef KISS_PROTOCOLL
|
||||
//encode_kiss(InputString);
|
||||
#endif
|
||||
writedisplaytext(" ((RX))","",InputString,"","","",SHOW_RX_TIME);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// licensed under CC BY-NC-SA
|
||||
|
||||
// USER DATA - USE THESE LINES TO MODIFY YOUR PREFERENCES
|
||||
#define KISS_PROTOCOLL // If enabled send and receive data in SIMPLE KISS format
|
||||
//#define TEXT_PROTOCOLL // TEXT outpu data
|
||||
#define CALLSIGN "SQ9MDD-11" // enter your callsign here - less then 6 letter callsigns please add "spaces" so total length is 6 (without SSID)
|
||||
#define LONGITUDE_PRESET "02055.59E" // please in APRS notation DDDMM.mmE or DDDMM.mmW
|
||||
#define LATIDUDE_PRESET "5215.02N" // please in APRS notation DDMM.mmN or DDMM.mmS
|
||||
|
|
Loading…
Reference in New Issue