libdrmconf 0.14.1
A library to program DMR radios.
Loading...
Searching...
No Matches
opengd77base_callsigndb.hh
1#ifndef OPENGD77BASECALLSIGNDB_HH
2#define OPENGD77BASECALLSIGNDB_HH
3
4#include "codeplug.hh"
5#include "callsigndb.hh"
6#include "userdatabase.hh"
7
11{
12 Q_OBJECT
13
14public:
16 struct __attribute__((packed)) userdb_entry_t {
17 uint32_t number;
18 char name[15];
19
23 void clear();
24
26 uint32_t getNumber() const;
28 void setNumber(uint32_t number);
29
31 QString getName() const;
34 void setName(const QString &name);
35
37 void fromEntry(const UserDatabase::User &user);
38 };
39
40
45 {
46 protected:
48 DatabaseEntryElement(uint8_t *ptr, size_t size);
49
50 public:
52 DatabaseEntryElement(uint8_t *ptr);
53
55 static constexpr unsigned int size() { return 0x000f; }
56
57 void clear() override;
58
60 virtual void setId(unsigned int id);
62 virtual void setText(const QString &text);
64 virtual bool fromEntry(const UserDatabase::User &user);
65
66 protected:
69 QByteArray pack(const QString &text);
70
71 public:
73 struct Limit: public Element::Limit {
74 // The length of the text.
75 static constexpr unsigned int textLength() { return 16; }
76 };
77
78 protected:
80 struct Offset: public Element::Offset {
82 static constexpr unsigned int dmrID() { return 0x0000; }
83 static constexpr unsigned int text() { return 0x0003; }
85 };
86
87 static QVector<QChar> _lut;
88 };
89
90
93 {
94 public:
96 enum class Format {
97 Uncompressed = 45,
98 Compressed = 78
99 };
100
101 protected:
103 DatabaseHeaderElement(uint8_t *ptr, size_t size);
104
105 public:
107 DatabaseHeaderElement(uint8_t *ptr);
108
110 static constexpr unsigned int size() { return 0x000c; }
111
112 void clear();
113
114 void setEntrySize(unsigned int size);
115 void setEntryCount(unsigned int count);
116
117 public:
119 struct Limit: public Element::Limit {
121 };
122
123 protected:
125 struct Offset: public Element::Offset {
127 static constexpr unsigned int magic() { return 0x0000; }
128 static constexpr unsigned int format() { return 0x0002; }
129 static constexpr unsigned int entrySize() { return 0x0003; }
130 static constexpr unsigned int version() { return 0x0004; }
131 static constexpr unsigned int entryCount() { return 0x0008; }
133 };
134 };
135
136
137public:
139 explicit OpenGD77BaseCallsignDB(QObject *parent=nullptr);
141 virtual ~OpenGD77BaseCallsignDB();
142
144 virtual bool encode(UserDatabase *calldb, const Flags &selection=Flags(),
145 const ErrorStack &err=ErrorStack()) = 0;
146
147public:
149 struct Limit {
151 static constexpr unsigned int blockSize() { return 32; }
152 };
153};
154
155#endif // OPENGD77BASECALLSIGNDB_HH
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
uint32_t size() const
Returns the total size of the DFU file.
Definition dfufile.cc:52
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
virtual bool fromEntry(const UserDatabase::User &user)
Encodes the given user.
Definition opengd77base_callsigndb.cc:51
virtual void setText(const QString &text)
Encodes the text.
Definition opengd77base_callsigndb.cc:44
QByteArray pack(const QString &text)
Encodes and packs the given string.
Definition opengd77base_callsigndb.cc:70
DatabaseEntryElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition opengd77base_callsigndb.cc:21
virtual void setId(unsigned int id)
Encodes the DMR ID.
Definition opengd77base_callsigndb.cc:39
static constexpr unsigned int size()
The size of the entry.
Definition opengd77base_callsigndb.hh:55
void clear() override
Abstract method to reset the element within the codeplug.
Definition opengd77base_callsigndb.cc:34
static constexpr unsigned int size()
The size of the header.
Definition opengd77base_callsigndb.hh:110
void clear()
Abstract method to reset the element within the codeplug.
Definition opengd77base_callsigndb.cc:118
DatabaseHeaderElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition opengd77base_callsigndb.cc:104
Format
Possible formats.
Definition opengd77base_callsigndb.hh:96
virtual ~OpenGD77BaseCallsignDB()
Destructor.
Definition opengd77base_callsigndb.cc:148
virtual bool encode(UserDatabase *calldb, const Flags &selection=Flags(), const ErrorStack &err=ErrorStack())=0
Encodes as many entries as possible of the given user-database.
OpenGD77BaseCallsignDB(QObject *parent=nullptr)
Constructor.
Definition opengd77base_callsigndb.cc:142
Represents the user information within the UserDatabase.
Definition userdatabase.hh:32
Auto-updating DMR user database.
Definition userdatabase.hh:24
Some limits.
Definition opengd77base_callsigndb.hh:73
Internal offsets within entry.
Definition opengd77base_callsigndb.hh:80
Some limits for the header.
Definition opengd77base_callsigndb.hh:119
Internal offsets within the header.
Definition opengd77base_callsigndb.hh:125
Some limits for this callsign DB.
Definition opengd77base_callsigndb.hh:149
static constexpr unsigned int blockSize()
Maximum block size.
Definition opengd77base_callsigndb.hh:151
void clear()
Resets the entry.
void fromEntry(const UserDatabase::User &user)
Encodes the given user.
void setName(const QString &name)
Sets the name of the entry, 15b max.
uint32_t number
DMR ID stored in BCD little-endian.
Definition opengd77base_callsigndb.hh:17
QString getName() const
Returns the name of the entry.
uint32_t getNumber() const
Returns the DMR ID number.
userdb_entry_t()
Constructor.
void setNumber(uint32_t number)
Sets the DMR ID number.
char name[15]
Call or name, up to 15 ASCII chars, 0x00 padded.
Definition opengd77base_callsigndb.hh:18