libdrmconf 0.14.1
A library to program DMR radios.
Loading...
Searching...
No Matches
d868uv_callsigndb.hh
1#ifndef D868UVCALLSIGNDB_HH
2#define D868UVCALLSIGNDB_HH
3
4#include "callsigndb.hh"
5#include "userdatabase.hh"
6#include "d868uv_codeplug.hh"
7
25{
26 Q_OBJECT
27
28public:
38 {
39 public:
41 enum class RingTone {
42 Off = 0,
43 Tone = 1,
44 Online = 2
45 };
46
47 enum class CallType {
48 Private = 0, Group = 1, All = 2
49 };
50
51 protected:
53 EntryElement(uint8_t *ptr, unsigned size);
54
55 public:
57 explicit EntryElement(uint8_t *ptr);
58
59 void clear();
60
62 virtual void setCallType(DMRContact::Type type);
64 virtual void setNumber(unsigned num);
66 virtual void setFriendFlag(bool set);
68 virtual void setRingTone(RingTone tone);
70 virtual void setContent(const QString &name, const QString &city, const QString &call,
71 const QString &state, const QString &country, const QString &comment);
72
75 virtual unsigned fromUser(const UserDatabase::User &user);
76
78 static unsigned size(const UserDatabase::User &user);
79
80 public:
82 struct Limit: Element::Limit {
83 static constexpr unsigned int headerLength() { return 6; }
84 static constexpr unsigned int nameLength() { return 16; }
85 static constexpr unsigned int cityLength() { return 15; }
86 static constexpr unsigned int callLength() { return 8; }
87 static constexpr unsigned int stateLength() { return 16; }
88 static constexpr unsigned int countryLength() { return 16; }
89 static constexpr unsigned int commentLength() { return 0; }
91 static constexpr unsigned int totalLength() {
92 return headerLength() + nameLength()+1 + cityLength()+1 + callLength()+1 + stateLength()+1
93 + countryLength()+1 + commentLength()+1; }
94 };
95
96
97 protected:
99 struct Offset: Element::Offset {
101 static constexpr unsigned int callType() { return 0x0000; }
102 static constexpr unsigned int number() { return 0x0001; }
103 static constexpr Bit friendFlag() { return {0x0005, 4}; }
104 static constexpr Bit ringTone() { return { 0x0005, 0}; }
105 static constexpr unsigned int name() { return Limit::headerLength(); }
107 };
108 };
109
110
113 {
114 protected:
116 EntryBankElement(uint8_t *ptr, unsigned size);
117
118 public:
120 explicit EntryBankElement(uint8_t *ptr);
121
123 static constexpr unsigned int size() { return 0x000186a0; }
124
125 void clear();
126
128 uint8_t *entry(unsigned int i) const;
129 };
130
131
135
138 {
139 protected:
141 IndexBankElement(uint8_t *ptr, unsigned size);
142
143 public:
145 explicit IndexBankElement(uint8_t *ptr);
146
148 static constexpr unsigned int size() { return 0x0001f400; }
149
150 void clear();
151
153 uint8_t *entry(unsigned int i) const;
154 };
155
156
159 {
160 protected:
162 LimitsElement(uint8_t *ptr, unsigned size);
163
164 public:
166 LimitsElement(uint8_t *ptr);
167
169 static constexpr unsigned int size() { return 0x0010; }
170
172 void clear();
173
175 virtual unsigned count() const;
177 virtual void setCount(unsigned count);
178
180 virtual unsigned endOfDB() const;
182 virtual void setEndOfDB(unsigned addr);
184 virtual void setTotalSize(unsigned size);
185
186 protected:
188 struct Offset: Element::Offset {
190 static constexpr unsigned int count() { return 0x0000; }
191 static constexpr unsigned int endOfDB() { return 0x0004; }
193 };
194 };
195
196
197public:
199 explicit D868UVCallsignDB(QObject *parent=nullptr);
200
202 bool encode(UserDatabase *db, const Flags &selection=Flags(),
203 const ErrorStack &err=ErrorStack());
204
205public:
207 struct Limit {
209 static constexpr unsigned int entries() { return 200000; }
210 };
211
212protected:
214 struct Offset {
216 static constexpr unsigned int index() { return 0x04000000; }
217 static constexpr unsigned int betweenIndexBanks() { return 0x00040000; }
218 static constexpr unsigned int callsigns() { return 0x04500000; }
219 static constexpr unsigned int betweenCallsignBanks() { return 0x00040000; }
220 static constexpr unsigned int limits() { return 0x044C0000; }
222 };
223};
224
225#endif // D868UVCALLSIGNDB_HH
Represents the base class for entries to the contact indices in all AnyTone codeplugs.
Definition anytone_codeplug.hh:3287
Controls the selection of callsigns from the UserDatabase to be encoded into the callsign db.
Definition callsigndb.hh:22
CallsignDB(QObject *parent=nullptr)
Hidden constructor.
Definition callsigndb.cc:45
Represents the abstract base class of all codeplug elements.
Definition codeplug.hh:65
EntryBankElement(uint8_t *ptr)
Constructor.
void clear()
Abstract method to reset the element within the codeplug.
EntryBankElement(uint8_t *ptr, unsigned size)
Hidden constructor.
static constexpr unsigned int size()
The size of the element.
Definition d868uv_callsigndb.hh:123
uint8_t * entry(unsigned int i) const
Returns the i-th element of the bank.
virtual void setNumber(unsigned num)
Sets the DMR ID number.
Definition d868uv_callsigndb.cc:39
EntryElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition d868uv_callsigndb.cc:11
virtual void setRingTone(RingTone tone)
Sets the ring tone.
Definition d868uv_callsigndb.cc:49
CallType
Possible call types.
Definition d868uv_callsigndb.hh:47
virtual void setCallType(DMRContact::Type type)
Sets the call type.
Definition d868uv_callsigndb.cc:30
virtual void setContent(const QString &name, const QString &city, const QString &call, const QString &state, const QString &country, const QString &comment)
Sets the entry content.
Definition d868uv_callsigndb.cc:54
virtual void setFriendFlag(bool set)
Set/clear friend flag.
Definition d868uv_callsigndb.cc:44
RingTone
Notification tones for callsign entry.
Definition d868uv_callsigndb.hh:41
virtual unsigned fromUser(const UserDatabase::User &user)
Constructs a database entry from the given user.
Definition d868uv_callsigndb.cc:68
void clear()
Abstract method to reset the element within the codeplug.
Definition d868uv_callsigndb.cc:24
IndexBankElement(uint8_t *ptr, unsigned size)
Hidden constructor.
uint8_t * entry(unsigned int i) const
Returns the i-th element of the bank.
void clear()
Abstract method to reset the element within the codeplug.
static constexpr unsigned int size()
The size of the element.
Definition d868uv_callsigndb.hh:148
IndexBankElement(uint8_t *ptr)
Constructor.
virtual void setCount(unsigned count)
Sets the number of entries.
Definition d868uv_callsigndb.cc:116
virtual void setTotalSize(unsigned size)
Sets the total size of the DB (updated end-of-db address).
Definition d868uv_callsigndb.cc:129
virtual unsigned endOfDB() const
Returns the end-of-db address.
Definition d868uv_callsigndb.cc:121
void clear()
Resets the limits.
Definition d868uv_callsigndb.cc:106
static constexpr unsigned int size()
Size of the element.
Definition d868uv_callsigndb.hh:169
virtual void setEndOfDB(unsigned addr)
Sets the end-of-db address.
Definition d868uv_callsigndb.cc:125
virtual unsigned count() const
Returns the number of entries in the DB.
Definition d868uv_callsigndb.cc:112
LimitsElement(uint8_t *ptr, unsigned size)
Hidden constructor.
Definition d868uv_callsigndb.cc:93
D868UVCodeplug::ContactMapElement IndexEntryElement
Same index entry used by the codeplug to map normal digital contacts to an contact index.
Definition d868uv_callsigndb.hh:134
D868UVCallsignDB(QObject *parent=nullptr)
Constructor, does not allocate any memory yet.
Definition d868uv_callsigndb.cc:137
bool encode(UserDatabase *db, const Flags &selection=Flags(), const ErrorStack &err=ErrorStack())
Tries to encode as many entries of the given user-database.
Definition d868uv_callsigndb.cc:144
uint32_t size() const
Returns the total size of the DFU file.
Definition dfufile.cc:52
Type
Possible call types for a contact.
Definition contact.hh:155
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
Represents the user information within the UserDatabase.
Definition userdatabase.hh:32
Auto-updating DMR user database.
Definition userdatabase.hh:24
Some limits for the entry.
Definition d868uv_callsigndb.hh:82
static constexpr unsigned int headerLength()
Header length (fixed).
Definition d868uv_callsigndb.hh:83
static constexpr unsigned int countryLength()
Maximum country length.
Definition d868uv_callsigndb.hh:88
static constexpr unsigned int cityLength()
Maximum city length.
Definition d868uv_callsigndb.hh:85
static constexpr unsigned int stateLength()
Maximum state length.
Definition d868uv_callsigndb.hh:87
static constexpr unsigned int commentLength()
Maximum comment length.
Definition d868uv_callsigndb.hh:89
static constexpr unsigned int callLength()
Maximum call length.
Definition d868uv_callsigndb.hh:86
static constexpr unsigned int nameLength()
Maximum name length.
Definition d868uv_callsigndb.hh:84
static constexpr unsigned int totalLength()
Maximum entry size.
Definition d868uv_callsigndb.hh:91
Some internal offsets.
Definition d868uv_callsigndb.hh:99
Some limits for the call-sign DB.
Definition d868uv_callsigndb.hh:207
static constexpr unsigned int entries()
Specifies the max number of entries in the DB.
Definition d868uv_callsigndb.hh:209
Some internal offsets.
Definition d868uv_callsigndb.hh:188
Some internal used offsets within the DB.
Definition d868uv_callsigndb.hh:214