Skip to content

Commit

Permalink
Fixed TX contact encoding. (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek authored Jan 2, 2025
1 parent c6db94c commit 3369b89
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
31 changes: 29 additions & 2 deletions lib/opengd77base_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ OpenGD77BaseCodeplug::ChannelElement::clear() {
setRXTone(SelectiveCall());
setTXTone(SelectiveCall());
setColorCode(0);
setGroupListIndex(0);
clearGroupListIndex();
clearDMRId();

clearAPRSIndex();
clearTXContact();
}


Expand Down Expand Up @@ -351,6 +352,27 @@ OpenGD77BaseCodeplug::ChannelElement::clearAPRSIndex() {
}


bool
OpenGD77BaseCodeplug::ChannelElement::hasTXContact() const {
return 0 != getUInt16_le(Offset::txContact());
}

unsigned int
OpenGD77BaseCodeplug::ChannelElement::txContactIndex() const {
return getUInt16_le(Offset::txContact()) - 1;
}

void
OpenGD77BaseCodeplug::ChannelElement::setTXContactIndex(unsigned int index) {
setUInt16_le(Offset::txContact(), index+1);
}

void
OpenGD77BaseCodeplug::ChannelElement::clearTXContact() {
setUInt16_le(Offset::txContact(), 0);
}


OpenGD77ChannelExtension::TalkerAlias
OpenGD77BaseCodeplug::ChannelElement::aliasTimeSlot1() const {
switch ((Alias) getUInt2(Offset::aliasTimeSlot1())) {
Expand Down Expand Up @@ -539,6 +561,8 @@ OpenGD77BaseCodeplug::ChannelElement::link(Channel *c, Context &ctx, const Error
DMRChannel *dc = c->as<DMRChannel>();
if (hasGroupList() && ctx.has<RXGroupList>(groupListIndex()))
dc->setGroupListObj(ctx.get<RXGroupList>(groupListIndex()));
if (hasTXContact() && ctx.has<DMRContact>(txContactIndex()))
dc->setTXContactObj(ctx.get<DMRContact>(txContactIndex()));
if (hasDMRId()) {
auto id = ctx.config()->radioIDs()->find(dmrId());
if (nullptr == id) {
Expand Down Expand Up @@ -597,8 +621,11 @@ OpenGD77BaseCodeplug::ChannelElement::encode(const Channel *c, Context &ctx, con
setMode(MODE_DIGITAL);
setTimeSlot(dc->timeSlot());
setColorCode(dc->colorCode());
// OpenGD77 does not allow for both TX contact and group list, select one, prefer group list
if (dc->groupListObj())
setGroupListIndex(ctx.index(dc->groupListObj()));
else if (dc->txContactObj())
setTXContactIndex(ctx.index(dc->txContactObj()));
if (dc->radioIdObj() != ctx.config()->settings()->defaultId())
setDMRId(dc->radioIdObj()->number());
} else {
Expand Down
10 changes: 10 additions & 0 deletions lib/opengd77base_codeplug.hh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ public:
/** Resets the APRS system index. */
virtual void clearAPRSIndex();

/** Returns @c true, if the TX contact is set. */
virtual bool hasTXContact() const;
/** Returns the TX contact index. */
virtual unsigned int txContactIndex() const;
/** Sets the TX contact index. */
virtual void setTXContactIndex(unsigned int index);
/** Clears the TX contact index. */
virtual void clearTXContact();

/** Returns the alias transmitted on time slot 1. */
virtual OpenGD77ChannelExtension::TalkerAlias aliasTimeSlot1() const;
/** Sets the alias transmitted on time slot 1. */
Expand Down Expand Up @@ -246,6 +255,7 @@ public:
static constexpr unsigned int groupList() { return 0x002b; }
static constexpr unsigned int colorCode() { return 0x002c; }
static constexpr unsigned int aprsIndex() { return 0x002d; }
static constexpr unsigned int txContact() { return 0x002e; }
static constexpr Bit aliasTimeSlot2() { return { 0x030, 2}; }
static constexpr Bit aliasTimeSlot1() { return { 0x030, 0}; }
static constexpr Bit timeSlot() { return {0x0031, 6}; }
Expand Down

0 comments on commit 3369b89

Please sign in to comment.