libdrmconf 0.12.1
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
77class RD5RCodeplug : public RadioddityCodeplug
78{
79 Q_OBJECT
80
81public:
86 class ChannelElement: public RadioddityCodeplug::ChannelElement
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:
109 struct Offset: RadioddityCodeplug::ChannelElement::Offset {
111 static constexpr unsigned int squelch() { return 0x0037; }
113 };
114 };
115
116
121 class TimestampElement: Element
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
163 class EncryptionElement: public RadioddityCodeplug::EncryptionElement
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
189 void clearGeneralSettings();
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
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:41
Implements the specialization of the Radioddity channel for the RD5R radio.
Definition rd5r_codeplug.hh:87
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
ChannelElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition rd5r_codeplug.cc:12
Implements the encoding/decoding of encryption keys for the RD-5R radio.
Definition rd5r_codeplug.hh:164
EncryptionElement(uint8_t *ptr)
Constructor.
Definition rd5r_codeplug.cc:132
Implements the timestamp for RD-5R codeplugs.
Definition rd5r_codeplug.hh:122
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
Represents, encodes and decodes the device specific codeplug for a Baofeng/Radioddity RD-5R.
Definition rd5r_codeplug.hh:78
RD5RCodeplug(QObject *parent=0)
Empty constructor.
Definition rd5r_codeplug.cc:165
virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack())
Sets the time-stamp.
Definition rd5r_codeplug.cc:206
virtual void clearTimestamp()
Clears the time-stamp in the codeplug.
Definition rd5r_codeplug.cc:201
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