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 Nov 2, 2023
2 parents 9ae21e4 + 2489bcc commit e2c26ee
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/anytone_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1888,12 +1888,12 @@ AnytoneCodeplug::GeneralSettingsElement::updateConfig(Context &ctx) {
ext->bootSettings()->enableDefaultChannel(this->defaultChannel());

// Store key settings
ext->keySettings()->setFuncKey1Short(funcKeyAShort());
ext->keySettings()->setFuncKey1Long(funcKeyALong());
ext->keySettings()->setFuncKey2Short(funcKeyBShort());
ext->keySettings()->setFuncKey2Long(funcKeyBLong());
ext->keySettings()->setFuncKey3Short(funcKeyCShort());
ext->keySettings()->setFuncKey3Long(funcKeyCLong());
ext->keySettings()->setFuncKeyAShort(funcKeyAShort());
ext->keySettings()->setFuncKeyALong(funcKeyALong());
ext->keySettings()->setFuncKeyBShort(funcKeyBShort());
ext->keySettings()->setFuncKeyBLong(funcKeyBLong());
ext->keySettings()->setFuncKeyCShort(funcKeyCShort());
ext->keySettings()->setFuncKeyCLong(funcKeyCLong());
ext->keySettings()->setFuncKey1Short(funcKey1Short());
ext->keySettings()->setFuncKey1Long(funcKey1Long());
ext->keySettings()->setFuncKey2Short(funcKey2Short());
Expand Down
57 changes: 57 additions & 0 deletions test/d878uv2_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,63 @@ D878UV2Test::testChannelFrequency() {
Frequency::fromHz(999999990ULL));
}

void
D878UV2Test::testKeyFunctions() {
ErrorStack err;

// Load config from file
Config config;
if (! config.readYAML(":/data/anytone_key_function.yaml", err)) {
QFAIL(QString("Cannot open codeplug file: %1")
.arg(err.format()).toStdString().c_str());
}

// Check config
QVERIFY2(config.settings()->anytoneExtension(), "Expected AnyTone settings extension.");
AnytoneKeySettingsExtension *ext = config.settings()->anytoneExtension()->keySettings();

QCOMPARE(ext->funcKey1Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleMainChannel);
QCOMPARE(ext->funcKey1Long(), AnytoneKeySettingsExtension::KeyFunction::SubChannel);
QCOMPARE(ext->funcKey2Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleVFO);
QCOMPARE(ext->funcKey2Long(), AnytoneKeySettingsExtension::KeyFunction::ChannelType);
QCOMPARE(ext->funcKeyAShort(), AnytoneKeySettingsExtension::KeyFunction::Off);
QCOMPARE(ext->funcKeyALong(), AnytoneKeySettingsExtension::KeyFunction::Encryption);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);

// Encode
D878UV2Codeplug codeplug;
Codeplug::Flags flags; flags.updateCodePlug=false;
if (! codeplug.encode(&config, flags, err)) {
QFAIL(QString("Cannot encode codeplug for AnyTone AT-D868UVE: %1")
.arg(err.format()).toStdString().c_str());
}

// Decode
Config comp_config;
if (! codeplug.decode(&comp_config, err)) {
QFAIL(QString("Cannot decode codeplug for AnyTone AT-D878UVII: %1")
.arg(err.format()).toStdString().c_str());
}

// Check config
QVERIFY2(comp_config.settings()->anytoneExtension(), "Expected AnyTone settings extension.");
ext = comp_config.settings()->anytoneExtension()->keySettings();

QCOMPARE(ext->funcKey1Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleMainChannel);
QCOMPARE(ext->funcKey1Long(), AnytoneKeySettingsExtension::KeyFunction::SubChannel);
QCOMPARE(ext->funcKey2Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleVFO);
QCOMPARE(ext->funcKey2Long(), AnytoneKeySettingsExtension::KeyFunction::ChannelType);
QCOMPARE(ext->funcKeyAShort(), AnytoneKeySettingsExtension::KeyFunction::Off);
QCOMPARE(ext->funcKeyALong(), AnytoneKeySettingsExtension::KeyFunction::Encryption);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
}


QTEST_GUILESS_MAIN(D878UV2Test)

1 change: 1 addition & 0 deletions test/d878uv2_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 testChannelFrequency();
void testKeyFunctions();
};

#endif // D878UV2TEST_HH
57 changes: 57 additions & 0 deletions test/d878uv_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,62 @@ D878UVTest::testHangTime() {

}

void
D878UVTest::testKeyFunctions() {
ErrorStack err;

// Load config from file
Config config;
if (! config.readYAML(":/data/anytone_key_function.yaml", err)) {
QFAIL(QString("Cannot open codeplug file: %1")
.arg(err.format()).toStdString().c_str());
}

// Check config
QVERIFY2(config.settings()->anytoneExtension(), "Expected AnyTone settings extension.");
AnytoneKeySettingsExtension *ext = config.settings()->anytoneExtension()->keySettings();

QCOMPARE(ext->funcKey1Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleMainChannel);
QCOMPARE(ext->funcKey1Long(), AnytoneKeySettingsExtension::KeyFunction::SubChannel);
QCOMPARE(ext->funcKey2Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleVFO);
QCOMPARE(ext->funcKey2Long(), AnytoneKeySettingsExtension::KeyFunction::ChannelType);
QCOMPARE(ext->funcKeyAShort(), AnytoneKeySettingsExtension::KeyFunction::Off);
QCOMPARE(ext->funcKeyALong(), AnytoneKeySettingsExtension::KeyFunction::Encryption);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);

