Fixing some APRS packet structures

This commit is contained in:
Jordan Sherer 2018-09-21 14:43:02 -04:00
parent 25e7631c09
commit 0451f6aca9
4 changed files with 40 additions and 25 deletions

View File

@ -8,10 +8,10 @@
const int PACKET_TIMEOUT_SECONDS = 300;
APRSISClient::APRSISClient(QString host, quint16 port, QObject *parent):
QTcpSocket(parent),
m_host(host),
m_port(port)
QTcpSocket(parent)
{
setServer(host, port);
connect(&m_timer, &QTimer::timeout, this, &APRSISClient::sendReports);
m_timer.setInterval(60*1000); // every 60 seconds
m_timer.start();
@ -184,13 +184,31 @@ QPair<QString, QString> APRSISClient::grid2aprs(QString grid){
};
}
QString APRSISClient::replaceCallsignSuffixWithSSID(QString call, QString base){
if(call != base){
QRegularExpression re("[/](?<ssid>(P|\\d+))");
auto matcher = re.globalMatch(call);
if(matcher.hasNext()){
auto match = matcher.next();
auto ssid = match.captured("ssid");
if(ssid == "P"){
ssid = "16";
}
call = base + "-" + ssid;
} else {
call = base;
}
}
return call;
}
void APRSISClient::enqueueSpot(QString theircall, QString grid, QString comment){
if(m_localCall.isEmpty()) return;
auto geo = APRSISClient::grid2aprs(grid);
auto spotFrame = QString("%1>%2,APRS,TCPIP*:=%3/%4nFT8CALL %5\n");
auto spotFrame = QString("%1>APRS,TCPIP*:=%2/%3nFT8CALL %4\n");
spotFrame = spotFrame.arg(theircall);
spotFrame = spotFrame.arg(m_localCall);
spotFrame = spotFrame.arg(geo.first);
spotFrame = spotFrame.arg(geo.second);
spotFrame = spotFrame.arg(comment.left(43));
@ -202,9 +220,8 @@ void APRSISClient::enqueueThirdParty(QString theircall, QString payload){
return;
}
auto frame = QString("%1>%2,APRS,TCPIP*:%3\n");
auto frame = QString("%1>APRS,TCPIP*:%2\n");
frame = frame.arg(theircall);
frame = frame.arg(m_localCall);
frame = frame.arg(payload);
enqueueRaw(frame);
}
@ -226,6 +243,7 @@ void APRSISClient::processQueue(bool disconnect){
// 4. disconnect
if(state() != QTcpSocket::ConnectedState){
qDebug() << "APRSISClient Connecting:" << m_host << m_port;
connectToHost(m_host, m_port);
if(!waitForConnected(5000)){
qDebug() << "APRSISClient Connection Error:" << errorString();

View File

@ -17,6 +17,7 @@ public:
static QString loginFrame(QString callsign);
static QPair<float, float> grid2deg(QString grid);
static QPair<QString, QString> grid2aprs(QString grid);
static QString replaceCallsignSuffixWithSSID(QString call, QString base);
void setServer(QString host, quint16 port){
if(state() == QTcpSocket::ConnectedState){
@ -25,6 +26,8 @@ public:
m_host = host;
m_port = port;
qDebug() << "APRSISClient Server Change:" << m_host << m_port;
}
void setPaused(bool paused){

View File

@ -30,7 +30,8 @@ print "Connected..."
data = s.recv(1024)
print data
call = 'KN4CRD'
print "Callsign: "
call = raw_input().strip()
pw = do_hash(call)
ver = "FT8Call"
@ -43,7 +44,7 @@ data = s.recv(1024)
print data
if 0:
message = "KN4CRD>OH8STN,APRS,TCPIP*::EMAIL-2 :KN4CRD@GMAIL.COM TESTING!{04}\n"
message = "KN4CRD>APRS,TCPIP*::EMAIL-2 :KN4CRD@GMAIL.COM TESTING!{04}\n"
s.send(message)
if 0:
@ -59,7 +60,7 @@ if 1:
position = "=3352.45N/08422.71Wn"
status = "FT8CALL VIA XX9XXX/XXXX 14.082500MHz -20dB"
payload = "".join((position, status))
message = "{}>OH8STN,APRS,TCPIP*:{}\n".format(call, payload)
message = "{}-16>APRS,TCPIP*:{}\n".format(call, payload)
s.send(message)
print "Spot sent...", message

View File

@ -4130,7 +4130,11 @@ void MainWindow::aprsLogReport(int offset, int snr, QString callsign, QString gr
if(callsign.contains("/")){
comment = QString("%1 %2").arg(callsign).arg(comment);
}
m_aprsClient->enqueueSpot(Radio::base_callsign(callsign), grid, comment);
auto base = Radio::base_callsign(callsign);
callsign = APRSISClient::replaceCallsignSuffixWithSSID(callsign, base);
m_aprsClient->enqueueSpot(callsign, grid, comment);
}
void MainWindow::killFile ()
@ -8819,21 +8823,10 @@ void MainWindow::aprsSetLocal ()
auto grid = m_config.my_grid();
auto passcode = m_config.aprs_passcode();
#if SPOT_SSID_SUFFIX
if(call != base){
QRegularExpression re("[/](?<ssid>\\d+)");
auto matcher = re.globalMatch(call);
if(matcher.hasNext()){
auto match = matcher.next();
call = base + "-" + match.captured("ssid");
} else {
call = base;
}
}
#endif
call = APRSISClient::replaceCallsignSuffixWithSSID(call, base);
qDebug() << "APRSISClient Set Local Station:" << base << grid << passcode;
m_aprsClient->setLocalStation(base, grid, passcode);
qDebug() << "APRSISClient Set Local Station:" << call << grid << passcode;
m_aprsClient->setLocalStation(call, grid, passcode);
}
void MainWindow::transmitDisplay (bool transmitting)