diff --git a/lib/anytone_codeplug.cc b/lib/anytone_codeplug.cc index a73d6d67..d7e83d24 100644 --- a/lib/anytone_codeplug.cc +++ b/lib/anytone_codeplug.cc @@ -3951,6 +3951,10 @@ AnytoneCodeplug::index(Config *config, Context &ctx, const ErrorStack &err) cons ctx.add(config->contacts()->contact(i)->as(), d); d++; } else if (config->contacts()->contact(i)->is()) { ctx.add(config->contacts()->contact(i)->as(), a); a++; + } else { + logInfo() << "Cannot index contact '" << config->contacts()->contact(i)->name() + << "'. Contact type '" << config->contacts()->contact(i)->metaObject()->className() + << "' not supported by or implemented for AnyTone devices."; } } @@ -3959,8 +3963,16 @@ AnytoneCodeplug::index(Config *config, Context &ctx, const ErrorStack &err) cons ctx.add(config->rxGroupLists()->list(i), i); // Map channels - for (int i=0; ichannelList()->count(); i++) - ctx.add(config->channelList()->channel(i), i); + for (int i=0,c=0; ichannelList()->count(); i++) { + Channel *channel = config->channelList()->channel(i); + if ((channel->is()) || (channel->is()) ) { + ctx.add(channel, c); c++; + } else { + logInfo() << "Cannot index channel '" << channel->name() + << "'. Channel type '" << channel->metaObject()->className() + << "' not supported by or implemented for AnyTone devices."; + } + } // Map zones for (int i=0; izones()->count(); i++) diff --git a/lib/codeplug.cc b/lib/codeplug.cc index 5ed25044..70e9434e 100644 --- a/lib/codeplug.cc +++ b/lib/codeplug.cc @@ -646,7 +646,7 @@ Codeplug::Context::index(ConfigItem *obj) { bool Codeplug::Context::add(ConfigItem *obj, unsigned idx) { - if (!hasTable(obj->metaObject())) + if (! hasTable(obj->metaObject())) return false; if (getTable(obj->metaObject()).indices.contains(obj)) return false; diff --git a/lib/codeplug.hh b/lib/codeplug.hh index 09ff5be3..9bd86cff 100644 --- a/lib/codeplug.hh +++ b/lib/codeplug.hh @@ -227,7 +227,7 @@ public: /** Returns the number of elements for the specified type. */ template unsigned int count() { - return getTable(&T::staticMetaObject).indices.size(); + return this->getTable(&T::staticMetaObject).indices.size(); } protected: diff --git a/lib/d868uv_codeplug.cc b/lib/d868uv_codeplug.cc index 675ab8dd..6de73402 100644 --- a/lib/d868uv_codeplug.cc +++ b/lib/d868uv_codeplug.cc @@ -585,23 +585,32 @@ D868UVCodeplug::setBitmaps(Config *config) // Mark valid channels (set bit) uint8_t *channel_bitmap = data(CHANNEL_BITMAP); memset(channel_bitmap, 0, CHANNEL_BITMAP_SIZE); - for (int i=0; ichannelList()->count()); i++) { - channel_bitmap[i/8] |= (1 << (i%8)); + for (int i=0,c=0; ichannelList()->count()); i++) { + Channel *channel = config->channelList()->channel(i); + if ((! channel->is()) && (! channel->is())) + continue; + channel_bitmap[c/8] |= (1 << (c%8)); c++; } // Mark valid contacts (clear bit) uint8_t *contact_bitmap = data(CONTACTS_BITMAP); memset(contact_bitmap, 0x00, CONTACTS_BITMAP_SIZE); memset(contact_bitmap, 0xff, NUM_CONTACTS/8+1); - for (int i=0; icontacts()->digitalCount()); i++) { - contact_bitmap[i/8] &= ~(1 << (i%8)); + for (int i=0, c=0; icontacts()->count()); i++) { + Contact *contact = config->contacts()->contact(i); + if (! contact->is()) + continue; + contact_bitmap[c/8] &= ~(1 << (c%8)); c++; } // Mark valid analog contacts (clear bytes) uint8_t *analog_contact_bitmap = data(ANALOGCONTACT_BYTEMAP); memset(analog_contact_bitmap, 0xff, ANALOGCONTACT_BYTEMAP_SIZE); - for (int i=0; icontacts()->dtmfCount()); i++) { - analog_contact_bitmap[i] = 0x00; + for (int i=0, c=0; icontacts()->count()); i++) { + Contact *contact = config->contacts()->contact(i); + if (! contact->is()) + continue; + analog_contact_bitmap[i] = 0x00; c++; } // Mark valid zones (set bits) @@ -756,11 +765,11 @@ D868UVCodeplug::encodeChannels(const Flags &flags, Context &ctx, const ErrorStac Q_UNUSED(flags); Q_UNUSED(err) // Encode channels - for (int i=0; ichannelList()->count(); i++) { + for (unsigned int i=0; i(); i++) { // enable channel uint16_t bank = i/128, idx = i%128; ChannelElement ch(data(CHANNEL_BANK_0 + bank*CHANNEL_BANK_OFFSET + idx*CHANNEL_SIZE)); - if (! ch.fromChannelObj(ctx.config()->channelList()->channel(i), ctx)) + if (! ch.fromChannelObj(ctx.get(i), ctx)) return false; } return true; @@ -843,11 +852,11 @@ D868UVCodeplug::encodeContacts(const Flags &flags, Context &ctx, const ErrorStac QVector contacts; // Encode contacts and also collect id<->index map - for (int i=0; icontacts()->digitalCount(); i++) { + for (unsigned int i=0; i(); i++) { uint32_t bank_addr = CONTACT_BLOCK_0 + (i/CONTACTS_PER_BANK)*CONTACT_BANK_SIZE; uint32_t addr = bank_addr + (i%CONTACTS_PER_BANK)*CONTACT_SIZE; ContactElement con(data(addr)); - DMRContact *contact = ctx.config()->contacts()->digitalContact(i); + DMRContact *contact = ctx.get(i); if(! con.fromContactObj(contact, ctx)) return false; ((uint32_t *)data(CONTACT_INDEX_LIST))[i] = qToLittleEndian(i); @@ -910,11 +919,11 @@ D868UVCodeplug::encodeAnalogContacts(const Flags &flags, Context &ctx, const Err uint8_t *idxlst = data(ANALOGCONTACT_INDEX_LIST); memset(idxlst, 0xff, ANALOGCONTACT_LIST_SIZE); - for (int i=0; icontacts()->dtmfCount(); i++) { + for (unsigned int i=0; i(); i++) { uint32_t addr = ANALOGCONTACT_BANK_0 + (i/ANALOGCONTACTS_PER_BANK)*ANALOGCONTACT_BANK_SIZE + (i%ANALOGCONTACTS_PER_BANK)*ANALOGCONTACT_SIZE; DTMFContactElement cont(data(addr)); - cont.fromContact(ctx.config()->contacts()->dtmfContact(i)); + cont.fromContact(ctx.get(i)); idxlst[i] = i; } return true; diff --git a/lib/d878uv2_codeplug.cc b/lib/d878uv2_codeplug.cc index deeec09c..98d32022 100644 --- a/lib/d878uv2_codeplug.cc +++ b/lib/d878uv2_codeplug.cc @@ -67,11 +67,11 @@ D878UV2Codeplug::encodeContacts(const Flags &flags, Context &ctx, const ErrorSta QVector contacts; // Encode contacts and also collect id<->index map - for (int i=0; icontacts()->digitalCount(); i++) { + for (unsigned int i=0; i(); i++) { uint32_t bank_addr = CONTACT_BLOCK_0 + (i/CONTACTS_PER_BANK)*CONTACT_BANK_SIZE; uint32_t addr = bank_addr + (i%CONTACTS_PER_BANK)*CONTACT_SIZE; ContactElement con(data(addr)); - DMRContact *contact = ctx.config()->contacts()->digitalContact(i); + DMRContact *contact = ctx.get(i); if(! con.fromContactObj(contact, ctx)) return false; ((uint32_t *)data(CONTACT_INDEX_LIST))[i] = qToLittleEndian(i); diff --git a/lib/d878uv_codeplug.cc b/lib/d878uv_codeplug.cc index 4110a744..e60376cd 100644 --- a/lib/d878uv_codeplug.cc +++ b/lib/d878uv_codeplug.cc @@ -2255,11 +2255,11 @@ bool D878UVCodeplug::encodeChannels(const Flags &flags, Context &ctx, const ErrorStack &err) { Q_UNUSED(flags); Q_UNUSED(err) // Encode channels - for (int i=0; ichannelList()->count(); i++) { + for (unsigned int i=0; i(); i++) { // enable channel uint16_t bank = i/128, idx = i%128; ChannelElement ch(data(CHANNEL_BANK_0 + bank*CHANNEL_BANK_OFFSET + idx*CHANNEL_SIZE)); - ch.fromChannelObj(ctx.config()->channelList()->channel(i), ctx); + ch.fromChannelObj(ctx.get(i), ctx); } return true; }