Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Jul 22, 2024
2 parents 2161d92 + 4dc24f6 commit 49c829f
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 177 deletions.
2 changes: 1 addition & 1 deletion doc/code/dr1801uv_zonebankelement.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
0000 | Zone count, uint16, little endian | Up current zone index, uint16, little endian |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
0004 | Up current zone index, uint16_t, little endian | Unused, set to 0x0000 |
0004 | Down current zone index, uint16_t, little endian | Unused, set to 0x0000 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
0008 | Zone 0 ...
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Expand Down
13 changes: 8 additions & 5 deletions lib/dr1801uv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ DR1801UV::startDownload(bool blocking, const ErrorStack &err) {
// If non-blocking -> move device to this thread
if (_device && _device->isOpen())
_device->moveToThread(this);

start();

return true;
}

Expand Down Expand Up @@ -104,6 +106,8 @@ DR1801UV::run() {
return;
}

emit downloadStarted();

if (! download()) {
_device->read_finish();
_device->reboot();
Expand All @@ -124,6 +128,8 @@ DR1801UV::run() {
return;
}

emit uploadStarted();

if (! upload()) {
_device->write_finish();
_device->reboot();
Expand All @@ -132,10 +138,12 @@ DR1801UV::run() {
emit uploadError(this);
return;
}

_device->write_finish();
_device->reboot();
_device->close();
_task = StatusIdle;

emit uploadComplete(this);
} else if (StatusUploadCallsigns == _task) {
// Not implemented.
Expand All @@ -146,22 +154,17 @@ DR1801UV::run() {

bool
DR1801UV::download() {
emit downloadStarted();

if (! _device->readCodeplug(_codeplug, [this](unsigned int n, unsigned int total){
emit downloadProgress(float(n*100)/total); }, _errorStack)) {
errMsg(_errorStack) << "Cannot read codeplug from device.";
return false;
}

emit downloadFinished(this, &_codeplug);
return true;
}

bool
DR1801UV::upload() {
emit uploadStarted();

// First, read codeplug from the device
if (! _device->readCodeplug(_codeplug, [this](unsigned int n, unsigned int total) {
emit uploadProgress(float(n*50)/total); }, _errorStack))
Expand Down
89 changes: 47 additions & 42 deletions lib/dr1801uv_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ DR1801UVCodeplug::ChannelBankElement::setChannelName(unsigned int index, const Q

bool
DR1801UVCodeplug::ChannelBankElement::decode(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<channelCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::channelCount() && j<channelCount(); i++) {
ChannelElement ch = channel(i);
if (! ch.isValid()) {
errMsg(err) << "Cannot decode invalid channel at index " << i
<< ", got promissed " << channelCount() << " valid channels.";
return false;
}
if (! ch.isValid())
continue;
j++;
Channel *obj = ch.toChannelObj(ctx, err);
if (nullptr == obj) {
errMsg(err) << "Cannot decode channel at index " << i << ".";
Expand All @@ -78,8 +76,11 @@ DR1801UVCodeplug::ChannelBankElement::decode(Context &ctx, const ErrorStack &err

bool
DR1801UVCodeplug::ChannelBankElement::link(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<channelCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::channelCount() && j<channelCount(); i++) {
ChannelElement ch = channel(i);
if (! ch.isValid())
continue;
j++;
if (! ctx.has<Channel>(ch.index())) {
errMsg(err) << "Cannot link channel at index " << i
<< ". Channel not defined.";
Expand Down Expand Up @@ -844,13 +845,11 @@ DR1801UVCodeplug::GroupListBankElement::groupList(unsigned int index) const {

bool
DR1801UVCodeplug::GroupListBankElement::decode(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<groupListCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::groupListCount() && j<groupListCount(); i++) {
GroupListElement gl = groupList(i);
if (! gl.isValid()) {
errMsg(err) << "Cannot decode invalid group list at index " << i
<< ". Got " << groupListCount() << " valid group lists promissed.";
return false;
}
if (! gl.isValid())
continue;
j++;
RXGroupList *obj = gl.toGroupListObj(ctx, err);
if (nullptr == obj) {
errMsg(err) << "Cannot decode group list at index " << i << ".";
Expand All @@ -866,8 +865,11 @@ DR1801UVCodeplug::GroupListBankElement::decode(Context &ctx, const ErrorStack &e

bool
DR1801UVCodeplug::GroupListBankElement::link(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<groupListCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::groupListCount() && j<groupListCount(); i++) {
GroupListElement gl = groupList(i);
if (! gl.isValid())
continue;
j++;
if (! ctx.has<RXGroupList>(gl.index())) {
errMsg(err) << "Cannot link group list at index " << i
<< ". Group list not defined.";
Expand Down Expand Up @@ -1052,13 +1054,11 @@ DR1801UVCodeplug::ZoneBankElement::zone(unsigned int index) const {

bool
DR1801UVCodeplug::ZoneBankElement::decode(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<zoneCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::zoneCount() && j<zoneCount(); i++) {
ZoneElement zone(this->zone(i));
if (! zone.isValid()) {
errMsg(err) << "Unexpected invalid zone at index " << i
<< ", was promissed " << zoneCount() << " zones.";
return false;
}
if (! zone.isValid())
continue;
j++;

Zone *obj = zone.toZoneObj(ctx, err);
if (nullptr == obj) {
Expand All @@ -1077,13 +1077,11 @@ DR1801UVCodeplug::ZoneBankElement::decode(Context &ctx, const ErrorStack &err) c

bool
DR1801UVCodeplug::ZoneBankElement::link(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<zoneCount(); i++) {
for (unsigned int i=0, j=0; i<Limit::zoneCount() && j<zoneCount(); i++) {
ZoneElement zone(this->zone(i));
if (! zone.isValid()) {
errMsg(err) << "Unexpected invalid zone at index " << i
<< ", was promissed " << zoneCount() << " zones.";
return false;
}
if (! zone.isValid())
continue;
j++;

if (! ctx.has<Zone>(zone.index())) {
errMsg(err) << "Cannot link zone at index " << i << ", not defined.";
Expand Down Expand Up @@ -1672,13 +1670,12 @@ DR1801UVCodeplug::ScanListBankElement::scanList(unsigned int index) const {

bool
DR1801UVCodeplug::ScanListBankElement::decode(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<scanListCount(); i++) {
for (unsigned int i=0, j=0; i<Limit::scanListCount() && j<scanListCount(); i++) {
ScanListElement sl = scanList(i);
if (! sl.isValid()) {
errMsg(err) << "Cannot decode invalid scan list at index " << i
<< ". Was promissed " << scanListCount() << " scan lists.";
return false;
}
if (! sl.isValid())
continue;
j++;

ScanList *obj = sl.toScanListObj(ctx, err);
if (nullptr == obj) {
errMsg(err) << "Cannot decode scan list at index " << i << ".";
Expand All @@ -1694,13 +1691,12 @@ DR1801UVCodeplug::ScanListBankElement::decode(Context &ctx, const ErrorStack &er

bool
DR1801UVCodeplug::ScanListBankElement::link(Context &ctx, const ErrorStack &err) const {
for (unsigned int i=0; i<scanListCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::scanListCount() && j<scanListCount(); i++) {
ScanListElement sl = scanList(i);
if (! sl.isValid()) {
errMsg(err) << "Cannot link invalid scan list at index " << i
<< ". Was promissed " << scanListCount() << " scan lists.";
return false;
}
if (! sl.isValid())
continue;
j++;

if (! ctx.has<ScanList>(sl.index())) {
errMsg(err) << "Cannot link scan list at index " << i
<< ". Scan list not defined.";
Expand Down Expand Up @@ -1975,10 +1971,11 @@ DR1801UVCodeplug::MessageBankElement::decode(Context &ctx, const ErrorStack &err

ctx.config()->smsExtension()->smsTemplates()->clear();

for (unsigned int i=0; i<messageCount(); i++) {
for (unsigned int i=0,j=0; i<Limit::messageCount() && j<messageCount(); i++) {
MessageElement msg = message(i);
if (! msg.isValid())
continue;
j++;
SMSTemplate *sms = new SMSTemplate();
sms->setName(QString("Message %1").arg(msg.index()));
sms->setMessage(msg.text());
Expand Down Expand Up @@ -2214,7 +2211,7 @@ DR1801UVCodeplug::EncryptionKeyBankElement::decode(Context &ctx, const ErrorStac
ctx.add(obj, key(i).index());
ctx.config()->commercialExtension()->encryptionKeys()->add(obj);
}
return false;
return true;
}

bool
Expand Down Expand Up @@ -3269,8 +3266,16 @@ DR1801UVCodeplug::index(Config *config, Context &ctx, const ErrorStack &err) con

// All indices as 0-based. That is, the first channel gets index 0 etc.

// There can only be one DMR radio ID
ctx.add(config->settings()->defaultId(), 0);
// There must be a default DMR radio ID.
if (nullptr == ctx.config()->settings()->defaultId()) {
errMsg(err) << "No default DMR radio ID specified.";
errMsg(err) << "Cannot index codplug for encoding for the BTECH DR-1801UV.";
return false;
}

// Map radio IDs
for (int i=0; i<ctx.config()->radioIDs()->count(); i++)
ctx.add(ctx.config()->radioIDs()->getId(i), i);

// Map digital and DTMF contacts
for (int i=0, d=0; i<config->contacts()->count(); i++) {
Expand Down
14 changes: 8 additions & 6 deletions lib/radiolimits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,21 +432,23 @@ RadioLimitFrequencies::verify(const ConfigItem *item, const QMetaProperty &prop,
return false;
}

if (0 == _frequencyRanges.size())
return true;

Frequency value = prop.read(item).value<Frequency>();
foreach (const FrequencyRange &range, _frequencyRanges) {
if (range.contains(value))
return true;
}

if (context.ignoreFrequencyLimits() || (0 == _frequencyRanges.size()) || _warnOnly) {
auto &msg = context.newMessage(RadioLimitIssue::Warning);
msg << "Frequency " << value.inMHz() << "MHz is outside of allowed frequency ranges or "
<< "range cannot be determined.";
if (context.ignoreFrequencyLimits())
return true;
}

auto &msg = context.newMessage(RadioLimitIssue::Critical);
auto &msg = context.newMessage(RadioLimitIssue::Warning);
msg << "Frequency " << value.inMHz() << "MHz is outside of allowed frequency ranges.";

if(_warnOnly)
return true;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions shared/ui/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>About qdrm</string>
<string>About qdmr</string>
</property>
<property name="windowIcon">
<iconset>
Expand Down Expand Up @@ -52,7 +52,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;title&gt;About qdmr&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:600;&quot;&gt;qdmr&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:600;&quot;&gt;Version %1&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:600;&quot;&gt;Hannes Matuschek, DM3MAT&lt;br /&gt; [email protected]&lt;/span&gt;&lt;/p&gt;
Expand Down
7 changes: 2 additions & 5 deletions shared/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
</size>
</property>
<property name="windowTitle">
<string>qdmr [*]</string>
<string notr="true">qdmr [*]</string>
</property>
<property name="windowIcon">
<iconset theme="qdmr">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="accessibleName">
<string>Main window</string>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -70,7 +67,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
2 changes: 1 addition & 1 deletion src/analogchanneldialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<string>Off</string>
</property>
<property name="suffix">
<string extracomment="Transmit time out (TOT) in seconds. A value of 0 means disabled."> s</string>
<string notr="true" extracomment="Transmit time out (TOT) in seconds. A value of 0 means disabled."> s</string>
</property>
<property name="maximum">
<number>9999</number>
Expand Down
3 changes: 2 additions & 1 deletion src/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ void
Application::onCodeplugDownloaded(Radio *radio, Codeplug *codeplug) {
_config->clear();
_mainWindow->setWindowModified(false);

ErrorStack err;
if (codeplug->decode(_config, err)) {
_mainWindow->statusBar()->showMessage(tr("Read complete"));
Expand All @@ -719,7 +720,7 @@ Application::onCodeplugDownloaded(Radio *radio, Codeplug *codeplug) {
_config->clear();
}

if (! radio->codeplug().postprocess(_config, err)) {
if (! codeplug->postprocess(_config, err)) {
ErrorMessageView(err).exec();
_config->clear();
}
Expand Down
Loading

0 comments on commit 49c829f

Please sign in to comment.