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

Handle missing default DMR IDs properly (fixes #458). #459

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions lib/dr1801uv_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3269,8 +3269,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
1 change: 1 addition & 0 deletions 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 Down
2 changes: 1 addition & 1 deletion test/configtest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private slots:

void testMelodyLilypond();
void testMelodyEncoding();
void testMelodyDecoding();
void testMelodyDecoding();

protected:
QTextStream _stderr;
Expand Down
12 changes: 12 additions & 0 deletions test/dr1801_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ DR1801Test::testBasicConfigReencoding() {
}
}


void
DR1801Test::testProstProcessingOfEmptyCodeplug() {
Config config;
DR1801UVCodeplug codeplug;
ErrorStack err;

config.clear();
QVERIFY(codeplug.postprocess(&config, err));
}


QTEST_GUILESS_MAIN(DR1801Test)


1 change: 1 addition & 0 deletions test/dr1801_test.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ private slots:
void testBasicConfigEncoding();
void testBasicConfigDecoding();
void testBasicConfigReencoding();
void testProstProcessingOfEmptyCodeplug();
};

#endif // DR1801TEST_HH
Loading