Merge branch 'develop' into feature/NatTraversal

pull/32/head
Geoffrey Merck 4 years ago
commit 25a6aefe11

@ -18,11 +18,16 @@ jobs:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libboost-dev
sudo apt-get -y install libgtest-dev libcurl4-openssl-dev libboost-dev
- run:
name: "Build"
command: "make"
name: "Build App"
command: "make -j 3 dstargateway"
- run:
name: "Build Tests"
command: "make -j 3 tests"
- run:
name: "Run Tests"
command: "make run-tests"
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:

2
.gitignore vendored

@ -44,4 +44,4 @@ Sandbox/*
*.out
*.app
dstargateway
Tests/dstargateway_tests

@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/bin/g++",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.makefile-tools"
}
],
"version": 4
}

@ -27,6 +27,30 @@
"ignoreFailures": true
}
]
},
{
"name": "Tests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Tests/dstargateway_tests",
"args": [ ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Activer l'impression en mode Pretty pour gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Définir la version désassemblage sur Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

@ -5,5 +5,34 @@
"binaryPath": "/home/geoffrey/Documents/Dev/DStarGateway/dstargateway",
"binaryArgs": []
}
]
],
"files.associations": {
"new": "cpp"
},
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "googletest.failed",
"settings": {
"foreground": "#f00"
}
},
{
"scope": "googletest.passed",
"settings": {
"foreground": "#0f0"
}
},
{
"scope": "googletest.run",
"settings": {
"foreground": "#0f0"
}
}
]
},
"gtest-adapter.debugConfig": [
"Tests"
],
"gtest-adapter.supportLocation": true
}

31
.vscode/tasks.json vendored

@ -0,0 +1,31 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "make",
"args": [
"-j3"
],
"group": "build",
"problemMatcher": []
},
{
"label": "Build Tests",
"type": "shell",
"command": "make",
"args": [
"-j3",
"tests"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}

@ -25,6 +25,9 @@
#include "APRSCollector.h"
#include "DStarDefines.h"
#include "Utils.h"
#include "NMEASentenceCollector.h"
#include "GPSACollector.h"
#include "RSMS1AMessageCollector.h"
const unsigned int APRS_CSUM_LENGTH = 4U;
const unsigned int APRS_DATA_LENGTH = 300U;
@ -34,528 +37,65 @@ const char APRS_OVERLAY = '\\';
const char APRS_SYMBOL = 'K';
CAPRSCollector::CAPRSCollector() :
m_state(AS_NONE),
m_ggaData(NULL),
m_ggaLength(0U),
m_ggaValid(false),
m_rmcData(NULL),
m_rmcLength(0U),
m_rmcValid(false),
m_crcData(NULL),
m_crcLength(0U),
m_crcValid(false),
m_buffer(NULL),
m_slowData(SS_FIRST),
m_collector(),
m_callsign()
m_collectors()
{
m_ggaData = new unsigned char[APRS_DATA_LENGTH];
m_rmcData = new unsigned char[APRS_DATA_LENGTH];
m_crcData = new unsigned char[APRS_DATA_LENGTH];
m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH];
m_collectors.push_back(new CRSMS1AMessageCollector());
m_collectors.push_back(new CGPSACollector());
m_collectors.push_back(new CNMEASentenceCollector("$GPRMC"));
m_collectors.push_back(new CNMEASentenceCollector("$GPGGA"));
m_collectors.push_back(new CNMEASentenceCollector("$GPGLL"));
m_collectors.push_back(new CNMEASentenceCollector("$GPVTG"));
m_collectors.push_back(new CNMEASentenceCollector("$GPGSA"));
m_collectors.push_back(new CNMEASentenceCollector("$GPGSV"));
}
CAPRSCollector::~CAPRSCollector()
{
delete[] m_ggaData;
delete[] m_rmcData;
delete[] m_crcData;
delete[] m_buffer;
for(auto collector : m_collectors) {
delete collector;
}
m_collectors.clear();
}
void CAPRSCollector::writeHeader(const std::string& callsign)
{
m_callsign = callsign;
for(auto collector : m_collectors) {
collector->setMyCall(callsign);
}
}
bool CAPRSCollector::writeData(const unsigned char* data)
{
assert(data != NULL);
switch (m_slowData) {
case SS_FIRST:
m_buffer[0U] = data[0U] ^ SCRAMBLER_BYTE1;
m_buffer[1U] = data[1U] ^ SCRAMBLER_BYTE2;
m_buffer[2U] = data[2U] ^ SCRAMBLER_BYTE3;
m_slowData = SS_SECOND;
return false;
case SS_SECOND:
m_buffer[3U] = data[0U] ^ SCRAMBLER_BYTE1;
m_buffer[4U] = data[1U] ^ SCRAMBLER_BYTE2;
m_buffer[5U] = data[2U] ^ SCRAMBLER_BYTE3;
m_slowData = SS_FIRST;
break;
bool ret = false;
for(auto collector : m_collectors) {
bool ret2 = collector->writeData(data);
ret = ret || ret2;
}
// Is it GPS data?
if ((m_buffer[0U] & SLOW_DATA_TYPE_MASK) == SLOW_DATA_TYPE_GPS)
return addGPSData(m_buffer + 1U);
return false;
return ret;
}
void CAPRSCollector::reset()
{
m_state = AS_NONE;
m_ggaLength = 0U;
m_ggaValid = false;
m_rmcLength = 0U;
m_rmcValid = false;
m_crcLength = 0U;
m_crcValid = false;
m_slowData = SS_FIRST;
m_collector.clear();
m_callsign.clear();
}
void CAPRSCollector::sync()
{
m_slowData = SS_FIRST;
}
bool CAPRSCollector::addGPSData(const unsigned char* data)
{
assert(data != NULL);
m_collector += std::string((char*)data, 5U);
if (m_state == AS_GGA) {
addGGAData();
return false;
} else if (m_state == AS_RMC) {
return addRMCData();
} else if (m_state == AS_CRC) {
return addCRCData();
}
if (m_state != AS_GGA && m_collector.find("$GPGGA") != std::string::npos) {
m_state = AS_GGA;
m_ggaLength = 0U;
m_ggaValid = false;
m_rmcLength = 0U;
m_rmcValid = false;
return false;
} else if (m_state != AS_RMC && m_collector.find("$GPRMC") != std::string::npos) {
m_state = AS_RMC;
m_rmcLength = 0U;
m_rmcValid = false;
return false;
} else if (m_state != AS_CRC && m_collector.find("$$CRC") != std::string::npos) {
m_state = AS_CRC;
m_crcLength = 0U;
m_crcValid = false;
}
return false;
}
void CAPRSCollector::addGGAData()
{
std::string::size_type n2 = m_collector.find_last_of('\x0A');
if (n2 == std::string::npos)
return;
std::string::size_type n1 = m_collector.find("$GPGGA");
if (n1 == std::string::npos)
return;
if (n2 < n1)
return;
std::string::size_type len = n2 - n1;
if (len >= APRS_DATA_LENGTH) {
m_ggaLength = 0U;
m_ggaValid = false;
m_state = AS_NONE;
return;
}
m_ggaLength = 0U;
for (unsigned int i = n1; i <= n2; i++) {
m_ggaData[m_ggaLength] = m_collector[i];
m_ggaData[m_ggaLength] &= 0x7FU;
m_ggaLength++;
}
bool ret = checkXOR(m_ggaData + 1U, m_ggaLength - 1U);
if (ret) {
// CUtils::dump("$GPGGA Valid", m_ggaData, m_ggaLength);
m_ggaValid = true;
m_state = AS_RMC;
} else {
// CUtils::dump("$GPGGA Bad checksum", m_ggaData, m_ggaLength);
m_ggaLength = 0U;
m_ggaValid = false;
m_state = AS_RMC;
}
m_collector = m_collector.substr(n2);
}
bool CAPRSCollector::addRMCData()
{
std::string::size_type n2 = m_collector.find_last_of('\x0A');
if (n2 == std::string::npos)
return false;
std::string::size_type n1 = m_collector.find("$GPRMC");
if (n1 == std::string::npos)
return false;
if (n2 < n1)
return false;
unsigned int len = n2 - n1;
if (len >= APRS_DATA_LENGTH) {
m_rmcLength = 0U;
m_rmcValid = false;
m_state = AS_NONE;
return false;
}
m_rmcLength = 0U;
for (unsigned int i = n1; i <= n2; i++) {
m_rmcData[m_rmcLength] = m_collector[i];
m_rmcData[m_rmcLength] &= 0x7FU;
m_rmcLength++;
}
bool ret = checkXOR(m_rmcData + 1U, m_rmcLength - 1U);
if (ret) {
// CUtils::dump("$GPRMC Valid", m_rmcData, m_rmcLength);
m_rmcValid = true;
} else {
// CUtils::dump("$GPRMC Bad checksum", m_rmcData, m_rmcLength);
m_rmcLength = 0U;
m_rmcValid = false;
}
m_collector = m_collector.substr(n2);
m_state = AS_NONE;
return true;
}
bool CAPRSCollector::addCRCData()
{
std::string::size_type n2 = m_collector.find_last_of('\x0D');
if (n2 == std::string::npos)
return false;
std::string::size_type n1 = m_collector.find("$$CRC");
if (n1 == std::string::npos)
return false;
if (n2 < n1)
return false;
unsigned int len = n2 - n1;
if (len >= APRS_DATA_LENGTH) {
m_crcLength = 0U;
m_crcValid = false;
m_state = AS_NONE;
return false;
}
m_crcLength = 0U;
for (unsigned int i = n1; i <= n2; i++) {
m_crcData[m_crcLength] = m_collector[i];
m_crcLength++;
}
bool ret = checkCRC(m_crcData, m_crcLength);
if (ret) {
// CUtils::dump("$$CRC Valid", m_crcData, m_crcLength);
m_crcValid = true;
m_state = AS_NONE;
m_collector = m_collector.substr(n2);
return true;
} else {
// CUtils::dump("$$CRC Bad checksum", m_crcData, m_crcLength);
m_crcLength = 0U;
m_crcValid = false;
m_state = AS_NONE;
m_collector = m_collector.substr(n2);
return false;
}
}
unsigned int CAPRSCollector::getData(unsigned char* data, unsigned int length)
{
assert(data != NULL);
// Have we got GPS-A data?
if (m_crcValid) {
unsigned int len = m_crcLength - 10U;
if (len > length)
len = length;
::memcpy(data, m_crcData + 10U, len);
m_crcLength = 0U;
m_crcValid = false;
return len;
for(auto collector : m_collectors) {
collector->reset();
}
// Have we got GGA data?
if (m_ggaValid) {
unsigned int len = convertNMEA1(data, length);
m_ggaLength = 0U;
m_rmcLength = 0U;
m_ggaValid = false;
m_rmcValid = false;
return len;
}
// Have we got RMC data?
if (m_rmcValid) {
unsigned int len = convertNMEA2(data, length);
m_ggaLength = 0U;
m_rmcLength = 0U;
m_ggaValid = false;
m_rmcValid = false;
return len;
}
return 0U;
}
bool CAPRSCollector::checkXOR(const unsigned char* data, unsigned int length) const
{
unsigned int posStar = 0U;
for (unsigned int i = length - 1U; i > 0U; i--) {
if (data[i] == '*') {
posStar = i;
break;
}
}
if (posStar == 0U)
return false;
unsigned char csum = calcXOR(data, posStar);
char buffer[10U];
::sprintf(buffer, "%02X", csum);
return ::memcmp(buffer, data + posStar + 1U, 2U) == 0;
}
unsigned char CAPRSCollector::calcXOR(const unsigned char* buffer, unsigned int length) const
{
assert(buffer != NULL);
assert(length > 0U);
unsigned char res = 0U;
for (unsigned int i = 0U; i < length; i++)
res ^= buffer[i];
return res;
}
bool CAPRSCollector::checkCRC(const unsigned char* data, unsigned int length) const
{
unsigned int csum = calcCRC(data + 10U, length - 10U);
char buffer[10U];
::sprintf(buffer, "%04X", csum);
return ::memcmp(buffer, data + 5U, APRS_CSUM_LENGTH) == 0;
}
unsigned int CAPRSCollector::calcCRC(const unsigned char* buffer, unsigned int length) const
{
assert(buffer != NULL);
assert(length > 0U);
unsigned int icomcrc = 0xFFFFU;
for (unsigned int j = 0U; j < length; j++) {
unsigned char ch = buffer[j];
for (unsigned int i = 0U; i < 8U; i++) {
bool xorflag = (((icomcrc ^ ch) & 0x01U) == 0x01U);
icomcrc >>= 1;
if (xorflag)
icomcrc ^= 0x8408U;
ch >>= 1;
}
}
return ~icomcrc & 0xFFFFU;
}
unsigned int CAPRSCollector::convertNMEA1(unsigned char* data, unsigned int)
{
// Parse the $GPGGA string into tokens
char* pGGA[20U];
::memset(pGGA, 0x00U, 20U * sizeof(char*));
unsigned int nGGA = 0U;
char* str = (char*)m_ggaData;
while (nGGA < 20U) {
char* p = mystrsep(&str, ",\r\n");
pGGA[nGGA++] = p;
if (p == NULL)
break;
}
// Is there any position data?
if (pGGA[2U] == NULL || pGGA[3U] == NULL || pGGA[4U] == NULL || pGGA[5U] == NULL || ::strlen(pGGA[2U]) == 0U || ::strlen(pGGA[3U]) == 0U || ::strlen(pGGA[4U]) == 0 || ::strlen(pGGA[5U]) == 0)
return 0U;
// Is it a valid GPS fix?
if (::strcmp(pGGA[6U], "0") == 0)
return 0U;
char callsign[10U];
dstarCallsignToAPRS(m_callsign, callsign);
::sprintf((char*)data, "%s>APDPRS,DSTAR*:!%.7s%s%c%.8s%s%c", callsign, pGGA[2U], pGGA[3U], APRS_OVERLAY, pGGA[4U], pGGA[5U], APRS_SYMBOL);
// Get the bearing and speed from the RMC data
if (m_rmcValid) {
// Parse the $GPRMC string into tokens
char* pRMC[20U];
::memset(pRMC, 0x00U, 20U * sizeof(char*));
unsigned int nRMC = 0U;
str = (char*)m_rmcData;
for (;;) {
char* p = mystrsep(&str, ",\r\n");
pRMC[nRMC++] = p;
if (p == NULL)
break;
}
// Check that we have a bearing and speed
if (pRMC[7U] != NULL && pRMC[8U] != NULL && ::strlen(pRMC[7U]) > 0U && ::strlen(pRMC[8U]) > 0U) {
int bearing = ::atoi(pRMC[8U]);
int speed = ::atoi(pRMC[7U]);
::sprintf((char*)data + ::strlen((char*)data), "%03d/%03d", bearing, speed);
}
}
if (pGGA[9U] != NULL && ::strlen(pGGA[9U]) > 0U) {
// Convert altitude from metres to feet
int altitude = ::atoi(pGGA[9U]);
::sprintf((char*)data + ::strlen((char*)data), "/A=%06.0f", float(altitude) * 3.28F);
}
return ::strlen((char*)data);
}
unsigned int CAPRSCollector::convertNMEA2(unsigned char* data, unsigned int)
void CAPRSCollector::sync()
{
// Parse the $GPRMC string into tokens
char* pRMC[20U];
::memset(pRMC, 0x00U, 20U * sizeof(char*));
unsigned int nRMC = 0U;
char* str = (char*)m_rmcData;
while (nRMC < 20U) {
char* p = mystrsep(&str, ",\r\n");
pRMC[nRMC++] = p;
if (p == NULL)
break;
for(auto collector : m_collectors) {
collector->sync();
}
// Is there any position data?
if (pRMC[3U] == NULL || pRMC[4U] == NULL || pRMC[5U] == NULL || pRMC[6U] == NULL || ::strlen(pRMC[3U]) == 0U || ::strlen(pRMC[4U]) == 0U || ::strlen(pRMC[5U]) == 0 || ::strlen(pRMC[6U]) == 0)
return 0U;
// Is it a valid GPS fix?
if (::strcmp(pRMC[2U], "A") != 0)
return 0U;
char callsign[10U];
dstarCallsignToAPRS(m_callsign, callsign);
::sprintf((char*)data, "%s>APDPRS,DSTAR*:!%.7s%s%c%.8s%s%c", callsign, pRMC[3U], pRMC[4U], APRS_OVERLAY, pRMC[5U], pRMC[6U], APRS_SYMBOL);
if (pRMC[7U] != NULL && pRMC[8U] != NULL && ::strlen(pRMC[7U]) > 0U && ::strlen(pRMC[8U]) > 0U) {
int bearing = ::atoi(pRMC[8U]);
int speed = ::atoi(pRMC[7U]);
::sprintf((char*)data + ::strlen((char*)data), "%03d/%03d", bearing, speed);
}
return ::strlen((char*)data);
}
void CAPRSCollector::dstarCallsignToAPRS(const std::string& dstarCallsign, char* aprsCallsign) const
unsigned int CAPRSCollector::getData(unsigned char dataType, unsigned char* data, unsigned int length)
{
assert(aprsCallsign != NULL);
std::string dstarcallsignTmp(dstarCallsign);
if(dstarcallsignTmp[dstarcallsignTmp.length() - 1] == ' ') {
boost::trim(dstarcallsignTmp);
} else {
//loop until got rid of all double blanks
while(dstarcallsignTmp.find(" ") != std::string::npos) {
boost::replace_all(dstarcallsignTmp, " ", " ");
for(auto collector : m_collectors) {
if(collector->getDataType() == dataType) {
unsigned int res = collector->getData(data, length);
if(res > 0U)
return res;
}
boost::replace_all(dstarcallsignTmp, " ", "-");//replace remaining blank with a -
}
unsigned int i = 0U;
for (; i < dstarcallsignTmp.length(); i++) {
aprsCallsign[i] = dstarcallsignTmp[i];
}
aprsCallsign[i] = '\0';
// std::string first = dstarCallsign.BeforeFirst(wxT(' '));
// std::string last = dstarCallsign.AfterLast(wxT(' '));
// if (last.empty() || first == last) {
// unsigned int n = 0U;
// for (unsigned int i = 0U; i < first.length(); i++)
// aprsCallsign[n++] = first[i];
// aprsCallsign[n++] = '\0';
// } else {
// unsigned int n = 0U;
// for (unsigned int i = 0U; i < first.length(); i++)
// aprsCallsign[n++] = first[i];
// aprsCallsign[n++] = '-';
// for (unsigned int i = 0U; i < last.length(); i++)
// aprsCallsign[n++] = last[i];
// aprsCallsign[n++] = '\0';
// }
}
// Source found at <http://unixpapa.com/incnote/string.html>
char* CAPRSCollector::mystrsep(char** sp, const char* sep) const
{
if (sp == NULL || *sp == NULL || **sp == '\0')
return NULL;
char* s = *sp;
char* p = s + ::strcspn(s, sep);
if (*p != '\0')
*p++ = '\0';
*sp = p;
return s;
return 0U;
}

@ -20,12 +20,16 @@
#ifndef APRSCollector_H
#define APRSCollector_H
#include <vector>
#include "SlowDataCollector.h"
#include "Defs.h"
enum APRS_STATE {
AS_NONE,
AS_GGA,
AS_RMC,
AS_MSG,
AS_CRC
};
@ -42,42 +46,10 @@ public:
void sync();
unsigned int getData(unsigned char* data, unsigned int length);
unsigned int getData(unsigned char dataType, unsigned char* data, unsigned int length);
private:
APRS_STATE m_state;
unsigned char* m_ggaData;
unsigned int m_ggaLength;
bool m_ggaValid;
unsigned char* m_rmcData;
unsigned int m_rmcLength;
bool m_rmcValid;
unsigned char* m_crcData;
unsigned int m_crcLength;
bool m_crcValid;
unsigned char* m_buffer;
SLOWDATA_STATE m_slowData;
std::string m_collector;
std::string m_callsign;
bool addGPSData(const unsigned char* data);
void addGGAData();
bool addRMCData();
bool addCRCData();
bool checkXOR(const unsigned char* data, unsigned int length) const;
unsigned char calcXOR(const unsigned char* buffer, unsigned int length) const;
bool checkCRC(const unsigned char* data, unsigned int length) const;
unsigned int calcCRC(const unsigned char* buffer, unsigned int length) const;
unsigned int convertNMEA1(unsigned char* data, unsigned int length);
unsigned int convertNMEA2(unsigned char* data, unsigned int length);
void dstarCallsignToAPRS(const std::string& dstarCallsign, char* aprsCallsign) const;
char* mystrsep(char** sp, const char* sep) const;
std::vector<CSlowDataCollector *> m_collectors;
};
#endif

@ -0,0 +1,46 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "APRSFrame.h"
CAPRSFrame::CAPRSFrame() :
m_source(),
m_destination(),
m_path(),
m_type(APFT_UNKNOWN)
{
}
CAPRSFrame::CAPRSFrame(const std::string& source, const std::string& destination, const std::vector<std::string>& path, APRS_FRAME_TYPE type) :
m_source(source),
m_destination(destination),
m_path(),
m_type(type)
{
m_path.assign(path.begin(), path.end());
}
void CAPRSFrame::clear()
{
m_source.clear();
m_destination.clear();
m_path.clear();
m_body.clear();
m_type = APFT_UNKNOWN;
}

@ -0,0 +1,48 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include <vector>
// We only support these types for now
enum APRS_FRAME_TYPE {
APFT_UNKNOWN = 0,
APFT_MESSAGE,
};
class CAPRSFrame {
public:
CAPRSFrame();
CAPRSFrame(const std::string& source, const std::string& destination, const std::vector<std::string>& path, APRS_FRAME_TYPE type);
void clear();
std::string& getSource() { return m_source; }
std::string& getDestination() { return m_destination; }
std::vector<std::string>& getPath() { return m_path; }
std::string& getBody() { return m_body; }
APRS_FRAME_TYPE& getType() { return m_type; }
private:
std::string m_source;
std::string m_destination;
std::vector<std::string> m_path;
std::string m_body;
APRS_FRAME_TYPE m_type;
};

@ -0,0 +1,83 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "APRSParser.h"
#include "Log.h"
bool CAPRSParser::parseFrame(const std::string& frameStr, CAPRSFrame& frame)
{
frame.clear();
bool ret = false;
if(!frameStr.empty()) {
auto pos = frameStr.find_first_of(':');
if(pos != std::string::npos && pos != frameStr.length() - 1) {
auto header = frameStr.substr(0, pos); // contains source, dest and path
auto body = frameStr.substr(pos +1);
std::vector<std::string> headerSplits;
boost::split(headerSplits, header, [](char c) { return c == ',' || c == '>';});
//we need at least source and dest to form a valid frame, also headers shall not contain empty strings
if(headerSplits.size() >= 2 && std::none_of(headerSplits.begin(), headerSplits.end(), [](std::string s){ return s.empty(); })) {
frame.getSource().assign(headerSplits[0]);
frame.getDestination().assign(headerSplits[1]);
for(unsigned int i = 2; i < headerSplits.size(); i++) {
frame.getPath().push_back(headerSplits[i]);
}
frame.getBody().assign(body);
setFrameType(frame);
if(frame.getType() == APFT_UNKNOWN) {
CLog::logInfo("Invalid or unsupported APRS frame : %s", frameStr);
}
else {
ret = true;
}
}
}
}
return ret;
}
void CAPRSParser::setFrameType(CAPRSFrame& frame)
{
APRS_FRAME_TYPE type = APFT_UNKNOWN;
std::string body(frame.getBody());
if(!body.empty()) {
switch (body[0])
{
case ':':
if(body[10] == ':' && std::all_of(body.begin() + 1, body.begin() + 10,
[](char c){ return c == ' ' || c == '-' || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); }))
type = APFT_MESSAGE;
break;
default:
break;
}
}
frame.getType() = type;
if(type == APFT_UNKNOWN)
frame.clear();
}

@ -0,0 +1,33 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include <boost/algorithm/string.hpp>
#include "APRSFrame.h"
class CAPRSParser
{
public:
static bool parseFrame(const std::string& frameStr, CAPRSFrame& frame);
private:
static void setFrameType(CAPRSFrame& frame);
};

@ -0,0 +1,33 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "APRSReader.h"
#include "APRSFrame.h"
#include "APRSParser.h"
CAPRSReader::CAPRSReader()
{
}
bool CAPRSReader::readAprsFrame(const std::string& aprsFrame)
{
auto bla = aprsFrame;
return false;
}

@ -0,0 +1,33 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include "ReadAPRSFrameCallback.h"
class CAPRSReader : public CReadAPRSFrameCallback
{
public:
CAPRSReader();
bool readAprsFrame(const std::string& aprsFrame);
private:
};

@ -0,0 +1,34 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <boost/algorithm/string.hpp>
#include "APRSUtils.h"
void CAPRSUtils::dstarCallsignToAPRS(std::string& dstarCallsign)
{
if(dstarCallsign[dstarCallsign.length() - 1] == ' ') {
boost::trim(dstarCallsign);
} else {
//loop until got rid of all double blanks
while(dstarCallsign.find(" ") != std::string::npos) {
boost::replace_all(dstarCallsign, " ", " ");
}
boost::replace_all(dstarCallsign, " ", "-");//replace remaining blank with a -
}
}

@ -0,0 +1,27 @@
/*
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
class CAPRSUtils
{
public:
static void dstarCallsignToAPRS(std::string& dstarCallsign);
};

@ -124,7 +124,7 @@ void CAPRSWriter::writeData(const std::string& callsign, const CAMBEData& data)
return;
}
unsigned int length = collector->getData(buffer, 400U);
unsigned int length = collector->getData(SLOW_DATA_TYPE_GPS, buffer, 400U);
std::string text((char*)buffer, length);
auto n = text.find(':');

@ -43,7 +43,7 @@ m_exit(false),
m_connected(false),
m_reconnectTimer(1000U),
m_tries(0U),
m_APRSReadCallback(NULL),
m_APRSReadCallback(),
m_filter(""),
m_clientName(FULL_PRODUCT_NAME)
{
@ -70,7 +70,7 @@ m_exit(false),
m_connected(false),
m_reconnectTimer(1000U),
m_tries(0U),
m_APRSReadCallback(NULL),
m_APRSReadCallback(),
m_filter(filter),
m_clientName(clientName)
{
@ -88,6 +88,17 @@ m_clientName(clientName)
CAPRSWriterThread::~CAPRSWriterThread()
{
std::vector<CReadAPRSFrameCallback *> callBacksCopy;
callBacksCopy.assign(m_APRSReadCallback.begin(), m_APRSReadCallback.end());
m_APRSReadCallback.clear();
for(auto cb : callBacksCopy) {
delete cb;
}
callBacksCopy.clear();
m_username.clear();
m_password.clear();
}
@ -159,11 +170,15 @@ void* CAPRSWriterThread::Entry()
startReconnectionTimer();
}
if(line.length() > 0 && line[0] != '#')
CLog::logDebug("Received APRS Frame : %s", line.c_str());
if(length > 0 && line[0] != '#'//check if we have something and if that something is an APRS frame
&& m_APRSReadCallback != NULL)//do we have someone wanting an APRS Frame?
&& m_APRSReadCallback.size() > 0U)//do we have someone wanting an APRS Frame?
{
//CLog::logInfo("Received APRS Frame : ") + line);
m_APRSReadCallback(std::string(line));
for(auto cb : m_APRSReadCallback) {
cb->readAprsFrame(line);
}
}
}
@ -191,9 +206,10 @@ void* CAPRSWriterThread::Entry()
return NULL;
}
void CAPRSWriterThread::setReadAPRSCallback(ReadAPRSFrameCallback cb)
void CAPRSWriterThread::addReadAPRSCallback(CReadAPRSFrameCallback * cb)
{
m_APRSReadCallback = cb;
assert(cb != nullptr);
m_APRSReadCallback.push_back(cb);
}
void CAPRSWriterThread::write(const char* data)

@ -19,12 +19,14 @@
#ifndef APRSWriterThread_H
#define APRSWriterThread_H
#include <vector>
#include "TCPReaderWriterClient.h"
#include "RingBuffer.h"
#include "Timer.h"
#include "Thread.h"
#include "ReadAPRSFrameCallback.h"
typedef void (*ReadAPRSFrameCallback)(const std::string&);
class CAPRSWriterThread : public CThread {
public:
@ -44,7 +46,7 @@ public:
void clock(unsigned int ms);
void setReadAPRSCallback(ReadAPRSFrameCallback cb);
void addReadAPRSCallback(CReadAPRSFrameCallback* cb);
private:
std::string m_username;
@ -56,7 +58,7 @@ private:
bool m_connected;
CTimer m_reconnectTimer;
unsigned int m_tries;
ReadAPRSFrameCallback m_APRSReadCallback;
std::vector<CReadAPRSFrameCallback *> m_APRSReadCallback;
std::string m_filter;
std::string m_clientName;

@ -81,14 +81,14 @@ const unsigned int DATA_BLOCK_SIZE_BYTES = 21U * DV_FRAME_LENGTH_BYTES;
const unsigned int LONG_CALLSIGN_LENGTH = 8U;
const unsigned int SHORT_CALLSIGN_LENGTH = 4U;
const unsigned char SLOW_DATA_TYPE_MASK = 0xF0U;
const unsigned char SLOW_DATA_TYPE_GPS = 0x30U;
const unsigned char SLOW_DATA_TYPE_TEXT = 0x40U;
const unsigned char SLOW_DATA_TYPE_HEADER = 0x50U;
const unsigned char SLOW_DATA_TYPE_FAST_DATA1 = 0x80U;
const unsigned char SLOW_DATA_TYPE_FAST_DATA2 = 0x90U;
const unsigned char SLOW_DATA_TYPE_SQUELCH = 0xC0U;
const unsigned char SLOW_DATA_LENGTH_MASK = 0x0FU;
const unsigned char SLOW_DATA_TYPE_MASK = 0xF0U;
const unsigned char SLOW_DATA_TYPE_GPS = 0x30U;
const unsigned char SLOW_DATA_TYPE_TEXT = 0x40U;
const unsigned char SLOW_DATA_TYPE_HEADER = 0x50U;
const unsigned char SLOW_DATA_TYPE_FAST_DATA1 = 0x80U;
const unsigned char SLOW_DATA_TYPE_FAST_DATA2 = 0x90U;
const unsigned char SLOW_DATA_TYPE_SQUELCH = 0xC0U;
const unsigned char SLOW_DATA_LENGTH_MASK = 0x0FU;
const unsigned char DATA_MASK = 0x80U;
const unsigned char REPEATER_MASK = 0x40U;

@ -41,6 +41,7 @@
#include "APRSGPSDIdFrameProvider.h"
#include "APRSFixedIdFrameProvider.h"
#ifndef UNIT_TESTS
int main(int argc, char *argv[])
{
setbuf(stdout, NULL);
@ -69,6 +70,7 @@ int main(int argc, char *argv[])
return 0;
}
#endif
CDStarGatewayApp::CDStarGatewayApp(const std::string &configFile) : m_configFile(configFile), m_thread(NULL)
{

@ -0,0 +1,99 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cstring>
#include <cassert>
#include <boost/algorithm/string.hpp>
#include "GPSACollector.h"
#include "StringUtils.h"
#include "Log.h"
const unsigned int APRS_CSUM_LENGTH = 4U;
CGPSACollector::CGPSACollector() :
CSentenceCollector(SLOW_DATA_TYPE_GPS, "$$CRC", '\x0D')
{
}
bool CGPSACollector::isValidSentence(const std::string& sentence)
{
return isValidGPSA(sentence);
}
bool CGPSACollector::isValidGPSA(const std::string& gpsa)
{
if(gpsa.length() < 10U || !boost::starts_with(gpsa, "$$CRC"))
return false;
auto csum = calcCRC(gpsa);
auto csumStr = CStringUtils::string_format("%04X", csum);
auto expectedCsum = gpsa.substr(5U, APRS_CSUM_LENGTH);
bool res = ::strcasecmp(csumStr.c_str(), expectedCsum.c_str()) == 0;
return res;
}
unsigned int CGPSACollector::calcCRC(const std::string& gpsa)
{
unsigned int icomcrc = 0xFFFFU;
auto length = gpsa.length();
for (unsigned int j = 10U; j < length; j++) {
unsigned char ch = (unsigned char)gpsa[j];
for (unsigned int i = 0U; i < 8U; i++) {
bool xorflag = (((icomcrc ^ ch) & 0x01U) == 0x01U);
icomcrc >>= 1;
if (xorflag)
icomcrc ^= 0x8408U;
ch >>= 1;
}
}
return ~icomcrc & 0xFFFFU;
}
unsigned int CGPSACollector::getDataInt(unsigned char * data, unsigned int length)
{
if(data == nullptr || length == 0U || getSentence().empty())
return 0U;
auto aprsFrame = getSentence();
if(aprsFrame.length() < 11U)
return 0U;
aprsFrame = aprsFrame.substr(10).append("\r\n");
auto aprsFrameLen = aprsFrame.length();
if(length < aprsFrameLen) {
CLog::logDebug("Not enough space to copy GPS-A APRS frame");
return 0U;
}
for(unsigned int i = 0U; i < aprsFrameLen; i++){
data[i] = aprsFrame[i];
}
return aprsFrameLen;
}

@ -0,0 +1,42 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include "SentenceCollector.h"
class CGPSACollector : public CSentenceCollector
{
public:
CGPSACollector();
protected:
unsigned int getDataInt(unsigned char * data, unsigned int length);
bool isValidSentence(const std::string& sentence);
private:
static unsigned int calcCRC(const std::string& gpsa);
static bool isValidGPSA(const std::string& gpsa);
std::string m_sentence;
std::string m_collector;
};

@ -83,6 +83,11 @@ public:
static void addTarget(CLogTarget * target);
static void finalise();
template<typename... Args> static void logTrace(const std::string & f, Args... args)
{
log(LOG_TRACE, f, args...);
}
template<typename... Args> static void logDebug(const std::string & f, Args... args)
{
log(LOG_DEBUG, f, args...);

@ -22,15 +22,15 @@ export DATA_DIR=/usr/local/share/dstargateway.d/
export LOG_DIR=/var/log/dstargateway/
# choose this if you want debugging help
CPPFLAGS=-g -ggdb -W -Wall -std=c++17
export CPPFLAGS=-g -ggdb -W -Wall -Werror -std=c++17
# or, you can choose this for a much smaller executable without debugging help
#CPPFLAGS=-W -Wall -std=c++17
LDFLAGS:=-lcurl -pthread
#CPPFLAGS=-W -Wall -Werror -std=c++17
export CC=g++
export LDFLAGS:=-lcurl -pthread
ifeq ($(USE_GPSD), 1)
CPPFLAGS+= -DUSE_GPSD
LDFLAGS+= -lgps
export CPPFLAGS+= -DUSE_GPSD
export LDFLAGS+= -lgps
endif
SRCS = $(wildcard *.cpp)
@ -41,10 +41,10 @@ DEPS = $(SRCS:.cpp=.d)
all: dstargateway
dstargateway : GitVersion.h $(OBJS)
g++ $(CPPFLAGS) -o dstargateway $(OBJS) $(LDFLAGS)
$(CC) $(CPPFLAGS) -o dstargateway $(OBJS) $(LDFLAGS)
%.o : %.cpp
g++ $(CPPFLAGS) -MMD -MD -c $< -o $@
$(CC) $(CPPFLAGS) -MMD -MD -c $< -o $@
GitVersion.h : FORCE
ifneq ("$(wildcard .git/index)","")
@ -66,7 +66,8 @@ endif
.PHONY: clean
clean:
$(RM) GitVersion.h $(OBJS) $(DEPS) dstargateway
@$(RM) GitVersion.h $(OBJS) $(DEPS) dstargateway
@$(MAKE) -C Tests clean
-include $(DEPS)
@ -129,6 +130,14 @@ removehostfiles :
@rm -f $(DATA_DIR)/DCS_Hosts.txt
@rm -f $(DATA_DIR)/DPlus_Hosts.txt
.PHONY tests:
tests : GitVersion.h
# remove these to force tests makefile to rebuild them with -DUNIT_TESTS, otherwise we end up with 2 mains
@$(RM) -f DStarGatewayApp.o
@$(RM) -f DStarGatewayApp.d
@$(MAKE) -C Tests dstargateway_tests
.PHONY run-tests:
@$(MAKE) -C Tests run-tests
FORCE:

@ -0,0 +1,122 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <cassert>
#include <boost/algorithm/string.hpp>
#include "NMEASentenceCollector.h"
#include "StringUtils.h"
#include "Log.h"
#include "APRSUtils.h"
CNMEASentenceCollector::CNMEASentenceCollector(const std::string& sentence) :
CSentenceCollector(SLOW_DATA_TYPE_GPS, sentence, '\x0A')
{
}
bool CNMEASentenceCollector::isValidSentence(const std::string& sentence)
{
return isValidNMEA(sentence);
}
bool CNMEASentenceCollector::isValidNMEA(const std::string& nmea)
{
if(nmea.empty() || nmea[0] != '$')
return false;
auto posStar = nmea.find_last_of('*');
if(posStar == 0U || posStar == std::string::npos)
return false;
auto csum = calcXOR(nmea);
auto csumStr = CStringUtils::string_format("%02X", csum);
auto expctedCSumStr = nmea.substr(posStar + 1, 2U);
auto res = ::strcasecmp(expctedCSumStr.c_str(), csumStr.c_str()) == 0;
return res;
}
unsigned char CNMEASentenceCollector::calcXOR(const std::string& nmea)
{
unsigned char res = 0U;
if(!nmea.empty()) {
unsigned int i = nmea[0] == '$' ? 1U : 0U; //skip $ it it is there
while(i < nmea.length())
{
if(nmea[i] != '*') {
res ^= (unsigned char)nmea[i];
}
else {
break;
}
i++;
}
}
return res;
}
unsigned int CNMEASentenceCollector::getDataInt(unsigned char * data, unsigned int length)
{
if(data == nullptr || length == 0U || getMyCall().empty() || getSentence().empty())
return 0U;
auto nmea = getSentence();
fixUpNMEATimeStamp(nmea);
std::string fromCall = getMyCall();
CAPRSUtils::dstarCallsignToAPRS(fromCall);
std::string aprsFrame(fromCall);
aprsFrame.append("-5>GPS30,DSTAR*:")
.append(nmea)
.append("\r\n");
auto aprsFrameLen = aprsFrame.length();
if(length < aprsFrameLen) {
CLog::logDebug("Not enough space to copy NMEA APRS frame");
return 0U;
}
for(unsigned int i = 0U; i < aprsFrameLen; i++){
data[i] = aprsFrame[i];
}
return aprsFrameLen;
}
// When set on manual position Icom radios send 000000.00 as NMEA timestamps
// this is a dirty hack to correct this issue. Actually I am not sure about APRS
// software being peeky about this except APRS.fi
void CNMEASentenceCollector::fixUpNMEATimeStamp(std::string& nmea)
{
auto posStar = nmea.find_last_of('*');
if(posStar != std::string::npos)
nmea = nmea.substr(0, posStar);
time_t now;
::time(&now);
struct tm* tm = ::gmtime(&now);
auto timeStamp = CStringUtils::string_format(",%02d%02d%02d.00,", tm->tm_hour, tm->tm_min, tm->tm_sec);
boost::replace_all(nmea, ",000000.00,", timeStamp);
//recalculate checksum
nmea = CStringUtils::string_format("%s*%02x", nmea.c_str(), calcXOR(nmea));
}

@ -0,0 +1,40 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include "SentenceCollector.h"
class CNMEASentenceCollector : public CSentenceCollector
{
public:
CNMEASentenceCollector(const std::string& sentence);
protected:
unsigned int getDataInt(unsigned char * data, unsigned int length);
bool isValidSentence(const std::string& sentence);
private:
static void dstarCallsignToAPRS(std::string& call);
static bool isValidNMEA(const std::string& nmea);
static unsigned char calcXOR(const std::string& nmea);
static void fixUpNMEATimeStamp(std::string& nmea);
};

@ -0,0 +1,155 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cstring>
#include <cassert>
#include <boost/algorithm/string.hpp>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include "RSMS1AMessageCollector.h"
#include "StringUtils.h"
#include "Log.h"
#include "Utils.h"
#include "APRSUtils.h"
const unsigned int APRS_CSUM_LENGTH = 4U;
CRSMS1AMessageCollector::CRSMS1AMessageCollector() :
CSentenceCollector(SLOW_DATA_TYPE_GPS, "$$Msg", '\x0D')
{
}
bool CRSMS1AMessageCollector::isValidSentence(const std::string& sentence)
{
return isValidMsg(sentence);
}
bool CRSMS1AMessageCollector::isValidMsg(const std::string& msg)
{
if(msg.empty() || !boost::starts_with(msg, "$$Msg"))
return false;
// CUtils::dump("RS-MS1A:", (unsigned char *)msg.c_str(), msg.length());
std::vector<std::string> splits;
boost::split(splits, msg, boost::is_any_of(","));
bool ret = splits.size() >= 4
&& !splits[1].empty()
&& !splits[2].empty();
return ret;
//TODO 2022-01-01 figure out what the heck it is about thic strange CRCs
// CUtils::dump("RS-MS1A:", (unsigned char *)gpsa.c_str(), gpsa.length() + 1U);
// CLog::logDebug("RS-MS1A: %s", gpsa.c_str());
// auto thirdCommaPos = CStringUtils::find_nth(gpsa, 0U, ',', 3);
// auto csum = calcCRC(gpsa, thirdCommaPos + 6 + 1, gpsa.length() - thirdCommaPos - 2U - 6U);
// auto csumStr = CStringUtils::string_format("%06X", csum);
// CLog::logDebug("RS-MS1A CRC: %s", csumStr.c_str());
// auto expectedCsum = gpsa.substr(5U, APRS_CSUM_LENGTH);
// bool res = ::strcasecmp(csumStr.c_str(), expectedCsum.c_str()) == 0;
// return res;
}
unsigned int CRSMS1AMessageCollector::calcCRC(const std::string& gpsa, unsigned int start, unsigned int length)
{
unsigned int icomcrc = 0xFFFFU;
auto end = start + length;
if(end > gpsa.length()) {
end = gpsa.length();
}
for (unsigned int j = start; j < end; j++) {
unsigned char ch = (unsigned char)gpsa[j];
for (unsigned int i = 0U; i < 8U; i++) {
bool xorflag = (((icomcrc ^ ch) & 0x01U) == 0x01U);
icomcrc >>= 1;
if (xorflag)
icomcrc ^= 0x8408U;
ch >>= 1;
}
}
return ~icomcrc & 0xFFFFU;
}
unsigned int CRSMS1AMessageCollector::getDataInt(unsigned char * data, unsigned int length)
{
if(data == nullptr || length == 0U || getSentence().empty())
return 0U;
auto sentence = getSentence();
std::vector<std::string> splits;
boost::split(splits, sentence, boost::is_any_of(","));
bool ret = splits.size() >= 4
&& !splits[1].empty()
&& !splits[2].empty();
if(!ret) {
return 0U;
}
auto sender = splits[1];
auto recipient = CUtils::ToUpper(splits[2]);
for(unsigned int i = 0;i < 3; i++) {
splits.erase(splits.begin());
}
auto message = boost::join(splits, ",");
if(message.length() > 6)
message = message.substr(6);
auto seqNum = rand() % 0xFFFFFU;
CAPRSUtils::dstarCallsignToAPRS(sender);
CAPRSUtils::dstarCallsignToAPRS(recipient);
recipient.resize(9, ' ');
message.resize(std::max<int>(0 , ((int)message.length()) - 2));
//unescape commas in message body
boost::replace_all(message, "o,", ",");
auto aprsFrame = CStringUtils::string_format("%s-5>APDPRS,DSTAR*::%s:%s{%05X\r\n", sender.c_str(), recipient.c_str(), message.c_str(), seqNum);
auto aprsFrameLen = aprsFrame.length();
if(length < aprsFrameLen) {
CLog::logDebug("Not enough space to copy GPS-A APRS frame");
return 0U;
}
for(unsigned int i = 0U; i < aprsFrameLen; i++){
data[i] = aprsFrame[i];
}
return aprsFrameLen;
}

@ -0,0 +1,41 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include "SentenceCollector.h"
class CRSMS1AMessageCollector : public CSentenceCollector
{
public:
CRSMS1AMessageCollector();
protected:
unsigned int getDataInt(unsigned char * data, unsigned int length);
bool isValidSentence(const std::string& sentence);
private:
static unsigned int calcCRC(const std::string& gpsa, unsigned int start, unsigned int length);
static bool isValidMsg(const std::string& gpsa);
std::string m_sentence;
std::string m_collector;
};

@ -0,0 +1,28 @@
/*
* Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
class CReadAPRSFrameCallback
{
public:
virtual ~CReadAPRSFrameCallback(){ }
virtual bool readAprsFrame(const std::string& aprsFrame) = 0;
};

@ -0,0 +1,75 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cassert>
#include "SentenceCollector.h"
CSentenceCollector::CSentenceCollector(unsigned char slowDataType, const std::string& sentenceIdentifier, unsigned char endMarker) :
CSlowDataCollector(slowDataType),
m_collector(),
m_sentenceIdentifier(sentenceIdentifier),
m_sentence(),
m_endMarker(endMarker)
{
assert(!sentenceIdentifier.empty());
}
bool CSentenceCollector::addData(const unsigned char * data)
{
m_collector.append(std::string((char*)data, 5U));
std::string::size_type n2 = m_collector.find_last_of(m_endMarker);
if (n2 == std::string::npos)
return false;
std::string::size_type n1 = m_collector.find(m_sentenceIdentifier);
if (n1 == std::string::npos)
return false;
if(n2 < n1)
return false;
std::string sentence;
for(unsigned int i = n1; i <= n2; i++) {
sentence.push_back(m_collector[i] & 0x7FU);
}
bool ret = isValidSentence(sentence);
if(ret) {
m_sentence = sentence;
} else {
m_sentence.clear();
}
m_collector = m_collector.substr(n2);
return ret;
}
std::string CSentenceCollector::getSentence()
{
return m_sentence;
}
void CSentenceCollector::resetInt()
{
m_collector.clear();
m_sentence.clear();
}

@ -0,0 +1,46 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include "SlowDataCollector.h"
class CSentenceCollector : public CSlowDataCollector
{
public:
CSentenceCollector(unsigned char slowDataType, const std::string& sentenceIdentifier, unsigned char endMarker);
protected:
bool addData(const unsigned char * data);
virtual unsigned int getDataInt(unsigned char * data, unsigned int length) = 0;
static void dstarCallsignToAPRS(std::string& call);
std::string getSentence();
private:
virtual bool isValidSentence(const std::string& sentence) = 0;
virtual void resetInt();
std::string m_collector;
std::string m_sentenceIdentifier;
std::string m_sentence;
unsigned char m_endMarker;
};

@ -0,0 +1,116 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cassert>
#include <cstring>
#include "SlowDataCollector.h"
#include "Log.h"
const unsigned int SLOW_DATA_BLOCK_LENGTH = 6U;
CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) :
m_slowDataType(slowDataType),
m_myCall(),
m_state(SS_FIRST)
{
m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH];
std::memset(m_buffer, 0, SLOW_DATA_BLOCK_LENGTH);
}
CSlowDataCollector::~CSlowDataCollector()
{
delete[] m_buffer;
}
std::string CSlowDataCollector::getMyCall() const
{
return m_myCall;
}
void CSlowDataCollector::setMyCall(const std::string& myCall)
{
m_myCall = myCall;
}
bool CSlowDataCollector::writeData(const unsigned char* data)
{
assert(data != nullptr);
switch (m_state) {
case SS_FIRST:
m_buffer[0U] = data[0U] ^ SCRAMBLER_BYTE1;
m_buffer[1U] = data[1U] ^ SCRAMBLER_BYTE2;
m_buffer[2U] = data[2U] ^ SCRAMBLER_BYTE3;
m_state = SS_SECOND;
return false;
case SS_SECOND:
m_buffer[3U] = data[0U] ^ SCRAMBLER_BYTE1;
m_buffer[4U] = data[1U] ^ SCRAMBLER_BYTE2;
m_buffer[5U] = data[2U] ^ SCRAMBLER_BYTE3;
m_state = SS_FIRST;
break;
}
// unsigned char rxDataType = (m_buffer[0] & SLOW_DATA_TYPE_MASK);
// switch (rxDataType)
// {
// case SLOW_DATA_TYPE_MASK: CLog::logDebug("SLOW_DATA_TYPE_MASK "); break;
// case SLOW_DATA_TYPE_GPS: CLog::logDebug("SLOW_DATA_TYPE_GPS "); break;
// case SLOW_DATA_TYPE_TEXT: CLog::logDebug("SLOW_DATA_TYPE_TEXT "); break;
// case SLOW_DATA_TYPE_HEADER: CLog::logDebug("SLOW_DATA_TYPE_HEADER "); break;
// case SLOW_DATA_TYPE_MESSAGE: CLog::logDebug("SLOW_DATA_TYPE_MESSAGE "); break;
// case SLOW_DATA_TYPE_FAST_DATA1: CLog::logDebug("SLOW_DATA_TYPE_FAST_DATA1 "); break;
// case SLOW_DATA_TYPE_FAST_DATA2: CLog::logDebug("SLOW_DATA_TYPE_FAST_DATA2 "); break;
// case SLOW_DATA_TYPE_SQUELCH: CLog::logDebug("SLOW_DATA_TYPE_SQUELCH "); break;
// case SLOW_DATA_LENGTH_MASK: CLog::logDebug("SLOW_DATA_LENGTH_MASK "); break;
// default:
// CLog::logDebug("!!!!!!!!!!!!!!! %X", rxDataType);
// break;
// };
if((m_buffer[0] & SLOW_DATA_TYPE_MASK) == m_slowDataType)
return addData(m_buffer + 1U);
return false;
}
void CSlowDataCollector::sync()
{
m_state = SS_FIRST;
}
unsigned int CSlowDataCollector::getData(unsigned char * data, unsigned int length)
{
return getDataInt(data, length);
}
void CSlowDataCollector::reset()
{
m_state = SS_FIRST;
m_myCall.clear();
resetInt();
}
unsigned char CSlowDataCollector::getDataType()
{
return m_slowDataType;
}

@ -0,0 +1,51 @@
/*
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include "DStarDefines.h"
#include "Defs.h"
class CSlowDataCollector
{
public:
CSlowDataCollector(unsigned char slowDataType);
virtual ~CSlowDataCollector();
std::string getMyCall() const;
void setMyCall(const std::string& mycall);
bool writeData(const unsigned char* data);
void sync();
unsigned int getData(unsigned char* data, unsigned int length);
void reset();
unsigned char getDataType();
protected:
virtual bool addData(const unsigned char* data) = 0;
virtual unsigned int getDataInt(unsigned char* data, unsigned int length) = 0;
virtual void resetInt() { }
private:
unsigned char m_slowDataType;
std::string m_myCall;
SLOWDATA_STATE m_state;
unsigned char * m_buffer;
};

@ -0,0 +1,35 @@
/*
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "StringUtils.h"
size_t CStringUtils::find_nth(const std::string& haystack, char needle, size_t nth)
{
size_t matches = 0U;
auto haystackLength = haystack.length();
for(size_t i = 0; i < haystackLength; i++) {
if(haystack[i] == needle) {
matches++;
if(matches == nth)
return i;
}
}
return std::string::npos;
}

@ -1,7 +1,5 @@
/*
* Copyright (C) 2009-2011,2013 by Jonathan Naylor G4KLX
* Copyright (c) 2017 by Thomas A. Early N7TAE
* Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,4 +47,6 @@ public:
output.reserve(size);
output.assign(buf.get(), size - 1); // -1 because we do not need trailing '\0'
}
static size_t find_nth(const std::string& haystack, char needle, size_t nth);
};

@ -0,0 +1,105 @@
/*
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gtest/gtest.h>
#include "../../APRSParser.h"
class APRSParser_parseAPRSFrame : public ::testing::Test {
};
TEST_F(APRSParser_parseAPRSFrame, EmpyString) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame("", aprsFrame);
EXPECT_FALSE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "");
EXPECT_EQ(aprsFrame.getType(), APFT_UNKNOWN);
EXPECT_EQ(aprsFrame.getPath().size(), 0U);
}
TEST_F(APRSParser_parseAPRSFrame, NoSourceCallsign) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame(">APRS::F4ABC Test Message", aprsFrame);
EXPECT_FALSE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "");
EXPECT_EQ(aprsFrame.getType(), APFT_UNKNOWN);
EXPECT_EQ(aprsFrame.getPath().size(), 0U);
}
TEST_F(APRSParser_parseAPRSFrame, NoDestCallsign) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame("N0CALL>::F4ABC Test Message", aprsFrame);
EXPECT_FALSE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "");
EXPECT_EQ(aprsFrame.getType(), APFT_UNKNOWN);
EXPECT_EQ(aprsFrame.getPath().size(), 0U);
}
TEST_F(APRSParser_parseAPRSFrame, CorrectMessageFrameWithDigipeater) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame("N0CALL>APRS,WIDE1-1,WIDE2-2::F4ABC :Test Message", aprsFrame);
EXPECT_TRUE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), ":F4ABC :Test Message");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "APRS");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "N0CALL");
EXPECT_EQ(aprsFrame.getType(), APFT_MESSAGE);
EXPECT_EQ(aprsFrame.getPath().size(), 2);
EXPECT_STREQ(aprsFrame.getPath()[0].c_str(), "WIDE1-1");
EXPECT_STREQ(aprsFrame.getPath()[1].c_str(), "WIDE2-2");
}
TEST_F(APRSParser_parseAPRSFrame, CorrectMessageFrameWithoutDigipeater) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame("N0CALL>APRS::F4ABC :Test Message", aprsFrame);
EXPECT_TRUE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), ":F4ABC :Test Message");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "APRS");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "N0CALL");
EXPECT_EQ(aprsFrame.getType(), APFT_MESSAGE);
EXPECT_EQ(aprsFrame.getPath().size(), 0);
}
TEST_F(APRSParser_parseAPRSFrame, InvalideMessageFrame) {
CAPRSFrame aprsFrame;
bool retVal = CAPRSParser::parseFrame("N0CALL>APRS::F4ABC&@#$:Test Message", aprsFrame);
EXPECT_FALSE(retVal);
EXPECT_STRCASEEQ(aprsFrame.getBody().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getDestination().c_str(), "");
EXPECT_STRCASEEQ(aprsFrame.getSource().c_str(), "");
EXPECT_EQ(aprsFrame.getType(), APFT_UNKNOWN);
EXPECT_EQ(aprsFrame.getPath().size(), 0U);
}

@ -0,0 +1,19 @@
SRCS = $(wildcard *.cpp) $(wildcard ../*.cpp) $(wildcard */*.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
dstargateway_tests: $(OBJS)
$(CC) $(CPPFLAGS) -o dstargateway_tests $(OBJS) $(LDFLAGS) -lgtest -lgtest_main
%.o : %.cpp
$(CC) $(CPPFLAGS) -DUNIT_TESTS -I../ -MMD -MD -c $< -o $@
-include $(DEPS)
.PHONY run-tests: dstargateway_tests
./dstargateway_tests
.PHONY clean :
clean :
@$(RM) $(OBJS) $(DEPS) dstargateway_tests

@ -164,7 +164,7 @@ maxDongles=5
[DPlus]
enabled=true # There is no reason to disable this
maxDongles=5
login=F4FXL # defaults to gateway callsign
login= # defaults to gateway callsign
[DCS]
enabled=true # There is no reason to disable this

Loading…
Cancel
Save

Powered by TurnKey Linux.