// Encode
D878UVCodeplug codeplug;
Codeplug::Flags flags; flags.updateCodePlug=false;
if (! codeplug.encode(&config, flags, err)) {
QFAIL(QString("Cannot encode codeplug for AnyTone AT-D868UVE: %1")
.arg(err.format()).toStdString().c_str());
}

// Decode
Config comp_config;
if (! codeplug.decode(&comp_config, err)) {
QFAIL(QString("Cannot decode codeplug for AnyTone AT-D878UVII: %1")
.arg(err.format()).toStdString().c_str());
}

// Check config
QVERIFY2(comp_config.settings()->anytoneExtension(), "Expected AnyTone settings extension.");
ext = comp_config.settings()->anytoneExtension()->keySettings();

QCOMPARE(ext->funcKey1Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleMainChannel);
QCOMPARE(ext->funcKey1Long(), AnytoneKeySettingsExtension::KeyFunction::SubChannel);
QCOMPARE(ext->funcKey2Short(), AnytoneKeySettingsExtension::KeyFunction::ToggleVFO);
QCOMPARE(ext->funcKey2Long(), AnytoneKeySettingsExtension::KeyFunction::ChannelType);
QCOMPARE(ext->funcKeyAShort(), AnytoneKeySettingsExtension::KeyFunction::Off);
QCOMPARE(ext->funcKeyALong(), AnytoneKeySettingsExtension::KeyFunction::Encryption);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
QCOMPARE(ext->funcKeyBShort(), AnytoneKeySettingsExtension::KeyFunction::Voltage);
QCOMPARE(ext->funcKeyBLong(), AnytoneKeySettingsExtension::KeyFunction::Call);
}

QTEST_GUILESS_MAIN(D878UVTest)

1 change: 1 addition & 0 deletions test/d878uv_test.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private slots:
void testAnalogMicGain();
void testRoaming();
void testHangTime();
void testKeyFunctions();

protected:
Config _micGainConfig;
Expand Down
108 changes: 108 additions & 0 deletions test/data/anytone_key_function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
version: 0.11.0
settings:
introLine1: DM3MAT
introLine2: qDMR
micLevel: 3
speech: false
power: High
squelch: 1
vox: 0
tot: 0
defaultID: id1
anytone:
keySettings:
funcKey1Short: ToggleMainChannel
funcKey1Long: SubChannel
funcKey2Short: ToggleVFO
funcKey2Long: ChannelType
funcKeyAShort: Off
funcKeyALong: Encryption
funcKeyBShort: Voltage
funcKeyBLong: Call
funcKeyCShort: Power
funcKeyCLong: VOX

radioIDs:
- dmr: {id: id1, name: DM3MAT, number: 2621370}
contacts:
- dmr: {id: cont1, name: Local, ring: false, type: GroupCall, number: 9}
- dmr: {id: cont2, name: Regional, ring: false, type: GroupCall, number: 8}
- dmr: {id: cont3, name: BB, ring: false, type: GroupCall, number: 2621}
- dmr: {id: cont4, name: DL, ring: false, type: GroupCall, number: 262}
- dmr: {id: cont5, name: BM APRS, ring: false, type: PrivateCall, number: 262999}
- dmr: {id: cont6, name: HamRadioVillage, ring: false, type: GroupCall, number: 3177826}
groupLists:
- {id: grp1, name: Local, contacts: [cont1, cont2, cont3]}
- {id: grp2, name: DL, contacts: [cont4]}
- {id: grp3, name: HamRadioVillage, contacts: [cont6]}
channels:
- dmr:
id: ch1
name: L9 DB0LDS
rxFrequency: 439.5625
txFrequency: 431.9625
rxOnly: false
admit: Always
colorCode: 1
timeSlot: TS2
groupList: grp1
contact: cont1
power: High
timeout: 0
vox: 0
- dmr:
id: ch2
name: BB DB0LDS
rxFrequency: 439.5625
txFrequency: 431.9625
rxOnly: false
admit: Always
colorCode: 1
timeSlot: TS2
groupList: grp1
contact: cont3
aprs: aprs1
power: High
timeout: 0
vox: 0
- dmr:
id: ch3
name: DL DB0LDS
rxFrequency: 439.5625
txFrequency: 431.9625
rxOnly: false
admit: Always
colorCode: 1
timeSlot: TS1
groupList: grp2
contact: cont4
power: High
timeout: 0
vox: 0
- dmr:
id: ch4
name: HRV DB0LDS
rxFrequency: 439.5625
txFrequency: 431.9625
rxOnly: false
admit: Always
colorCode: 1
timeSlot: TS1
groupList: grp3
contact: cont6
power: High
timeout: 0
vox: 0
zones:
- id: zone1
name: Zu Hause
A: [ch1, ch2, ch4]
B: [ch3]
positioning:
- dmr:
id: aprs1
name: GPS System
period: 300
contact: cont5
...
1 change: 1 addition & 0 deletions test/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<file>data/anytone_call_hangtime.yaml</file>
<file>data/multiple_radio_ids.yaml</file>
<file>data/ctcss_copy_test.yaml</file>
<file>data/anytone_key_function.yaml</file>
</qresource>
</RCC>

0 comments on commit e2c26ee

Please sign in to comment.