Skip to content

Commit 0668a6a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into kv4p-207-from-203
2 parents 0e0054e + b32a8bb commit 0668a6a

File tree

16 files changed

+206
-96
lines changed

16 files changed

+206
-96
lines changed

.github/workflows/arduino.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ jobs:
3030
libraries: |
3131
- name: EspSoftwareSerial
3232
version: 8.1.0
33-
- source-url: https://github.com/fatpat/arduino-dra818/archive/refs/tags/v1.0.1.zip
33+
- source-url: https://github.com/fatpat/arduino-dra818.git
34+
version: 89582e3ef7bf3f31f1af149e32cec16c4b9e4cf2
3435
verbose: true

android-src/KV4PHT/.idea/deploymentTargetDropDown.xml

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android-src/KV4PHT/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "com.vagell.kv4pht"
1111
minSdk 26
1212
targetSdk 34
13-
versionCode 35
14-
versionName "1.7.1"
13+
versionCode 36
14+
versionName "1.7.2"
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717

android-src/KV4PHT/app/src/main/java/com/vagell/kv4pht/firmware/FirmwareUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public class FirmwareUtils {
1818
private static int progressPercent = 0;
1919

2020
// Whenever there is new firmware, put the files in res/raw, and update these constants.
21-
public static final int PACKAGED_FIRMWARE_VER = 11;
22-
private static final int FIRMWARE_FILE_1_ID = R.raw.v11_kv4p_ht_esp32_wroom_32_ino_bootloader;
23-
private static final int FIRMWARE_FILE_2_ID = R.raw.v11_kv4p_ht_esp32_wroom_32_ino_partitions;
21+
public static final int PACKAGED_FIRMWARE_VER = 12;
22+
private static final int FIRMWARE_FILE_1_ID = R.raw.v12_kv4p_ht_esp32_wroom_32_ino_bootloader;
23+
private static final int FIRMWARE_FILE_2_ID = R.raw.v12_kv4p_ht_esp32_wroom_32_ino_partitions;
2424
private static final int FIRMWARE_FILE_3_ID = R.raw.boot_app0; // This one never changes, it's the Arduino ESP32 bootloader
25-
private static final int FIRMWARE_FILE_4_ID = R.raw.v11_kv4p_ht_esp32_wroom_32_ino;
25+
private static final int FIRMWARE_FILE_4_ID = R.raw.v12_kv4p_ht_esp32_wroom_32_ino;
2626

2727
public FirmwareUtils() {
2828
}

android-src/KV4PHT/app/src/main/java/com/vagell/kv4pht/radio/ESP32DataStreamParser.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ESP32DataStreamParser {
99

1010
private int matchedDelimiterTokens = 0;
1111
private byte command;
12-
private byte commandParamLen;
12+
private int commandParamLen;
1313
private final ByteArrayOutputStream commandParams = new ByteArrayOutputStream();
1414
private final ByteArrayOutputStream lookaheadBuffer = new ByteArrayOutputStream();
1515

@@ -35,12 +35,10 @@ public byte[] extractAudioAndHandleCommands(byte[] newData) {
3535
// Log.d("DEBUG", "command: " + command);
3636
matchedDelimiterTokens++;
3737
} else if (matchedDelimiterTokens == COMMAND_DELIMITER.length + 1) {
38-
commandParamLen = b;
38+
commandParamLen = b & 0xFF;
3939
commandParams.reset();
4040
matchedDelimiterTokens++;
41-
4241
if (commandParamLen == 0) { // If this command has no params...
43-
lookaheadBuffer.reset();
4442
onCommand.accept(command, commandParams.toByteArray());
4543
resetParser(audioOut);
4644
}

android-src/KV4PHT/app/src/main/java/com/vagell/kv4pht/radio/RadioAudioService.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public class RadioAudioService extends Service {
122122
private int mode = MODE_STARTUP;
123123
private int messageNumber = 0;
124124

125-
public static final byte SILENT_BYTE = -128;
125+
public static final byte SILENT_BYTE = 0;
126126

127127
// Callbacks to the Activity that started us
128128
private RadioAudioServiceCallbacks callbacks = null;
@@ -151,9 +151,14 @@ public class RadioAudioService extends Service {
151151

152152
// Delimiter must match ESP32 code
153153
static final byte[] COMMAND_DELIMITER = new byte[] {(byte)0xDE, (byte)0xAD, (byte)0xBE, (byte)0xEF, (byte)0xDE, (byte)0xAD, (byte)0xBE, (byte)0xEF};
154-
private static final byte COMMAND_SMETER_REPORT = 0x53; // Ascii "S"
155-
private static final byte COMMAND_PHYS_PTT_DOWN = 0x44; // Ascii "D"
156-
private static final byte COMMAND_PHYS_PTT_UP = 0x55; // Ascii "U"
154+
private static final byte COMMAND_SMETER_REPORT = 0x53; // Ascii "S"
155+
private static final byte COMMAND_PHYS_PTT_DOWN = 0x44; // Ascii "D"
156+
private static final byte COMMAND_PHYS_PTT_UP = 0x55; // Ascii "U"
157+
private static final byte COMMAND_DEBUG_INFO = 0x01;
158+
private static final byte COMMAND_DEBUG_ERROR = 0x02;
159+
private static final byte COMMAND_DEBUG_WARN = 0x03;
160+
private static final byte COMMAND_DEBUG_DEBUG = 0x04;
161+
private static final byte COMMAND_DEBUG_TRACE = 0x05;
157162

158163
private final ESP32DataStreamParser esp32DataStreamParser = new ESP32DataStreamParser(this::handleParsedCommand);
159164

@@ -602,8 +607,10 @@ public void tuneToFreq(String frequencyStr, int squelchLevel, boolean forceTune)
602607

603608
try {
604609
Float freq = Float.parseFloat(makeSafeHamFreq(activeFrequencyStr));
605-
Float offsetMaxFreq = maxHamFreq - (bandwidth.equals("W") ? 0.025f : 0.0125f);
606-
if (freq < minHamFreq|| freq > offsetMaxFreq) {
610+
Float halfBandwidth = (bandwidth.equals("Wide") ? 0.025f : 0.0125f) / 2;
611+
Float offsetMaxFreq = maxHamFreq - halfBandwidth;
612+
Float offsetMinFreq = minHamFreq + halfBandwidth;
613+
if (freq < offsetMinFreq || freq > offsetMaxFreq) {
607614
txAllowed = false;
608615
} else {
609616
txAllowed = true;
@@ -693,8 +700,10 @@ public void tuneToMemory(ChannelMemory memory, int squelchLevel, boolean forceTu
693700

694701
try {
695702
Float txFreq = Float.parseFloat(getTxFreq(memory.frequency, memory.offset, memory.offsetKhz));
696-
Float offsetMaxFreq = maxHamFreq - (bandwidth.equals("W") ? 0.025f : 0.0125f);
697-
if (txFreq < minHamFreq || txFreq > offsetMaxFreq) {
703+
Float halfBandwidth = (bandwidth.equals("Wide") ? 0.025f : 0.0125f) / 2;
704+
Float offsetMaxFreq = maxHamFreq - halfBandwidth;
705+
Float offsetMinFreq = minHamFreq + halfBandwidth;
706+
if (txFreq < offsetMinFreq || txFreq > offsetMaxFreq) {
698707
txAllowed = false;
699708
} else {
700709
txAllowed = true;
@@ -945,8 +954,8 @@ public void onRunError(Exception e) {
945954
}
946955
});
947956
usbIoManager.setWriteBufferSize(90000); // Must be large enough that ESP32 can take its time accepting our bytes without overrun.
948-
usbIoManager.setReadBufferSize(1024/4); // Must not be 0 (infinite) or it may block on read() until a write() occurs.
949-
usbIoManager.setReadBufferCount(16*4);
957+
usbIoManager.setReadBufferSize(1024); // Must not be 0 (infinite) or it may block on read() until a write() occurs.
958+
usbIoManager.setReadBufferCount(16*2);
950959
usbIoManager.start();
951960
checkedFirmwareVersion = false;
952961

@@ -1097,8 +1106,14 @@ public void nextScan() {
10971106
do {
10981107
ChannelMemory candidate = channelMemories.get(nextIndex);
10991108

1100-
// If not marked as skipped, we tune to it and return.
1101-
if (!candidate.skipDuringScan) {
1109+
// If not marked as skipped, and it's in the active band, we tune to it and return.
1110+
float memoryFreqFloat = 0.0f;
1111+
try {
1112+
memoryFreqFloat = Float.parseFloat(candidate.frequency);
1113+
} catch (Exception e) {
1114+
Log.d("DEBUG", "Memory with id " + candidate.memoryId + " had invalid frequency.");
1115+
}
1116+
if (!candidate.skipDuringScan && memoryFreqFloat >= minRadioFreq && memoryFreqFloat <= maxRadioFreq) {
11021117
// Reset silence since we found an active memory.
11031118
consecutiveSilenceBytes = 0;
11041119

@@ -1434,6 +1449,16 @@ private void handleParsedCommand(byte cmd, byte[] param) {
14341449
endPtt();
14351450
callbacks.forcedPttEnd();
14361451
}
1452+
} else if (cmd == COMMAND_DEBUG_INFO) {
1453+
Log.i("firmware", new String(param));
1454+
} else if (cmd == COMMAND_DEBUG_DEBUG) {
1455+
Log.d("firmware", new String(param));
1456+
} else if (cmd == COMMAND_DEBUG_ERROR) {
1457+
Log.e("firmware", new String(param));
1458+
} else if (cmd == COMMAND_DEBUG_WARN) {
1459+
Log.w("firmware", new String(param));
1460+
} else if (cmd == COMMAND_DEBUG_TRACE) {
1461+
Log.v("firmware", new String(param));
14371462
} else {
14381463
Log.d("DEBUG", "Unknown cmd received from ESP32: 0x" + Integer.toHexString(cmd & 0xFF) +
14391464
" paramLen=" + param.length);

android-src/KV4PHT/app/src/main/res/layout/activity_firmware.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
android:fontFamily="@font/jost"
7979
android:text="Keep your phone screen on, this app open, and don’t unplug your kv4p HT until flashing is done.\n
8080
\n
81-
This usually takes 5-10 minutes."
81+
This usually takes about 30 seconds."
8282
android:textColor="@color/primary_deselected"
8383
android:textSize="20dp"
8484
android:visibility="gone"/>
Binary file not shown.

android-src/KV4PHT/app/src/main/res/raw/v11_kv4p_ht_esp32_wroom_32_ino_bootloader.bin renamed to android-src/KV4PHT/app/src/main/res/raw/v12_kv4p_ht_esp32_wroom_32_ino_bootloader.bin

File renamed without changes.

android-src/KV4PHT/app/src/main/res/raw/v11_kv4p_ht_esp32_wroom_32_ino_partitions.bin renamed to android-src/KV4PHT/app/src/main/res/raw/v12_kv4p_ht_esp32_wroom_32_ino_partitions.bin

File renamed without changes.

0 commit comments

Comments
 (0)