libdrmconf 0.13.3
A library to program DMR radios.
Loading...
Searching...
No Matches
rd5r_codeplug.hh
1#ifndef RD5R_CODEPLUG_HH
2#define RD5R_CODEPLUG_HH
3
4#include <QObject>
5#include "radioddity_codeplug.hh"
6#include "signaling.hh"
7
8class Channel;
9
78{
79 Q_OBJECT
80
81public:
87 {
88 protected:
90 ChannelElement(uint8_t *ptr, size_t size);
91
92 public:
94 explicit ChannelElement(uint8_t *ptr);
95
96 void clear();
97
99 virtual unsigned squelch() const;
101 virtual void setSquelch(unsigned level);
102
103 bool fromChannelObj(const Channel *c, Context &ctx, const ErrorStack &err=ErrorStack());
104 Channel *toChannelObj(Context &ctx, const ErrorStack &err=ErrorStack()) const;
105 bool linkChannelObj(Channel *c, Context &ctx, const ErrorStack &err=ErrorStack()) const;
106
107 protected:
111 static constexpr unsigned int squelch() { return 0x0037; }
113 };
114 };
115
116
122 {
123 protected:
125 TimestampElement(uint8_t *ptr, unsigned size);
126
127 public:
129 explicit TimestampElement(uint8_t *ptr);
131 virtual ~TimestampElement();
132
134 static constexpr unsigned int size() { return 0x0006; }
135
137 void clear();
138
140 virtual QDateTime get() const;
142 virtual void set(const QDateTime &ts=QDateTime::currentDateTime());
143
144 protected:
146 struct Offset {
148 static constexpr unsigned int year() { return 0x0000; }
149 static constexpr unsigned int month() { return 0x0002; }
150 static constexpr unsigned int day() { return 0x0003; }
151 static constexpr unsigned int hour() { return 0x0004; }
152 static constexpr unsigned int minute() { return 0x0005; }
154 };
155 };
156
157
164 {
165 public:
167 EncryptionElement(uint8_t *ptr);
168
169 bool isBasicKeySet(unsigned n) const;
170 QByteArray basicKey(unsigned n) const;
171 void setBasicKey(unsigned n, const QByteArray &key);
172 };
173
174public:
176 RD5RCodeplug(QObject *parent=0);
177
178 void clear();
179
180public:
181 bool encodeElements(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
182 bool decodeElements(Context &ctx, const ErrorStack &err=ErrorStack());
183
185 virtual void clearTimestamp();
187 virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack());
188
190 bool encodeGeneralSettings(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
191 bool decodeGeneralSettings(Context &ctx, const ErrorStack &err=ErrorStack());
192
193 void clearButtonSettings();
194 bool encodeButtonSettings(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack());
195 bool decodeButtonSettings(Context &ctx, const ErrorStack &err=ErrorStack());
196
197 void clearMessages();
198 bool encodeMessages(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack());
199 bool decodeMessages(Context &ctx, const ErrorStack &err=ErrorStack());
200
201 void clearContacts();
202 bool encodeContacts(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
203 bool createContacts(Context &ctx, const ErrorStack &err=ErrorStack());
204
205 void clearDTMFContacts();
206 bool encodeDTMFContacts(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
207 bool createDTMFContacts(Context &ctx, const ErrorStack &err=ErrorStack());
208
209 void clearChannels();
210 bool encodeChannels(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
211 bool createChannels(Context &ctx, const ErrorStack &err=ErrorStack());
212 bool linkChannels(Context &ctx, const ErrorStack &err=ErrorStack());
213
214 void clearBootSettings();
215 void clearMenuSettings();
216
217 void clearBootText();
218 bool encodeBootText(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
219 bool decodeBootText(Context &ctx, const ErrorStack &err=ErrorStack());
220
221 void clearVFOSettings();
222
223 void clearZones();
224 bool encodeZones(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
225 bool createZones(Context &ctx, const ErrorStack &err=ErrorStack());
226 bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack());
227
228 void clearScanLists();
229 bool encodeScanLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
230 bool createScanLists(Context &ctx, const ErrorStack &err=ErrorStack());
231 bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack());
232
233 void clearGroupLists();
234 bool encodeGroupLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
235 bool createGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
236 bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
237
238 void clearEncryption();
239 bool encodeEncryption(const Flags &flags, Context &ctx, const ErrorStack &err);
240 bool createEncryption(Context &ctx, const ErrorStack &err);
241 bool linkEncryption(Context &ctx, const ErrorStack &err);
242
243public:
245 struct Limit {
246 static constexpr unsigned int channelBankCount() { return 8; }
247 static constexpr unsigned int channelCount() { return 1024; }
248 static constexpr unsigned int contactCount() { return 256; }
249 static constexpr unsigned int dtmfContactCount() { return 32; }
250 static constexpr unsigned int zoneCount() { return 250; }
251 };
252
253protected:
255 struct Offset {
257 static constexpr unsigned int timestamp() { return 0x000088; }
258 static constexpr unsigned int settings() { return 0x0000e0; }
259 static constexpr unsigned int buttons() { return 0x000108; }
260 static constexpr unsigned int messages() { return 0x000128; }
261 static constexpr unsigned int encryption() { return 0x001370; }
262 static constexpr unsigned int contacts() { return 0x001788; }
263 static constexpr unsigned int dtmfContacts() { return 0x002f88; }
264 static constexpr unsigned int channelBank0() { return 0x003780; }
265 static constexpr unsigned int bootSettings() { return 0x007518; }
266 static constexpr unsigned int menuSettings() { return 0x007538; }
267 static constexpr unsigned int bootText() { return 0x007540; }
268 static constexpr unsigned int vfoA() { return 0x007590; }
269 static constexpr unsigned int vfoB() { return 0x0075c8; }
270 static constexpr unsigned int zoneBank() { return 0x008010; }
271 static constexpr unsigned int channelBank1() { return 0x00b1b0; }
272 static constexpr unsigned int scanListBank() { return 0x017620; }
273 static constexpr unsigned int groupListBank() { return 0x01d620; }
275 };
276};
277
278#endif // RD5R_CODEPLUG_HH
The base class of all channels (analog and digital) of a codeplug configuration.
Definition channel.hh:34
Base class for all codeplug contexts.
Definition codeplug.hh:291
Represents the abstract base class of all codeplug elements.
Definition codeplug.hh:65
Certain flags passed to CodePlug::encode to control the transfer and encoding of the codeplug.
Definition codeplug.hh:24
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
Channel * toChannelObj(Context &ctx, const ErrorStack &err=ErrorStack()) const
Constructs a generic Channel object from the codeplug channel.
Definition rd5r_codeplug.cc:62
virtual void setSquelch(unsigned level)
Sets the squelch level.
Definition rd5r_codeplug.cc:35
virtual unsigned squelch() const
Returns the squelch level.
Definition rd5r_codeplug.cc:31
bool linkChannelObj(Channel *c, Context &ctx, const ErrorStack &err=ErrorStack()) const
Links a previously constructed channel to the rest of the configuration.
Definition rd5r_codeplug.cc:76
bool fromChannelObj(const Channel *c, Context &ctx, const ErrorStack &err=ErrorStack())
Initializes this codeplug channel from the given generic configuration.
Definition rd5r_codeplug.cc:41
ChannelElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition rd5r_codeplug.cc:12
void clear()
Resets the channel.
Definition rd5r_codeplug.cc:25
void setBasicKey(unsigned n, const QByteArray &key)
Sets the n-th "basic" key (32bit).
Definition rd5r_codeplug.cc:153
EncryptionElement(uint8_t *ptr)
Constructor.
Definition rd5r_codeplug.cc:132
bool isBasicKeySet(unsigned n) const
Returns true if the n-th "basic" key (32bit) is set.
Definition rd5r_codeplug.cc:139
QByteArray basicKey(unsigned n) const
Returns the n-th "basic" key (32bit).
Definition rd5r_codeplug.cc:146
TimestampElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition rd5r_codeplug.cc:93
void clear()
Resets the timestamp.
Definition rd5r_codeplug.cc:110
virtual void set(const QDateTime &ts=QDateTime::currentDateTime())
Sets the time stamp.
Definition rd5r_codeplug.cc:120
virtual ~TimestampElement()
Destructor.
Definition rd5r_codeplug.cc:105
virtual QDateTime get() const
Returns the time stamp.
Definition rd5r_codeplug.cc:115
static constexpr unsigned int size()
The size of the element.
Definition rd5r_codeplug.hh:134
bool encodeGroupLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists.
Definition rd5r_codeplug.cc:588
bool linkEncryption(Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition rd5r_codeplug.cc:663
void clearContacts()
Clears all contacts in the codeplug.
Definition rd5r_codeplug.cc:268
void clear()
Clears and resets the complete codeplug to some default values.
Definition rd5r_codeplug.cc:174
bool decodeElements(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes the binary codeplug and stores its content in the given generic configuration using the given...
Definition rd5r_codeplug.cc:194
RD5RCodeplug(QObject *parent=0)
Empty constructor.
Definition rd5r_codeplug.cc:165
bool encodeZones(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition rd5r_codeplug.cc:466
bool linkChannels(Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition rd5r_codeplug.cc:406
bool createChannels(Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition rd5r_codeplug.cc:384
void clearScanLists()
Clears all scan lists.
Definition rd5r_codeplug.cc:522
bool encodeElements(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes the given generic configuration as a binary codeplug using the given context.
Definition rd5r_codeplug.cc:180
void clearVFOSettings()
Clears the VFO settings.
Definition rd5r_codeplug.cc:452
void clearChannels()
Clear all channels.
Definition rd5r_codeplug.cc:347
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition rd5r_codeplug.cc:213
bool encodeMessages(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes preset messages.
Definition rd5r_codeplug.cc:250
void clearEncryption()
Clears all encryption keys.
Definition rd5r_codeplug.cc:640
bool decodeButtonSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes the button settings.
Definition rd5r_codeplug.cc:241
bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition rd5r_codeplug.cc:505
void clearBootSettings()
Clear boot settings.
Definition rd5r_codeplug.cc:424
void clearGroupLists()
Clears all group lists.
Definition rd5r_codeplug.cc:581
bool encodeBootText(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition rd5r_codeplug.cc:439
bool createGroupLists(Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition rd5r_codeplug.cc:609
bool encodeContacts(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all digital contacts in the configuration into the codeplug.
Definition rd5r_codeplug.cc:274
bool encodeGeneralSettings(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition rd5r_codeplug.cc:218
void clearBootText()
Clears boot text.
Definition rd5r_codeplug.cc:434
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition rd5r_codeplug.cc:306
bool createZones(Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition rd5r_codeplug.cc:488
bool createDTMFContacts(Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition rd5r_codeplug.cc:329
bool createContacts(Context &ctx, const ErrorStack &err=ErrorStack())
Adds a digital contact to the configuration for each one in the codeplug.
Definition rd5r_codeplug.cc:291
bool encodeButtonSettings(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes button settings.
Definition rd5r_codeplug.cc:236
bool createScanLists(Context &ctx, const ErrorStack &err=ErrorStack())
Creates all scan lists.
Definition rd5r_codeplug.cc:548
bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition rd5r_codeplug.cc:622
bool encodeEncryption(const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all encryption keys defined.
Definition rd5r_codeplug.cc:646
void clearZones()
Clears all zones.
Definition rd5r_codeplug.cc:458
bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition rd5r_codeplug.cc:565
void clearMenuSettings()
Clears menu settings.
Definition rd5r_codeplug.cc:429
bool decodeBootText(Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition rd5r_codeplug.cc:446
virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack())
Sets the time-stamp.
Definition rd5r_codeplug.cc:206
bool encodeDTMFContacts(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition rd5r_codeplug.cc:312
bool decodeMessages(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes preset messages.
Definition rd5r_codeplug.cc:258
bool decodeGeneralSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition rd5r_codeplug.cc:227
bool createEncryption(Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition rd5r_codeplug.cc:654
bool encodeScanLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition rd5r_codeplug.cc:529
void clearButtonSettings()
Clears the button settings.
Definition rd5r_codeplug.cc:232
void clearMessages()
Clears the messages.
Definition rd5r_codeplug.cc:246
virtual void clearTimestamp()
Clears the time-stamp in the codeplug.
Definition rd5r_codeplug.cc:201
bool encodeChannels(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encode all channels.
Definition rd5r_codeplug.cc:359
Implements the base for all Radioddity channel encodings.
Definition radioddity_codeplug.hh:33
static constexpr unsigned int size()
The size of the channel.
Definition radioddity_codeplug.hh:65
Represents all encryption keys and settings within the codeplug on the device.
Definition radioddity_codeplug.hh:1598
RadioddityCodeplug(QObject *parent=nullptr)
Hidden constructor, use a device specific class to instantiate.
Definition radioddity_codeplug.cc:2793
Internal offsets within the channel element.
Definition rd5r_codeplug.hh:109
Some limits for the codeplug.
Definition rd5r_codeplug.hh:245
static constexpr unsigned int contactCount()
Maximum number of DMR contacts.
Definition rd5r_codeplug.hh:248
static constexpr unsigned int zoneCount()
Maximum number of zones.
Definition rd5r_codeplug.hh:250
static constexpr unsigned int dtmfContactCount()
Maximum number of DTMF contacts.
Definition rd5r_codeplug.hh:249
static constexpr unsigned int channelBankCount()
The number of channel banks.
Definition rd5r_codeplug.hh:246
static constexpr unsigned int channelCount()
Maximum number of channels in the codeplug.
Definition rd5r_codeplug.hh:247
Some internal offsets within the codeplug.
Definition rd5r_codeplug.hh:255
Internal offsets within the element.
Definition rd5r_codeplug.hh:146
Some internal offsets within the channel element.
Definition radioddity_codeplug.hh:234