mirror of https://github.com/SQ9MDD/ESP32IGate.git
Add RF Module and Edit IGate APRSC Supoort
This commit is contained in:
parent
9865aea668
commit
222e352c3d
|
|
@ -124,3 +124,6 @@ for Handheld
|
||||||
|
|
||||||
## ESP32 Flash Download Tools
|
## ESP32 Flash Download Tools
|
||||||
https://www.espressif.com/en/support/download/other-tools
|
https://www.espressif.com/en/support/download/other-tools
|
||||||
|
|
||||||
|
## HITH
|
||||||
|
This project implement by APRS text (TNC2 Raw) only,It not support null string(0x00) in the package.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef DIGIREPEATER_H
|
||||||
|
#define DIGIREPEATER_H
|
||||||
|
|
||||||
|
#include <AX25.h>
|
||||||
|
|
||||||
|
int digiProcess(AX25Msg &Packet);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef IGATE_H
|
||||||
|
#define IGATE_H
|
||||||
|
|
||||||
|
#include <LibAPRSesp.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
#include <AX25.h>
|
||||||
|
|
||||||
|
int igateProcess(AX25Msg &Packet);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -10,33 +10,40 @@
|
||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
#define VERSION "0.5a"
|
#define VERSION "0.6"
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
//#define DEBUG_IS
|
//#define DEBUG_IS
|
||||||
|
|
||||||
//#define SDCARD
|
//#define SDCARD
|
||||||
//#define SA818
|
//#define SA818
|
||||||
|
//#define SR_FRS
|
||||||
|
|
||||||
#define WIFI_OFF_FIX 0
|
#ifdef SR_FRS
|
||||||
#define WIFI_AP_FIX 1
|
#ifndef SA818
|
||||||
#define WIFI_STA_FIX 2
|
#define SA818
|
||||||
#define WIFI_AP_STA_FIX 3
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IMPLEMENTATION FIFO
|
#define WIFI_OFF_FIX 0
|
||||||
|
#define WIFI_AP_FIX 1
|
||||||
|
#define WIFI_STA_FIX 2
|
||||||
|
#define WIFI_AP_STA_FIX 3
|
||||||
|
|
||||||
#define TZ 0 // (utc+) TZ in hours
|
#define IMPLEMENTATION FIFO
|
||||||
#define DST_MN 0 // use 60mn for summer time in some countries
|
|
||||||
#define TZ_MN ((TZ)*60)
|
#define TZ 0 // (utc+) TZ in hours
|
||||||
#define TZ_SEC ((TZ)*3600)
|
#define DST_MN 0 // use 60mn for summer time in some countries
|
||||||
#define DST_SEC ((DST_MN)*60)
|
#define TZ_MN ((TZ)*60)
|
||||||
|
#define TZ_SEC ((TZ)*3600)
|
||||||
|
#define DST_SEC ((DST_MN)*60)
|
||||||
|
|
||||||
#define FORMAT_SPIFFS_IF_FAILED true
|
#define FORMAT_SPIFFS_IF_FAILED true
|
||||||
|
|
||||||
#define PKGLISTSIZE 10
|
#define PKGLISTSIZE 10
|
||||||
#define PKGTXSIZE 5
|
#define PKGTXSIZE 5
|
||||||
|
|
||||||
const int timeZone = 7; // Bangkok
|
const int timeZone = 7; // Bangkok
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
|
|
@ -59,12 +66,13 @@ enum M17Flags
|
||||||
CONNECTED_RO = 1 << 6
|
CONNECTED_RO = 1 << 6
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Config_Struct {
|
typedef struct Config_Struct
|
||||||
|
{
|
||||||
bool synctime;
|
bool synctime;
|
||||||
bool aprs;
|
bool aprs;
|
||||||
bool wifi_client;
|
bool wifi_client;
|
||||||
bool wifi;
|
bool wifi;
|
||||||
char wifi_mode; //WIFI_AP,WIFI_STA,WIFI_AP_STA,WIFI_OFF
|
char wifi_mode; // WIFI_AP,WIFI_STA,WIFI_AP_STA,WIFI_OFF
|
||||||
char wifi_ch;
|
char wifi_ch;
|
||||||
float gps_lat;
|
float gps_lat;
|
||||||
float gps_lon;
|
float gps_lon;
|
||||||
|
|
@ -116,10 +124,11 @@ typedef struct Config_Struct {
|
||||||
uint8_t sql_level;
|
uint8_t sql_level;
|
||||||
bool rf_power;
|
bool rf_power;
|
||||||
uint8_t volume;
|
uint8_t volume;
|
||||||
#endif
|
#endif
|
||||||
}Configuration;
|
} Configuration;
|
||||||
|
|
||||||
typedef struct igateTLM_struct {
|
typedef struct igateTLM_struct
|
||||||
|
{
|
||||||
uint16_t Sequence;
|
uint16_t Sequence;
|
||||||
unsigned long ParmTimeout;
|
unsigned long ParmTimeout;
|
||||||
unsigned long TeleTimeout;
|
unsigned long TeleTimeout;
|
||||||
|
|
@ -128,18 +137,20 @@ typedef struct igateTLM_struct {
|
||||||
uint8_t RX;
|
uint8_t RX;
|
||||||
uint8_t TX;
|
uint8_t TX;
|
||||||
uint8_t DROP;
|
uint8_t DROP;
|
||||||
}igateTLMType;
|
} igateTLMType;
|
||||||
|
|
||||||
typedef struct pkgListStruct {
|
typedef struct pkgListStruct
|
||||||
|
{
|
||||||
time_t time;
|
time_t time;
|
||||||
char calsign[11];
|
char calsign[11];
|
||||||
char ssid[5];
|
char ssid[5];
|
||||||
unsigned int pkg;
|
unsigned int pkg;
|
||||||
bool type;
|
bool type;
|
||||||
uint8_t symbol;
|
uint8_t symbol;
|
||||||
}pkgListType;
|
} pkgListType;
|
||||||
|
|
||||||
typedef struct statisticStruct {
|
typedef struct statisticStruct
|
||||||
|
{
|
||||||
uint32_t allCount;
|
uint32_t allCount;
|
||||||
uint32_t tncCount;
|
uint32_t tncCount;
|
||||||
uint32_t isCount;
|
uint32_t isCount;
|
||||||
|
|
@ -150,38 +161,40 @@ typedef struct statisticStruct {
|
||||||
uint32_t dropCount;
|
uint32_t dropCount;
|
||||||
uint32_t rf2inet;
|
uint32_t rf2inet;
|
||||||
uint32_t inet2rf;
|
uint32_t inet2rf;
|
||||||
}statusType;
|
} statusType;
|
||||||
|
|
||||||
typedef struct digiTLM_struct{
|
typedef struct digiTLM_struct
|
||||||
unsigned int Sequence;
|
{
|
||||||
unsigned int ParmTimeout;
|
unsigned int Sequence;
|
||||||
unsigned int TeleTimeout;
|
unsigned int ParmTimeout;
|
||||||
unsigned char RxPkts;
|
unsigned int TeleTimeout;
|
||||||
unsigned char TxPkts;
|
unsigned char RxPkts;
|
||||||
unsigned char DropRx;
|
unsigned char TxPkts;
|
||||||
unsigned char ErPkts;
|
unsigned char DropRx;
|
||||||
}digiTLMType;
|
unsigned char ErPkts;
|
||||||
|
} digiTLMType;
|
||||||
|
|
||||||
typedef struct txQueue_struct{
|
typedef struct txQueue_struct
|
||||||
|
{
|
||||||
bool Active;
|
bool Active;
|
||||||
long timeStamp;
|
long timeStamp;
|
||||||
int Delay;
|
int Delay;
|
||||||
char Info[300];
|
char Info[300];
|
||||||
}txQueueType;
|
} txQueueType;
|
||||||
|
|
||||||
const char PARM[] = { "PARM.RF->INET,INET->RF,RxPkts,TxPkts,IGateDropRx" };
|
const char PARM[] = {"PARM.RF->INET,INET->RF,RxPkts,TxPkts,IGateDropRx"};
|
||||||
const char UNIT[] = { "UNIT.Pkts,Pkts,Pkts,Pkts,Pkts" };
|
const char UNIT[] = {"UNIT.Pkts,Pkts,Pkts,Pkts,Pkts"};
|
||||||
const char EQNS[] = { "EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0" };
|
const char EQNS[] = {"EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0"};
|
||||||
|
|
||||||
const float ctcss[] = {0,67,71.9,74.4,77,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100,103.5,107.2,110.9,114.8,118.8,123,127.3,131.8,136.5,141.3,146.2,151.4,156.7,162.2,167.9,173.8,179.9,186.2,192.8,203.5,210.7,218.1,225.7,233.6,241.8,250.3};
|
const float ctcss[] = {0, 67, 71.9, 74.4, 77, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, 97.4, 100, 103.5, 107.2, 110.9, 114.8, 118.8, 123, 127.3, 131.8, 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, 192.8, 203.5, 210.7, 218.1, 225.7, 233.6, 241.8, 250.3};
|
||||||
const float wifiPwr[12][2]={{-4,-1},{8,2},{20,5},{28,7},{34,8.5},{44,11},{52,13},{60,15},{68,17},{74,18.5},{76,19},{78,19.5}};
|
const float wifiPwr[12][2] = {{-4, -1}, {8, 2}, {20, 5}, {28, 7}, {34, 8.5}, {44, 11}, {52, 13}, {60, 15}, {68, 17}, {74, 18.5}, {76, 19}, {78, 19.5}};
|
||||||
|
|
||||||
void saveEEPROM();
|
void saveEEPROM();
|
||||||
void defaultConfig();
|
void defaultConfig();
|
||||||
String getValue(String data, char separator, int index);
|
String getValue(String data, char separator, int index);
|
||||||
boolean isValidNumber(String str);
|
boolean isValidNumber(String str);
|
||||||
void taskAPRS(void * pvParameters);
|
void taskAPRS(void *pvParameters);
|
||||||
void taskNetwork(void * pvParameters);
|
void taskNetwork(void *pvParameters);
|
||||||
void sort(pkgListType a[], int size);
|
void sort(pkgListType a[], int size);
|
||||||
void sortPkgDesc(pkgListType a[], int size);
|
void sortPkgDesc(pkgListType a[], int size);
|
||||||
int processPacket(String &tnc2);
|
int processPacket(String &tnc2);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,6 @@ void listDir(fs::FS& fs, const char* dirname, uint8_t levels);
|
||||||
void webService();
|
void webService();
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
void handle_radio();
|
void handle_radio();
|
||||||
extern void SA818_INIT(uint8_t HL);
|
extern void SA818_INIT(bool boot);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef PROTOCOL_AX25_H
|
#ifndef PROTOCOL_AX25_H
|
||||||
#define PROTOCOL_AX25_H
|
#define PROTOCOL_AX25_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,281 @@
|
||||||
|
#include "digirepeater.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
RTC_DATA_ATTR digiTLMType digiLog;
|
||||||
|
RTC_DATA_ATTR uint8_t digiCount = 0;
|
||||||
|
|
||||||
|
extern Configuration config;
|
||||||
|
|
||||||
|
int digiProcess(AX25Msg &Packet)
|
||||||
|
{
|
||||||
|
int idx, j;
|
||||||
|
uint8_t ctmp;
|
||||||
|
// if(!DIGI) return;
|
||||||
|
// if(rx_data) return;
|
||||||
|
// if(digi_timeout<aprs_delay) return;
|
||||||
|
// digi_timeout = 65530;
|
||||||
|
// aprs_delay = 65535;
|
||||||
|
|
||||||
|
j = 0;
|
||||||
|
if (Packet.len < 5)
|
||||||
|
{
|
||||||
|
digiLog.ErPkts++;
|
||||||
|
return 0; // NO DST
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(&Packet.src.call[0], "NOCALL", 6))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!strncmp(&Packet.src.call[0], "MYCALL", 6))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destination SSID Trace
|
||||||
|
if (Packet.dst.ssid > 0)
|
||||||
|
{
|
||||||
|
uint8_t ctmp = Packet.dst.ssid & 0x1E; // Check DSSID
|
||||||
|
|
||||||
|
if (ctmp > 15)
|
||||||
|
ctmp = 0;
|
||||||
|
if (ctmp < 8)
|
||||||
|
{ // Edit PATH Change to TRACEn-N
|
||||||
|
if (ctmp > 0)
|
||||||
|
ctmp--;
|
||||||
|
Packet.dst.ssid = ctmp;
|
||||||
|
if (Packet.rpt_count > 0)
|
||||||
|
{
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (!strcmp(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0])) // Is path same callsign
|
||||||
|
{
|
||||||
|
if (Packet.rpt_list[idx].ssid == config.aprs_ssid) // IS path same SSID
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0; // bypass flag *
|
||||||
|
}
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
continue;
|
||||||
|
for (j = idx; j < Packet.rpt_count; j++)
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << j))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Move current part to next part
|
||||||
|
for (; j >= idx; j--)
|
||||||
|
{
|
||||||
|
int n = j + 1;
|
||||||
|
strcpy(&Packet.rpt_list[n].call[0], &Packet.rpt_list[j].call[0]);
|
||||||
|
Packet.rpt_list[n].ssid = Packet.rpt_list[j].ssid;
|
||||||
|
if (Packet.rpt_flags & (1 << j))
|
||||||
|
Packet.rpt_flags |= (1 << n);
|
||||||
|
else
|
||||||
|
Packet.rpt_flags &= ~(1 << n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new part
|
||||||
|
Packet.rpt_count += 1;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
return 2;
|
||||||
|
// j = 1;
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idx = 0;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
Packet.rpt_count += 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0; // NO PATH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (!strncmp(&Packet.rpt_list[idx].call[0], "qA", 2))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (!strncmp(&Packet.rpt_list[idx].call[0], "TCP", 3))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
{
|
||||||
|
if (idx == (Packet.rpt_count - 1))
|
||||||
|
digiCount++;
|
||||||
|
continue; // bypass flag *
|
||||||
|
}
|
||||||
|
if (!strncmp(&Packet.rpt_list[idx].call[0], "WIDE", 4))
|
||||||
|
{
|
||||||
|
// Check WIDEn-N
|
||||||
|
if (Packet.rpt_list[idx].ssid > 0)
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
continue; // bypass flag *
|
||||||
|
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
||||||
|
if (ctmp > 0)
|
||||||
|
ctmp--;
|
||||||
|
if (ctmp > 15)
|
||||||
|
ctmp = 0;
|
||||||
|
if (ctmp == 0)
|
||||||
|
{
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
j = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Packet.rpt_list[idx].ssid = ctmp;
|
||||||
|
Packet.rpt_flags &= ~(1 << idx);
|
||||||
|
j = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strncmp(&Packet.rpt_list[idx].call[0], "TRACE", 5))
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
continue; // bypass flag *
|
||||||
|
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
||||||
|
if (ctmp > 0)
|
||||||
|
ctmp--;
|
||||||
|
if (ctmp > 15)
|
||||||
|
ctmp = 0;
|
||||||
|
if (ctmp == 0)
|
||||||
|
{
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
j = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (j = idx; j < Packet.rpt_count; j++)
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << j))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Move current part to next part
|
||||||
|
for (; j >= idx; j--)
|
||||||
|
{
|
||||||
|
int n = j + 1;
|
||||||
|
strcpy(&Packet.rpt_list[n].call[0], &Packet.rpt_list[j].call[0]);
|
||||||
|
Packet.rpt_list[n].ssid = Packet.rpt_list[j].ssid;
|
||||||
|
if (Packet.rpt_flags & (1 << j))
|
||||||
|
Packet.rpt_flags |= (1 << n);
|
||||||
|
else
|
||||||
|
Packet.rpt_flags &= ~(1 << n);
|
||||||
|
}
|
||||||
|
// Reduce N part of TRACEn-N
|
||||||
|
Packet.rpt_list[idx + 1].ssid = ctmp;
|
||||||
|
|
||||||
|
// Add new part
|
||||||
|
Packet.rpt_count += 1;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
j = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strncmp(&Packet.rpt_list[idx].call[0], "RFONLY", 6))
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
// strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
// Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!strncmp(&Packet.rpt_list[idx].call[0], "RELAY", 5))
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!strncmp(&Packet.rpt_list[idx].call[0], "GATE", 4))
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!strncmp(&Packet.rpt_list[idx].call[0], "ECHO", 4))
|
||||||
|
{
|
||||||
|
j = 2;
|
||||||
|
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
||||||
|
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!strcmp(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0])) // Is path same callsign
|
||||||
|
{
|
||||||
|
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
||||||
|
if (ctmp == config.aprs_ssid) // IS path same SSID
|
||||||
|
{
|
||||||
|
if (Packet.rpt_flags & (1 << idx))
|
||||||
|
{
|
||||||
|
digiLog.DropRx++;
|
||||||
|
break; // bypass flag *
|
||||||
|
}
|
||||||
|
Packet.rpt_flags |= (1 << idx);
|
||||||
|
j = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include "igate.h"
|
||||||
|
|
||||||
|
extern WiFiClient aprsClient;
|
||||||
|
|
||||||
|
int igateProcess(AX25Msg &Packet)
|
||||||
|
{
|
||||||
|
int idx, j;
|
||||||
|
uint8_t ctmp;
|
||||||
|
String header;
|
||||||
|
|
||||||
|
j = 0;
|
||||||
|
if (Packet.len < 2)
|
||||||
|
{
|
||||||
|
// digiLog.ErPkts++;
|
||||||
|
return 0; // NO INFO DATA
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (!strncmp(&Packet.rpt_list[idx].call[0], "RFONLY", 6))
|
||||||
|
{
|
||||||
|
// digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < Packet.rpt_count; idx++)
|
||||||
|
{
|
||||||
|
if (!strncmp(&Packet.rpt_list[idx].call[0], "TCPIP", 5))
|
||||||
|
{
|
||||||
|
// digiLog.DropRx++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header = String(Packet.src.call);
|
||||||
|
if (Packet.src.ssid > 0)
|
||||||
|
{
|
||||||
|
header += String(F("-"));
|
||||||
|
header += String(Packet.src.ssid);
|
||||||
|
}
|
||||||
|
header += String(F(">"));
|
||||||
|
header += String(Packet.dst.call);
|
||||||
|
if (Packet.dst.ssid > 0)
|
||||||
|
{
|
||||||
|
header += String(F("-"));
|
||||||
|
header += String(Packet.dst.ssid);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Packet.rpt_count; i++)
|
||||||
|
{
|
||||||
|
header += String(",");
|
||||||
|
header += String(Packet.rpt_list[i].call);
|
||||||
|
if (Packet.rpt_list[i].ssid > 0)
|
||||||
|
{
|
||||||
|
header += String("-");
|
||||||
|
header += String(Packet.rpt_list[i].ssid);
|
||||||
|
}
|
||||||
|
if (Packet.rpt_flags & (1 << i))
|
||||||
|
header += "*";
|
||||||
|
}
|
||||||
|
header += String(F(":"));
|
||||||
|
aprsClient.print(header);
|
||||||
|
aprsClient.write(&Packet.info[0], Packet.len); // info binary write aprsc support
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
510
src/main.cpp
510
src/main.cpp
|
|
@ -19,6 +19,8 @@
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include "cppQueue.h"
|
#include "cppQueue.h"
|
||||||
#include "BluetoothSerial.h"
|
#include "BluetoothSerial.h"
|
||||||
|
#include "digirepeater.h"
|
||||||
|
#include "igate.h"
|
||||||
|
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
|
|
||||||
|
|
@ -66,9 +68,9 @@ cppQueue PacketBuffer(sizeof(AX25Msg), 5, IMPLEMENTATION); // Instantiate queue
|
||||||
|
|
||||||
statusType status;
|
statusType status;
|
||||||
RTC_DATA_ATTR igateTLMType igateTLM;
|
RTC_DATA_ATTR igateTLMType igateTLM;
|
||||||
RTC_DATA_ATTR digiTLMType digiLog;
|
|
||||||
RTC_DATA_ATTR txQueueType txQueue[PKGTXSIZE];
|
RTC_DATA_ATTR txQueueType txQueue[PKGTXSIZE];
|
||||||
RTC_DATA_ATTR uint8_t digiCount = 0;
|
|
||||||
|
extern RTC_DATA_ATTR uint8_t digiCount;
|
||||||
|
|
||||||
Configuration config;
|
Configuration config;
|
||||||
|
|
||||||
|
|
@ -186,7 +188,7 @@ void defaultConfig()
|
||||||
sprintf(config.tnc_comment, "ESP32 Build in TNC");
|
sprintf(config.tnc_comment, "ESP32 Build in TNC");
|
||||||
sprintf(config.aprs_filter, "g/HS*/E2*");
|
sprintf(config.aprs_filter, "g/HS*/E2*");
|
||||||
sprintf(config.tnc_path, "WIDE1-1");
|
sprintf(config.tnc_path, "WIDE1-1");
|
||||||
config.wifi_power = -4;
|
config.wifi_power = 44;
|
||||||
config.input_hpf = true;
|
config.input_hpf = true;
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
config.freq_rx = 144.3900;
|
config.freq_rx = 144.3900;
|
||||||
|
|
@ -351,9 +353,9 @@ bool pkgTxSend()
|
||||||
int decTime = millis() - txQueue[i].timeStamp;
|
int decTime = millis() - txQueue[i].timeStamp;
|
||||||
if (decTime > txQueue[i].Delay)
|
if (decTime > txQueue[i].Delay)
|
||||||
{
|
{
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
digitalWrite(POWER_PIN, config.rf_power); //RF Power LOW
|
digitalWrite(POWER_PIN, config.rf_power); // RF Power LOW
|
||||||
#endif
|
#endif
|
||||||
APRS_setPreamble(350L);
|
APRS_setPreamble(350L);
|
||||||
APRS_sendTNC2Pkt(String(txQueue[i].Info)); // Send packet to RF
|
APRS_sendTNC2Pkt(String(txQueue[i].Info)); // Send packet to RF
|
||||||
txQueue[i].Active = false;
|
txQueue[i].Active = false;
|
||||||
|
|
@ -424,51 +426,56 @@ uint8_t popGwRaw(uint8_t *raw)
|
||||||
|
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
unsigned long SA818_Timeout = 0;
|
unsigned long SA818_Timeout = 0;
|
||||||
void SA818_INIT(uint8_t HL)
|
void SA818_INIT(bool boot)
|
||||||
{
|
{
|
||||||
Serial.println("SA868 Init");
|
#ifdef SR_FRS
|
||||||
pinMode(0, INPUT);
|
Serial.println("Radio Module SR_FRS Init");
|
||||||
pinMode(POWER_PIN, OUTPUT);
|
#else
|
||||||
pinMode(PULLDOWN_PIN, OUTPUT);
|
Serial.println("Radio Module SA868 Init");
|
||||||
pinMode(SQL_PIN, INPUT_PULLUP);
|
#endif
|
||||||
|
if (boot)
|
||||||
|
{
|
||||||
|
SerialRF.begin(9600, SERIAL_8N1, 14, 13);
|
||||||
|
pinMode(POWER_PIN, OUTPUT);
|
||||||
|
pinMode(PULLDOWN_PIN, OUTPUT);
|
||||||
|
pinMode(SQL_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
SerialRF.begin(9600, SERIAL_8N1, 14, 13);
|
digitalWrite(POWER_PIN, LOW);
|
||||||
|
digitalWrite(PULLDOWN_PIN, LOW);
|
||||||
digitalWrite(PULLDOWN_PIN, HIGH);
|
delay(500);
|
||||||
digitalWrite(POWER_PIN, LOW);
|
digitalWrite(PULLDOWN_PIN, HIGH);
|
||||||
delay(500);
|
delay(1500);
|
||||||
// SerialRF.println("AT+DMOSETVOLUME=2");
|
SerialRF.println();
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
SerialRF.println();
|
SerialRF.println();
|
||||||
delay(1000);
|
delay(500);
|
||||||
// AT+DMOSETGROUP=1,144.3900,144.3900,0,1,0,0
|
|
||||||
// SerialRF.println("AT+DMOSETGROUP=0,145.7625,145.7625,0,1,0,0");
|
|
||||||
char str[100];
|
char str[100];
|
||||||
if (config.sql_level > 8)
|
if (config.sql_level > 8)
|
||||||
config.sql_level = 8;
|
config.sql_level = 8;
|
||||||
sprintf(str, "AT+DMOSETGROUP=%01d,%0.4f,%0.4f,%04d,%01d,%04d", config.band, config.freq_tx + ((float)config.offset_tx / 1000000), config.freq_rx + ((float)config.offset_rx / 1000000), config.tone_tx, config.sql_level, config.tone_rx);
|
#ifdef SR_FRS
|
||||||
Serial.println(str);
|
sprintf(str, "AT+DMOSETGROUP=%01d,%0.4f,%0.4f,%d,%01d,%d,4", config.band, config.freq_tx + ((float)config.offset_tx / 1000000), config.freq_rx + ((float)config.offset_rx / 1000000), config.tone_rx, config.sql_level, config.tone_tx);
|
||||||
SerialRF.println(str);
|
SerialRF.println(str);
|
||||||
delay(500);
|
delay(500);
|
||||||
// SerialRF.println("AT+DMOAUTOPOWCONTR=1");
|
// Module auto power save setting
|
||||||
// delay(500);
|
SerialRF.println("AT+DMOAUTOPOWCONTR=1");
|
||||||
|
delay(500);
|
||||||
|
SerialRF.println("AT+DMOSETVOX=0");
|
||||||
|
delay(500);
|
||||||
|
SerialRF.println("AT+DMOSETMIC=1,0,0");
|
||||||
|
#else
|
||||||
|
sprintf(str, "AT+DMOSETGROUP=%01d,%0.4f,%0.4f,%04d,%01d,%04d", config.band, config.freq_tx + ((float)config.offset_tx / 1000000), config.freq_rx + ((float)config.offset_rx / 1000000), config.tone_tx, config.sql_level, config.tone_rx);
|
||||||
|
SerialRF.println(str);
|
||||||
|
delay(500);
|
||||||
|
SerialRF.println("AT+SETTAIL=0");
|
||||||
|
delay(500);
|
||||||
|
SerialRF.println("AT+SETFILTER=1,1,1");
|
||||||
|
#endif
|
||||||
|
// SerialRF.println(str);
|
||||||
|
delay(500);
|
||||||
if (config.volume > 8)
|
if (config.volume > 8)
|
||||||
config.volume = 8;
|
config.volume = 8;
|
||||||
SerialRF.printf("AT+DMOSETVOLUME=%d\r\n", config.volume);
|
SerialRF.printf("AT+DMOSETVOLUME=%d\r\n", config.volume);
|
||||||
delay(500);
|
|
||||||
// SerialRF.println("AT+DMOSETVOX=0");
|
|
||||||
// delay(500);
|
|
||||||
// SerialRF.println("AT+DMOSETMIC=1,0,0");
|
|
||||||
// delay(500);
|
|
||||||
SerialRF.println("AT+SETTAIL=0");
|
|
||||||
delay(500);
|
|
||||||
// APRS,4FSK
|
|
||||||
SerialRF.println("AT+SETFILTER=1,1,1");
|
|
||||||
// delay(500);
|
|
||||||
// M17
|
|
||||||
// SerialRF.println("AT+SETFILTER=0,0,0");
|
|
||||||
// delay(100);
|
|
||||||
// AFSK_TimerEnable(true);
|
|
||||||
// digitalWrite(POWER_PIN, LOW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SA818_SLEEP()
|
void SA818_SLEEP()
|
||||||
|
|
@ -493,17 +500,17 @@ void SA818_CHECK()
|
||||||
SA818_Timeout = millis();
|
SA818_Timeout = millis();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Serial.println(SerialRF.readString());
|
// Serial.println(SerialRF.readString());
|
||||||
Serial.println("SA818 Activated");
|
Serial.println("Radio SA818/SR_FRS Activated");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("SA818 deActive");
|
Serial.println("Radio SA818/SR_FRS deActive");
|
||||||
digitalWrite(POWER_PIN, LOW);
|
digitalWrite(POWER_PIN, LOW);
|
||||||
digitalWrite(PULLDOWN_PIN, LOW);
|
digitalWrite(PULLDOWN_PIN, LOW);
|
||||||
delay(500);
|
delay(500);
|
||||||
SA818_INIT(LOW);
|
SA818_INIT(true);
|
||||||
}
|
}
|
||||||
// SerialGPS.print("$PMTK161,0*28\r\n");
|
// SerialGPS.print("$PMTK161,0*28\r\n");
|
||||||
// AFSK_TimerEnable(false);
|
// AFSK_TimerEnable(false);
|
||||||
|
|
@ -651,7 +658,7 @@ void setup()
|
||||||
input_HPF = config.input_hpf;
|
input_HPF = config.input_hpf;
|
||||||
|
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
SA818_INIT(LOW);
|
SA818_INIT(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enableLoopWDT();
|
enableLoopWDT();
|
||||||
|
|
@ -726,37 +733,37 @@ String send_fix_location()
|
||||||
return tnc2Raw;
|
return tnc2Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processPacket(String &tnc2)
|
int packet2Raw(String &tnc2, AX25Msg &Packet)
|
||||||
{
|
{
|
||||||
if (incomingPacket.len < 5)
|
if (Packet.len < 5)
|
||||||
return 0;
|
return 0;
|
||||||
tnc2 = String(incomingPacket.src.call);
|
tnc2 = String(Packet.src.call);
|
||||||
if (incomingPacket.src.ssid > 0)
|
if (Packet.src.ssid > 0)
|
||||||
{
|
{
|
||||||
tnc2 += String(F("-"));
|
tnc2 += String(F("-"));
|
||||||
tnc2 += String(incomingPacket.src.ssid);
|
tnc2 += String(Packet.src.ssid);
|
||||||
}
|
}
|
||||||
tnc2 += String(F(">"));
|
tnc2 += String(F(">"));
|
||||||
tnc2 += String(incomingPacket.dst.call);
|
tnc2 += String(Packet.dst.call);
|
||||||
if (incomingPacket.dst.ssid > 0)
|
if (Packet.dst.ssid > 0)
|
||||||
{
|
{
|
||||||
tnc2 += String(F("-"));
|
tnc2 += String(F("-"));
|
||||||
tnc2 += String(incomingPacket.dst.ssid);
|
tnc2 += String(Packet.dst.ssid);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < incomingPacket.rpt_count; i++)
|
for (int i = 0; i < Packet.rpt_count; i++)
|
||||||
{
|
{
|
||||||
tnc2 += String(",");
|
tnc2 += String(",");
|
||||||
tnc2 += String(incomingPacket.rpt_list[i].call);
|
tnc2 += String(Packet.rpt_list[i].call);
|
||||||
if (incomingPacket.rpt_list[i].ssid > 0)
|
if (Packet.rpt_list[i].ssid > 0)
|
||||||
{
|
{
|
||||||
tnc2 += String("-");
|
tnc2 += String("-");
|
||||||
tnc2 += String(incomingPacket.rpt_list[i].ssid);
|
tnc2 += String(Packet.rpt_list[i].ssid);
|
||||||
}
|
}
|
||||||
if (incomingPacket.rpt_flags & (1 << i))
|
if (Packet.rpt_flags & (1 << i))
|
||||||
tnc2 += "*";
|
tnc2 += "*";
|
||||||
}
|
}
|
||||||
tnc2 += String(F(":"));
|
tnc2 += String(F(":"));
|
||||||
tnc2 += String((const char *)incomingPacket.info);
|
tnc2 += String((const char *)Packet.info);
|
||||||
tnc2 += String("\n");
|
tnc2 += String("\n");
|
||||||
|
|
||||||
// #ifdef DEBUG_TNC
|
// #ifdef DEBUG_TNC
|
||||||
|
|
@ -780,11 +787,11 @@ void loop()
|
||||||
#endif
|
#endif
|
||||||
if (AFSKInitAct == true)
|
if (AFSKInitAct == true)
|
||||||
{
|
{
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
AFSK_Poll(true,config.rf_power);
|
AFSK_Poll(true, config.rf_power);
|
||||||
#else
|
#else
|
||||||
AFSK_Poll(false,LOW);
|
AFSK_Poll(false, LOW);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -914,7 +921,7 @@ void taskAPRS(void *pvParameters)
|
||||||
if (digiCount > 0)
|
if (digiCount > 0)
|
||||||
digiCount--;
|
digiCount--;
|
||||||
#ifdef SA818
|
#ifdef SA818
|
||||||
//SA818_CHECK();
|
SA818_CHECK();
|
||||||
#endif
|
#endif
|
||||||
if (AFSKInitAct == true)
|
if (AFSKInitAct == true)
|
||||||
{
|
{
|
||||||
|
|
@ -980,8 +987,38 @@ void taskAPRS(void *pvParameters)
|
||||||
String tnc2;
|
String tnc2;
|
||||||
//นำข้อมูลแพ็จเกจจาก TNC ออกจากคิว
|
//นำข้อมูลแพ็จเกจจาก TNC ออกจากคิว
|
||||||
PacketBuffer.pop(&incomingPacket);
|
PacketBuffer.pop(&incomingPacket);
|
||||||
processPacket(tnc2);
|
// igateProcess(incomingPacket);
|
||||||
|
packet2Raw(tnc2, incomingPacket);
|
||||||
|
|
||||||
|
// IGate Process
|
||||||
|
if (config.rf2inet && aprsClient.connected())
|
||||||
|
{
|
||||||
|
int ret = igateProcess(incomingPacket);
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
status.dropCount++;
|
||||||
|
igateTLM.DROP++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.rf2inet++;
|
||||||
|
igateTLM.RF2INET++;
|
||||||
|
igateTLM.TX++;
|
||||||
|
#ifdef DEBUG
|
||||||
|
printTime();
|
||||||
|
Serial.print("RF->INET: ");
|
||||||
|
Serial.println(tnc2);
|
||||||
|
#endif
|
||||||
|
char call[11];
|
||||||
|
if (incomingPacket.src.ssid > 0)
|
||||||
|
sprintf(call, "%s-%d", incomingPacket.src.call, incomingPacket.src.ssid);
|
||||||
|
else
|
||||||
|
sprintf(call, "%s", incomingPacket.src.call);
|
||||||
|
pkgListUpdate(call, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Digi Repeater Process
|
||||||
if (config.tnc_digi)
|
if (config.tnc_digi)
|
||||||
{
|
{
|
||||||
int dlyFlag = digiProcess(incomingPacket);
|
int dlyFlag = digiProcess(incomingPacket);
|
||||||
|
|
@ -1011,7 +1048,7 @@ void taskAPRS(void *pvParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String digiPkg;
|
String digiPkg;
|
||||||
processPacket(digiPkg);
|
packet2Raw(digiPkg, incomingPacket);
|
||||||
pkgTxUpdate(digiPkg.c_str(), digiDelay);
|
pkgTxUpdate(digiPkg.c_str(), digiDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1020,73 +1057,6 @@ void taskAPRS(void *pvParameters)
|
||||||
lastPkgRaw = tnc2;
|
lastPkgRaw = tnc2;
|
||||||
// ESP_BT.println(tnc2);
|
// ESP_BT.println(tnc2);
|
||||||
status.allCount++;
|
status.allCount++;
|
||||||
|
|
||||||
// String tnc2 = SerialTNC.readStringUntil('\n');
|
|
||||||
if (config.rf2inet && aprsClient.connected())
|
|
||||||
{
|
|
||||||
int start_val = tnc2.indexOf(">", 0); // หาตำแหน่งแรกของ >
|
|
||||||
if (start_val > 3)
|
|
||||||
{
|
|
||||||
raw = (char *)malloc(tnc2.length() + 20);
|
|
||||||
status.tncCount++;
|
|
||||||
if (tnc2.indexOf("RFONLY", 10) > 0) //NOGATE PATH RFONLY จะไม่ส่งเข้า APRS-IS
|
|
||||||
{
|
|
||||||
status.dropCount++;
|
|
||||||
igateTLM.DROP++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
str = (char *)malloc(tnc2.length());
|
|
||||||
tnc2.toCharArray(&str[0], tnc2.length());
|
|
||||||
int i = tnc2.indexOf(":");
|
|
||||||
int t = tnc2.indexOf("TCPIP*", 5);
|
|
||||||
|
|
||||||
if (i > 10)
|
|
||||||
{
|
|
||||||
if (t > 0)
|
|
||||||
str[t - 1] = 0;
|
|
||||||
else
|
|
||||||
str[i] = 0;
|
|
||||||
if (config.aprs_ssid == 0)
|
|
||||||
sprintf(raw, "%s,qAR,%s:%s", &str[0], config.aprs_mycall, &str[i + 1]);
|
|
||||||
else
|
|
||||||
sprintf(raw, "%s,qAR,%s-%d:%s", &str[0], config.aprs_mycall, config.aprs_ssid, &str[i + 1]);
|
|
||||||
// sprintf(raw, "%s", &str[0]);
|
|
||||||
tnc2 = String(raw);
|
|
||||||
aprsClient.println(tnc2);
|
|
||||||
status.rf2inet++;
|
|
||||||
igateTLM.RF2INET++;
|
|
||||||
igateTLM.TX++;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
printTime();
|
|
||||||
Serial.print("RF->INET: ");
|
|
||||||
Serial.println(tnc2);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status.errorCount++;
|
|
||||||
igateTLM.DROP++;
|
|
||||||
}
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
// memset(&raw[0], 0, sizeof(raw));
|
|
||||||
tnc2.toCharArray(&raw[0], start_val + 1);
|
|
||||||
raw[start_val + 1] = 0;
|
|
||||||
pkgListUpdate(&raw[0], 1);
|
|
||||||
free(raw);
|
|
||||||
// #ifdef DEBUG
|
|
||||||
// printTime();
|
|
||||||
// Serial.print("TNC ");
|
|
||||||
// Serial.println(tnc2);
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status.errorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1294,277 +1264,3 @@ void taskNetwork(void *pvParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int digiProcess(AX25Msg &Packet)
|
|
||||||
{
|
|
||||||
int idx, j;
|
|
||||||
uint8_t ctmp;
|
|
||||||
// if(!DIGI) return;
|
|
||||||
// if(rx_data) return;
|
|
||||||
// if(digi_timeout<aprs_delay) return;
|
|
||||||
// digi_timeout = 65530;
|
|
||||||
// aprs_delay = 65535;
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
if (Packet.len < 5)
|
|
||||||
{
|
|
||||||
digiLog.ErPkts++;
|
|
||||||
return 0; // NO DST
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(&Packet.src.call[0], "NOCALL", 6))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!strncmp(&Packet.src.call[0], "MYCALL", 6))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destination SSID Trace
|
|
||||||
if (Packet.dst.ssid > 0)
|
|
||||||
{
|
|
||||||
uint8_t ctmp = Packet.dst.ssid & 0x1E; // Check DSSID
|
|
||||||
|
|
||||||
if (ctmp > 15)
|
|
||||||
ctmp = 0;
|
|
||||||
if (ctmp < 8)
|
|
||||||
{ // Edit PATH Change to TRACEn-N
|
|
||||||
if (ctmp > 0)
|
|
||||||
ctmp--;
|
|
||||||
Packet.dst.ssid = ctmp;
|
|
||||||
if (Packet.rpt_count > 0)
|
|
||||||
{
|
|
||||||
for (idx = 0; idx < Packet.rpt_count; idx++)
|
|
||||||
{
|
|
||||||
if (!strcmp(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0])) // Is path same callsign
|
|
||||||
{
|
|
||||||
if (Packet.rpt_list[idx].ssid == config.aprs_ssid) // IS path same SSID
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0; // bypass flag *
|
|
||||||
}
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
continue;
|
|
||||||
for (j = idx; j < Packet.rpt_count; j++)
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << j))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Move current part to next part
|
|
||||||
for (; j >= idx; j--)
|
|
||||||
{
|
|
||||||
int n = j + 1;
|
|
||||||
strcpy(&Packet.rpt_list[n].call[0], &Packet.rpt_list[j].call[0]);
|
|
||||||
Packet.rpt_list[n].ssid = Packet.rpt_list[j].ssid;
|
|
||||||
if (Packet.rpt_flags & (1 << j))
|
|
||||||
Packet.rpt_flags |= (1 << n);
|
|
||||||
else
|
|
||||||
Packet.rpt_flags &= ~(1 << n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new part
|
|
||||||
Packet.rpt_count += 1;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
return 2;
|
|
||||||
// j = 1;
|
|
||||||
// break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idx = 0;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
Packet.rpt_count += 1;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0; // NO PATH
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (idx = 0; idx < Packet.rpt_count; idx++)
|
|
||||||
{
|
|
||||||
if (!strncmp(&Packet.rpt_list[idx].call[0], "qA", 2))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (idx = 0; idx < Packet.rpt_count; idx++)
|
|
||||||
{
|
|
||||||
if (!strncmp(&Packet.rpt_list[idx].call[0], "TCP", 3))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (idx = 0; idx < Packet.rpt_count; idx++)
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
{
|
|
||||||
if (idx == (Packet.rpt_count - 1))
|
|
||||||
digiCount++;
|
|
||||||
continue; // bypass flag *
|
|
||||||
}
|
|
||||||
if (!strncmp(&Packet.rpt_list[idx].call[0], "WIDE", 4))
|
|
||||||
{
|
|
||||||
// Check WIDEn-N
|
|
||||||
if (Packet.rpt_list[idx].ssid > 0)
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
continue; // bypass flag *
|
|
||||||
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
|
||||||
if (ctmp > 0)
|
|
||||||
ctmp--;
|
|
||||||
if (ctmp > 15)
|
|
||||||
ctmp = 0;
|
|
||||||
if (ctmp == 0)
|
|
||||||
{
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
j = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Packet.rpt_list[idx].ssid = ctmp;
|
|
||||||
Packet.rpt_flags &= ~(1 << idx);
|
|
||||||
j = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!strncmp(&Packet.rpt_list[idx].call[0], "TRACE", 5))
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
continue; // bypass flag *
|
|
||||||
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
|
||||||
if (ctmp > 0)
|
|
||||||
ctmp--;
|
|
||||||
if (ctmp > 15)
|
|
||||||
ctmp = 0;
|
|
||||||
if (ctmp == 0)
|
|
||||||
{
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
j = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (j = idx; j < Packet.rpt_count; j++)
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << j))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Move current part to next part
|
|
||||||
for (; j >= idx; j--)
|
|
||||||
{
|
|
||||||
int n = j + 1;
|
|
||||||
strcpy(&Packet.rpt_list[n].call[0], &Packet.rpt_list[j].call[0]);
|
|
||||||
Packet.rpt_list[n].ssid = Packet.rpt_list[j].ssid;
|
|
||||||
if (Packet.rpt_flags & (1 << j))
|
|
||||||
Packet.rpt_flags |= (1 << n);
|
|
||||||
else
|
|
||||||
Packet.rpt_flags &= ~(1 << n);
|
|
||||||
}
|
|
||||||
// Reduce N part of TRACEn-N
|
|
||||||
Packet.rpt_list[idx + 1].ssid = ctmp;
|
|
||||||
|
|
||||||
// Add new part
|
|
||||||
Packet.rpt_count += 1;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
j = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!strncmp(&Packet.rpt_list[idx].call[0], "RFONLY", 6))
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
// strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
// Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!strncmp(&Packet.rpt_list[idx].call[0], "RELAY", 5))
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!strncmp(&Packet.rpt_list[idx].call[0], "GATE", 4))
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!strncmp(&Packet.rpt_list[idx].call[0], "ECHO", 4))
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
strcpy(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0]);
|
|
||||||
Packet.rpt_list[idx].ssid = config.aprs_ssid;
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!strcmp(&Packet.rpt_list[idx].call[0], &config.aprs_mycall[0])) // Is path same callsign
|
|
||||||
{
|
|
||||||
ctmp = Packet.rpt_list[idx].ssid & 0x1F;
|
|
||||||
if (ctmp == config.aprs_ssid) // IS path same SSID
|
|
||||||
{
|
|
||||||
if (Packet.rpt_flags & (1 << idx))
|
|
||||||
{
|
|
||||||
digiLog.DropRx++;
|
|
||||||
break; // bypass flag *
|
|
||||||
}
|
|
||||||
Packet.rpt_flags |= (1 << idx);
|
|
||||||
j = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1110,7 +1110,7 @@ void handle_radio()
|
||||||
// config.agc=agcEn;
|
// config.agc=agcEn;
|
||||||
saveEEPROM();
|
saveEEPROM();
|
||||||
// delay(100);
|
// delay(100);
|
||||||
SA818_INIT(LOW);
|
SA818_INIT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHTML(7);
|
setHTML(7);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue