libdrmconf  0.12.0
A library to program DMR radios.
gd77_codeplug.hh
1 #ifndef GD77_CODEPLUG_HH
2 #define GD77_CODEPLUG_HH
3 
4 #include "radioddity_codeplug.hh"
5 #include "signaling.hh"
6 
7 
63 {
64  Q_OBJECT
65 
66 public:
72  {
73  public:
75  enum ARTSMode {
76  ARTS_OFF = 0,
77  ARTS_TX = 1,
78  ARTS_RX = 2,
79  ARTS_BOTH = 3
80  };
81 
83  enum STEAngle {
85  STE_120DEG = 1,
86  STE_180DEG = 2,
87  STE_240DEG = 3
88  };
89 
91  enum PTTId {
92  PTTID_OFF = 0,
93  PTTID_START = 1,
94  PTTID_END = 2,
95  PTTID_BOTH = 3
96  };
97 
98  protected:
100  ChannelElement(uint8_t *ptr, size_t size);
101 
102  public:
104  explicit ChannelElement(uint8_t *ptr);
105 
106  void clear();
107 
109  virtual ARTSMode artsMode() const;
111  virtual void setARTSMode(ARTSMode mode);
112 
114  virtual STEAngle steAngle() const;
116  virtual void setSTEAngle(STEAngle angle);
117 
119  virtual PTTId pttIDMode() const;
121  virtual void setPTTIDMode(PTTId mode);
122 
124  virtual bool squelchIsTight() const;
126  virtual void enableTightSquelch(bool enable);
127 
129  virtual bool loneWorker() const;
131  virtual void enableLoneWorker(bool enable);
132 
134  virtual bool autoscan() const;
136  virtual void enableAutoscan(bool enable);
137  };
138 
145  {
146  protected:
148  ContactElement(uint8_t *ptr, unsigned size);
149 
150  public:
152  ContactElement(uint8_t *ptr);
153 
155  void clear();
157  bool isValid() const;
158 
160  virtual void markValid(bool valid=true);
161  void fromContactObj(const DMRContact *obj, Context &ctx);
162  };
163 
169  {
170  protected:
172  GroupListElement(uint8_t *ptr, unsigned size);
173 
174  public:
176  GroupListElement(uint8_t *ptr);
177 
179  static constexpr unsigned int size() { return 0x0050; }
180 
181  public:
185  static constexpr unsigned int memberCount() { return 32; }
186  };
187  };
188 
199  {
200  protected:
202  GroupListBankElement(uint8_t *ptr, unsigned size);
203 
204  public:
206  GroupListBankElement(uint8_t *ptr);
207 
209  static constexpr unsigned int size() { return 0x1480; }
210 
211  uint8_t *get(unsigned n) const;
212  };
213 
219  {
220  protected:
222  ScanListElement(uint8_t *ptr, unsigned size);
223 
224  public:
226  ScanListElement(uint8_t *ptr);
227 
229  void clear();
230  };
231 
237  {
238  protected:
240  ScanListBankElement(uint8_t *ptr, unsigned size);
241 
242  public:
244  ScanListBankElement(uint8_t *ptr);
245 
247  void clear();
248  uint8_t *get(unsigned n) const;
249  };
250 
251 public:
253  explicit GD77Codeplug(QObject *parent=nullptr);
254 
255 public:
256  void clearGeneralSettings();
257  bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
258  bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
259 
260  void clearButtonSettings();
261  bool encodeButtonSettings(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack());
262  bool decodeButtonSettings(Context &ctx, const ErrorStack &err=ErrorStack());
263 
264  void clearMessages();
265  bool encodeMessages(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack());
266  bool decodeMessages(Context &ctx, const ErrorStack &err=ErrorStack());
267 
268  void clearScanLists();
269  bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
270  bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
271  bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
272 
273  void clearContacts();
274  bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
275  bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
276 
277  void clearDTMFContacts();
278  bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
279  bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
280 
281  void clearChannels();
282  bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
283  bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
284  bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
285 
286  void clearBootSettings();
287  void clearMenuSettings();
288 
289  void clearBootText();
290  bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
291  bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
292 
293  void clearVFOSettings();
294 
295  void clearZones();
296  bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
297  bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
298  bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
299 
300  void clearGroupLists();
301  bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
302  bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
303  bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
304 
305  void clearEncryption();
306  bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
307  bool createEncryption(Config *config, Context &ctx, const ErrorStack &err);
308  bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err);
309 
310 protected:
312  struct Offset {
314  static constexpr unsigned int buttonSettings() { return 0x000108; }
315  static constexpr unsigned int messages() { return 0x000128; }
317  };
318 };
319 
320 #endif // GD77_CODEPLUG_HH
Base class for all codeplug contexts.
Definition: codeplug.hh:238
Certain flags passed to CodePlug::encode to control the transfer and encoding of the codeplug.
Definition: codeplug.hh:25
The config class, representing the codeplug configuration.
Definition: config.hh:70
uint32_t size() const
Returns the total size of the DFU file.
Definition: dfufile.cc:52
Represents a digital contact, that is a DMR number.
Definition: contact.hh:141
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Channel representation within the binary codeplug.
Definition: gd77_codeplug.hh:72
virtual ARTSMode artsMode() const
Returns the ARTS mode.
Definition: gd77_codeplug.cc:73
PTTId
PTT ID send.
Definition: gd77_codeplug.hh:91
virtual STEAngle steAngle() const
Returns the STE angle.
Definition: gd77_codeplug.cc:82
virtual void enableTightSquelch(bool enable)
Enables/disables tight squelch.
Definition: gd77_codeplug.cc:104
virtual PTTId pttIDMode() const
Returns the PTT ID mode.
Definition: gd77_codeplug.cc:91
STEAngle
STE angle.
Definition: gd77_codeplug.hh:83
@ STE_180DEG
180 degree.
Definition: gd77_codeplug.hh:86
@ STE_120DEG
120 degree.
Definition: gd77_codeplug.hh:85
@ STE_240DEG
240 degree.
Definition: gd77_codeplug.hh:87
@ STE_FREQUENCY
STE Frequency.
Definition: gd77_codeplug.hh:84
virtual void setSTEAngle(STEAngle angle)
Sets the STE angle.
Definition: gd77_codeplug.cc:86
virtual void enableLoneWorker(bool enable)
Enables/disables lone worker.
Definition: gd77_codeplug.cc:113
virtual void setPTTIDMode(PTTId mode)
Sets the PTT ID mode.
Definition: gd77_codeplug.cc:95
ARTSMode
ARTS send.
Definition: gd77_codeplug.hh:75
virtual bool squelchIsTight() const
Returns true if the squech type is tight.
Definition: gd77_codeplug.cc:100
void clear()
Resets the channel.
Definition: gd77_codeplug.cc:65
ChannelElement(uint8_t *ptr, size_t size)
Hidden Constructor.
Definition: gd77_codeplug.cc:52
virtual bool loneWorker() const
Returns true if lone worker is enabled.
Definition: gd77_codeplug.cc:109
virtual void setARTSMode(ARTSMode mode)
Sets the ARTS mode.
Definition: gd77_codeplug.cc:77
virtual void enableAutoscan(bool enable)
Enables/disables auto scan.
Definition: gd77_codeplug.cc:122
virtual bool autoscan() const
Returns true if auto scan is enabled.
Definition: gd77_codeplug.cc:118
Specific codeplug representation of a DMR contact for the GD77.
Definition: gd77_codeplug.hh:145
bool isValid() const
Returns true if the contact is valid.
Definition: gd77_codeplug.cc:148
void fromContactObj(const DMRContact *obj, Context &ctx)
Resets this codeplug contact from the given DigitalContact.
Definition: gd77_codeplug.cc:160
virtual void markValid(bool valid=true)
Marks the entry as valid/invalid.
Definition: gd77_codeplug.cc:153
ContactElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: gd77_codeplug.cc:130
void clear()
Resets the contact.
Definition: gd77_codeplug.cc:143
Table of RX group lists.
Definition: gd77_codeplug.hh:199
uint8_t * get(unsigned n) const
Returns a pointer to the n-th group list.
Definition: gd77_codeplug.cc:246
GroupListBankElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: gd77_codeplug.cc:233
static constexpr unsigned int size()
Size of the element.
Definition: gd77_codeplug.hh:209
Represents an RX group list within the codeplug.
Definition: gd77_codeplug.hh:169
static constexpr unsigned int size()
Size of the group list element.
Definition: gd77_codeplug.hh:179
GroupListElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: gd77_codeplug.cc:217
Bank of scan lists for the GD77.
Definition: gd77_codeplug.hh:237
ScanListBankElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: gd77_codeplug.cc:191
uint8_t * get(unsigned n) const
Returns a pointer to the n-th scan list.
Definition: gd77_codeplug.cc:209
void clear()
Clears the scan list bank.
Definition: gd77_codeplug.cc:204
Represents a single scan list within the GD77 codeplug.
Definition: gd77_codeplug.hh:219
void clear()
Resets the scan list.
Definition: gd77_codeplug.cc:182
ScanListElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: gd77_codeplug.cc:169
Represents, encodes and decodes the device specific codeplug for a Radioddity GD-77.
Definition: gd77_codeplug.hh:63
bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists.
Definition: gd77_codeplug.cc:617
bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition: gd77_codeplug.cc:278
bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition: gd77_codeplug.cc:318
bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition: gd77_codeplug.cc:632
void clearContacts()
Clears all contacts in the codeplug.
Definition: gd77_codeplug.cc:539
bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a digital contact to the configuration for each one in the codeplug.
Definition: gd77_codeplug.cc:559
bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition: gd77_codeplug.cc:453
void clearMessages()
Clears the messages.
Definition: gd77_codeplug.cc:298
bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition: gd77_codeplug.cc:268
void clearEncryption()
Clears all encryption keys.
Definition: gd77_codeplug.cc:665
bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition: gd77_codeplug.cc:520
bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition: gd77_codeplug.cc:581
void clearMenuSettings()
Clears menu settings.
Definition: gd77_codeplug.cc:443
bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition: gd77_codeplug.cc:348
void clearBootText()
Clears boot text.
Definition: gd77_codeplug.cc:448
bool encodeMessages(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes preset messages.
Definition: gd77_codeplug.cc:302
void clearChannels()
Clear all channels.
Definition: gd77_codeplug.cc:362
bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all scan lists.
Definition: gd77_codeplug.cc:333
void clearScanLists()
Clears all scan lists.
Definition: gd77_codeplug.cc:311
void clearBootSettings()
Clear boot settings.
Definition: gd77_codeplug.cc:438
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition: gd77_codeplug.cc:575
bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all encryption keys defined.
Definition: gd77_codeplug.cc:671
bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition: gd77_codeplug.cc:504
GD77Codeplug(QObject *parent=nullptr)
Constructs an empty codeplug for the GD-77.
Definition: gd77_codeplug.cc:254
bool encodeButtonSettings(Context &ctx, const Flags &flags, const ErrorStack &err=ErrorStack())
Encodes button settings.
Definition: gd77_codeplug.cc:288
bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all digital contacts in the configuration into the codeplug.
Definition: gd77_codeplug.cc:545
bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition: gd77_codeplug.cc:645
bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition: gd77_codeplug.cc:482
void clearGroupLists()
Clears all group lists.
Definition: gd77_codeplug.cc:610
bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encode all channels.
Definition: gd77_codeplug.cc:374
bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition: gd77_codeplug.cc:688
void clearZones()
Clears all zones.
Definition: gd77_codeplug.cc:474
void clearButtonSettings()
Clears the button settings.
Definition: gd77_codeplug.cc:284
bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition: gd77_codeplug.cc:595
bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition: gd77_codeplug.cc:461
bool createEncryption(Config *config, Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition: gd77_codeplug.cc:679
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition: gd77_codeplug.cc:263
bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition: gd77_codeplug.cc:419
bool decodeButtonSettings(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes the button settings.
Definition: gd77_codeplug.cc:293
bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition: gd77_codeplug.cc:400
bool decodeMessages(Context &ctx, const ErrorStack &err=ErrorStack())
Decodes preset messages.
Definition: gd77_codeplug.cc:306
void clearVFOSettings()
Clears the VFO settings.
Definition: gd77_codeplug.cc:468
Implements the base for all Radioddity channel encodings.
Definition: radioddity_codeplug.hh:33
virtual Mode mode() const
Returns the channel mode.
Definition: radioddity_codeplug.cc:89
Implements the base for digital contacts in Radioddity codeplugs.
Definition: radioddity_codeplug.hh:312
Implements a base class of group list memory banks for all Radioddity codeplugs.
Definition: radioddity_codeplug.hh:543
Represents a base class for all group lists within Radioddity codeplugs.
Definition: radioddity_codeplug.hh:478
Implements the base class of scan lists banks for all Radioddity codeplugs.
Definition: radioddity_codeplug.hh:717
Implements the base class for scan lists of all Radioddity codeplugs.
Definition: radioddity_codeplug.hh:597
Base class of all Radioddity codeplugs.
Definition: radioddity_codeplug.hh:24
Limits of the element.
Definition: gd77_codeplug.hh:183
static constexpr unsigned int memberCount()
Maximum member count.
Definition: gd77_codeplug.hh:185
Internal used offsets within the codeplug.
Definition: gd77_codeplug.hh:312
Some limits for the group list.
Definition: radioddity_codeplug.hh:519