Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of BTECH DR-1801A6 #392

Merged
merged 67 commits into from
Nov 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
81823e0
Started rev.eng. of Baofeng DR-1801UV (Auctus A6).
hmatuschek Oct 28, 2022
03a0f36
Started interface implementation for Actus A6 devices.
hmatuschek Dec 4, 2022
aed0e5c
Merge branch 'master' into dr1801
hmatuschek Jan 21, 2023
df9b7e7
Implemented codeplug download.
hmatuschek Jan 21, 2023
858fafc
Fixed codeplug download for DR-1801UV
hmatuschek Jan 21, 2023
2ab8ae7
Implemented contact decoding for BTECH DR-1801UV.
hmatuschek Jan 21, 2023
3f773b0
Implemented decofing of group lists for BTECH DR-1801UV.
hmatuschek Jan 21, 2023
da3bf24
Cleanup.
hmatuschek Jan 21, 2023
59461e5
Implemented zones and general settings for BTECH DR1801.
hmatuschek Jan 22, 2023
640828b
Fixed docs.
hmatuschek Jan 22, 2023
931dfbd
Implemented scan list decoding for BTECH DR-1801UV. Addresses #285.
hmatuschek Jan 23, 2023
5620722
Oops.
hmatuschek Jan 23, 2023
c7b3188
Backup.
hmatuschek Jan 23, 2023
2d5dcd4
Implemented banks.
hmatuschek Jan 23, 2023
708bfd8
Fixed crash decoding contacts for DR-1801UV.
hmatuschek Jan 24, 2023
97b2ab3
Fixed zone decoding.
hmatuschek Jan 24, 2023
7a4fc24
Implemented key settings for DR1801UV.
hmatuschek Jan 25, 2023
3d7f93f
Codeplug cleanup.
hmatuschek Jan 26, 2023
af712db
Implemented VFO settings. Addresses #285.
hmatuschek Jan 26, 2023
0c72dff
Implemented encryption keys for DR-1801UV. Addresses #285.
hmatuschek Jan 26, 2023
09cdd2d
Reverse engineered DTMF settings for DR-1801UV. Addresses #285.
hmatuschek Jan 26, 2023
ef9a865
Reverse engineered alarm settings for DR-1801UV. Addresses #285.
hmatuschek Jan 27, 2023
4c3207b
Implemented DTMF settings. Addresses #285.
hmatuschek Jan 27, 2023
61e4a78
Implemented alarm settings. Addresses #285.
hmatuschek Jan 27, 2023
14be77c
Implemented DMR settings for the DR-1801UV. Addresses #285.
hmatuschek Jan 27, 2023
8be991a
Implemented one-touch settings for DR-1801UV, addresses #285.
hmatuschek Jan 28, 2023
7ffa53c
Implemted import from manufacturer CPS file for DR1801UV, addresses #…
hmatuschek Jan 28, 2023
b6fbcf3
Implemented encoding of settings, zones and contacts for DR1801UV, ad…
hmatuschek Jan 28, 2023
1b52db0
Implemented encoding of scan lists, addresses #285.
hmatuschek Jan 28, 2023
f4f7366
Implemented encoding of channels for DR-1801UV, addresses #285.
hmatuschek Jan 28, 2023
e8e74ab
Implemented encoding of group lists for DR-1801UV, addresses #285.
hmatuschek Jan 28, 2023
78a3922
Added common reveng code.
hmatuschek Jan 29, 2023
c27e889
Fixed codeplug upload for DR-1801UV, addresses #285.
hmatuschek Jan 29, 2023
34e492f
Fixed codeplug encoding and transfer for DR-1801UV, addresses #285.
hmatuschek Jan 29, 2023
0489581
Fixed codeplug transfer for DR-1801UV, addresses #285.
hmatuschek Jan 29, 2023
143723b
Cleanup of DR-1801UV interface. Addresses #285.
hmatuschek Jan 30, 2023
52016fb
Fixed compiler warning.
hmatuschek Jan 30, 2023
e2cd1bd
Merge branch 'devel' into dr1801
hmatuschek Jan 30, 2023
f01c68c
Merge branch 'devel' into dr1801
hmatuschek Jan 30, 2023
0ec4420
Merge branch 'devel' into dr1801
hmatuschek Jan 30, 2023
31f1b8e
Merge branch 'devel' into dr1801
hmatuschek Feb 2, 2023
3c43499
Merge branch 'devel' into dr1801
hmatuschek Feb 4, 2023
3f9bfe7
Merge branch 'devel' into dr1801
hmatuschek Feb 10, 2023
e939e3c
Merge branch 'devel' into dr1801
hmatuschek Feb 22, 2023
206b568
Merge branch 'dr1801' of https://github.com/hmatuschek/qdmr into dr1801
hmatuschek Feb 22, 2023
e9da3c0
Merge branch 'master' into dr1801
hmatuschek Mar 8, 2023
852ea47
Merge branch 'devel' into dr1801
hmatuschek Mar 15, 2023
7eed00d
Merge branch 'devel' into dr1801
hmatuschek Apr 21, 2023
2e0cce6
Merge branch 'devel' into dr1801
hmatuschek Jun 1, 2023
f63753b
Merge branch 'devel' into dr1801
hmatuschek Jun 19, 2023
89ee229
Merge branch 'devel' into dr1801
hmatuschek Jul 10, 2023
0e988a7
Merge branch 'devel' into dr1801
hmatuschek Jul 19, 2023
b2e8f7b
Merged.
hmatuschek Jul 19, 2023
59bde91
Merge branch 'devel' into dr1801
hmatuschek Jul 20, 2023
22ef138
Merge branch 'devel' into dr1801
hmatuschek Sep 20, 2023
513cd78
Merge branch 'devel' into dr1801
hmatuschek Sep 24, 2023
6923329
Merge branch 'devel' into dr1801
hmatuschek Oct 10, 2023
6f539bb
Merge branch 'devel' into dr1801
hmatuschek Oct 14, 2023
de53519
Fixed DR1801UVA6 codeplug generation.
hmatuschek Oct 14, 2023
6723b45
Merge branch 'devel' into dr1801
hmatuschek Oct 23, 2023
2d5ac14
Merge branch 'devel' into dr1801
hmatuschek Nov 2, 2023
c7cc3d6
Merge branch 'devel' into dr1801
hmatuschek Nov 6, 2023
e28cb0a
Fixed communication issue with DR1801UV (A6) devices.
hmatuschek Nov 13, 2023
9ce237f
Fixed DR1801UV group list encoding.
hmatuschek Nov 13, 2023
f83693d
Added basic unit tests for DR1801UV (A6).
hmatuschek Nov 13, 2023
3340feb
Added reencoding test.
hmatuschek Nov 13, 2023
2eea9fe
Cleanup of Auctus A6 interface.
hmatuschek Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implemented decofing of group lists for BTECH DR-1801UV.
hmatuschek committed Jan 21, 2023
commit 3f773b047bd61a48471484f18b97586fe9ec86a3
14 changes: 14 additions & 0 deletions doc/code/dr1801uv_grouplistelement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
00 | Number of members, uint16, little endian | Group list index+1, uint16, little endian, 0=invalid |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
04 | Member index0 +1, uint16, little endian | Member index1 +1, uint16, little endian |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
... ...
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
14 | Member index8 +1, uint16, little endian | Member index9 +1, uint16, little endian |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
18 | Unused, filled with 0 ...
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
40 ... |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
153 changes: 151 additions & 2 deletions lib/dr1801uv_codeplug.cc
Original file line number Diff line number Diff line change
@@ -14,6 +14,11 @@
#define ADDR_CONTACT_ELEMENTS 0x04338
#define CONTACT_ELEMENT_SIZE 0x00018

