libdrmconf  0.12.0
A library to program DMR radios.
Classes | Public Member Functions | Protected Member Functions | List of all members
D868UVCodeplug Class Reference

Represents the device specific binary codeplug for Anytone AT-D868UV radios. More...

#include <d868uv_codeplug.hh>

Inheritance diagram for D868UVCodeplug:
Inheritance graph
[legend]
Collaboration diagram for D868UVCodeplug:
Collaboration graph
[legend]

Classes

class  ChannelElement
 Represents the channel element for AnyTone D868UV devices. More...
 
struct  Color
 Colors supported by the D868UVE. More...
 
struct  CTCSS
 Implements encoding of CTCSS tones. More...
 
class  GeneralSettingsElement
 Represents the general config of the radio within the D868UV binary codeplug. More...
 
struct  Limit
 Some limits for the codeplug. More...
 
struct  Offset
 Some internal used offsets within the codeplug. More...
 
struct  Size
 Internal used sizes. More...
 

Public Member Functions

 D868UVCodeplug (QObject *parent=nullptr)
 Empty constructor.
 
- Public Member Functions inherited from AnytoneCodeplug
virtual ~AnytoneCodeplug ()
 Destructor.
 
virtual void clear ()
 Clears and resets the complete codeplug to some default values.
 
Configpreprocess (Config *config, const ErrorStack &err) const
 Retruns a prepared configuration for this particular radio. More...
 
bool encode (Config *config, const Flags &flags, const ErrorStack &err)
 Encodes a given abstract configuration (config) to the device specific binary code-plug. More...
 
bool decode (Config *config, const ErrorStack &err)
 Decodes a binary codeplug to the given abstract configuration config. More...
 
bool postprocess (Config *config, const ErrorStack &err) const
 Retruns a post-processed configuration of the decoded config. More...
 
- Public Member Functions inherited from Codeplug
virtual ~Codeplug ()
 Destructor.
 
- Public Member Functions inherited from DFUFile
 DFUFile (QObject *parent=nullptr)
 Constructs an empty DFU file object.
 
uint32_t size () const
 Returns the total size of the DFU file.
 
uint32_t memSize () const
 Returns the total memory size stored in the DFU file.
 
int numImages () const
 Returns the number of images within the DFU file.
 
const Imageimage (int i) const
 Returns a reference to the i-th image of the file.
 
Imageimage (int i)
 Returns a reference to the i-th image of the file.
 
void addImage (const QString &name, uint8_t altSettings=1)
 Adds a new image to the file.
 
void addImage (const Image &img)
 Adds an image to the file.
 
void remImage (int i)
 Deletes the i-th image from the file.
 
bool isAligned (unsigned blocksize) const
 Checks if all image addresses and sizes is aligned with the given block size.
 
bool read (const QString &filename, const ErrorStack &err=ErrorStack())
 Reads the specified DFU file. More...
 
bool read (QFile &file, const ErrorStack &err=ErrorStack())
 Reads the specified DFU file. More...
 
bool write (const QString &filename, const ErrorStack &err=ErrorStack())
 Writes to the specified file. More...
 
bool write (QFile &file, const ErrorStack &err=ErrorStack())
 Writes to the specified file. More...
 
void dump (QTextStream &stream) const
 Dumps a text representation of the DFU file structure to the specified text stream.
 
virtual bool isAllocated (uint32_t offset, uint32_t img=0) const
 Returns true if the specified address (and image) is allocated.
 
virtual unsigned char * data (uint32_t offset, uint32_t img=0)
 Returns a pointer to the encoded raw data at the specified offset.
 
virtual const unsigned char * data (uint32_t offset, uint32_t img=0) const
 Returns a const pointer to the encoded raw data at the specified offset.
 

Protected Member Functions

 D868UVCodeplug (const QString &label, QObject *parent=nullptr)
 Hidden constructor constructor.
 
bool allocateBitmaps ()
 Allocates the bitmaps. More...
 
