Skip to content

DXSpot for Flex Radio #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: testing_0.45
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions rig/drivers/HamlibRigDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "core/debug.h"
#include "rig/macros.h"
#include "data/SerialPort.h"
#include "data/Data.h"

#ifndef HAMLIB_FILPATHLEN
#define HAMLIB_FILPATHLEN FILPATHLEN
Expand Down Expand Up @@ -90,7 +91,6 @@ RigCaps HamlibRigDrv::getCaps(int model)

const struct rig_caps *caps = rig_get_caps(model);
RigCaps ret;

ret.isNetworkOnly = (model == RIG_MODEL_NETRIGCTL);
ret.needPolling = true;

Expand All @@ -107,6 +107,10 @@ RigCaps HamlibRigDrv::getCaps(int model)
ret.canGetPTT = ( caps->get_ptt );
ret.canSendMorse = ( caps->send_morse != nullptr );

if (QString::fromLatin1(caps->model_name).contains("SmartSDR Slice", Qt::CaseInsensitive)) {
ret.canProcessDXSpot = true;
}

if ( ret.isNetworkOnly )
{
#if ( HAMLIBVERSION_MAJOR == 4 && ( HAMLIBVERSION_MINOR == 2 || HAMLIBVERSION_MINOR == 3 ) )
Expand Down Expand Up @@ -246,7 +250,7 @@ bool HamlibRigDrv::open()

int status = rig_open(rig);

if ( !isRigRespOK(status, tr("Rig Open Error"), false) )
if (!isRigRespOK(status, tr("Rig Open Error"), false))
return false;

qCDebug(runtime) << "Rig Open - OK";
Expand Down Expand Up @@ -495,13 +499,61 @@ void HamlibRigDrv::stopTimers()
errorTimer.stop();
}

void HamlibRigDrv::sendDXSpot(const DxSpot &)
void HamlibRigDrv::sendDXSpot(const DxSpot &spot)
{
FCT_IDENTIFICATION;

// no action
if (!rig || !opened || currFreq == 0) {
qCWarning(runtime) << "Rig is not active";
return;
}
if (QString::fromLatin1(rig->caps->model_name).contains("SmartSDR Slice", Qt::CaseInsensitive))
{
QString freqStr = QString::number(spot.freq, 'f', 3);
QString call = spot.callsign.trimmed();

QColor spotColor = Data::statusToColor(spot.status, spot.dupeCount, QColor(187,194,195));

SmartSDRSpotCounter = SmartSDRSpotCounter + 1;
QString command = QString("C%1|spot add rx_freq=%2 callsign=%3 color=%4 source=QLog timestamp=%5 lifetime_seconds=300 priority=4\n")
.arg(SmartSDRSpotCounter)
.arg(freqStr)
.arg(call.toUpper())
.arg(spotColor.name(QColor::HexArgb).toUpper())
.arg(spot.dateTime.toSecsSinceEpoch());

qWarning() << "Sending DX Spot command:" << command;

#if (HAMLIBVERSION_MAJOR >= 4 && HAMLIBVERSION_MINOR >= 5 )

QByteArray cmdBytes = command.toUtf8();
unsigned char terminator = '\n';
const unsigned char* dataPtr = reinterpret_cast<const unsigned char*>(cmdBytes.constData());

int status = rig_send_raw(
rig,
dataPtr,
cmdBytes.length(),
nullptr,
0,
&terminator
);

if (status != RIG_OK) {
qCDebug(runtime) << "rig_send_raw failed:" << status;
qCDebug(runtime) << hamlibErrorString(status);
} else {
qCDebug(runtime) << "DX Spot sent successfully";
}

#else
qCWarning(runtime) << "Hamlib version does not support rig_send_raw. DX Spot not sent.";
#endif
}
}



void HamlibRigDrv::checkChanges()
{
FCT_IDENTIFICATION;
Expand Down
3 changes: 1 addition & 2 deletions rig/drivers/HamlibRigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ private slots:
serial_handshake_e stringToHamlibFlowControl(const QString &in_flowcontrol);
serial_parity_e stringToHamlibParity(const QString &in_parity);
QString hamlibErrorString(int);

RIG* rig;
QTimer timer;
QTimer errorTimer;

int SmartSDRSpotCounter;
bool forceSendState;
bool currPTT;
double currFreq;
Expand Down
Loading