Skip to content

Commit

Permalink
Added APRS-PTT setting to AnyTone FM and DMR channel extensions. Addr…
Browse files Browse the repository at this point in the history
…esses #468.
  • Loading branch information
hmatuschek committed Oct 1, 2024
1 parent 83fe52e commit cdfafdb
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 7 deletions.
14 changes: 13 additions & 1 deletion lib/anytone_extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ AnytoneAPRSFrequencyList::allocateChild(const YAML::Node &node, ConfigItem::Cont
* ********************************************************************************************* */
AnytoneChannelExtension::AnytoneChannelExtension(QObject *parent)
: ConfigExtension(parent), _talkaround(false), _frequencyCorrection(0), _handsFree(false),
_fmAPRSFrequency(new AnytoneAPRSFrequencyRef(this))
_fmAPRSFrequency(new AnytoneAPRSFrequencyRef(this)), _aprsPTT(APRSPTT::Off)
{
// pass...
}
Expand Down Expand Up @@ -110,6 +110,18 @@ AnytoneChannelExtension::fmAPRSFrequency() const {
return _fmAPRSFrequency;
}

AnytoneChannelExtension::APRSPTT
AnytoneChannelExtension::aprsPTT() const {
return _aprsPTT;
}
void
AnytoneChannelExtension::setAPRSPTT(APRSPTT mode) {
if (_aprsPTT == mode)
return;
_aprsPTT = mode;
emit modified(this);
}


/* ********************************************************************************************* *
* Implementation of AnytoneAnalogChannelExtension
Expand Down
17 changes: 17 additions & 0 deletions lib/anytone_extension.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class AnytoneChannelExtension: public ConfigExtension
Q_PROPERTY(bool handsFree READ handsFree WRITE enableHandsFree)
/** A reference to the FM APRS frequency. If not set, the default will be used. */
Q_PROPERTY(AnytoneAPRSFrequencyRef *fmAPRSFrequency READ fmAPRSFrequency())
/** Specifies if and when the position is send via the associated APRS system, once the PTT is
* pressed. */
Q_PROPERTY(APRSPTT aprsPTT READ aprsPTT WRITE setAPRSPTT)

public:
/** Possible APRS PTT modes. */
enum class APRSPTT{
Off, Start, End
};
Q_ENUM(APRSPTT)

protected:
/** Hidden constructor. */
Expand All @@ -106,6 +116,11 @@ public:
/** Holds a reference to the FM APRS frequency to be used if FM APRS is enabled on the channel. */
AnytoneAPRSFrequencyRef *fmAPRSFrequency() const;

/** Holds the APRS PTT mode. That his, if and when the APRS information is send via the
* associated APRS system. */
APRSPTT aprsPTT() const;
void setAPRSPTT(APRSPTT mode);

protected:
/** If @c true, talkaround is enabled. */
bool _talkaround;
Expand All @@ -115,6 +130,8 @@ protected:
bool _handsFree;
/** A reference to the FM APRS frequency. */
AnytoneAPRSFrequencyRef *_fmAPRSFrequency;
/** Holds the APRS PTT mode. */
APRSPTT _aprsPTT;
};


Expand Down
44 changes: 39 additions & 5 deletions lib/dmr6x2uv_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1582,16 +1582,33 @@ DMR6X2UVCodeplug::ChannelElement::fromChannelObj(const Channel *c, Context &ctx)
return false;

