#42 add different APRS to Call depending on gateway type

feature/aprs_#42
Geoffrey Merck 2 years ago
parent fa80327ce9
commit e45103fe27

@ -21,7 +21,7 @@
#include "APRSEntry.h"
CAPRSEntry::CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) :
CAPRSEntry::CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl, GATEWAY_TYPE gwType) :
m_callsign(callsign),
m_band(band),
m_frequency(frequency),
@ -33,7 +33,8 @@ m_agl(agl),
m_timer(1000U, 10U),
m_first(true),
m_collector(NULL),
m_linkStatus()
m_linkStatus(),
m_gatewayType(gwType)
{
boost::trim(m_callsign);
@ -95,6 +96,11 @@ CAPRSEntryStatus& CAPRSEntry::getStatus()
return m_linkStatus;
}
GATEWAY_TYPE CAPRSEntry::getType() const
{
return m_gatewayType;
}
void CAPRSEntry::reset()
{
m_first = true;

@ -28,7 +28,7 @@
class CAPRSEntry {
public:
CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl);
CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl, GATEWAY_TYPE gwType);
~CAPRSEntry();
std::string getCallsign() const;
@ -41,6 +41,7 @@ public:
double getAGL() const;
CAPRSCollector* getCollector() const;
CAPRSEntryStatus& getStatus();
GATEWAY_TYPE getType() const;
// Transmission timer
void reset();
@ -60,4 +61,5 @@ private:
bool m_first;
CAPRSCollector* m_collector;
CAPRSEntryStatus m_linkStatus;
GATEWAY_TYPE m_gatewayType;
};

@ -116,8 +116,11 @@ bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std
lon.c_str(), (entry->getLongitude() < 0.0F) ? 'W' : 'E',
entry->getRange() * 0.6214, entry->getAGL() * 3.28, band.c_str(), desc.c_str());
std::string toCall;
getToCall(entry->getType(), toCall);
CAPRSFrame * frame = new CAPRSFrame(m_gateway + "-S",
"APD5T1",
toCall,
{ "TCPIP*", "qAC" , m_gateway + "-GS" },
body, APFT_OBJECT);
@ -130,7 +133,7 @@ bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std
entry->getRange() * 0.6214, entry->getAGL() * 3.28, band.c_str(), desc.c_str());
frame = new CAPRSFrame(entry->getCallsign() + "-" + entry->getBand(),
"APD5T2",
toCall,
{ "TCPIP*", "qAC", entry->getCallsign() + "-" + entry->getBand() + "S"},
body, APFT_POSITION);

@ -188,9 +188,11 @@ bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std:
body.append(CStringUtils::string_format("RNG%04.0lf %s %s\r\n", entry->getRange() * 0.6214, band.c_str(), desc.c_str()));
std::string toCall;
getToCall(entry->getType(), toCall);
CAPRSFrame * frame = new CAPRSFrame(m_gateway + "-S",
"APD5T1",
toCall,
{ "TCPIP*", "qAC" , m_gateway + "-GS" },
body, APFT_OBJECT);
@ -209,7 +211,7 @@ bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const CAPRSEntry * entry, std:
lon.c_str(), (rawLongitude < 0.0) ? 'W' : 'E');
frame = new CAPRSFrame(m_gateway,
"APD5T2",
toCall,
{ "TCPIP*", "qAC" , m_gateway + "-GS" },
body, APFT_POSITION);

@ -51,13 +51,13 @@ CAPRSHandler::~CAPRSHandler()
delete m_backend;
}
void CAPRSHandler::setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl)
void CAPRSHandler::setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl, GATEWAY_TYPE gwType)
{
std::string temp = callsign;
temp.resize(LONG_CALLSIGN_LENGTH - 1U, ' ');
temp += band;
m_array[temp] = new CAPRSEntry(callsign, band, frequency, offset, range, latitude, longitude, agl);
m_array[temp] = new CAPRSEntry(callsign, band, frequency, offset, range, latitude, longitude, agl, gwType);
}
bool CAPRSHandler::open()
@ -183,8 +183,11 @@ void CAPRSHandler::sendStatusFrame(CAPRSEntry * entry)
std::string sourCall = entry->getCallsign() + '-' + entry->getBand();
std::string toCall;
CAPRSIdFrameProvider::getToCall(entry->getType(), toCall);
CAPRSFrame frame(sourCall,
"APD5T3",
toCall,
{ "TCPIP*", "qAC", sourCall + "S" },
body,
APFT_STATUS);

