mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2026-01-06 08:19:59 +01:00
Use the header my callsign for the APRS callsign on a TH-D74.
This commit is contained in:
parent
ba7d848f78
commit
71f388197f
|
|
@ -57,12 +57,15 @@ CAPRSCollector::~CAPRSCollector()
|
|||
delete[] m_buffer;
|
||||
}
|
||||
|
||||
bool CAPRSCollector::writeData(const wxString& callsign, const unsigned char* data)
|
||||
void CAPRSCollector::writeHeader(const wxString& callsign)
|
||||
{
|
||||
m_callsign = callsign;
|
||||
}
|
||||
|
||||
bool CAPRSCollector::writeData(const unsigned char* data)
|
||||
{
|
||||
wxASSERT(data != NULL);
|
||||
|
||||
m_callsign = callsign;
|
||||
|
||||
switch (m_slowData) {
|
||||
case SS_FIRST:
|
||||
m_buffer[0U] = data[0U] ^ SCRAMBLER_BYTE1;
|
||||
|
|
@ -415,13 +418,7 @@ unsigned int CAPRSCollector::convertNMEA1(unsigned char* data, unsigned int)
|
|||
return 0U;
|
||||
|
||||
char callsign[10U];
|
||||
::memset(callsign, ' ', 10U);
|
||||
for (unsigned int i = 0U; i < m_callsign.Len(); i++)
|
||||
callsign[i] = m_callsign.GetChar(i);
|
||||
|
||||
// This can't fail!
|
||||
char* p = ::strchr(callsign, ' ');
|
||||
*p = '\0';
|
||||
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);
|
||||
|
||||
|
|
@ -434,7 +431,7 @@ unsigned int CAPRSCollector::convertNMEA1(unsigned char* data, unsigned int)
|
|||
|
||||
str = (char*)m_rmcData;
|
||||
for (;;) {
|
||||
p = mystrsep(&str, ",\r\n");
|
||||
char* p = mystrsep(&str, ",\r\n");
|
||||
|
||||
pRMC[nRMC++] = p;
|
||||
if (p == NULL)
|
||||
|
|
@ -484,13 +481,7 @@ unsigned int CAPRSCollector::convertNMEA2(unsigned char* data, unsigned int)
|
|||
return 0U;
|
||||
|
||||
char callsign[10U];
|
||||
::memset(callsign, ' ', 10U);
|
||||
for (unsigned int i = 0U; i < m_callsign.Len(); i++)
|
||||
callsign[i] = m_callsign.GetChar(i);
|
||||
|
||||
// This can't fail!
|
||||
char* p = ::strchr(callsign, ' ');
|
||||
*p = '\0';
|
||||
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);
|
||||
|
||||
|
|
@ -504,6 +495,29 @@ unsigned int CAPRSCollector::convertNMEA2(unsigned char* data, unsigned int)
|
|||
return ::strlen((char*)data);
|
||||
}
|
||||
|
||||
void CAPRSCollector::dstarCallsignToAPRS(const wxString& dstarCallsign, char* aprsCallsign) const
|
||||
{
|
||||
wxASSERT(aprsCallsign != NULL);
|
||||
|
||||
wxString first = dstarCallsign.BeforeFirst(wxT(' '));
|
||||
wxString last = dstarCallsign.AfterLast(wxT(' '));
|
||||
|
||||
if (first.IsSameAs(last)) {
|
||||
unsigned int n = 0U;
|
||||
for (unsigned int i = 0U; i < dstarCallsign.Len(); i++)
|
||||
aprsCallsign[n++] = dstarCallsign.GetChar(i);
|
||||
aprsCallsign[n++] = '\0';
|
||||
} else {
|
||||
unsigned int n = 0U;
|
||||
for (unsigned int i = 0U; i < first.Len(); i++)
|
||||
aprsCallsign[n++] = first.GetChar(i);
|
||||
aprsCallsign[n++] = '-';
|
||||
for (unsigned int i = 0U; i < last.Len(); i++)
|
||||
aprsCallsign[n++] = last.GetChar(i);
|
||||
aprsCallsign[n++] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Source found at <http://unixpapa.com/incnote/string.html>
|
||||
char* CAPRSCollector::mystrsep(char** sp, const char* sep) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,12 +35,14 @@ public:
|
|||
CAPRSCollector();
|
||||
~CAPRSCollector();
|
||||
|
||||
bool writeData(const wxString& callsign, const unsigned char* data);
|
||||
void writeHeader(const wxString& callsign);
|
||||
|
||||
void sync();
|
||||
bool writeData(const unsigned char* data);
|
||||
|
||||
void reset();
|
||||
|
||||
void sync();
|
||||
|
||||
unsigned int getData(unsigned char* data, unsigned int length);
|
||||
|
||||
private:
|
||||
|
|
@ -74,6 +76,8 @@ private:
|
|||
unsigned int convertNMEA1(unsigned char* data, unsigned int length);
|
||||
unsigned int convertNMEA2(unsigned char* data, unsigned int length);
|
||||
|
||||
void dstarCallsignToAPRS(const wxString& dstarCallsign, char* aprsCallsign) const;
|
||||
|
||||
char* mystrsep(char** sp, const char* sep) const;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,21 @@ bool CAPRSWriter::open()
|
|||
return m_thread->start();
|
||||
}
|
||||
|
||||
void CAPRSWriter::writeHeader(const wxString& callsign, const CHeaderData& header)
|
||||
{
|
||||
CAPRSEntry* entry = m_array[callsign];
|
||||
if (entry == NULL) {
|
||||
wxLogError(wxT("Cannot find the callsign \"%s\" in the APRS array"), callsign.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
entry->reset();
|
||||
|
||||
CAPRSCollector* collector = entry->getCollector();
|
||||
|
||||
collector->writeHeader(header.getMyCall1());
|
||||
}
|
||||
|
||||
void CAPRSWriter::writeData(const wxString& callsign, const CAMBEData& data)
|
||||
{
|
||||
if (data.isEnd())
|
||||
|
|
@ -179,7 +194,7 @@ void CAPRSWriter::writeData(const wxString& callsign, const CAMBEData& data)
|
|||
unsigned char buffer[400U];
|
||||
data.getData(buffer, DV_FRAME_MAX_LENGTH_BYTES);
|
||||
|
||||
bool complete = collector->writeData(callsign, buffer + VOICE_FRAME_LENGTH_BYTES);
|
||||
bool complete = collector->writeData(buffer + VOICE_FRAME_LENGTH_BYTES);
|
||||
if (!complete)
|
||||
return;
|
||||
|
||||
|
|
@ -230,17 +245,6 @@ void CAPRSWriter::writeData(const wxString& callsign, const CAMBEData& data)
|
|||
collector->reset();
|
||||
}
|
||||
|
||||
void CAPRSWriter::reset(const wxString& callsign)
|
||||
{
|
||||
CAPRSEntry* entry = m_array[callsign];
|
||||
if (entry == NULL) {
|
||||
wxLogError(wxT("Cannot find the callsign \"%s\" in the APRS array"), callsign.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
entry->reset();
|
||||
}
|
||||
|
||||
void CAPRSWriter::clock(unsigned int ms)
|
||||
{
|
||||
m_idTimer.clock(ms);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "APRSWriterThread.h"
|
||||
#include "APRSCollector.h"
|
||||
#include "DStarDefines.h"
|
||||
#include "HeaderData.h"
|
||||
#include "AMBEData.h"
|
||||
#include "Timer.h"
|
||||
#include "Defs.h"
|
||||
|
|
@ -73,9 +74,9 @@ public:
|
|||
|
||||
void setPort(const wxString& callsign, const wxString& band, double frequency, double offset, double range, double latitude, double longitude, double agl);
|
||||
|
||||
void writeData(const wxString& callsign, const CAMBEData& data);
|
||||
void writeHeader(const wxString& callsign, const CHeaderData& header);
|
||||
|
||||
void reset(const wxString& callsign);
|
||||
void writeData(const wxString& callsign, const CAMBEData& data);
|
||||
|
||||
bool isConnected() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ void CRepeaterHandler::processRepeater(CHeaderData& header)
|
|||
|
||||
// Reset the APRS Writer if it's enabled
|
||||
if (m_aprsWriter != NULL)
|
||||
m_aprsWriter->reset(m_rptCallsign);
|
||||
m_aprsWriter->writeHeader(m_rptCallsign, header);
|
||||
|
||||
// Write to Header.log if it's enabled
|
||||
if (m_headerLogger != NULL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue