Skip to content

Commit

Permalink
Remove previous feature, needs another approach
Browse files Browse the repository at this point in the history
  • Loading branch information
sh123 committed Feb 19, 2024
1 parent ad6e790 commit fb809eb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
4 changes: 2 additions & 2 deletions codec2talkie/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.radio.codec2talkie"
minSdkVersion 23
targetSdkVersion 30
versionCode 169
versionName "1.69"
versionCode 170
versionName "1.70"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static Transport create(TransportType transportType, Context context) thr

switch (transportType) {
case USB:
return new UsbSerial(UsbPortHandler.getPort(), UsbPortHandler.getName(), context);
return new UsbSerial(UsbPortHandler.getPort(), UsbPortHandler.getName());
case BLUETOOTH:
return new Bluetooth(BluetoothSocketHandler.getSocket(), BluetoothSocketHandler.getName());
case TCP_IP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,9 @@ public class UsbSerial implements Transport {
private final UsbSerialPort _usbPort;
private final String _name;

private final boolean _isPrefixEnabled;
private final byte[] _bytePrefix;

protected SharedPreferences _sharedPreferences;

public UsbSerial(UsbSerialPort usbPort, String name, Context context) {
public UsbSerial(UsbSerialPort usbPort, String name) {
_usbPort = usbPort;
_name = name;
_sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
_isPrefixEnabled = _sharedPreferences.getBoolean(PreferenceKeys.PORTS_USB_IS_PREFIX_ENABLED, false);
String prefix = _sharedPreferences.getString(PreferenceKeys.PORTS_USB_PREFIX, "");
_bytePrefix = TextTools.hexStringToByteArray(prefix);
}

@Override
Expand All @@ -48,15 +39,7 @@ public int read(byte[] data) throws IOException {
@Override
public int write(byte[] data) throws IOException {
try {
if (_isPrefixEnabled) {
byte[] pkt = ByteBuffer.allocate(_bytePrefix.length + data.length)
.put(_bytePrefix)
.put(data)
.array();
_usbPort.write(pkt, TX_TIMEOUT);
} else {
_usbPort.write(data, TX_TIMEOUT);
}
_usbPort.write(data, TX_TIMEOUT);
return data.length;
} catch (SerialTimeoutException e) {
e.printStackTrace();
Expand Down
2 changes: 0 additions & 2 deletions codec2talkie/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@
<string name="usb_serial_summary">Set USB serial settings, such as speed, bits, parity, etc.</string>
<string name="usb_is_prefix_enabled_title">Enable USB packet prefix</string>
<string name="usb_is_prefix_enabled_summary">Prefix USB data with the HEX string for LoRA UART modems</string>
<string name="usb_prefix_title">USB packet prefix value as HEX string</string>
<string name="usb_prefix_summary">Prefix sent content with a hex string (so called transmission target in UART modems), e.g. C0FFEE</string>

<string name="app_audio_output_speaker_title">Play audio through the speaker</string>
<string name="app_audio_output_speaker_summary">Output incoming audio through the speaker</string>
Expand Down
15 changes: 0 additions & 15 deletions codec2talkie/src/main/res/xml/preferences_usb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,5 @@
app:defaultValue="false">
</CheckBoxPreference>

<CheckBoxPreference
app:key="ports_usb_is_prefix_enabled"
app:title="@string/usb_is_prefix_enabled_title"
app:summary="@string/usb_is_prefix_enabled_summary"
app:defaultValue="false">
</CheckBoxPreference>
</PreferenceCategory>

<EditTextPreference
app:key="ports_usb_prefix"
app:title="@string/usb_prefix_title"
app:summary = "@string/usb_prefix_summary"
app:dependency="ports_usb_is_prefix_enabled"
app:defaultValue="C0FFEE">
</EditTextPreference>

</PreferenceScreen>

0 comments on commit fb809eb

Please sign in to comment.