#define NUM_GROUP_LISTS 64
#define ADDR_GROUP_LIST_ELEMENTS 0x1c6e0
#define GROUP_LIST_ELEMENT_SIZE 0x00044
#define GROUP_LIST_MEMBER_COUNT 10


/* ******************************************************************************************** *
* Implementation of DR1801UVCodeplug::ChannelElement
@@ -536,6 +541,87 @@ DR1801UVCodeplug::ContactElement::linkContactObj(DMRContact *contact, Context &c



/* ******************************************************************************************** *
* Implementation of DR1801UVCodeplug::GroupListElement
* ******************************************************************************************** */
DR1801UVCodeplug::GroupListElement::GroupListElement(uint8_t *ptr, size_t size)
: Element(ptr, size)
{
// pass...
}

DR1801UVCodeplug::GroupListElement::GroupListElement(uint8_t *ptr)
: Element(ptr, GROUP_LIST_ELEMENT_SIZE)
{
// pass...
}

void
DR1801UVCodeplug::GroupListElement::clear() {
memset(_data, 0, _size);
}

bool
DR1801UVCodeplug::GroupListElement::isValid() const {
return 0 != getUInt16_le(0x0002);
}

uint16_t
DR1801UVCodeplug::GroupListElement::index() const {
return getUInt16_le(0x0002)-1;
}
void
DR1801UVCodeplug::GroupListElement::setIndex(uint16_t index) {
setUInt16_le(0x0002, index-1);
}

