libdrmconf  0.11.3
A library to program DMR radios.
opengd77_codeplug.hh
1 #ifndef OPENGD77_CODEPLUG_HH
2 #define OPENGD77_CODEPLUG_HH
3 
4 #include "gd77_codeplug.hh"
5 #include "opengd77_extension.hh"
6 
7 
57 {
58  Q_OBJECT
59 
60 public:
62  static const uint32_t EEPROM = 0;
64  static const uint32_t FLASH = 1;
65 
66 public:
72  {
73  public:
75  typedef OpenGD77ChannelExtension::Power Power;
76 
77  public:
79  explicit ChannelElement(uint8_t *ptr);
80 
81  void clear();
82 
83  Channel::Power power() const;
85 
87  virtual bool scanZoneSkip() const;
89  virtual void enableScanZoneSkip(bool enable);
91  virtual bool scanAllSkip() const;
93  virtual void enableScanAllSkip(bool enable);
94 
96  virtual Power extendedPower() const;
98  virtual void setExtendedPower(Power power);
99 
101  virtual bool squelchIsDefault() const;
103  virtual unsigned squelch() const;
105  virtual void setSquelch(unsigned squelch);
107  virtual void setSquelchDefault();
108 
110  virtual bool hasRadioId() const;
112  virtual unsigned radioId() const;
114  virtual void setRadioId(unsigned id);
116  virtual void clearRadioId();
117 
118  Channel *toChannelObj(Context &ctx) const;
119  bool linkChannelObj(Channel *c, Context &ctx) const;
120  bool fromChannelObj(const Channel *c, Context &ctx);
121 
122  /* Reused fields in OpenGD77.
123  * The following properties are reused in the OpenGD77 firmware for other purposes.*/
125  bool autoscan() const;
127  void enableAutoscan(bool enable);
129  bool loneWorker() const;
131  void enableLoneWorker(bool enable);
133  unsigned rxSignalingIndex() const;
135  void setRXSignalingIndex(unsigned idx);
137  PrivacyGroup privacyGroup() const ;
139  void setPrivacyGroup(PrivacyGroup grp);
140  };
141 
147  {
148  public:
150  explicit ZoneElement(uint8_t *ptr);
151 
153  void clear();
154  bool linkZoneObj(Zone *zone, Context &ctx, bool putInB) const;
155  void fromZoneObjA(const Zone *zone, Context &ctx);
156  void fromZoneObjB(const Zone *zone, Context &ctx);
157  };
158 
164  {
165  public:
167  explicit ZoneBankElement(uint8_t *ptr);
168 
169  uint8_t *get(unsigned n) const;
170  };
171 
178  {
179  public:
182 
184  struct Offset {
185  enum {
186  TimeSlotOverride = 0x0017
187  };
188  };
189 
190  public:
192  explicit ContactElement(uint8_t *ptr);
193 
195  void clear();
197  bool isValid() const;
198  void markValid(bool valid=true);
199 
201  virtual bool overridesTimeSlot() const;
204  virtual DMRChannel::TimeSlot timeSlot() const;
208  virtual void setTimeSlot(DMRChannel::TimeSlot ts);
210  virtual void disableTimeSlotOverride();
211 
212  DMRContact *toContactObj(Context &ctx) const;
213  void fromContactObj(const DMRContact *c, Context &ctx);
214  };
215 
221  {
222  protected:
224  GroupListElement(uint8_t *ptr, unsigned size);
225 
226  public:
228  GroupListElement(uint8_t *ptr);
229 
230  void fromRXGroupListObj(const RXGroupList *lst, Context &ctx, const ErrorStack &err=ErrorStack());
231  };
232 
233 public:
235  explicit OpenGD77Codeplug(QObject *parent=nullptr);
236 
237 public:
238  void clearGeneralSettings();
239  bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
240  bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
241 
242  void clearButtonSettings();
243  void clearMessages();
244 
245  void clearScanLists();
246  bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
247  bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
248  bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
249 
250  void clearContacts();
251  bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
252  bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
253 
254  void clearDTMFContacts();
255  bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
256  bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
257 
258  void clearChannels();
259  bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
260  bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
261  bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
262 
263  void clearBootSettings();
264  void clearMenuSettings();
265 
266  void clearBootText();
267  bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
268  bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
269 
270  void clearVFOSettings();
271 
272  void clearZones();
273  bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
274  bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
275  bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
276 
277  void clearGroupLists();
278  bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
279  bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
280  bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
281 
282  void clearEncryption();
283  bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
284  bool createEncryption(Config *config, Context &ctx, const ErrorStack &err);
285  bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err);
286 };
287 
288 #endif // OPENGD77_CODEPLUG_HH
The base class of all channels (analog and digital) of a codeplug configuration.
Definition: channel.hh:34
Power
Specifies the prefix for every ID assigned to every channel during serialization.
Definition: channel.hh:61
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:69
uint32_t size() const
Returns the total size of the DFU file.
Definition: dfufile.cc:52
TimeSlot
Possible timeslots for digital channels.
Definition: channel.hh:385
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
Specific codeplug representation of a DMR contact for the GD77.
Definition: gd77_codeplug.hh:145
Represents an RX group list within the codeplug.
Definition: gd77_codeplug.hh:169
Represents, encodes and decodes the device specific codeplug for a Radioddity GD-77.
Definition: gd77_codeplug.hh:63
Implements the OpenGD77 specific channel.
Definition: opengd77_codeplug.hh:72
virtual bool scanAllSkip() const
If true, the scan all skip is enabled.
Definition: opengd77_codeplug.cc:151
virtual void setExtendedPower(Power power)
Sets extended power.
Definition: opengd77_codeplug.cc:120
virtual Power extendedPower() const
Returns extended power settings.
Definition: opengd77_codeplug.cc:116
virtual void setSquelchDefault()
Sets the squelch to radio wide default.
Definition: opengd77_codeplug.cc:137
virtual unsigned radioId() const
Returns the radio ID for the channel.
Definition: opengd77_codeplug.cc:164
virtual void setRadioId(unsigned id)
Sets and enables the radio ID for the channel.
Definition: opengd77_codeplug.cc:168
bool autoscan() const
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:263
virtual bool hasRadioId() const
Returns true if the channel specific radio ID is set.
Definition: opengd77_codeplug.cc:160
void clear()
Resets the channel.
Definition: opengd77_codeplug.cc:71
void setPrivacyGroup(PrivacyGroup grp)
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:294
void enableLoneWorker(bool enable)
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:276
Channel * toChannelObj(Context &ctx) const
Constructs a generic Channel object from the codeplug channel.
Definition: opengd77_codeplug.cc:179
virtual void enableScanAllSkip(bool enable)
Enables/disables scan all skip.
Definition: opengd77_codeplug.cc:155
ChannelElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:64
void setPower(Channel::Power power)
Sets the power setting of the channel.
Definition: opengd77_codeplug.cc:105
virtual bool scanZoneSkip() const
If true, the scan zone skip is enabled.
Definition: opengd77_codeplug.cc:142
virtual void enableScanZoneSkip(bool enable)
Enables/disables scan zone skip.
Definition: opengd77_codeplug.cc:146
virtual unsigned squelch() const
Returns the quelch value [0-10].
Definition: opengd77_codeplug.cc:129
bool loneWorker() const
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:272
unsigned rxSignalingIndex() const
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:281
virtual bool squelchIsDefault() const
Returns true if the squelch is set to radio wide default.
Definition: opengd77_codeplug.cc:125
OpenGD77ChannelExtension::Power Power
Reuse Power enum from extension.
Definition: opengd77_codeplug.hh:75
void setRXSignalingIndex(unsigned idx)
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:285
PrivacyGroup privacyGroup() const
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:290
bool linkChannelObj(Channel *c, Context &ctx) const
Links a previously constructed channel to the rest of the configuration.
Definition: opengd77_codeplug.cc:205
bool fromChannelObj(const Channel *c, Context &ctx)
Initializes this codeplug channel from the given generic configuration.
Definition: opengd77_codeplug.cc:229
void enableAutoscan(bool enable)
Overridden, reused in OpenGD77.
Definition: opengd77_codeplug.cc:267
Channel::Power power() const
Returns the power setting of the channel.
Definition: opengd77_codeplug.cc:81
virtual void setSquelch(unsigned squelch)
Sets the squelch value.
Definition: opengd77_codeplug.cc:133
virtual void clearRadioId()
Clears the radio ID.
Definition: opengd77_codeplug.cc:173
Implements the OpenGD77 specific DMR contact.
Definition: opengd77_codeplug.hh:178
void markValid(bool valid=true)
Marks the entry as valid/invalid.
Definition: opengd77_codeplug.cc:402
virtual bool overridesTimeSlot() const
Returns true if this contact overrides the channel time slot.
Definition: opengd77_codeplug.cc:409
ContactElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:384
DMRContact * toContactObj(Context &ctx) const
Constructs a DigitalContact instance from this codeplug contact.
Definition: opengd77_codeplug.cc:434
virtual DMRChannel::TimeSlot timeSlot() const
Returns the time slot associated with the contact.
Definition: opengd77_codeplug.cc:413
OpenGD77ContactExtension::TimeSlotOverride TimeSlotOverride
Reuse enum from extension.
Definition: opengd77_codeplug.hh:181
bool isValid() const
Returns true if the contact is valid.
Definition: opengd77_codeplug.cc:397
virtual void disableTimeSlotOverride()
Disables time slot override feature.
Definition: opengd77_codeplug.cc:429
void fromContactObj(const DMRContact *c, Context &ctx)
Resets this codeplug contact from the given DigitalContact.
Definition: opengd77_codeplug.cc:454
virtual void setTimeSlot(DMRChannel::TimeSlot ts)
Associates the given time slot with this contact.
Definition: opengd77_codeplug.cc:422
void clear()
Resets the contact.
Definition: opengd77_codeplug.cc:391
Implements the OpenGD77 specific group list.
Definition: opengd77_codeplug.hh:221
void fromRXGroupListObj(const RXGroupList *lst, Context &ctx, const ErrorStack &err=ErrorStack())
Reset this codeplug representation from a RXGroupList object.
Definition: opengd77_codeplug.cc:486
GroupListElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: opengd77_codeplug.cc:473
Implements the OpenGD77 specific zone bank.
Definition: opengd77_codeplug.hh:164
uint8_t * get(unsigned n) const
Returns a pointer to the channel at the given index.
Definition: opengd77_codeplug.cc:376
ZoneBankElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:369
Implements the OpenGD77 specific zone.
Definition: opengd77_codeplug.hh:147
bool linkZoneObj(Zone *zone, Context &ctx, bool putInB) const
Links a previously constructed Zone object to the rest of the configuration.
Definition: opengd77_codeplug.cc:315
void fromZoneObjA(const Zone *zone, Context &ctx)
Resets this codeplug zone representation from the given generic Zone object.
Definition: opengd77_codeplug.cc:336
void clear()
Clears the zone.
Definition: opengd77_codeplug.cc:309
ZoneElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:302
void fromZoneObjB(const Zone *zone, Context &ctx)
Resets this codeplug zone representation from the given generic Zone object.
Definition: opengd77_codeplug.cc:351
Represents, encodes and decodes the device specific codeplug for Open GD-77 firmware.
Definition: opengd77_codeplug.hh:57
bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all scan lists.
Definition: opengd77_codeplug.cc:562
void clearZones()
Clears all zones.
Definition: opengd77_codeplug.cc:758
bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition: opengd77_codeplug.cc:766
void clearBootText()
Clears boot text.
Definition: opengd77_codeplug.cc:731
bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition: opengd77_codeplug.cc:616
void clearBootSettings()
Clear boot settings.
Definition: opengd77_codeplug.cc:721
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition: opengd77_codeplug.cc:522
bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition: opengd77_codeplug.cc:943
void clearButtonSettings()
Clears the button settings.
Definition: opengd77_codeplug.cc:542
bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition: opengd77_codeplug.cc:803
bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition: opengd77_codeplug.cc:536
bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition: opengd77_codeplug.cc:683
OpenGD77Codeplug(QObject *parent=nullptr)
Constructs an empty codeplug for the GD-77.
Definition: opengd77_codeplug.cc:506
bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition: opengd77_codeplug.cc:527
bool createEncryption(Config *config, Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition: opengd77_codeplug.cc:937
void clearChannels()
Clear all channels.
Definition: opengd77_codeplug.cc:645
void clearScanLists()
Clears all scan lists.
Definition: opengd77_codeplug.cc:552
void clearMenuSettings()
Clears menu settings.
Definition: opengd77_codeplug.cc:726
void clearMessages()
Clears the messages.
Definition: opengd77_codeplug.cc:547
static const uint32_t EEPROM
EEPROM memory bank.
Definition: opengd77_codeplug.hh:62
bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all encryption keys defined.
Definition: opengd77_codeplug.cc:931
bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition: opengd77_codeplug.cc:630
void clearContacts()
Clears all contacts in the codeplug.
Definition: opengd77_codeplug.cc:575
void clearGroupLists()
Clears all group lists.
Definition: opengd77_codeplug.cc:873
void clearEncryption()
Clears all encryption keys.
Definition: opengd77_codeplug.cc:927
bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition: opengd77_codeplug.cc:744
bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all digital contacts in the configuration into the codeplug.
Definition: opengd77_codeplug.cc:581
static const uint32_t FLASH
Flash memory bank.
Definition: opengd77_codeplug.hh:64
bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encode all channels.
Definition: opengd77_codeplug.cc:657
bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition: opengd77_codeplug.cc:568
void clearVFOSettings()
Clears the VFO settings.
Definition: opengd77_codeplug.cc:752
bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition: opengd77_codeplug.cc:702
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition: opengd77_codeplug.cc:610
bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists.
Definition: opengd77_codeplug.cc:880
bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition: opengd77_codeplug.cc:556
bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a digital contact to the configuration for each one in the codeplug.
Definition: opengd77_codeplug.cc:595
bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition: opengd77_codeplug.cc:736
bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition: opengd77_codeplug.cc:908
bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition: opengd77_codeplug.cc:838
bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition: opengd77_codeplug.cc:895
TimeSlotOverride
Possible values for the time-slot override option.
Definition: opengd77_extension.hh:101
Generic representation of a RX group list.
Definition: rxgrouplist.hh:14
PrivacyGroup
Possible privacy groups, not used in ham radio.
Definition: radioddity_codeplug.hh:47
Implements the base class for all zone banks of Radioddity codeplugs.
Definition: radioddity_codeplug.hh:448
Represents a zone within Radioddity codeplugs.
Definition: radioddity_codeplug.hh:401
Represents a zone within the generic configuration.
Definition: zone.hh:15
Holds some offsets within the element.
Definition: opengd77_codeplug.hh:184