Merge pull request #8 from oe3cjb/base91_coding

Base91 coding
pull/10/head
oe3cjb 2020-12-13 09:51:11 +01:00 zatwierdzone przez GitHub
commit f1541cf03e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 253 dodań i 95 usunięć

Wyświetl plik

@ -41,6 +41,8 @@ Now the DS18B20 is supported as well - uncomment line 31: // #define DS18B20
by uncommenting <b>// #define SHOW_RX_PACKET</b> the tracker shows received LoRa APRS packets in raw format for the time in milliseconds defined in SHOW_RX_TIME - both in ...config.h<br>
<br>
<b>new features:</b><br>
- compressed packets in tracker mode
- symbol RV added
- show RX packets
- DS18B20 support (setable in config.h)
- GPS switched off in WX_FIXED mode (only available with boards with HW-Version >=V1.0)

Wyświetl plik

@ -11,9 +11,14 @@
//
// licensed under CC BY-NC-SA
//
// version: V1.3
// last update: 27.08.2020
// change history
// symbol RV added
// compressed packets in tracker mode (base91)
//
// version: V1.2
// last update: 02.01.2020
//
// change history
// added course change to smart Beaconing
// code cleaned
@ -214,6 +219,8 @@ float avg_c_y, avg_c_x;
float millis_angle[ANGLE_AVGS];
#endif
#define TX_BASE91 // if BASE91 is set, packets will be sent compressed (in TRACKER-mode only)
static const adc_atten_t atten = ADC_ATTEN_DB_6;
static const adc_unit_t unit = ADC_UNIT_1;
@ -736,14 +743,29 @@ static void smartDelay(unsigned long ms)
} while (millis() - start < ms);
}
char *ax25_base91enc(char *s, uint8_t n, uint32_t v)
{
/* Creates a Base-91 representation of the value in v in the string */
/* pointed to by s, n-characters long. String length should be n+1. */
for(s += n, *s = '\0'; n; n--)
{
*(--s) = v % 91 + 33;
v /= 91;
}
return(s);
}
/////////////////////////////////////////////////////////////////////////////////////////
//@APA Recalc GPS Position == generate APRS string
void recalcGPS(){
String Ns, Ew, helper;
char helper_base91[] = {"0000\0"};
float Tlat=48.2012, Tlon=15.6361;
int i, Talt, lenalt;
uint32_t aprs_lat, aprs_lon;
float Lat=0.0;
float Lon=0.0;
float Tspeed=0, Tcourse=0;
@ -771,6 +793,10 @@ void recalcGPS(){
if(Tlon < 0) { Tlon= -Tlon; }
unsigned int Deg_Lon = Tlon;
Lon = 100*(Deg_Lon) + (Tlon - Deg_Lon)*60;
aprs_lat = 900000000 - Tlat * 10000000;
aprs_lat = aprs_lat / 26 - aprs_lat / 2710 + aprs_lat / 15384615;
aprs_lon = 900000000 + Tlon * 10000000 / 2;
aprs_lon = aprs_lon / 26 - aprs_lon / 2710 + aprs_lon / 15384615;
}
outString = "";
@ -796,6 +822,10 @@ switch(tracker_mode) {
outString += wxTable;
outString += LongFixed;
outString += wxSymbol;
outString += ".../...g...t";
if (tempf < 0) { // negative Werte erstellen
outString += "-";
@ -814,6 +844,7 @@ switch(tracker_mode) {
helper.trim();
outString += helper;
outString += "b......DHT22";
outString += MY_COMMENT;
break;
case WX_TRACKER:
if (wx) {
@ -825,22 +856,46 @@ switch(tracker_mode) {
hum = dht.getHumidity();
tempf = dht.getTemperature()*9/5+32;
#endif
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
if (wxTcall.charAt(i) != ' ') {
outString += wxTcall.charAt(i);
#ifndef TX_BASE91
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
if (wxTcall.charAt(i) != ' ') {
outString += wxTcall.charAt(i);
}
}
}
// outString = (wxTcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += wxTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += wxSymbol;
// outString = (wxTcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += wxTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += wxSymbol;
#else
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
// outString = (Tcall);
outString += ">APRS:!/";
ax25_base91enc(helper_base91, 4, aprs_lat);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
ax25_base91enc(helper_base91, 4, aprs_lon);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
outString += wxSymbol;
ax25_base91enc(helper_base91, 1, (uint32_t) Tcourse/4 );
outString += helper_base91[0];
ax25_base91enc(helper_base91, 1, (uint32_t) (log1p(Tspeed)/0.07696));
outString += helper_base91[0];
outString += "\x48";
#endif
outString += ".../...g...t";
if (tempf < 0) { // negative Werte erstellen
outString += "-";
@ -859,29 +914,58 @@ switch(tracker_mode) {
helper.trim();
outString += helper;
outString += "b......DHT22";
outString += MY_COMMENT;
wx = !wx;
} else {
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
#ifndef TX_BASE91
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
}
// outString = (Tcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += sTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += TxSymbol;
outString += "/A=";
outString += Altx;
outString += " Batt=";
outString += String(BattVolts,2);
outString += ("V");
// outString = (Tcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += sTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += TxSymbol;
#else
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
// outString = (Tcall);
outString += ">APRS:!/";
ax25_base91enc(helper_base91, 4, aprs_lat);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
ax25_base91enc(helper_base91, 4, aprs_lon);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
outString += TxSymbol;
ax25_base91enc(helper_base91, 1, (uint32_t) Tcourse/4 );
outString += helper_base91[0];
ax25_base91enc(helper_base91, 1, (uint32_t) (log1p(Tspeed)/0.07696));
outString += helper_base91[0];
outString += "\x48";
#endif
#ifdef HW_COMMENT
outString += "/A=";
outString += Altx;
outString += " Batt=";
outString += String(BattVolts,2);
outString += ("V");
#endif
outString += MY_COMMENT;
wx = !wx;
}
break;
@ -894,22 +978,48 @@ case WX_MOVE:
hum = dht.getHumidity();
tempf = dht.getTemperature()*9/5+32;
#endif
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
if (wxTcall.charAt(i) != ' ') {
outString += wxTcall.charAt(i);
#ifndef TX_BASE91
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
if (wxTcall.charAt(i) != ' ') {
outString += wxTcall.charAt(i);
}
}
}
// outString = (wxTcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += wxTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += wxSymbol;
// outString = (wxTcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += wxTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += wxSymbol;
#else
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
// outString = (Tcall);
outString += ">APRS:!/";
ax25_base91enc(helper_base91, 4, aprs_lat);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
ax25_base91enc(helper_base91, 4, aprs_lon);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
outString += wxSymbol;
ax25_base91enc(helper_base91, 1, (uint32_t) Tcourse/4 );
outString += helper_base91[0];
ax25_base91enc(helper_base91, 1, (uint32_t) (log1p(Tspeed)/0.07696));
outString += helper_base91[0];
outString += "\x48";
#endif
outString += ".../...g...t";
if (tempf < 0) { // negative Werte erstellen
outString += "-";
@ -928,51 +1038,87 @@ case WX_MOVE:
helper.trim();
outString += helper;
outString += "b......DHT22";
outString += MY_COMMENT;
break;
case TRACKER:
default:
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
#ifndef TX_BASE91
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
}
// outString = (Tcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += sTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += TxSymbol;
if(Tcourse<100) {outString += "0"; }
if(Tcourse<10) {outString += "0"; }
Coursex = String(Tcourse,0);
Coursex.replace(" ","");
outString += Coursex;
outString += "/";
if(Tspeed<100) {outString += "0"; }
if(Tspeed<10) {outString += "0"; }
Speedx = String(Tspeed,0);
Speedx.replace(" ","");
outString += Speedx;
outString += "/A=";
outString += Altx;
outString += " Batt=";
outString += String(BattVolts,2);
outString += ("V");
#ifdef DEBUG
outString += (" Debug: ");
outString += TxRoot;
#endif
// outString = (Tcall);
outString += ">APRS:!";
if(Tlat<10) {outString += "0"; }
outString += String(Lat,2);
outString += Ns;
outString += sTable;
if(Tlon<100) {outString += "0"; }
if(Tlon<10) {outString += "0"; }
outString += String(Lon,2);
outString += Ew;
outString += TxSymbol;
if(Tcourse<100) {outString += "0"; }
if(Tcourse<10) {outString += "0"; }
Coursex = String(Tcourse,0);
Coursex.replace(" ","");
outString += Coursex;
outString += "/";
if(Tspeed<100) {outString += "0"; }
if(Tspeed<10) {outString += "0"; }
Speedx = String(Tspeed,0);
Speedx.replace(" ","");
outString += Speedx;
#ifdef HW_COMMENT
outString += "/A=";
outString += Altx;
outString += " Batt=";
outString += String(BattVolts,2);
outString += ("V");
#endif
outString += MY_COMMENT;
#ifdef DEBUG
outString += (" Debug: ");
outString += TxRoot;
#endif
#else
for (i=0; i<Tcall.length();++i){ // remove unneeded "spaces" from callsign field
if (Tcall.charAt(i) != ' ') {
outString += Tcall.charAt(i);
}
}
// outString = (Tcall);
outString += ">APRS:!/";
ax25_base91enc(helper_base91, 4, aprs_lat);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
ax25_base91enc(helper_base91, 4, aprs_lon);
for (i=0; i<4; i++) {
outString += helper_base91[i];
}
outString += TxSymbol;
ax25_base91enc(helper_base91, 1, (uint32_t) Tcourse/4 );
outString += helper_base91[0];
ax25_base91enc(helper_base91, 1, (uint32_t) (log1p(Tspeed)/0.07696));
outString += helper_base91[0];
outString += "\x48";
#ifdef HW_COMMENT
outString += "/A=";
outString += Altx;
outString += " Batt=";
outString += String(BattVolts,2);
outString += ("V");
#endif
outString += MY_COMMENT;
#endif
Serial.print("outString=");
// Speedx = String(Tspeed,0);
// Speedx.replace(" ","");
Serial.println(outString);
// Serial.println("=");
break;
break;
}
}
@ -1079,9 +1225,9 @@ void setup_data(void) {
char werte_call[37] = {' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0'};
String werte_SSID[16] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"};
char werte_latlon[14] = {'0','1','2','3','4','5','6','7','8','9','N','S','E','W'};
String werte_TxSymbol_text[5] = {"WX Station"," Car"," Person"," Bicycle","Motorcycle"};
String werte_TxSymbol_symbol[5] = {"_",">","[","b","<"};
String werte_weiter_symbol[5] = {"yes","no"};
String werte_TxSymbol_text[6] = {"WX Station"," Car"," Person"," Bicycle","Motorcycle"," RV"};
String werte_TxSymbol_symbol[6] = {"_",">","[","b","<","R"};
String werte_weiter_symbol[2] = {"yes","no"};
int8_t pos_in_string;
int8_t pos_ssid;
bool key_pressed = false;
@ -1112,7 +1258,7 @@ void setup_data(void) {
break;
}
++pos_ssid;
if (pos_ssid>=5) {pos_ssid=0;}
if (pos_ssid>=6) {pos_ssid=0;}
}
// smartDelay(500);

Wyświetl plik

@ -10,6 +10,12 @@
//
// licensed under CC BY-NC-SA
//
// version: V1.3
// last update: 27.08.2020
// change history
// symbol RV added
// compressed packets in tracker mode (base91)
//
// version: V1.1beta
// last update: 22.11.2019
//
@ -24,8 +30,8 @@
// first released version
// SET HW version
// #define T_BEAM_V1_0 // use this for newer Boards AKA Rev1 (second board release)
#define T_BEAM_V0_7 // use this for older Boards AKA Rev0.x (first board release)
#define T_BEAM_V1_0 // use this for newer Boards AKA Rev1 (second board release)
// #define T_BEAM_V0_7 // use this for older Boards AKA Rev0.x (first board release)
// SET temperature sensor type
// #define DS18B20 // use this if you use DS18B20, default ist DHT22
@ -34,8 +40,8 @@
// IF NOT CHANGED you have to go through the configuration routine at first boot up of the TTGO T-Beam
// #define DONT_USE_FLASH_MEMORY // uncomment if you don't want to use Flashmemory - instead data below must be corrected
#define CALLSIGN "OE1XYZ-0" // enter your callsign here - less then 6 letter callsigns please add "spaces" so total length is 6 (without SSID)
#define WX_CALLSIGN "OE1XYZ-0" // use same callsign but you can use different SSID
#define CALLSIGN "OE3CJB-11" // enter your callsign here - less then 6 letter callsigns please add "spaces" so total length is 6 (without SSID)
#define WX_CALLSIGN "OE3CJB-11" // use same callsign but you can use different SSID
#define LONGITUDE_PRESET "01539.85E" // please in APRS notation DDDMM.mmE or DDDMM.mmW
#define LATIDUDE_PRESET "4813.62N" // please in APRS notation DDMM.mmN or DDMM.mmS
#define APRS_SYMBOL ">" // other symbols are
@ -44,6 +50,10 @@
// "[" => RUNNER
// "b" => BICYCLE
// "<" => MOTORCYCLE
// "R" => Recreation Vehicle
// #define HW_COMMENT // send Alt und Battery Voltage, UNcomment if don't want to send it
#define MY_COMMENT "" // add your coment here - if empty then no comment is sent
// #define MY_COMMENT "TTGO by OE3CJB" // add your coment here - if empty then no comment is sent
// TRANSMIT INTERVAL
unsigned long max_time_to_nextTX = 180000L; // set here MAXIMUM time in ms(!) for smart beaconing - minimum time is always 1 min = 60 secs = 60000L !!!