@ -44,7 +44,7 @@ public:
void setIdFrameProvider(CAPRSIdFrameProvider * idFrameProvider) { m_idFrameProvider = idFrameProvider; }
void setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl);
void setPort(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl, GATEWAY_TYPE gwType);
void writeHeader(const std::string& callsign, const CHeaderData& header);

@ -56,3 +56,21 @@ bool CAPRSIdFrameProvider::wantsToSend()
return false;
}
void CAPRSIdFrameProvider::getToCall(GATEWAY_TYPE gwType, std::string& toCall)
{
switch(gwType)
{
case GT_REPEATER:
toCall.assign("APD5TR");
return;
case GT_HOTSPOT:
toCall.assign("APD5TH");
return;
case GT_DONGLE:
toCall.assign("APD5TD");
return;
default:
toCall.assign("APD5T0");
}
}

@ -35,6 +35,7 @@ public:
bool wantsToSend();
virtual void start() { };
virtual void close() { };
static void getToCall(GATEWAY_TYPE gwType, std::string& toCall);
protected:
virtual bool buildAPRSFramesInt(const CAPRSEntry * aprsEntry, std::vector<CAPRSFrame *>& frames) = 0;

@ -286,9 +286,9 @@ bool CDStarGatewayApp::createThread()
rptrConfig.band3);
if(outgoingAprsWriter != nullptr)
outgoingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl);
outgoingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl, gatewayConfig.type);
if(incomingAprsWriter != nullptr)
incomingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl);
incomingAprsWriter->setPort(rptrConfig.callsign, rptrConfig.band, rptrConfig.frequency, rptrConfig.offset, rptrConfig.range, rptrConfig.latitude, rptrConfig.longitude, rptrConfig.agl, gatewayConfig.type);
if(!ddEnabled) ddEnabled = rptrConfig.band.length() > 1U;
}

@ -146,7 +146,7 @@ The testing framwework used is Google Test.
# 5. Version History
## 5.1. Version 1.0
- [**Improvement**] APRS Improvements: Diplay 220MHz in APRS Posits ([#42](https://github.com/F4FXL/DStarGateway/issues/42))
- [**Improvement**] APRS Improvements: Diplay 220MHz in APRS Posits, add different ToCalls depending on gateway type ([#42](https://github.com/F4FXL/DStarGateway/issues/42))
- [**Improvement**] Improve CI to include all variants of build configurations ([#40](https://github.com/F4FXL/DStarGateway/issues/40))
- [**Bugfix**] Fix #37 Unable to transmit multiple files (DGWVoiceTransmit) ([#37](https://github.com/F4FXL/DStarGateway/issues/37))
- [**Bugfix**] Fix #36 Error1 Build fails in some environment ([#36](https://github.com/F4FXL/DStarGateway/issues/36))

@ -0,0 +1,68 @@
/*
* Copyright (c) 2021-2023 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 "APRSIdFrameProvider.h"
namespace APRSIdFrameProviderTests
{
class APRSIdFrameProvider_getToCall : public ::testing::Test {
};
TEST_F(APRSIdFrameProvider_getToCall, RepeaterToCall)
{
std::string toCall;
CAPRSIdFrameProvider::getToCall(GT_REPEATER, toCall);
EXPECT_STRCASEEQ(toCall.c_str(), "APD5TR") << "Unexpected toCall";
}
TEST_F(APRSIdFrameProvider_getToCall, HotspotToCall)
{
std::string toCall;
CAPRSIdFrameProvider::getToCall(GT_HOTSPOT, toCall);
EXPECT_STRCASEEQ(toCall.c_str(), "APD5TH") << "Unexpected toCall";
}
TEST_F(APRSIdFrameProvider_getToCall, DongleToCall)
{
std::string toCall;
CAPRSIdFrameProvider::getToCall(GT_DONGLE, toCall);
EXPECT_STRCASEEQ(toCall.c_str(), "APD5TD") << "Unexpected toCall";
}
TEST_F(APRSIdFrameProvider_getToCall, SmartGroupToCall)
{
std::string toCall;
CAPRSIdFrameProvider::getToCall(GT_SMARTGROUP, toCall);
EXPECT_STRCASEEQ(toCall.c_str(), "APD5T0") << "Unexpected toCall";
}
TEST_F(APRSIdFrameProvider_getToCall, UnknownToCall)
{
std::string toCall;
CAPRSIdFrameProvider::getToCall((GATEWAY_TYPE)123456789, toCall);
EXPECT_STRCASEEQ(toCall.c_str(), "APD5T0");
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.