diff --git a/lib/opengd77base_codeplug.cc b/lib/opengd77base_codeplug.cc index 7a56420c..7e76c179 100644 --- a/lib/opengd77base_codeplug.cc +++ b/lib/opengd77base_codeplug.cc @@ -88,9 +88,10 @@ OpenGD77BaseCodeplug::ChannelElement::clear() { setRXTone(SelectiveCall()); setTXTone(SelectiveCall()); setColorCode(0); - setGroupListIndex(0); + clearGroupListIndex(); clearDMRId(); - + clearAPRSIndex(); + clearTXContact(); } @@ -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())) { @@ -539,6 +561,8 @@ OpenGD77BaseCodeplug::ChannelElement::link(Channel *c, Context &ctx, const Error DMRChannel *dc = c->as(); if (hasGroupList() && ctx.has(groupListIndex())) dc->setGroupListObj(ctx.get(groupListIndex())); + if (hasTXContact() && ctx.has(txContactIndex())) + dc->setTXContactObj(ctx.get(txContactIndex())); if (hasDMRId()) { auto id = ctx.config()->radioIDs()->find(dmrId()); if (nullptr == id) { @@ -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 { diff --git a/lib/opengd77base_codeplug.hh b/lib/opengd77base_codeplug.hh index 4a36ad6c..4df8f499 100644 --- a/lib/opengd77base_codeplug.hh +++ b/lib/opengd77base_codeplug.hh @@ -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. */ @@ -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}; }