kopia lustrzana https://github.com/sh123/codec2_talkie
Support for icom cat ptt control
rodzic
e016e16df1
commit
4de9298b7b
|
@ -21,6 +21,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.hoho.android.usbserial.driver.CdcAcmSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.Cp21xxSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.ProbeTable;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialPort;
|
||||
|
@ -94,6 +95,8 @@ public class UsbConnectActivity extends AppCompatActivity {
|
|||
customTable.addProduct(0x2341, 0x003d, CdcAcmSerialDriver.class);
|
||||
// STM, MCHF
|
||||
customTable.addProduct(0x0483, 0x5732, CdcAcmSerialDriver.class);
|
||||
// CP2102/2109, iCom
|
||||
customTable.addProduct(0x10c4, 0xea60, Cp21xxSerialDriver.class);
|
||||
return new UsbSerialProber(customTable);
|
||||
}
|
||||
|
||||
|
@ -115,34 +118,37 @@ public class UsbConnectActivity extends AppCompatActivity {
|
|||
return;
|
||||
}
|
||||
|
||||
UsbSerialDriver driver = availableDrivers.get(0);
|
||||
UsbDeviceConnection connection = manager.openDevice(driver.getDevice());
|
||||
if (connection == null) {
|
||||
resultMsg.what = USB_NOT_FOUND;
|
||||
onUsbStateChanged.sendMessage(resultMsg);
|
||||
return;
|
||||
}
|
||||
UsbSerialPort port = driver.getPorts().get(0);
|
||||
if (port == null) {
|
||||
resultMsg.what = USB_NOT_FOUND;
|
||||
onUsbStateChanged.sendMessage(resultMsg);
|
||||
return;
|
||||
}
|
||||
boolean isFound = false;
|
||||
for (int i = 0; i < availableDrivers.size(); i++) {
|
||||
UsbSerialDriver driver = availableDrivers.get(i);
|
||||
UsbDeviceConnection connection = manager.openDevice(driver.getDevice());
|
||||
if (connection == null) {
|
||||
continue;
|
||||
}
|
||||
UsbSerialPort port = driver.getPorts().get(i);
|
||||
if (port == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
port.open(connection);
|
||||
port.setParameters(_baudRate, _dataBits, _stopBits, _parity);
|
||||
port.setDTR(_enableDtr);
|
||||
port.setRTS(_enableRts);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
port.open(connection);
|
||||
port.setParameters(_baudRate, _dataBits, _stopBits, _parity);
|
||||
port.setDTR(_enableDtr);
|
||||
port.setRTS(_enableRts);
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
}
|
||||
_usbPort = port;
|
||||
_usbDeviceName = port.getClass().getSimpleName().replace("SerialDriver", "");
|
||||
resultMsg.what = USB_CONNECTED;
|
||||
onUsbStateChanged.sendMessage(resultMsg);
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
if (!isFound) {
|
||||
resultMsg.what = USB_NOT_FOUND;
|
||||
onUsbStateChanged.sendMessage(resultMsg);
|
||||
return;
|
||||
}
|
||||
_usbPort = port;
|
||||
_usbDeviceName = port.getClass().getSimpleName().replace("SerialDriver","");
|
||||
resultMsg.what = USB_CONNECTED;
|
||||
onUsbStateChanged.sendMessage(resultMsg);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.radio.codec2talkie.rigctl;
|
||||
|
||||
public class Ic7000 extends Icom {
|
||||
@Override
|
||||
protected byte getCivAddress() {
|
||||
return (byte)0x70;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.radio.codec2talkie.rigctl;
|
||||
|
||||
public class Ic7100 extends Icom {
|
||||
@Override
|
||||
protected byte getCivAddress() {
|
||||
return (byte)0x88;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.radio.codec2talkie.rigctl;
|
||||
|
||||
public class Ic7200 extends Icom {
|
||||
@Override
|
||||
protected byte getCivAddress() {
|
||||
return (byte)0x76;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.radio.codec2talkie.rigctl;
|
||||
|
||||
public class Ic7300 extends Icom {
|
||||
@Override
|
||||
protected byte getCivAddress() {
|
||||
return (byte)0x94;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.radio.codec2talkie.rigctl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.radio.codec2talkie.transport.Transport;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public abstract class Icom implements RigCtl {
|
||||
private static final String TAG = Icom.class.getSimpleName();
|
||||
|
||||
private static final byte PREAMBLE_CODE = (byte)0xfe;
|
||||
private static final byte END_CODE = (byte)0xfd;
|
||||
private static final byte CTRL_ADDRESS = (byte)0xe0;
|
||||
|
||||
private Transport _transport;
|
||||
|
||||
@Override
|
||||
public void initialize(Transport transport, Context context, RigCtlCallback protocolCallback) throws IOException {
|
||||
_transport = transport;
|
||||
}
|
||||
|
||||
protected byte getCivAddress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pttOn() throws IOException {
|
||||
Log.i(TAG, String.format("PTT ON 0x%x", getCivAddress()));
|
||||
ByteBuffer cmd = ByteBuffer.allocate(8);
|
||||
cmd.put(PREAMBLE_CODE)
|
||||
.put(PREAMBLE_CODE)
|
||||
.put(getCivAddress())
|
||||
.put(CTRL_ADDRESS)
|
||||
.put((byte)0x1c)
|
||||
.put((byte)0x00)
|
||||
.put((byte)0x01)
|
||||
.put(END_CODE);
|
||||
_transport.write(cmd.array());
|
||||
Log.i(TAG, "PTT ON done");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pttOff() throws IOException {
|
||||
Log.i(TAG, String.format("PTT OFF 0x%x", getCivAddress()));
|
||||
ByteBuffer cmd = ByteBuffer.allocate(8);
|
||||
cmd.put(PREAMBLE_CODE)
|
||||
.put(PREAMBLE_CODE)
|
||||
.put(getCivAddress())
|
||||
.put(CTRL_ADDRESS)
|
||||
.put((byte)0x1c)
|
||||
.put((byte)0x00)
|
||||
.put((byte)0x00)
|
||||
.put(END_CODE);
|
||||
_transport.write(cmd.array());
|
||||
Log.i(TAG, "PTT OFF done");
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ public final class PreferenceKeys {
|
|||
public static String PORTS_SOUND_MODEM_DISABLE_RX = "ports_sound_modem_disable_rx";
|
||||
public static String PORTS_SOUND_MODEM_RIG = "ports_sound_modem_rig";
|
||||
public static String PORTS_SOUND_MODEM_GAIN ="ports_sound_modem_gain";
|
||||
public static final String PORTS_SOUND_MODEM_PTT_OFF_DELAY_MS = "ports_sound_modem_ptt_off_delay_ms";
|
||||
|
||||
public static String CODEC2_MODE = "codec2_mode";
|
||||
public static String CODEC2_RECORDING_ENABLED = "codec2_recording_enabled";
|
||||
|
|
|
@ -37,7 +37,8 @@ public class SettingsActivity extends AppCompatActivity
|
|||
"ports_tcp_ip_port",
|
||||
"ports_tcp_ip_retry_count",
|
||||
"ports_tcp_ip_retry_delay",
|
||||
"ports_sound_modem_preamble"
|
||||
"ports_sound_modem_preamble",
|
||||
"ports_sound_modem_ptt_off_delay_ms"
|
||||
};
|
||||
|
||||
private static final String[] _signedDecimalSettings = {
|
||||
|
|
|
@ -31,8 +31,6 @@ public class SoundModem implements Transport, Runnable {
|
|||
|
||||
private static final String TAG = SoundModem.class.getSimpleName();
|
||||
|
||||
private static final int PTT_OFF_DELAY_MS = 1000;
|
||||
|
||||
// NOTE, codec2 library requires that sample_rate % bit_rate == 0
|
||||
public static final int SAMPLE_RATE = 19200;
|
||||
//public static final int SAMPLE_RATE = 48000;
|
||||
|
@ -62,6 +60,7 @@ public class SoundModem implements Transport, Runnable {
|
|||
private final RigCtl _rigCtl;
|
||||
private Timer _pttOffTimer;
|
||||
private boolean _isPttOn = false;
|
||||
private int _pttOffDelayMs = 1000;
|
||||
|
||||
public SoundModem(Context context) {
|
||||
_context = context;
|
||||
|
@ -70,6 +69,7 @@ public class SoundModem implements Transport, Runnable {
|
|||
boolean disableRx = _sharedPreferences.getBoolean(PreferenceKeys.PORTS_SOUND_MODEM_DISABLE_RX, false);
|
||||
int bitRate = Integer.parseInt(_sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_TYPE, "1200"));
|
||||
int gain = Integer.parseInt(_sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_GAIN, "10000"));
|
||||
_pttOffDelayMs = Integer.parseInt(_sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_PTT_OFF_DELAY_MS, "1000"));
|
||||
_name = "SoundModem" + bitRate;
|
||||
if (bitRate == 300) {
|
||||
// <230 spacing for 300 bps does not work with codec2 fsk for receive
|
||||
|
@ -304,6 +304,6 @@ public class SoundModem implements Transport, Runnable {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, PTT_OFF_DELAY_MS);
|
||||
}, _pttOffDelayMs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,14 +356,26 @@
|
|||
<string-array name="ports_sound_modem_rig_entries">
|
||||
<item>Do not use rig control</item>
|
||||
<item>FT-817/818/MCHF</item>
|
||||
<item>IC-7000</item>
|
||||
<item>IC-7100</item>
|
||||
<item>IC-7200</item>
|
||||
<item>IC-7300</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ports_sound_modem_rig_values">
|
||||
<item>Disabled</item>
|
||||
<item>Ft817</item>
|
||||
<item>Ic7000</item>
|
||||
<item>Ic7100</item>
|
||||
<item>Ic7200</item>
|
||||
<item>Ic7300</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ports_sound_modem_gain_entries">
|
||||
<item>-4 db</item>
|
||||
<item>-3 db</item>
|
||||
<item>-2 db</item>
|
||||
<item>-1 db</item>
|
||||
<item>+0 db</item>
|
||||
<item>+1 db</item>
|
||||
<item>+2 db</item>
|
||||
|
@ -380,6 +392,10 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="ports_sound_modem_gain_values">
|
||||
<item>398</item>
|
||||
<item>501</item>
|
||||
<item>630</item>
|
||||
<item>794</item>
|
||||
<item>1000</item>
|
||||
<item>1258</item>
|
||||
<item>1584</item>
|
||||
|
|
|
@ -305,4 +305,6 @@
|
|||
<string name="ports_sound_modem_rig_title">Select RIG model for CAT PTT control</string>
|
||||
<string name="ports_sound_modem_gain_title">Set modem audio gain</string>
|
||||
<string name="ports_sound_modem_rig_label">🎛</string>
|
||||
<string name="ports_sound_modem_ptt_off_delay_ms_title">CAT PTT transmit off delay</string>
|
||||
<string name="ports_sound_modem_ptt_off_delay_ms_summary">How long to wait before switching off the transmission after last data is sent out (milliseconds)</string>
|
||||
</resources>
|
|
@ -31,4 +31,6 @@
|
|||
|
||||
<!-- RIG CAT control -->
|
||||
<usb-device vendor-id="1155" product-id="22322" /> <!-- 0x0483 / 0x5732: STM, MCHF -->
|
||||
<usb-device vendor-id="4292" product-id="60000" /> <!-- 0x10c4 / 0xea60: CP2102/2109, iCom -->
|
||||
|
||||
</resources>
|
|
@ -47,5 +47,12 @@
|
|||
app:summary="%s">
|
||||
</ListPreference>
|
||||
|
||||
<EditTextPreference
|
||||
app:key="ports_sound_modem_ptt_off_delay_ms"
|
||||
app:title="@string/ports_sound_modem_ptt_off_delay_ms_title"
|
||||
app:summary="@string/ports_sound_modem_ptt_off_delay_ms_summary"
|
||||
app:defaultValue="1000">
|
||||
</EditTextPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Ładowanie…
Reference in New Issue