mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-09 15:17:24 -05:00
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -33,6 +33,7 @@ public class HackRFTunerConfiguration extends TunerConfiguration
|
||||
private HackRFLNAGain mLNAGain = HackRFLNAGain.GAIN_16; // We can see some signal at this gain
|
||||
private HackRFVGAGain mVGAGain = HackRFVGAGain.GAIN_16; // We can see some signal at this gain
|
||||
private boolean mAmplifierEnabled = false; //Probably should start off disabled
|
||||
private boolean mBiasTEnabled = false;
|
||||
|
||||
/**
|
||||
* Default constructor for JAXB
|
||||
@@ -65,6 +66,23 @@ public class HackRFTunerConfiguration extends TunerConfiguration
|
||||
mAmplifierEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the Bias-T antenna port power is enabled.
|
||||
*/
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "bias_t")
|
||||
public boolean isBiasT()
|
||||
{
|
||||
return mBiasTEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the Bias-T antenna port power.
|
||||
*/
|
||||
public void setBiasT(boolean enabled)
|
||||
{
|
||||
mBiasTEnabled = enabled;
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "lna_gain")
|
||||
public HackRFLNAGain getLNAGain()
|
||||
{
|
||||
|
||||
@@ -73,6 +73,7 @@ public class HackRFTunerController extends TunerController
|
||||
private String mFirmwareVersion;
|
||||
private HackRFSampleRate mSampleRate = HackRFSampleRate.RATE_5_0;
|
||||
private boolean mAmplifierEnabled = false;
|
||||
private boolean mBiasTEnabled = false;
|
||||
private volatile int mBufferSampleCount = DEFAULT_BUFFER_SAMPLE_COUNT;
|
||||
private boolean mStreaming = false;
|
||||
|
||||
@@ -198,6 +199,15 @@ public class HackRFTunerController extends TunerController
|
||||
{
|
||||
if(device != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
device.setAntennaEnable(false);
|
||||
}
|
||||
catch(HackRfException | RuntimeException e)
|
||||
{
|
||||
mLog.error("Error disabling HackRF Bias-T antenna power", e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
device.close();
|
||||
@@ -413,6 +423,12 @@ public class HackRFTunerController extends TunerController
|
||||
{
|
||||
execute(device -> device.startRx(this::receive));
|
||||
mStreaming = mDevice != null;
|
||||
|
||||
//The firmware turns off antenna power when the transceiver returns to idle, so restore it
|
||||
if(mBiasTEnabled)
|
||||
{
|
||||
execute(device -> device.setAntennaEnable(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,6 +556,20 @@ public class HackRFTunerController extends TunerController
|
||||
return mAmplifierEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables (true) or disables (false) the Bias-T power on the antenna port.
|
||||
*/
|
||||
public void setBiasTEnabled(boolean enabled) throws SourceException
|
||||
{
|
||||
execute(device -> device.setAntennaEnable(enabled));
|
||||
mBiasTEnabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isBiasTEnabled()
|
||||
{
|
||||
return mBiasTEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IF LNA Gain
|
||||
*/
|
||||
@@ -602,6 +632,7 @@ public class HackRFTunerController extends TunerController
|
||||
{
|
||||
setSampleRate(hackRFConfig.getSampleRate());
|
||||
setAmplifierEnabled(hackRFConfig.getAmplifierEnabled());
|
||||
setBiasTEnabled(hackRFConfig.isBiasT());
|
||||
setLNAGain(hackRFConfig.getLNAGain());
|
||||
setVGAGain(hackRFConfig.getVGAGain());
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
private JButton mTunerInfo;
|
||||
private JComboBox<HackRFSampleRate> mSampleRateCombo;
|
||||
private JToggleButton mAmplifier;
|
||||
private JToggleButton mBiasT;
|
||||
private JComboBox<HackRFLNAGain> mLnaGainCombo;
|
||||
private JComboBox<HackRFVGAGain> mVgaGainCombo;
|
||||
|
||||
@@ -80,7 +81,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
||||
"[][][][][][][][][][][grow]"));
|
||||
"[][][][][][][][][][][][grow]"));
|
||||
|
||||
add(new JLabel("Tuner:"));
|
||||
add(getTunerIdLabel());
|
||||
@@ -109,6 +110,12 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
|
||||
add(new JLabel("VGA:"));
|
||||
add(getVgaGainCombo(), "wrap");
|
||||
|
||||
add(new JLabel("Bias-T:"));
|
||||
add(getBiasTToggle(), "wrap");
|
||||
|
||||
//Empty filler row that grows to take up the remaining vertical space
|
||||
add(new JLabel(), "span,grow,push");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,6 +144,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
getTunerInfoButton().setEnabled(hasTuner());
|
||||
|
||||
getAmplifierToggle().setEnabled(hasTuner());
|
||||
getBiasTToggle().setEnabled(hasTuner());
|
||||
getLnaGainCombo().setEnabled(hasTuner());
|
||||
getVgaGainCombo().setEnabled(hasTuner());
|
||||
|
||||
@@ -144,6 +152,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
{
|
||||
getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate());
|
||||
getAmplifierToggle().setSelected(getConfiguration().getAmplifierEnabled());
|
||||
getBiasTToggle().setSelected(getConfiguration().isBiasT());
|
||||
getLnaGainCombo().setSelectedItem(getConfiguration().getLNAGain());
|
||||
getVgaGainCombo().setSelectedItem(getConfiguration().getVGAGain());
|
||||
}
|
||||
@@ -254,6 +263,38 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
return mAmplifier;
|
||||
}
|
||||
|
||||
private JToggleButton getBiasTToggle()
|
||||
{
|
||||
if(mBiasT == null)
|
||||
{
|
||||
mBiasT = new JToggleButton("Disabled");
|
||||
mBiasT.setToolTipText("Enable or disable Bias-T power (3.3V) on the antenna port for active antennas or LNAs");
|
||||
mBiasT.setEnabled(false);
|
||||
//Item listener also fires for programmatic setSelected() when the configuration loads
|
||||
mBiasT.addItemListener(e -> mBiasT.setText(mBiasT.isSelected() ? "Enabled" : "Disabled"));
|
||||
mBiasT.addActionListener(arg0 ->
|
||||
{
|
||||
if(!isLoading())
|
||||
{
|
||||
try
|
||||
{
|
||||
getTuner().getController().setBiasTEnabled(mBiasT.isSelected());
|
||||
save();
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
mLog.error("couldn't enable/disable bias-t", e);
|
||||
|
||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "Couldn't change Bias-T setting",
|
||||
"Error changing Bias-T setting", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return mBiasT;
|
||||
}
|
||||
|
||||
private JComboBox getSampleRateCombo()
|
||||
{
|
||||
if(mSampleRateCombo == null)
|
||||
@@ -371,6 +412,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
||||
getConfiguration().setSampleRate((HackRFSampleRate)getSampleRateCombo().getSelectedItem());
|
||||
getConfiguration().setAmplifierEnabled(getAmplifierToggle().isSelected());
|
||||
getConfiguration().setBiasT(getBiasTToggle().isSelected());
|
||||
getConfiguration().setLNAGain((HackRFLNAGain)getLnaGainCombo().getSelectedItem());
|
||||
getConfiguration().setVGAGain((HackRFVGAGain)getVgaGainCombo().getSelectedItem());
|
||||
saveConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user