uint16_t
DR1801UVCodeplug::GroupListElement::count() const {
return getUInt16_le(0x0000);
}
bool
DR1801UVCodeplug::GroupListElement::hasMemberIndex(uint8_t n) const {
return 0 != getUInt16_le(0x0004 + n*0x02);
}
uint16_t
DR1801UVCodeplug::GroupListElement::memberIndex(uint8_t n) const {
return getUInt16_le(0x0004 + n*0x02) - 1;
}
void
DR1801UVCodeplug::GroupListElement::setMemberIndex(uint8_t n, uint16_t index) {
setUInt16_le(0x0004 + n*0x02, index+1);
}
void
DR1801UVCodeplug::GroupListElement::clearMemberIndex(uint8_t n) {
setUInt16_le(0x0004 + n*0x02, 0);
}

RXGroupList *
DR1801UVCodeplug::GroupListElement::toGroupListObj(Context &ctx, const ErrorStack &err) const {
Q_UNUSED(ctx); Q_UNUSED(err);
// Simply derive name from index
return new RXGroupList(QString("Group List %1").arg(index()+1));
}

bool
DR1801UVCodeplug::GroupListElement::linkGroupListObj(RXGroupList *list, Context &ctx, const ErrorStack &err) {
if (! isValid())
return false;

for (int i=0; i<GROUP_LIST_MEMBER_COUNT; i++) {
if (! hasMemberIndex(i))
continue;
if (! ctx.has<DMRContact>(memberIndex(i))) {
errMsg(err) << "Member index " << memberIndex(i) << " is not known.";
return false;
}
list->addContact(ctx.get<DMRContact>(memberIndex(i)));
}

return true;
}


/* ******************************************************************************************** *
* Implementation of DR1801UVCodeplug
* ******************************************************************************************** */
@@ -585,18 +671,28 @@ DR1801UVCodeplug::decodeElements(Context &ctx, const ErrorStack &err) {
return false;
}

if (! decodeGroupLists(ctx, err)) {
errMsg(err) << "Cannot decode group list elements.";
return false;
}

return true;
}