virtual void setBitmaps (Context &ctx)
 Sets all bitmaps for the given config.
 
virtual void allocateUpdated ()
 Allocate all code-plug elements that must be written back to the device to maintain a working codeplug. More...
 
virtual void allocateForDecoding ()
 Allocate all code-plug elements that must be downloaded for decoding. More...
 
virtual void allocateForEncoding ()
 Allocate all code-plug elements that are defined through the common Config.
 
virtual bool encodeElements (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes the given config (via context) to the binary codeplug.
 
virtual bool decodeElements (Context &ctx, const ErrorStack &err=ErrorStack())
 Decodes the downloaded codeplug.
 
virtual void allocateChannels ()
 Allocate channels from bitmap.
 
virtual bool encodeChannels (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode channels into codeplug.
 
virtual bool createChannels (Context &ctx, const ErrorStack &err=ErrorStack())
 Create channels from codeplug.
 
virtual bool linkChannels (Context &ctx, const ErrorStack &err=ErrorStack())
 Link channels.
 
virtual void allocateVFOSettings ()
 Allocate VFO settings.
 
virtual void allocateContacts ()
 Allocate contacts from bitmaps.
 
virtual bool encodeContacts (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode contacts into codeplug.
 
virtual bool createContacts (Context &ctx, const ErrorStack &err=ErrorStack())
 Create contacts from codeplug.
 
virtual void allocateAnalogContacts ()
 Allocate analog contacts from bitmaps.
 
virtual bool encodeAnalogContacts (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode analog contacts into codeplug.
 
virtual bool createAnalogContacts (Context &ctx, const ErrorStack &err=ErrorStack())
 Create analog contacts from codeplug.
 
virtual void allocateRadioIDs ()
 Allocate radio IDs from bitmaps.
 
virtual bool encodeRadioID (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode radio ID into codeplug.
 
virtual bool setRadioID (Context &ctx, const ErrorStack &err=ErrorStack())
 Set radio ID from codeplug.
 
virtual void allocateRXGroupLists ()
 Allocates RX group lists from bitmaps.
 
virtual bool encodeRXGroupLists (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode RX group lists into codeplug.
 
virtual bool createRXGroupLists (Context &ctx, const ErrorStack &err=ErrorStack())
 Create RX group lists from codeplug.
 
virtual bool linkRXGroupLists (Context &ctx, const ErrorStack &err=ErrorStack())
 Link RX group lists.
 
virtual void allocateZones ()
 Allocate zones from bitmaps.
 
virtual bool encodeZones (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode zones into codeplug.
 
virtual bool encodeZone (int i, Zone *zone, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Function to encode a single zone.
 
virtual bool createZones (Context &ctx, const ErrorStack &err=ErrorStack())
 Create zones from codeplug.
 
virtual bool decodeZone (int i, Zone *zone, Context &ctx, const ErrorStack &err=ErrorStack())
 Function to decode a single zone.
 
virtual bool linkZones (Context &ctx, const ErrorStack &err=ErrorStack())
 Link zones.
 
virtual bool linkZone (int i, Zone *zone, bool isB, Context &ctx, const ErrorStack &err=ErrorStack())
 Function to link a single zone.
 
virtual void allocateScanLists ()
 Allocate scanlists from bitmaps.
 
virtual bool encodeScanLists (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encode scan lists into codeplug.
 
virtual bool createScanLists (Context &ctx, const ErrorStack &err=ErrorStack())
 Create scan lists from codeplug.
 
virtual bool linkScanLists (Context &ctx, const ErrorStack &err=ErrorStack())
 Link scan lists.
 
virtual void allocateGeneralSettings ()
 Allocates general settings memory section.
 
virtual bool encodeGeneralSettings (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes the general settings section.
 
virtual bool decodeGeneralSettings (Context &ctx, const ErrorStack &err=ErrorStack())
 Decodes the general settings section.
 
virtual bool linkGeneralSettings (Context &ctx, const ErrorStack &err=ErrorStack())
 Link the general settings.
 
virtual void allocateZoneChannelList ()
 Allocates zone channel list memory section.
 
virtual void allocateDTMFNumbers ()
 Allocates DTMF number list memory section.
 
virtual void allocateBootSettings ()
 Allocates boot settings memory section.
 
virtual bool encodeBootSettings (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes the boot settings section.
 
virtual bool decodeBootSettings (Context &ctx, const ErrorStack &err=ErrorStack())
 Decodes the boot settings section.
 
virtual void allocateGPSSystems ()
 Allocates GPS settings memory section.
 
virtual bool encodeGPSSystems (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes the GPS settings section.
 
virtual bool createGPSSystems (Context &ctx, const ErrorStack &err=ErrorStack())
 Create GPS systems from codeplug.
 
virtual bool linkGPSSystems (Context &ctx, const ErrorStack &err=ErrorStack())
 Link GPS systems.
 
virtual void allocateSMSMessages ()
 Allocate prefab SMS messages.
 
virtual bool encodeSMSMessages (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes prefab SMS messages.
 
virtual bool createSMSMessages (Context &ctx, const ErrorStack &err=ErrorStack())
 Create SMS messages from codeplug.
 
virtual bool linkSMSMessages (Context &ctx, const ErrorStack &err=ErrorStack())
 Link SMS messages.
 
virtual void allocateHotKeySettings ()
 Allocates hot key settings memory section.
 
virtual void allocateRepeaterOffsetFrequencies ()
 Allocates repeater offset settings memory section.
 
virtual bool encodeRepeaterOffsetFrequencies (const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
 Encodes auto-repeater offset frequencies.
 
virtual bool decodeRepeaterOffsetFrequencies (Context &ctx, const ErrorStack &err=ErrorStack())
 Decodes auto-repeater offset frequencies.
 
virtual void allocateAlarmSettings ()
 Allocates alarm settings memory section.
 
virtual void allocateFMBroadcastSettings ()
 Allocates FM broadcast settings memory section.
 
virtual void allocate5ToneIDs ()
 Allocates all 5-Tone IDs used.
 
virtual void allocate5ToneFunctions ()
 Allocates 5-Tone functions.
 
virtual void allocate5ToneSettings ()
 Allocates 5-Tone settings.
 
virtual void allocate2ToneIDs ()
 Allocates all 2-Tone IDs used.
 
virtual void allocate2ToneFunctions ()
 Allocates 2-Tone functions.
 
virtual void allocate2ToneSettings ()
 Allocates 2-Tone settings.
 
virtual void allocateDTMFSettings ()
 Allocates DTMF settings.
 
- Protected Member Functions inherited from AnytoneCodeplug
 AnytoneCodeplug (const QString &label, QObject *parent=nullptr)
 Hidden constructor.
 
virtual bool index (Config *config, Context &ctx, const ErrorStack &err=ErrorStack()) const
 Indexes all elements of the codeplug. More...
 
- Protected Member Functions inherited from Codeplug
 Codeplug (QObject *parent=nullptr)
 Hidden default constructor.
 

Additional Inherited Members

- Protected Attributes inherited from AnytoneCodeplug
QString _label
 Holds the image label.
 
- Protected Attributes inherited from DFUFile
QVector< Image_images
 The list of images.
 

Detailed Description

Represents the device specific binary codeplug for Anytone AT-D868UV radios.

In contrast to many other code-plugs, the code-plug for Anytone radios are spread over a large memory area. The amount of fragmentation of the codeplug is overwhelming. For example, while channels are organized more or less nicely in continuous banks, zones are distributed throughout the entire code-plug. That is, the names of zones are located in a different memory section that the channel lists. Some lists are defined though bit-masks others by byte-masks. All bit-masks are positive, that is 1 indicates an enabled item while the bit-mask for contacts is inverted.

In general the code-plug is huge and complex. Moreover, the radio provides a huge amount of options and features. To this end, reverse-engineering this code-plug was a nightmare.

More over, the binary code-plug file generate by the windows CPS does not directly relate to the data being written to the radio. To this end the code-plug has been reverse-engineered using wireshark to monitor the USB communication between the windows CPS (running in a virtual box) and the device. The latter makes the reverse-engineering particularly cumbersome.

Codeplug structure within radio

Channels
Start Size Content
024C1500 000200 Bitmap of 4000 channels, default 0x00, 0x00 padded.
00800000 max. 002000 Channel bank 0 of up to 128 channels, see AnytoneCodeplug::ChannelElement 64 b each.
00840000 max. 002000 Channel bank 1 of up to 128 channels.
... ... ...
00FC0000 max. 000800 Channel bank 32, up to 32 channels.
00FC0800 000040 VFO A settings, see AnytoneCodeplug::ChannelElement.
00FC0840 000040

VFO B settings, see AnytoneCodeplug::ChannelElement.

Zones
Start Size Content
024C1300 000020 Bitmap of 250 zones.
01000000 max. 01f400 250 zones channel lists of 250 16bit indices each. 0-based, little endian, default/padded=0xffff. Offset between channel lists 0x200, size of each list 0x1f4.
02540000 max. 001f40

250 Zone names. Each zone name is up to 16 ASCII chars long and gets 0-padded to 32b.

Contacts
Start Size Content
02600000 max. 009C40 Index list of valid contacts. 10000 32bit indices, little endian, default 0xffffffff
02640000 000500 Contact bitmap, 10000 bit, inverted, default 0xff, 0x00 padded.
02680000 max. 0186a0 Bank 1 of 1000 contacts, see AnytoneCodeplug::ContactElement. As each contact is 100b, they do not align with the 16b blocks being transferred to the device. Hence contacts are organized internally in groups of 4 contacts. There are 10 banks, each containing 1000 contacts. The offset between banks is 0x40000.
04340000 max. 013880

DMR ID to contact index map, see AnytoneCodeplug::ContactMapElement. Sorted by ID, empty entries set to 0xffffffffffffffff.

Analog Contacts
Start Size Content
02900000 000080 Index list of valid analog contacts.
02900100 000080 Bytemap for 128 analog contacts.
02940000 max. 000180

128 analog contacts. See AnytoneCodeplug::DTMFContactElement. As each analog contact is 24b, they do not align with the 16b transfer block-size. Hence analog contacts are internally organized in groups of 2.

RX Group Lists
Start Size Content
025C0B10 000020 Bitmap of 250 RX group lists, default/padding 0x00.
02980000 max. 000120 Grouplist 0, see AnytoneCodeplug::GroupListElement.
02980200 max. 000120 Grouplist 1
... ... ...
0299f200 max. 000120

Grouplist 250

Scan lists
Start Size Content
024C1340 000020 Bitmap of 250 scan lists.
01080000 000090 Bank 0, Scanlist 1, see AnytoneCodeplug::ScanListElement.
01080200 000090 Bank 0, Scanlist 2
... ... ...
01081E00 000090 Bank 0, Scanlist 16
010C0000 000090 Bank 1, Scanlist 17
... ... ...
01440000 000090 Bank 15, Scanlist 241
... ... ...
01441400 000090

Bank 15, Scanlist 250

Radio IDs
Start Size Content
024C1320 000020 Bitmap of 250 radio IDs.
02580000 max. 001f40

250 Radio IDs. See AnytoneCodeplug::RadioIDElement.

GPS
Start Size Content
02501000 000030 GPS settings, see AnytoneCodeplug::DMRAPRSSettingsElement.
02501100 000030

GPS message.

General Settings
Start Size Content
02500000 0000D0 General settings, see D868UVCodeplug::GeneralSettingsElement.
02500100 000400 Zone A & B channel list.
02500500 000100 DTMF list
02500600 000030 Power on settings, see AnytoneCodeplug::BootSettingsElement.
024C2000 0003F0

List of 250 auto-repeater offset frequencies. 32bit little endian frequency in 10Hz. I.e., 600kHz = 60000. Default 0x00000000, 0x00 padded.

Messages
Start Size Content
01640000 max. 000100 Some kind of linked list of messages. See AnytoneCodeplug::MessageListElement. Each entry has a size of 0x10.
01640800 000090 Bytemap of up to 100 valid messages. 0x00=valid, 0xff=invalid, remaining 46b set to 0x00.
02140000 max. 000800 Bank 0, Messages 1-8. Each message consumes 0x100b. See AnytoneCodeplug::MessageElement.
02180000 max. 000800 Bank 1, Messages 9-16
... ... ...
02440000 max. 000800

Bank 12, Messages 97-100

Hot Keys
Start Size Content
025C0000 000100 4 analog quick-call settings. See AnytoneCodeplug::AnalogQuickCallElement.
025C0B00 000010 Status message bitmap.
025C0100 000400 Up to 32 status messages. Length unknown, offset 0x20. ASCII 0x00 terminated and padded.
025C0500 000360

18 hot-key settings, see AnytoneCodeplug::HotKeyElement

Misc
Start Size Content
024C1400 000020 Alarm setting, see AnytoneCodeplug::AlarmSettingElement.
024C1440 000030

Digital alarm settings extension, see AnytoneCodeplug::DigitalAlarmExtensionElement.

FM Broadcast
Start Size Content
02480210 000020 Bitmap of 100 FM broadcast channels.
02480000 max. 000200 100 FM broadcast channels. Encoded as 8-digit BCD little-endian in 100Hz. Filled with 0x00.
02480200 000010

FM broadcast VFO frequency. Encoded as 8-digit BCD little-endian in 100Hz. Filled with 0x00.

DTMF, 2-tone & 5-tone signaling.
Start Size Content
024C0C80 000010 5-tone encoding bitmap for 100 IDs.
024C0000 000020 List of 100 5-tone IDs, see AnytoneCodeplug::FiveToneIDElement
024C0D00 000200 List of 16 5-tone functions, see AnytoneCodeplug::FiveToneFunctionElement.
024C1000 000080 5-tone settings, see AnytoneCodeplug::FiveToneSettingsElement.
024C1080 000050 DTMF settings, see AnytoneCodeplug::DTMFSettingsElement.
024C1280 000010 2-tone encoding bitmap.
024C1100 000010 2-tone encoding.
024C1290 000010 2-tone settings.
024C2600 000010 2-tone decoding bitmap.
024C2400 000030

2-tone decoding.

Encryption
Start Size Content
024C1700 000040 32 Encryption IDs, 0-based, 16bit big-endian.
024C1800 000500 32 DMR-Encryption keys, see dmr_encryption_key_t, 40b each.

Member Function Documentation

◆ allocateBitmaps()

bool D868UVCodeplug::allocateBitmaps ( )
protectedvirtual

Allocates the bitmaps.

This is also performed during a clear.

Implements AnytoneCodeplug.

Reimplemented in DMR6X2UVCodeplug, and D878UVCodeplug.

◆ allocateForDecoding()

void D868UVCodeplug::allocateForDecoding ( )
protectedvirtual

Allocate all code-plug elements that must be downloaded for decoding.

All code-plug elements within the radio that are not represented within the common Config are omitted.

Implements AnytoneCodeplug.

Reimplemented in DMR6X2UVCodeplug, and D878UVCodeplug.

◆ allocateUpdated()

void D868UVCodeplug::allocateUpdated ( )
protectedvirtual

Allocate all code-plug elements that must be written back to the device to maintain a working codeplug.

These elements might be updated during encoding.

Implements AnytoneCodeplug.

Reimplemented in DMR6X2UVCodeplug, D878UVCodeplug, and D578UVCodeplug.


The documentation for this class was generated from the following files: