kopia lustrzana https://github.com/N0BOY/FT8CN
rodzic
c731f6e507
commit
8f5975b107
|
@ -734,13 +734,6 @@ public class MainViewModel extends ViewModel {
|
||||||
* 根据指令集创建不同型号的电台
|
* 根据指令集创建不同型号的电台
|
||||||
*/
|
*/
|
||||||
private void connectRig() {
|
private void connectRig() {
|
||||||
if ((GeneralVariables.instructionSet == InstructionSet.FLEX_NETWORK)
|
|
||||||
|| (GeneralVariables.instructionSet == InstructionSet.ICOM
|
|
||||||
&& GeneralVariables.connectMode == ConnectMode.NETWORK)) {
|
|
||||||
hamRecorder.setDataFromLan();
|
|
||||||
} else {
|
|
||||||
hamRecorder.setDataFromMic();
|
|
||||||
}
|
|
||||||
baseRig = null;
|
baseRig = null;
|
||||||
//此处判断是用什么类型的电台,ICOM,YAESU 2,YAESU 3
|
//此处判断是用什么类型的电台,ICOM,YAESU 2,YAESU 3
|
||||||
switch (GeneralVariables.instructionSet) {
|
switch (GeneralVariables.instructionSet) {
|
||||||
|
@ -799,6 +792,18 @@ public class MainViewModel extends ViewModel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((GeneralVariables.instructionSet == InstructionSet.FLEX_NETWORK)
|
||||||
|
|| (GeneralVariables.instructionSet == InstructionSet.ICOM
|
||||||
|
&& GeneralVariables.connectMode == ConnectMode.NETWORK)) {
|
||||||
|
hamRecorder.setDataFromLan();
|
||||||
|
} else {
|
||||||
|
if (GeneralVariables.controlMode != ControlMode.CAT || baseRig == null || !baseRig.supportWaveOverCAT()) {
|
||||||
|
hamRecorder.setDataFromMic();
|
||||||
|
} else {
|
||||||
|
hamRecorder.setDataFromLan();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mutableIsFlexRadio.postValue(GeneralVariables.instructionSet == InstructionSet.FLEX_NETWORK);
|
mutableIsFlexRadio.postValue(GeneralVariables.instructionSet == InstructionSet.FLEX_NETWORK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.bg7yoz.ft8cn.R;
|
||||||
import com.bg7yoz.ft8cn.database.ControlMode;
|
import com.bg7yoz.ft8cn.database.ControlMode;
|
||||||
import com.bg7yoz.ft8cn.ui.ToastMessage;
|
import com.bg7yoz.ft8cn.ui.ToastMessage;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
@ -21,6 +22,7 @@ import java.util.TimerTask;
|
||||||
public class TrUSDXRig extends BaseRig {
|
public class TrUSDXRig extends BaseRig {
|
||||||
private static final String TAG = "TrUSDXRig";
|
private static final String TAG = "TrUSDXRig";
|
||||||
private final StringBuilder buffer = new StringBuilder();
|
private final StringBuilder buffer = new StringBuilder();
|
||||||
|
private final ByteArrayOutputStream rxStreamBuffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
private Timer readFreqTimer = new Timer();
|
private Timer readFreqTimer = new Timer();
|
||||||
private int swr=0;
|
private int swr=0;
|
||||||
|
@ -126,7 +128,7 @@ public class TrUSDXRig extends BaseRig {
|
||||||
s = new String(remain);
|
s = new String(remain);
|
||||||
|
|
||||||
if (rxStreaming) {
|
if (rxStreaming) {
|
||||||
onReceivedWaveData(cutted);
|
onReceivedWaveData(cutted, true);
|
||||||
rxStreaming = false;
|
rxStreaming = false;
|
||||||
} else {
|
} else {
|
||||||
buffer.append(new String(cutted));
|
buffer.append(new String(cutted));
|
||||||
|
@ -135,7 +137,7 @@ public class TrUSDXRig extends BaseRig {
|
||||||
clearBufferData();//清一下缓存
|
clearBufferData();//清一下缓存
|
||||||
|
|
||||||
if (yaesu3Command == null) {
|
if (yaesu3Command == null) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
String cmd=yaesu3Command.getCommandID();
|
String cmd=yaesu3Command.getCommandID();
|
||||||
Log.i(TAG, "command: " + cmd);
|
Log.i(TAG, "command: " + cmd);
|
||||||
|
@ -152,13 +154,19 @@ public class TrUSDXRig extends BaseRig {
|
||||||
alc = Yaesu3Command.get590ALCOrSWR(yaesu3Command);
|
alc = Yaesu3Command.get590ALCOrSWR(yaesu3Command);
|
||||||
}
|
}
|
||||||
showAlert();
|
showAlert();
|
||||||
|
}else if (cmd.equalsIgnoreCase("US")){
|
||||||
|
rxStreaming = true;
|
||||||
|
byte[] wave = Arrays.copyOfRange(cutted, 2, cutted.length);
|
||||||
|
onReceivedWaveData(wave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (remain.length <= 0) {
|
if (remain.length <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (remain.length >= 2 && remain[0] == 0x55 && remain[1] == 0x53) {// US
|
if (rxStreaming) {
|
||||||
|
onReceivedWaveData(remain);
|
||||||
|
} else if (remain.length >= 2 && remain[0] == 0x55 && remain[1] == 0x53) {// US
|
||||||
clearBufferData();
|
clearBufferData();
|
||||||
rxStreaming = true;
|
rxStreaming = true;
|
||||||
byte[] wave = Arrays.copyOfRange(remain, 2, remain.length);
|
byte[] wave = Arrays.copyOfRange(remain, 2, remain.length);
|
||||||
|
@ -201,7 +209,7 @@ public class TrUSDXRig extends BaseRig {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportWaveOverCAT() {
|
public boolean supportWaveOverCAT() {
|
||||||
return getConnector() != null && getControlMode() == ControlMode.CAT;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,16 +221,25 @@ public class TrUSDXRig extends BaseRig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceivedWaveData(byte[] data) {
|
public void onReceivedWaveData(byte[] data) {
|
||||||
|
onReceivedWaveData(data, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceivedWaveData(byte[] data, boolean force) {
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getConnector() == null) {
|
if (getConnector() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//float[] resampled = TrUSDXRig.resampler(data, rxSampling, 44000); // 44KHz
|
rxStreamBuffer.write(data, 0, data.length);
|
||||||
float[] resampled = TrUSDXRig.resampler(data, rxSampling, 12000); // 12KHz
|
if (rxStreamBuffer.size() >= 512 || force) {
|
||||||
|
byte[] wave = rxStreamBuffer.toByteArray();
|
||||||
|
rxStreamBuffer.reset();
|
||||||
|
float[] resampled = TrUSDXRig.resampler(wave, rxSampling, 48000); // 48KHz
|
||||||
|
//float[] resampled = TrUSDXRig.resampler(data, rxSampling, 12000); // 12KHz
|
||||||
getConnector().receiveWaveData(resampled);
|
getConnector().receiveWaveData(resampled);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static float[] resampler(byte[] data, int oldSampleRate, int newSampleRate) {
|
static float[] resampler(byte[] data, int oldSampleRate, int newSampleRate) {
|
||||||
float rate = (float)newSampleRate / oldSampleRate;
|
float rate = (float)newSampleRate / oldSampleRate;
|
||||||
|
|
Ładowanie…
Reference in New Issue