libdrmconf 0.15.0
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 Level squelch() const;
101 virtual void setSquelch(Level 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 clearMenuSettings();
215
216 void clearBootSettings();
217 bool encodeBootSettings(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
218 bool decodeBootSettings(Context &ctx, const ErrorStack &err=ErrorStack());
219
220 void clearVFOSettings();
221
222 void clearZones();
223 bool encodeZones(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
224 bool createZones(Context &ctx, const ErrorStack &err=ErrorStack());
225 bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack());
226
227 void clearScanLists();
228 bool encodeScanLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
229 bool createScanLists(Context &ctx, const ErrorStack &err=ErrorStack());
230 bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack());
231
232 void clearGroupLists();
233 bool encodeGroupLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
234 bool createGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
235 bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
236
237 void clearEncryption();
238 bool encodeEncryption(const Flags &flags, Context &ctx, const ErrorStack &err);
239 bool createEncryption(Context &ctx, const ErrorStack &err);
240 bool linkEncryption(Context &ctx, const ErrorStack &err);
241
242public:
244 struct Limit {
245 static constexpr unsigned int channelBankCount() { return 8; }
246 static constexpr unsigned int channelCount() { return 1024; }
247 static constexpr unsigned int contactCount() { return 256; }
248 static constexpr unsigned int dtmfContactCount() { return 32; }
249 static constexpr unsigned int zoneCount() { return 250; }
250 };
251
252protected:
254 struct Offset {
256 static constexpr unsigned int timestamp() { return 0x000088; }
257 static constexpr unsigned int settings() { return 0x0000e0; }
258 static constexpr unsigned int buttons() { return 0x000108; }
259 static constexpr unsigned int messages() { return 0x000128; }
260 static constexpr unsigned int encryption() { return 0x001370; }
261 static constexpr unsigned int contacts() { return 0x001788; }
262 static constexpr unsigned int dtmfContacts() { return 0x002f88; }
263 static constexpr unsigned int channelBank0() { return 0x003780; }
264 static constexpr unsigned int bootSettings() { return 0x007518; }
265 static constexpr unsigned int menuSettings() { return 0x007538; }
266 static constexpr unsigned int bootText() { return 0x007540; }
267 static constexpr unsigned int vfoA() { return 0x007590; }
268 static constexpr unsigned int vfoB() { return 0x0075c8; }
269 static constexpr unsigned int zoneBank() { return 0x008010; }
270 static constexpr unsigned int channelBank1() { return 0x00b1b0; }
271 static constexpr unsigned int scanListBank() { return 0x017620; }
272 static constexpr unsigned int groupListBank() { return 0x01d620; }
274 };
275};
276
277#endif // RD5R_CODEPLUG_HH
The base class of all channels (analog and digital) of a codeplug configuration.
Definition channel.hh:38
Base class for all codeplug contexts.
Definition codeplug.hh:331
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
Some simple class implementing a [1-10] level setting.
Definition level.hh:15
Channel * toChannelObj(Context &ctx, const ErrorStack &err=ErrorStack()) const
Constructs a generic Channel object from the codeplug channel.
Definition rd5r_codeplug.cc:60
virtual Level squelch() const
Returns the squelch level.
Definition rd5r_codeplug.cc:30
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:74
bool fromChannelObj(const Channel *c, Context &ctx, const ErrorStack &err=ErrorStack())
Initializes this codeplug channel from the given generic configuration.
Definition rd5r_codeplug.cc:39
ChannelElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition rd5r_codeplug.cc:11
void clear()
Resets the channel.
Definition rd5r_codeplug.cc:24
virtual void setSquelch(Level level)
Sets the squelch level.
Definition rd5r_codeplug.cc:34
void setBasicKey(unsigned n, const QByteArray &key)
Sets the n-th "basic" key (32bit).
Definition rd5r_codeplug.cc:151
EncryptionElement(uint8_t *ptr)
Constructor.
Definition rd5r_codeplug.cc:130
bool isBasicKeySet(unsigned n) const
Returns true if the n-th "basic" key (32bit) is set.
Definition rd5r_codeplug.cc:137
QByteArray basicKey(unsigned n) const
Returns the n-th "basic" key (32bit).
Definition rd5r_codeplug.cc:144
TimestampElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition rd5r_codeplug.cc:91
void clear()
Resets the timestamp.
Definition rd5r_codeplug.cc:108
virtual void set(const QDateTime &ts=QDateTime::currentDateTime())
Sets the time stamp.
Definition rd5r_codeplug.cc:118
virtual ~TimestampElement()
Destructor.
Definition rd5r_codeplug.cc:103
virtual QDateTime get() const
Returns the time stamp.
Definition rd5r_codeplug.cc:113
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:585
bool linkEncryption(Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition rd5r_codeplug.cc:660
void clearContacts()
Clears all contacts in the codeplug.
Definition rd5r_codeplug.cc:266
void clear()
Clears and resets the complete codeplug to some default values.
Definition rd5r_codeplug.cc:172
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:192
RD5RCodeplug(QObject *parent=0)
Empty constructor.
Definition rd5r_codeplug.cc:163
bool encodeZones(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition rd5r_codeplug.cc:463
bool linkChannels(Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition rd5r_codeplug.cc:404
bool createChannels(Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition rd5r_codeplug.cc:382
void clearScanLists()
Clears all scan lists.
Definition rd5r_codeplug.cc:519
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:178
void clearVFOSettings()
Clears the VFO settings.
Definition rd5r_codeplug.cc:449
void clearChannels()
Clear all channels.
Definition rd5r_codeplug.cc:345
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition rd5r_codeplug.cc:211
bool encodeMessages(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes preset messages.
Definition rd5r_codeplug.cc:248
void clearEncryption()
Clears all encryption keys.
Definition rd5r_codeplug.cc:637
bool decodeButtonSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes the button settings.
Definition rd5r_codeplug.cc:239
bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition rd5r_codeplug.cc:502
void clearBootSettings()
Clears boot text.
Definition rd5r_codeplug.cc:428
bool decodeBootSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition rd5r_codeplug.cc:442
void clearGroupLists()
Clears all group lists.
Definition rd5r_codeplug.cc:578
bool createGroupLists(Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition rd5r_codeplug.cc:606
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:272
bool encodeGeneralSettings(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition rd5r_codeplug.cc:216
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition rd5r_codeplug.cc:304
bool createZones(Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition rd5r_codeplug.cc:485
bool createDTMFContacts(Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition rd5r_codeplug.cc:327
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:289
bool encodeButtonSettings(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes button settings.
Definition rd5r_codeplug.cc:234
bool createScanLists(Context &ctx, const ErrorStack &err=ErrorStack())
Creates all scan lists.
Definition rd5r_codeplug.cc:545
bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition rd5r_codeplug.cc:619
bool encodeEncryption(const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all encryption keys defined.
Definition rd5r_codeplug.cc:643
void clearZones()
Clears all zones.
Definition rd5r_codeplug.cc:455
bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition rd5r_codeplug.cc:562
void clearMenuSettings()
Clears menu settings.
Definition rd5r_codeplug.cc:423
virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack())
Sets the time-stamp.
Definition rd5r_codeplug.cc:204
bool encodeDTMFContacts(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition rd5r_codeplug.cc:310
bool decodeMessages(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes preset messages.
Definition rd5r_codeplug.cc:256
bool decodeGeneralSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition rd5r_codeplug.cc:225
bool createEncryption(Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition rd5r_codeplug.cc:651
bool encodeScanLists(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition rd5r_codeplug.cc:526
void clearButtonSettings()
Clears the button settings.
Definition rd5r_codeplug.cc:230
void clearMessages()
Clears the messages.
Definition rd5r_codeplug.cc:244
virtual void clearTimestamp()
Clears the time-stamp in the codeplug.
Definition rd5r_codeplug.cc:199
bool encodeBootSettings(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition rd5r_codeplug.cc:434
bool encodeChannels(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encode all channels.
Definition rd5r_codeplug.cc:357
Implements the base for all Radioddity channel encodings.
Definition radioddity_codeplug.hh:34
static constexpr unsigned int size()
The size of the channel.
Definition radioddity_codeplug.hh:66
Represents all encryption keys and settings within the codeplug on the device.
Definition radioddity_codeplug.hh:1629
RadioddityCodeplug(QObject *parent=nullptr)
Hidden constructor, use a device specific class to instantiate.
Definition radioddity_codeplug.cc:2861
Internal offsets within the channel element.
Definition rd5r_codeplug.hh:109
Some limits for the codeplug.
Definition rd5r_codeplug.hh:244
static constexpr unsigned int contactCount()
Maximum number of DMR contacts.
Definition rd5r_codeplug.hh:247
static constexpr unsigned int zoneCount()
Maximum number of zones.
Definition rd5r_codeplug.hh:249
static constexpr unsigned int dtmfContactCount()
Maximum number of DTMF contacts.
Definition rd5r_codeplug.hh:248
static constexpr unsigned int channelBankCount()
The number of channel banks.
Definition rd5r_codeplug.hh:245
static constexpr unsigned int channelCount()
Maximum number of channels in the codeplug.
Definition rd5r_codeplug.hh:246
Some internal offsets within the codeplug.
Definition rd5r_codeplug.hh:254
Internal offsets within the element.
Definition rd5r_codeplug.hh:146
Some internal offsets within the channel element.
Definition radioddity_codeplug.hh:235