libdrmconf  0.10.4
A library to program DMR radios.
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 
8 class Channel;
9 
78 {
79  Q_OBJECT
80 
81 public:
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);
104  Channel *toChannelObj(Context &ctx) const;
105  bool linkChannelObj(Channel *c, Context &ctx) const;
106  };
107 
112  class TimestampElement: Element
113  {
114  protected:
116  TimestampElement(uint8_t *ptr, unsigned size);
117 
118  public:
120  explicit TimestampElement(uint8_t *ptr);
122  virtual ~TimestampElement();
123 
125  void clear();
126 
128  virtual QDateTime get() const;
130  virtual void set(const QDateTime &ts=QDateTime::currentDateTime());
131  };
132 
139  {
140  public:
142  EncryptionElement(uint8_t *ptr);
143 
144  bool isBasicKeySet(unsigned n) const;
145  QByteArray basicKey(unsigned n) const;
146  void setBasicKey(unsigned n, const QByteArray &key);
147  };
148 
149 public:
151  RD5RCodeplug(QObject *parent=0);
152 
153  void clear();
154 
155 public:
156  bool encodeElements(const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
157  bool decodeElements(Context &ctx, const ErrorStack &err=ErrorStack());
158 
160  virtual void clearTimestamp();
162  virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack());
163 
164  void clearGeneralSettings();
165  bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
166  bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
167 
168  void clearButtonSettings();
169  void clearMessages();
170 
171  void clearContacts();
172  bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
173  bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
174 
175  void clearDTMFContacts();
176  bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
177  bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
178 
179  void clearChannels();
180  bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
181  bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
182  bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
183 
184  void clearBootSettings();
185  void clearMenuSettings();
186 
187  void clearBootText();
188  bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
189  bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
190 
191  void clearVFOSettings();
192 
193  void clearZones();
194  bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
195  bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
196  bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
197 
198  void clearScanLists();
199  bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
200  bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
201  bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
202 
203  void clearGroupLists();
204  bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
205  bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
206  bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
207 
208  void clearEncryption();
209  bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
210  bool createEncryption(Config *config, Context &ctx, const ErrorStack &err);
211  bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err);
212 };
213 
214 #endif // RD5R_CODEPLUG_HH
The base class of all channels (analog and digital) of a codeplug configuration.
Definition: channel.hh:32
Base class for all codeplug contexts.
Definition: codeplug.hh:195
Certain flags passed to CodePlug::encode to control the transfer and encoding of the codeplug.
Definition: codeplug.hh:24
The config class, representing the codeplug configuration.
Definition: config.hh:67
uint32_t size() const
Returns the total size of the DFU file.
Definition: dfufile.cc:50
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
bool linkChannelObj(Channel *c, Context &ctx) const
Links a previously constructed channel to the rest of the configuration.
Definition: rd5r_codeplug.cc:116
virtual void setSquelch(unsigned level)
Sets the squelch level.
Definition: rd5r_codeplug.cc:75
virtual unsigned squelch() const
Returns the squelch level.
Definition: rd5r_codeplug.cc:71
bool fromChannelObj(const Channel *c, Context &ctx)
Initializes this codeplug channel from the given generic configuration.
Definition: rd5r_codeplug.cc:81
Channel * toChannelObj(Context &ctx) const
Constructs a generic Channel object from the codeplug channel.
Definition: rd5r_codeplug.cc:102
ChannelElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: rd5r_codeplug.cc:52
void clear()
Resets the channel.
Definition: rd5r_codeplug.cc:65
Implements the encoding/decoding of encryption keys for the RD-5R radio.
Definition: rd5r_codeplug.hh:139
void setBasicKey(unsigned n, const QByteArray &key)
Sets the n-th "basic" key (32bit).
Definition: rd5r_codeplug.cc:193
EncryptionElement(uint8_t *ptr)
Constructor.
Definition: rd5r_codeplug.cc:172
bool isBasicKeySet(unsigned n) const
Returns true if the n-th "basic" key (32bit) is set.
Definition: rd5r_codeplug.cc:179
QByteArray basicKey(unsigned n) const
Returns the n-th "basic" key (32bit).
Definition: rd5r_codeplug.cc:186
Implements the timestamp for RD-5R codeplugs.
Definition: rd5r_codeplug.hh:113
TimestampElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: rd5r_codeplug.cc:133
void clear()
Resets the timestamp.
Definition: rd5r_codeplug.cc:150
virtual void set(const QDateTime &ts=QDateTime::currentDateTime())
Sets the time stamp.
Definition: rd5r_codeplug.cc:160
virtual ~TimestampElement()
Destructor.
Definition: rd5r_codeplug.cc:145
virtual QDateTime get() const
Returns the time stamp.
Definition: rd5r_codeplug.cc:155
Represents, encodes and decodes the device specific codeplug for a Baofeng/Radioddity RD-5R.
Definition: rd5r_codeplug.hh:78
bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition: rd5r_codeplug.cc:267
void clearContacts()
Clears all contacts in the codeplug.
Definition: rd5r_codeplug.cc:283
void clear()
Clears and resets the complete codeplug to some default values.
Definition: rd5r_codeplug.cc:214
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:234
RD5RCodeplug(QObject *parent=0)
Empty constructor.
Definition: rd5r_codeplug.cc:205
bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition: rd5r_codeplug.cc:709
bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition: rd5r_codeplug.cc:258
void clearScanLists()
Clears all scan lists.
Definition: rd5r_codeplug.cc:573
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:220
void clearVFOSettings()
Clears the VFO settings.
Definition: rd5r_codeplug.cc:452
void clearChannels()
Clear all channels.
Definition: rd5r_codeplug.cc:350
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition: rd5r_codeplug.cc:253
void clearEncryption()
Clears all encryption keys.
Definition: rd5r_codeplug.cc:686
bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists.
Definition: rd5r_codeplug.cc:631
bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encode all channels.
Definition: rd5r_codeplug.cc:362
bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition: rd5r_codeplug.cc:651
bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition: rd5r_codeplug.cc:503
bool createEncryption(Config *config, Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition: rd5r_codeplug.cc:700
bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all digital contacts in the configuration into the codeplug.
Definition: rd5r_codeplug.cc:289
bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition: rd5r_codeplug.cc:466
bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition: rd5r_codeplug.cc:323
void clearBootSettings()
Clear boot settings.
Definition: rd5r_codeplug.cc:423
void clearGroupLists()
Clears all group lists.
Definition: rd5r_codeplug.cc:624
bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition: rd5r_codeplug.cc:438
bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition: rd5r_codeplug.cc:610
void clearBootText()
Clears boot text.
Definition: rd5r_codeplug.cc:433
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition: rd5r_codeplug.cc:317
bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition: rd5r_codeplug.cc:405
bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition: rd5r_codeplug.cc:445
bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition: rd5r_codeplug.cc:666
void clearZones()
Clears all zones.
Definition: rd5r_codeplug.cc:458
bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a digital contact to the configuration for each one in the codeplug.
Definition: rd5r_codeplug.cc:302
bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition: rd5r_codeplug.cc:387
void clearMenuSettings()
Clears menu settings.
Definition: rd5r_codeplug.cc:428
bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition: rd5r_codeplug.cc:538
virtual bool encodeTimestamp(const ErrorStack &err=ErrorStack())
Sets the time-stamp.
Definition: rd5r_codeplug.cc:246
bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition: rd5r_codeplug.cc:580
void clearButtonSettings()
Clears the button settings.
Definition: rd5r_codeplug.cc:273
void clearMessages()
Clears the messages.
Definition: rd5r_codeplug.cc:278
bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all scan lists.
Definition: rd5r_codeplug.cc:595
virtual void clearTimestamp()
Clears the time-stamp in the codeplug.
Definition: rd5r_codeplug.cc:241
bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all encryption keys defined.
Definition: rd5r_codeplug.cc:692
bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition: rd5r_codeplug.cc:336
Implements the base for all Radioddity channel encodings.
Definition: radioddity_codeplug.hh:31
Represents all encryption keys and settings within the codeplug on the device.
Definition: radioddity_codeplug.hh:1255
Base class of all Radioddity codeplugs.
Definition: radioddity_codeplug.hh:22