if (const FMChannel *fm = c->as<FMChannel>()) {
if (fm->aprsSystem())
if (fm->aprsSystem()) {
setAPRSType(APRSType::FM);
if (auto ext = fm->anytoneChannelExtension()) {
switch (ext->aprsPTT()) {
case AnytoneChannelExtension::APRSPTT::Off: setFMAPRSPTTMode(FMAPRSPTTMode::Off); break;
case AnytoneChannelExtension::APRSPTT::Start: setFMAPRSPTTMode(FMAPRSPTTMode::Start); break;
case AnytoneChannelExtension::APRSPTT::End: setFMAPRSPTTMode(FMAPRSPTTMode::End); break;
}
}
}
} else if (const DMRChannel *dmr = c->as<DMRChannel>()) {
if (dmr->aprs()) {
if (dmr->aprs()->is<APRSSystem>()) {
setAPRSType(APRSType::FM);
if (auto ext = dmr->anytoneChannelExtension()) {
switch (ext->aprsPTT()) {
case AnytoneChannelExtension::APRSPTT::Off: setFMAPRSPTTMode(FMAPRSPTTMode::Off); break;
case AnytoneChannelExtension::APRSPTT::Start: setFMAPRSPTTMode(FMAPRSPTTMode::Start); break;
case AnytoneChannelExtension::APRSPTT::End: setFMAPRSPTTMode(FMAPRSPTTMode::End); break;
}
}
} else if (GPSSystem *sys = dmr->aprs()->as<GPSSystem>()){
if (0 <= ctx.index(sys)) {
setAPRSType(APRSType::DMR);
setDMRAPRSChannelIndex(ctx.index(sys));
if (auto ext = dmr->anytoneChannelExtension())
enableDMRAPRSPTT(AnytoneChannelExtension::APRSPTT::Off != ext->aprsPTT());
}
}
}
Expand All @@ -1604,14 +1621,31 @@ bool
DMR6X2UVCodeplug::ChannelElement::linkChannelObj(Channel *c, Context &ctx) const {
if (! AnytoneCodeplug::ChannelElement::linkChannelObj(c, ctx))
return false;

if (FMChannel *fm = c->as<FMChannel>()) {
if ((APRSType::FM == aprsType()) && ctx.count<APRSSystem>())
auto ext = fm->anytoneChannelExtension();
if (nullptr == ext)
fm->setAnytoneChannelExtension(ext = new AnytoneFMChannelExtension());
if ((APRSType::FM == aprsType()) && ctx.count<APRSSystem>()) {
switch (fmAPRSPTTMode()) {
case FMAPRSPTTMode::Off: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::Off); break;
case FMAPRSPTTMode::Start: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::Start); break;
case FMAPRSPTTMode::End: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::End); break;
}
fm->setAPRSSystem(ctx.get<APRSSystem>(0));
}
} else if (DMRChannel *dmr = c->as<DMRChannel>()) {
if ((APRSType::FM == aprsType()) && ctx.count<APRSSystem>())
auto ext = dmr->anytoneChannelExtension();
if (nullptr == ext)
dmr->setAnytoneChannelExtension(ext = new AnytoneDMRChannelExtension());
if ((APRSType::FM == aprsType()) && ctx.count<APRSSystem>()) {
switch (fmAPRSPTTMode()) {
case FMAPRSPTTMode::Off: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::Off); break;
case FMAPRSPTTMode::Start: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::Start); break;
case FMAPRSPTTMode::End: ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::End); break;
}
dmr->setAPRSObj(ctx.get<APRSSystem>(0));
else if ((APRSType::DMR == aprsType()) && ctx.has<GPSSystem>(dmrAPRSChannelIndex())) {
} else if ((APRSType::DMR == aprsType()) && ctx.has<GPSSystem>(dmrAPRSChannelIndex())) {
ext->setAPRSPTT(dmrAPRSPTTEnabled() ? AnytoneChannelExtension::APRSPTT::Start : AnytoneChannelExtension::APRSPTT::Off);
dmr->setAPRSObj(ctx.get<GPSSystem>(dmrAPRSChannelIndex()));
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/data/fm_aprs_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ channels:
power: High
timeout: 0
vox: 0
- fm:
id: ch1
name: Some FM Channel
rxFrequency: 145.1 MHz
txFrequency: 145.1 MHz
rxOnly: false
admit: Always
power: High
timeout: 0
vox: 0
aprs: aprs

zones:
- id: zone1
Expand Down
10 changes: 9 additions & 1 deletion test/dmr6x2uv_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ DMR6X2UVTest::testFMAPRSSettings() {
.arg(err.format()).toStdString().c_str());
}

auto ch_ext = new AnytoneFMChannelExtension();
ch_ext->setAPRSPTT(AnytoneChannelExtension::APRSPTT::Start);
config.channelList()->channel(1)->as<FMChannel>()->setAnytoneChannelExtension(ch_ext);

// Check config
QCOMPARE(config.posSystems()->count(), 1);
QVERIFY(config.posSystems()->get(0)->is<APRSSystem>());
Expand Down Expand Up @@ -132,13 +136,17 @@ DMR6X2UVTest::testFMAPRSSettings() {
200);

// Check revert channel
QCOMPARE(comp_config.channelList()->count(), 1);
QCOMPARE(comp_config.channelList()->count(), 2);
QVERIFY(comp_config.channelList()->channel(0)->is<FMChannel>());
QCOMPARE(comp_config.channelList()->channel(0)->rxFrequency(),
config.channelList()->channel(0)->rxFrequency());
QCOMPARE(comp_config.channelList()->channel(0)->txFrequency(),
config.channelList()->channel(0)->txFrequency());

// Check channel extension properties
QVERIFY(nullptr != comp_config.channelList()->channel(1)->as<FMChannel>()->anytoneChannelExtension());
auto comp_ch_ext = comp_config.channelList()->channel(1)->as<FMChannel>()->anytoneChannelExtension();
QCOMPARE(comp_ch_ext->aprsPTT(), ch_ext->aprsPTT());
}

QTEST_GUILESS_MAIN(DMR6X2UVTest)
Expand Down

0 comments on commit cdfafdb

Please sign in to comment.