bool
DR1801UVCodeplug::linkElements(Context &ctx, const ErrorStack &err) {
if (! linkChannels(ctx, err)) {
errMsg(err) << "Cannot decode channel elements.";
errMsg(err) << "Cannot link channels.";
return false;
}

if (! linkContacts(ctx, err)) {
errMsg(err) << "Cannot decode contact elements.";
errMsg(err) << "Cannot link contacts.";
return false;
}

if (! linkGroupLists(ctx, err)) {
errMsg(err) << "Cannot link group lists.";
return false;
}

@@ -710,3 +806,56 @@ DR1801UVCodeplug::linkContacts(Context &ctx, const ErrorStack &err) {

return true;
}


bool
DR1801UVCodeplug::decodeGroupLists(Context &ctx, const ErrorStack &err) {
// Decode all group list elements
for (int i=0; i<NUM_GROUP_LISTS; i++) {
GroupListElement gl(data(ADDR_GROUP_LIST_ELEMENTS + i*GROUP_LIST_ELEMENT_SIZE));

// Skip invalid group lists
if (! gl.isValid())
continue;

// Decode group list
RXGroupList *obj = gl.toGroupListObj(ctx, err);
if (nullptr == obj) {
errMsg(err) << "Cannot decode group list at index " << i << ".";
return false;
}
logDebug() << "Register group list at index " << gl.index();

// Add group list to index table
ctx.add(obj, gl.index());
// Add group list to config
ctx.config()->rxGroupLists()->add(obj);
}

return true;
}

bool
DR1801UVCodeplug::linkGroupLists(Context &ctx, const ErrorStack &err) {
// link all group lists
for (int i=0; i<NUM_GROUP_LISTS; i++) {
GroupListElement gl(data(ADDR_GROUP_LIST_ELEMENTS + i*GROUP_LIST_ELEMENT_SIZE));

// Skip invalid group lists
if (! gl.isValid())
continue;

// Link group list if defined
if (! ctx.has<RXGroupList>(gl.index()))
continue;

// Link contact
if (! gl.linkGroupListObj(ctx.get<RXGroupList>(i), ctx, err)) {
errMsg(err) << "Cannot link group list '" << ctx.get<RXGroupList>(i)->name()
<< " at index " << i << ".";
return false;
}
}

return true;
}
49 changes: 49 additions & 0 deletions lib/dr1801uv_codeplug.hh
Original file line number Diff line number Diff line change
@@ -28,6 +28,8 @@
* details.</td></tr>
* <tr><td>0x17660</td> <td>0x1c660</td> <td>0x5000</td> <td>1024 Channel names, 20 ASCII chars,
* 0-terminated. Unset/unused names are filled with 0.</td></tr>
* <tr><td>0x1c6e0</td> <td>0x1d7e0</td> <td>0x1100</td> <td>64 group lists. See
* @c DR1801UVCodeplug::GroupListElement.</td></tr>
* </table>
*
* @ingroup dr1801uv */
@@ -227,6 +229,7 @@ public:
virtual bool linkChannelObj(Channel *channel, Context &ctx, const ErrorStack &err=ErrorStack()) const;
};


/** Implements the binary encoding of a contact.
*
* Memory representation of contact (0018h bytes):
@@ -274,10 +277,52 @@ public:
/** Sets the name of the contact. */
virtual void setName(const QString &name);

/** Constructs a DMR contact object from this contact elmeent. */
virtual DMRContact *toContactObj(Context &ctx, const ErrorStack &err=ErrorStack()) const;
/** Links the DMR contact object. */
virtual bool linkContactObj(DMRContact *contact, Context &ctx, const ErrorStack &err=ErrorStack());
};


/** Implements the binary encoding of a group list.
*
* Memory representation of group list (00h bytes):
* @verbinclude dr1801uv_grouplistelement.txt */
class GroupListElement: public Element
{
protected:
/** Hidden constructor. */
GroupListElement(uint8_t *ptr, size_t size);

public:
/** Constructor. */
GroupListElement(uint8_t *ptr);

bool isValid() const;
void clear();

/** Returns the index of the group list. */
virtual uint16_t index() const;
/** Sets the index of the group list. */
virtual void setIndex(uint16_t index);

/** Returns the number of elements in the list. */
virtual uint16_t count() const;
/** Returns @c true if the n-th member index is set. */
virtual bool hasMemberIndex(uint8_t n) const;
/** Retuns the n-th member index. */
virtual uint16_t memberIndex(uint8_t n) const;
/** Sets the n-th member index. */
virtual void setMemberIndex(uint8_t n, uint16_t index);
/** Clears the n-th member index. */
virtual void clearMemberIndex(uint8_t n);

/** Constructs a group list object from this elmeent. */
virtual RXGroupList *toGroupListObj(Context &ctx, const ErrorStack &err=ErrorStack()) const;
/** Links the group list object. */
virtual bool linkGroupListObj(RXGroupList *list, Context &ctx, const ErrorStack &err=ErrorStack());
};

public:
/** Default constructor. */
explicit DR1801UVCodeplug(QObject *parent = nullptr);
@@ -302,6 +347,10 @@ protected:
/** Link contact elements. */
virtual bool linkContacts(Context &ctx, const ErrorStack &err=ErrorStack());

/** Decode group list elements. */
virtual bool decodeGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
/** Link group lists. */
virtual bool linkGroupLists(Context &ctx, const ErrorStack &err=ErrorStack());
};

#endif // DR1801UVCODEPLUG_HH