libdrmconf  0.12.0
A library to program DMR radios.
dm1701_codeplug.hh
1 #ifndef DM1701_CODEPLUG_HH
2 #define DM1701_CODEPLUG_HH
3 
4 #include "tyt_codeplug.hh"
5 
49 {
50  Q_OBJECT
51 
52 public:
58  {
59  protected:
61  ChannelElement(uint8_t *ptr, size_t size);
62 
63  public:
65  explicit ChannelElement(uint8_t *ptr);
66 
67  void clear();
68 
70  virtual bool tightSquelchEnabled() const;
72  virtual void enableTightSquelch(bool enable);
73 
75  virtual bool reverseBurst() const;
77  virtual void enableReverseBurst(bool enable);
78 
80  virtual Channel::Power power() const;
82  virtual void setPower(Channel::Power pwr);
83 
85  Channel *toChannelObj(const ErrorStack &err=ErrorStack()) const;
87  void fromChannelObj(const Channel *c, Context &ctx);
88  };
89 
95  {
96  protected:
98  VFOChannelElement(uint8_t *ptr, size_t size);
99 
100  public:
102  VFOChannelElement(uint8_t *ptr);
104  virtual ~VFOChannelElement();
105 
106  QString name() const;
107  void setName(const QString &txt);
108 
110  virtual unsigned stepSize() const;
112  virtual void setStepSize(unsigned ss_hz);
113  };
114 
121  {
122  protected:
124  GeneralSettingsElement(uint8_t *ptr, size_t size);
125 
126  public:
128  GeneralSettingsElement(uint8_t *ptr);
129 
130  void clear();
131 
133  virtual bool channelModeA() const;
135  virtual void enableChannelModeA(bool enable);
137  virtual bool channelModeB() const;
139  virtual void enableChannelModeB(bool enable);
140 
142  virtual bool channelMode() const;
144  virtual void enableChannelMode(bool enable);
145 
147  virtual bool groupCallMatch() const;
149  virtual void enableGroupCallMatch(bool enable);
151  virtual bool privateCallMatch() const;
153  virtual void enablePrivateCallMatch(bool enable);
154 
156  virtual QTimeZone timeZone() const;
158  virtual void setTimeZone(const QTimeZone &zone);
159 
161  virtual unsigned channelHangTime() const;
163  virtual void setChannelHangTime(unsigned dur);
164 
166  virtual bool fromConfig(const Config *config);
168  virtual bool updateConfig(Config *config);
169  };
170 
177  {
178  protected:
180  ButtonSettingsElement(uint8_t *ptr, size_t size);
181 
182  public:
184  explicit ButtonSettingsElement(uint8_t *ptr);
185 
186  void clear();
187 
189  virtual ButtonAction sideButton3Short() const;
191  virtual void setSideButton3Short(ButtonAction action);
193  virtual ButtonAction sideButton3Long() const;
195  virtual void setSideButton3Long(ButtonAction action);
196 
198  virtual ButtonAction progButton1Short() const;
200  virtual void setProgButton1Short(ButtonAction action);
202  virtual ButtonAction progButton1Long() const;
204  virtual void setProgButton1Long(ButtonAction action);
205 
207  virtual ButtonAction progButton2Short() const;
209  virtual void setProgButton2Short(ButtonAction action);
211  virtual ButtonAction progButton2Long() const;
213  virtual void setProgButton2Long(ButtonAction action);
214 
216  virtual bool fromConfig(const Config *config);
218  virtual bool updateConfig(Config *config);
219  };
220 
228  {
229  protected:
231  ZoneExtElement(uint8_t *ptr, size_t size);
232 
233  public:
235  ZoneExtElement(uint8_t *ptr);
237  virtual ~ZoneExtElement();
238 
239  void clear();
240 
242  virtual uint16_t memberIndexA(unsigned n) const;
244  virtual void setMemberIndexA(unsigned n, uint16_t idx);
246  virtual uint16_t memberIndexB(unsigned n) const;
248  virtual void setMemberIndexB(unsigned n, uint16_t idx);
249 
251  virtual bool fromZoneObj(const Zone *zone, Context &ctx);
254  virtual bool linkZoneObj(Zone *zone, Context &ctx);
255  };
256 
257 public:
259  explicit DM1701Codeplug(QObject *parent = nullptr);
261  virtual ~DM1701Codeplug();
262 
263 public:
264  void clearTimestamp();
265  bool encodeTimestamp();
266 
267  void clearGeneralSettings();
268  bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
269  bool decodeGeneralSettings(Config *config, const ErrorStack &err=ErrorStack());
270 
271  void clearChannels();
272  bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
273  bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
274  bool linkChannels(Context &ctx, const ErrorStack &err=ErrorStack());
275 
276  void clearContacts();
277  bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
278  bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
279 
280  void clearZones();
281  bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
282  bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
283  bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack());
284 
285  void clearGroupLists();
286  bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
287  bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
288  bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
289 
290  void clearScanLists();
291  bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
292  bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack());
293  bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack());
294 
295  void clearButtonSettings();
296  bool encodeButtonSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack());
297  bool decodeButtonSetttings(Config *config, const ErrorStack &err=ErrorStack());
298 
300  bool encodePositioningSystems(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
301  bool createPositioningSystems(Config *config, Context &ctx, const ErrorStack &err);
302  bool linkPositioningSystems(Context &ctx, const ErrorStack &err);
303 
304  void clearPrivacyKeys();
305  bool encodePrivacyKeys(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err);
306  bool decodePrivacyKeys(Config *config, Context &ctx, const ErrorStack &err);
307 
308  void clearTextMessages();
309  bool encodeTextMessages(Context &ctx, const Flags &flags, const ErrorStack &err);
310  bool decodeTextMessages(Context &ctx, const ErrorStack &err);
311 
312  void clearMenuSettings();
313  void clearEmergencySystems();
315  virtual void clearVFOSettings();
316 
317 protected:
319  struct Offset {
321  static constexpr unsigned int messages() { return 0x002180; }
323  };
324 };
325 
326 #endif // DM1701_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
Represents the abstract base class of all codeplug elements.
Definition: codeplug.hh:51
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
Extens the common TyTCodeplug::ButtonSettingsElement to implement the DM-1701 specific settings.
Definition: dm1701_codeplug.hh:177
virtual ButtonAction progButton2Short() const
Returns the action for a short press on programmable button 2.
Definition: dm1701_codeplug.cc:382
virtual ButtonAction progButton1Short() const
Returns the action for a short press on programmable button 1.
Definition: dm1701_codeplug.cc:364
virtual void setSideButton3Short(ButtonAction action)
Sets the action for a short press on side button 3.
Definition: dm1701_codeplug.cc:350
virtual ButtonAction sideButton3Short() const
Returns the action for a short press on side button 3.
Definition: dm1701_codeplug.cc:346
virtual void setProgButton2Long(ButtonAction action)
Sets the action for a long press on programmable button 2.
Definition: dm1701_codeplug.cc:395
ButtonSettingsElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: dm1701_codeplug.cc:323
virtual bool updateConfig(Config *config)
Updates config from button settings.
Definition: dm1701_codeplug.cc:418
virtual bool fromConfig(const Config *config)
Encodes the button settings.
Definition: dm1701_codeplug.cc:400
virtual void setProgButton2Short(ButtonAction action)
Sets the action for a short press on programmable button 2.
Definition: dm1701_codeplug.cc:386
virtual ButtonAction progButton2Long() const
Returns the action for a long press on programmable button 2.
Definition: dm1701_codeplug.cc:391
virtual ButtonAction sideButton3Long() const
Returns the action for a long press on side button 3.
Definition: dm1701_codeplug.cc:355
virtual void setProgButton1Long(ButtonAction action)
Sets the action for a long press on programmable button 1.
Definition: dm1701_codeplug.cc:377
virtual void setSideButton3Long(ButtonAction action)
Sets the action for a long press on side button 3.
Definition: dm1701_codeplug.cc:359
virtual void setProgButton1Short(ButtonAction action)
Sets the action for a short press on programmable button 1.
Definition: dm1701_codeplug.cc:368
virtual ButtonAction progButton1Long() const
Returns the action for a long press on programmable button 1.
Definition: dm1701_codeplug.cc:373
void clear()
Abstract method to reset the element within the codeplug.
Definition: dm1701_codeplug.cc:336
Extends the common TyTCodeplug::ChannelElement to implement the DM-1701 specific settings.
Definition: dm1701_codeplug.hh:58
void clear()
Abstract method to reset the element within the codeplug.
Definition: dm1701_codeplug.cc:68
virtual void setPower(Channel::Power pwr)
Sets the power of this channel.
Definition: dm1701_codeplug.cc:104
Channel * toChannelObj(const ErrorStack &err=ErrorStack()) const
Constructs a generic Channel object from the codeplug channel.
Definition: dm1701_codeplug.cc:118
virtual void enableReverseBurst(bool enable)
Enables/disables reverse burst.
Definition: dm1701_codeplug.cc:93
virtual Channel::Power power() const
Returns the power of this channel.
Definition: dm1701_codeplug.cc:98
virtual void enableTightSquelch(bool enable)
Enables/disables tight squelch.
Definition: dm1701_codeplug.cc:84
virtual bool tightSquelchEnabled() const
Returns true if the squelch is 'tight'.
Definition: dm1701_codeplug.cc:80
void fromChannelObj(const Channel *c, Context &ctx)
Initializes this codeplug channel from the given generic configuration.
Definition: dm1701_codeplug.cc:135
ChannelElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: dm1701_codeplug.cc:55
virtual bool reverseBurst() const
Returns true if the reversed burst is enabled.
Definition: dm1701_codeplug.cc:89
Extends the common TyTCodeplug::GeneralSettingsElement to implement the DM-1701 specific settings.
Definition: dm1701_codeplug.hh:121
virtual bool channelMode() const
Returns true, if the radio is in channel (and not VFO) mode.
Definition: dm1701_codeplug.cc:238
virtual bool fromConfig(const Config *config)
Encodes the general settings.
Definition: dm1701_codeplug.cc:283
GeneralSettingsElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: dm1701_codeplug.cc:192
virtual void enablePrivateCallMatch(bool enable)
Enables/disables private-call match.
Definition: dm1701_codeplug.cc:259
virtual bool groupCallMatch() const
Returns true if group-call match is enabled.
Definition: dm1701_codeplug.cc:247
void clear()
Abstract method to reset the element within the codeplug.
Definition: dm1701_codeplug.cc:205
virtual void setTimeZone(const QTimeZone &zone)
Sets the time-zone.
Definition: dm1701_codeplug.cc:268
virtual bool channelModeB() const
Returns true, if VFO B is in channel mode.
Definition: dm1701_codeplug.cc:229
virtual bool privateCallMatch() const
Returns true if private-call match is enabled.
Definition: dm1701_codeplug.cc:255
virtual void enableChannelModeA(bool enable)
Enables/disables the channel mode for VFO A.
Definition: dm1701_codeplug.cc:224
virtual void enableChannelModeB(bool enable)
Enables/disables the channel mode for VFO B.
Definition: dm1701_codeplug.cc:233
virtual bool channelModeA() const
Returns true, if VFO A is in channel mode.
Definition: dm1701_codeplug.cc:220
virtual unsigned channelHangTime() const
Returns the channel hang time in ms.
Definition: dm1701_codeplug.cc:274
virtual void setChannelHangTime(unsigned dur)
Sets the channel hang time in ms.
Definition: dm1701_codeplug.cc:278
virtual bool updateConfig(Config *config)
Updates config from general settings.
Definition: dm1701_codeplug.cc:303
virtual void enableChannelMode(bool enable)
Enable/disable channel mode.
Definition: dm1701_codeplug.cc:242
virtual QTimeZone timeZone() const
Returns the time-zone.
Definition: dm1701_codeplug.cc:264
virtual void enableGroupCallMatch(bool enable)
Enables/disables group-call match.
Definition: dm1701_codeplug.cc:251
Extends the ChannelElement to implement the VFO channel settings for the DM-1701.
Definition: dm1701_codeplug.hh:95
virtual void setStepSize(unsigned ss_hz)
Sets the step-size for the VFO channel in Hz.
Definition: dm1701_codeplug.cc:182
QString name() const
Returns the name of this channel.
Definition: dm1701_codeplug.cc:168
VFOChannelElement(uint8_t *ptr, size_t size)
Constructor from pointer to memory.
Definition: dm1701_codeplug.cc:151
void setName(const QString &txt)
Sets the name of this channel.
Definition: dm1701_codeplug.cc:172
virtual ~VFOChannelElement()
Destructor.
Definition: dm1701_codeplug.cc:163
virtual unsigned stepSize() const
Returns the step-size for the VFO channel.
Definition: dm1701_codeplug.cc:178
Extended zone data for the DM-1701.
Definition: dm1701_codeplug.hh:228
virtual void setMemberIndexB(unsigned n, uint16_t idx)
Returns the n-th member index of the channel list for B.
Definition: dm1701_codeplug.cc:476
virtual uint16_t memberIndexA(unsigned n) const
Returns the n-th member index of the channel list for A.
Definition: dm1701_codeplug.cc:461
virtual bool linkZoneObj(Zone *zone, Context &ctx)
Links the given zone object.
Definition: dm1701_codeplug.cc:501
virtual ~ZoneExtElement()
Destructor.
Definition: dm1701_codeplug.cc:451
virtual bool fromZoneObj(const Zone *zone, Context &ctx)
Encodes the given zone.
Definition: dm1701_codeplug.cc:481
virtual uint16_t memberIndexB(unsigned n) const
Returns the n-th member index of the channel list for B.
Definition: dm1701_codeplug.cc:471
virtual void setMemberIndexA(unsigned n, uint16_t idx)
Sets the n-th member index of the channel list for A.
Definition: dm1701_codeplug.cc:466
ZoneExtElement(uint8_t *ptr, size_t size)
Constructor.
Definition: dm1701_codeplug.cc:439
void clear()
Abstract method to reset the element within the codeplug.
Definition: dm1701_codeplug.cc:456
Device specific implementation of the codeplug for the Baofeng DM-1701.
Definition: dm1701_codeplug.hh:49
bool encodePositioningSystems(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes all DMR positioning systems in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:911
bool encodeChannels(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all channels in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:577
void clearContacts()
Clears all contacts in the codeplug.
Definition: dm1701_codeplug.cc:622
bool encodeGroupLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all group lists in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:728
bool linkScanLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all added scan lists within the configuration.
Definition: dm1701_codeplug.cc:808
bool createScanLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a scan list to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:792
bool decodeTextMessages(Context &ctx, const ErrorStack &err)
Decodes text messages.
Definition: dm1701_codeplug.cc:886
bool createZones(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a zone to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:685
void clearMenuSettings()
Clears the menu settings in the codeplug.
Definition: dm1701_codeplug.cc:823
void clearChannels()
Clears all channels in the codeplug.
Definition: dm1701_codeplug.cc:570
bool decodeButtonSetttings(Config *config, const ErrorStack &err=ErrorStack())
Decodes the button settings.
Definition: dm1701_codeplug.cc:840
void clearScanLists()
Clears all scan lists in the codeplug.
Definition: dm1701_codeplug.cc:771
void clearTimestamp()
Clears the time-stamp in the codeplug.
Definition: dm1701_codeplug.cc:541
bool encodeContacts(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all digital contacts in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:629
bool encodeButtonSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes the button settings.
Definition: dm1701_codeplug.cc:833
void clearTextMessages()
Clears all text messages in the codeplug.
Definition: dm1701_codeplug.cc:876
void clearPositioningSystems()
Clears all positioning systems in the codeplug.
Definition: dm1701_codeplug.cc:906
bool linkPositioningSystems(Context &ctx, const ErrorStack &err)
Links all added positioning systems within the configuration.
Definition: dm1701_codeplug.cc:925
virtual ~DM1701Codeplug()
Destructor.
Definition: dm1701_codeplug.cc:536
bool decodeGeneralSettings(Config *config, const ErrorStack &err=ErrorStack())
Updates the given configuration from the general settings.
Definition: dm1701_codeplug.cc:564
bool createPositioningSystems(Config *config, Context &ctx, const ErrorStack &err)
Adds a GPS positioning system to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:918
void clearGroupLists()
Clears all RX group lists in the codeplug.
Definition: dm1701_codeplug.cc:722
bool createGroupLists(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a RX group list to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:741
virtual void clearVFOSettings()
Resets VFO settings.
Definition: dm1701_codeplug.cc:899
bool createChannels(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a channel to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:592
bool encodeScanLists(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all scan lists in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:778
bool linkChannels(Context &ctx, const ErrorStack &err=ErrorStack())
Links all added channels within the configuration.
Definition: dm1701_codeplug.cc:608
bool createContacts(Config *config, Context &ctx, const ErrorStack &err=ErrorStack())
Adds a digital contact to the configuration for each one in the codeplug.
Definition: dm1701_codeplug.cc:643
bool encodePrivacyKeys(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err)
Encodes the encryption keys.
Definition: dm1701_codeplug.cc:852
bool encodeZones(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Encodes all zones in the configuration into the codeplug.
Definition: dm1701_codeplug.cc:668
bool encodeTextMessages(Context &ctx, const Flags &flags, const ErrorStack &err)
Encodes text messages.
Definition: dm1701_codeplug.cc:881
bool decodePrivacyKeys(Config *config, Context &ctx, const ErrorStack &err)
Decodes the encryption keys.
Definition: dm1701_codeplug.cc:862
bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack())
Links all added RX group lists within the configuration.
Definition: dm1701_codeplug.cc:757
bool encodeTimestamp()
Sets the time-stamp.
Definition: dm1701_codeplug.cc:546
void clearZones()
Clears all zones in the codeplug.
Definition: dm1701_codeplug.cc:659
void clearPrivacyKeys()
Clears all encryption keys in the codeplug.
Definition: dm1701_codeplug.cc:847
void clearButtonSettings()
Clears the button settings in the codeplug.
Definition: dm1701_codeplug.cc:828
void clearEmergencySystems()
Clears all emergency systems in the codeplug.
Definition: dm1701_codeplug.cc:892
void clearGeneralSettings()
Clears the general settings in the codeplug.
Definition: dm1701_codeplug.cc:553
bool encodeGeneralSettings(Config *config, const Flags &flags, Context &ctx, const ErrorStack &err=ErrorStack())
Updates the general settings from the given configuration.
Definition: dm1701_codeplug.cc:558
DM1701Codeplug(QObject *parent=nullptr)
Constructor.
Definition: dm1701_codeplug.cc:525
bool linkZones(Context &ctx, const ErrorStack &err=ErrorStack())
Links all added zones within the configuration.
Definition: dm1701_codeplug.cc:702
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Represents all button settings within the codeplug on the radio.
Definition: tyt_codeplug.hh:836
enum TyTButtonSettings::ButtonAction ButtonAction
The possible button actions.
Definition: tyt_codeplug.hh:839
Represents a single channel (analog or digital) within the TyT codeplug.
Definition: tyt_codeplug.hh:35
Codeplug representation of the general settings.
Definition: tyt_codeplug.hh:443
Base class of all TyT codeplugs.
Definition: tyt_codeplug.hh:26
Represents a zone within the generic configuration.
Definition: zone.hh:15
Some internal offsets within the codeplug.
Definition: dm1701_codeplug.hh:319