libdrmconf  0.12.0
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) 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 
244  void clearScanLists();
245  bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
246  bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
247  bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
248 
249  void clearContacts();
250  bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
251  bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
252 
253  void clearDTMFContacts();
254  bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
255  bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
256 
257  void clearChannels();
258  bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
259  bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
260  bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
261 
262  void clearBootSettings();
263  void clearMenuSettings();
264 
265  void clearBootText();
266  bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
267  bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
268 
269  void clearVFOSettings();
270 
271  void clearZones();
272  bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
273  bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
274  bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
275 
276  void clearGroupLists();
277  bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
278  bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
279  bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
280 
281  void clearEncryption();
282  bool encodeEncryption(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
283  bool createEncryption(Config *config, Context &ctx, const ErrorStack &err);
284  bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err);
285 };
286 
287 #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: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
TimeSlot
Possible timeslots for digital channels.
Definition: channel.hh:389
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
static constexpr unsigned int size()
Size of the group list element.
Definition: gd77_codeplug.hh:179
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:399
virtual bool overridesTimeSlot() const
Returns true if this contact overrides the channel time slot.
Definition: opengd77_codeplug.cc:406
ContactElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:381
DMRContact * toContactObj(Context &ctx) const
Constructs a DigitalContact instance from this codeplug contact.
Definition: opengd77_codeplug.cc:431
virtual DMRChannel::TimeSlot timeSlot() const
Returns the time slot associated with the contact.
Definition: opengd77_codeplug.cc:410
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:394
virtual void disableTimeSlotOverride()
Disables time slot override feature.
Definition: opengd77_codeplug.cc:426
void fromContactObj(const DMRContact *c, Context &ctx)
Resets this codeplug contact from the given DigitalContact.
Definition: opengd77_codeplug.cc:451
virtual void setTimeSlot(DMRChannel::TimeSlot ts)
Associates the given time slot with this contact.
Definition: opengd77_codeplug.cc:419
void clear()
Resets the contact.
Definition: opengd77_codeplug.cc:388
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:483
GroupListElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition: opengd77_codeplug.cc:470
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:373
ZoneBankElement(uint8_t *ptr)
Constructor.
Definition: opengd77_codeplug.cc:366
Implements the OpenGD77 specific zone.
Definition: opengd77_codeplug.hh:147
void fromZoneObjA(const Zone *zone, Context &ctx)
Resets this codeplug zone representation from the given generic Zone object.
Definition: opengd77_codeplug.cc:333
bool linkZoneObj(Zone *zone, Context &ctx) const
Links a previously constructed Zone object to the rest of the configuration.
Definition: opengd77_codeplug.cc:315
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:348
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:554
void clearZones()
Clears all zones.
Definition: opengd77_codeplug.cc:750
bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes zones.
Definition: opengd77_codeplug.cc:758
void clearBootText()
Clears boot text.
Definition: opengd77_codeplug.cc:723
bool encodeDTMFContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all DTMF contacts.
Definition: opengd77_codeplug.cc:608
void clearBootSettings()
Clear boot settings.
Definition: opengd77_codeplug.cc:713
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition: opengd77_codeplug.cc:519
bool linkEncryption(Config *config, Context &ctx, const ErrorStack &err)
Links all encryption keys.
Definition: opengd77_codeplug.cc:888
void clearButtonSettings()
Clears the button settings.
Definition: opengd77_codeplug.cc:539
bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds zones to the configuration.
Definition: opengd77_codeplug.cc:780
bool decodeGeneralSettings(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition: opengd77_codeplug.cc:533
bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all defined channels to the configuration.
Definition: opengd77_codeplug.cc:675
OpenGD77Codeplug(QObject *parent=nullptr)
Constructs an empty codeplug for the GD-77.
Definition: opengd77_codeplug.cc:503
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:524
bool createEncryption(Config *config, Context &ctx, const ErrorStack &err)
Creates all encryption keys.
Definition: opengd77_codeplug.cc:882
void clearChannels()
Clear all channels.
Definition: opengd77_codeplug.cc:637
void clearScanLists()
Clears all scan lists.
Definition: opengd77_codeplug.cc:544
void clearMenuSettings()
Clears menu settings.
Definition: opengd77_codeplug.cc:718
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:876
bool createDTMFContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds all DTMF contacts to the configuration.
Definition: opengd77_codeplug.cc:622
void clearContacts()
Clears all contacts in the codeplug.
Definition: opengd77_codeplug.cc:567
void clearGroupLists()
Clears all group lists.
Definition: opengd77_codeplug.cc:818
void clearEncryption()
Clears all encryption keys.
Definition: opengd77_codeplug.cc:872
bool decodeBootText(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the given configuration from the boot text settings.
Definition: opengd77_codeplug.cc:736
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:573
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:649
bool linkScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all scan lists.
Definition: opengd77_codeplug.cc:560
void clearVFOSettings()
Clears the VFO settings.
Definition: opengd77_codeplug.cc:744
bool linkChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all channels.
Definition: opengd77_codeplug.cc:694
void clearDTMFContacts()
Clears all DTMF contacts in the codeplug.
Definition: opengd77_codeplug.cc:602
bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists.
Definition: opengd77_codeplug.cc:825
bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists.
Definition: opengd77_codeplug.cc:548
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:587
bool encodeBootText(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes boot text.
Definition: opengd77_codeplug.cc:728
bool linkGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all group lists.
Definition: opengd77_codeplug.cc:853
bool linkZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Links all zones within the configuration.
Definition: opengd77_codeplug.cc:798
bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Creates all group lists.
Definition: opengd77_codeplug.cc:840
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:49
Implements the base class for all zone banks of Radioddity codeplugs.
Definition: radioddity_codeplug.hh:450
Represents a zone within Radioddity codeplugs.
Definition: radioddity_codeplug.hh:403
Represents a zone within the generic configuration.
Definition: zone.hh:15
Holds some offsets within the element.
Definition: opengd77_codeplug.hh:184