mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#36 NBFM squelch control. Updates NBFM decoder to incorporate squelch control. Squelch is a configuration item and also available to adjust at runtime with new 'Channel' tab in Now Playing window. All decoders were updated to produce continuous channel power (dB) measurements that are displayed in the Channel tab's new Power Meter. (#1100)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -21,14 +21,20 @@ package io.github.dsheirer.module.decode.nbfm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import io.github.dsheirer.dsp.squelch.ISquelchConfiguration;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
|
||||
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
|
||||
|
||||
public class DecodeConfigNBFM extends DecodeConfiguration
|
||||
/**
|
||||
* Decoder configuration for an NBFM channel
|
||||
*/
|
||||
public class DecodeConfigNBFM extends DecodeConfiguration implements ISquelchConfiguration
|
||||
{
|
||||
private Bandwidth mBandwidth = Bandwidth.BW_12_5;
|
||||
private boolean mRecordAudio = false;
|
||||
private Boolean mRecordAudio;
|
||||
private int mTalkgroup = 1;
|
||||
private int mSquelchThreshold = -60;
|
||||
|
||||
public DecodeConfigNBFM()
|
||||
{
|
||||
@@ -71,27 +77,74 @@ public class DecodeConfigNBFM extends DecodeConfiguration
|
||||
mBandwidth = bandwidth;
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "recordAudio")
|
||||
public boolean getRecordAudio()
|
||||
// @Deprecated //No longer used: 20211107
|
||||
// @JacksonXmlProperty(isAttribute = true, localName = "recordAudio")
|
||||
// public boolean getRecordAudio()
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Deprecated //No longer used: 20211107
|
||||
// public void setRecordAudio(boolean recordAudio)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* Talkgroup to associate with audio produced by the NBFM decoder
|
||||
*/
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "talkgroup")
|
||||
public int getTalkgroup()
|
||||
{
|
||||
return mRecordAudio;
|
||||
return mTalkgroup;
|
||||
}
|
||||
|
||||
public void setRecordAudio(boolean recordAudio)
|
||||
/**
|
||||
* Sets the talkgroup identifier to attach to any demodulated audio streams
|
||||
* @param talkgroup (1-65,535)
|
||||
*/
|
||||
public void setTalkgroup(int talkgroup)
|
||||
{
|
||||
mRecordAudio = recordAudio;
|
||||
if(talkgroup < 1 || talkgroup > 65535)
|
||||
{
|
||||
throw new IllegalArgumentException("Valid talkgroup range is 1 - 65,535");
|
||||
}
|
||||
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets squelch threshold
|
||||
* @param threshold (dB)
|
||||
*/
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "squelch")
|
||||
@Override
|
||||
public void setSquelchThreshold(int threshold)
|
||||
{
|
||||
mSquelchThreshold = threshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Squelch threshold
|
||||
* @return threshold (dB)
|
||||
*/
|
||||
@Override
|
||||
public int getSquelchThreshold()
|
||||
{
|
||||
return mSquelchThreshold;
|
||||
}
|
||||
|
||||
public enum Bandwidth
|
||||
{
|
||||
BW_12_5("12.5 kHz"),
|
||||
BW_25_0("25.0 kHz");
|
||||
BW_12_5("12.5 kHz", 12500.0),
|
||||
BW_25_0("25.0 kHz", 25000.0);
|
||||
|
||||
private String mLabel;
|
||||
private double mValue;
|
||||
|
||||
Bandwidth(String label)
|
||||
Bandwidth(String label, double value)
|
||||
{
|
||||
mLabel = label;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,5 +152,10 @@ public class DecodeConfigNBFM extends DecodeConfiguration
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,62 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.decode.nbfm;
|
||||
|
||||
|
||||
import io.github.dsheirer.channel.state.DecoderStateEvent;
|
||||
import io.github.dsheirer.channel.state.IDecoderStateEventProvider;
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.dsp.filter.FilterFactory;
|
||||
import io.github.dsheirer.dsp.filter.Window;
|
||||
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
|
||||
import io.github.dsheirer.dsp.filter.fir.FIRFilterSpecification;
|
||||
import io.github.dsheirer.dsp.filter.fir.complex.ComplexFIRFilter2;
|
||||
import io.github.dsheirer.dsp.filter.resample.RealResampler;
|
||||
import io.github.dsheirer.dsp.fm.SquelchingFMDemodulator;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.PrimaryDecoder;
|
||||
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.IReusableBufferProvider;
|
||||
import io.github.dsheirer.sample.buffer.IReusableComplexBufferListener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.sample.buffer.ReusableFloatBuffer;
|
||||
import io.github.dsheirer.source.ISourceEventListener;
|
||||
import io.github.dsheirer.source.ISourceEventProvider;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NBFMDecoder extends PrimaryDecoder
|
||||
/**
|
||||
* Decoder module with integrated narrowband FM (12.5 or 25.0 kHz channel) demodulator
|
||||
*/
|
||||
public class NBFMDecoder extends PrimaryDecoder implements ISourceEventListener, ISourceEventProvider,
|
||||
IReusableComplexBufferListener, Listener<ReusableComplexBuffer>, IReusableBufferProvider,
|
||||
IDecoderStateEventProvider
|
||||
{
|
||||
public NBFMDecoder( DecodeConfiguration config )
|
||||
private final static Logger mLog = LoggerFactory.getLogger(NBFMDecoder.class);
|
||||
private static final double DEMODULATED_AUDIO_SAMPLE_RATE = 8000.0;
|
||||
private static final double POWER_SQUELCH_ALPHA_DECAY = 0.0002;
|
||||
private static final double POWER_SQUELCH_THRESHOLD_DB = -78.0;
|
||||
private static final int POWER_SQUELCH_RAMP = 4;
|
||||
|
||||
private ComplexFIRFilter2 mIQFilter;
|
||||
private SquelchingFMDemodulator mDemodulator = new SquelchingFMDemodulator(POWER_SQUELCH_ALPHA_DECAY,
|
||||
POWER_SQUELCH_THRESHOLD_DB, POWER_SQUELCH_RAMP);
|
||||
private RealResampler mResampler;
|
||||
private SourceEventProcessor mSourceEventProcessor = new SourceEventProcessor();
|
||||
private Listener<ReusableFloatBuffer> mResampledReusableBufferListener;
|
||||
private Listener<DecoderStateEvent> mDecoderStateEventListener;
|
||||
private double mChannelBandwidth;
|
||||
private double mOutputSampleRate = DEMODULATED_AUDIO_SAMPLE_RATE;
|
||||
private boolean mSquelch = true;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param config to setup the decoder
|
||||
*/
|
||||
public NBFMDecoder( DecodeConfigNBFM config )
|
||||
{
|
||||
super( config );
|
||||
mChannelBandwidth = config.getBandwidth().getValue();
|
||||
mDemodulator.setSquelchThreshold(config.getSquelchThreshold());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,9 +81,22 @@ public class NBFMDecoder extends PrimaryDecoder
|
||||
return DecoderType.NBFM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<ReusableComplexBuffer> getReusableComplexBufferListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<SourceEvent> getSourceEventListener()
|
||||
{
|
||||
return mSourceEventProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
mDemodulator.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,4 +108,232 @@ public class NBFMDecoder extends PrimaryDecoder
|
||||
public void stop()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferListener(Listener<ReusableFloatBuffer> listener)
|
||||
{
|
||||
mResampledReusableBufferListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBufferListener()
|
||||
{
|
||||
mResampledReusableBufferListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(ReusableComplexBuffer reusableComplexBuffer)
|
||||
{
|
||||
if(mIQFilter == null)
|
||||
{
|
||||
reusableComplexBuffer.decrementUserCount();
|
||||
throw new IllegalStateException("NBFM demodulator module must receive a sample rate change source " +
|
||||
"event before it can process complex sample buffers");
|
||||
}
|
||||
|
||||
ReusableComplexBuffer basebandFilteredBuffer = mIQFilter.filter(reusableComplexBuffer);
|
||||
ReusableFloatBuffer demodulatedBuffer = mDemodulator.demodulate(basebandFilteredBuffer);
|
||||
|
||||
if(mResampler != null)
|
||||
{
|
||||
//If we're currently squelched and the squelch state changed while demodulating the baseband samples,
|
||||
// then un-squelch so we can send this buffer
|
||||
if(mSquelch && mDemodulator.isSquelchChanged())
|
||||
{
|
||||
mSquelch = false;
|
||||
notifyCallStart();
|
||||
}
|
||||
|
||||
//Either send the demodulated buffer to the resampler for distro, or decrement the user count
|
||||
if(mSquelch)
|
||||
{
|
||||
demodulatedBuffer.incrementUserCount();
|
||||
notifyIdle();
|
||||
}
|
||||
else
|
||||
{
|
||||
mResampler.resample(demodulatedBuffer);
|
||||
notifyCallContinuation();
|
||||
}
|
||||
|
||||
//Set to squelch if necessary to close out the audio buffers
|
||||
if(!mSquelch && mDemodulator.isMuted())
|
||||
{
|
||||
mSquelch = true;
|
||||
notifyCallEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
demodulatedBuffer.decrementUserCount();
|
||||
notifyIdle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a call start state event
|
||||
*/
|
||||
private void notifyCallStart()
|
||||
{
|
||||
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.START, State.CALL, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a call continuation state event
|
||||
*/
|
||||
private void notifyCallContinuation()
|
||||
{
|
||||
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.CONTINUATION, State.CALL, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a call end state event
|
||||
*/
|
||||
private void notifyCallEnd()
|
||||
{
|
||||
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.END, State.CALL, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts an idle notification
|
||||
*/
|
||||
private void notifyIdle()
|
||||
{
|
||||
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.CONTINUATION, State.IDLE, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts the decoder state event to an optional registered listener
|
||||
*/
|
||||
private void broadcast(DecoderStateEvent event)
|
||||
{
|
||||
if(mDecoderStateEventListener != null)
|
||||
{
|
||||
mDecoderStateEventListener.receive(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the decoder state listener
|
||||
*/
|
||||
@Override
|
||||
public void setDecoderStateListener(Listener<DecoderStateEvent> listener)
|
||||
{
|
||||
mDecoderStateEventListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the decoder state event listener
|
||||
*/
|
||||
@Override
|
||||
public void removeDecoderStateListener()
|
||||
{
|
||||
mDecoderStateEventListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the listener to receive squelch change events from the demodulator/squelch controller.
|
||||
*/
|
||||
@Override
|
||||
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||
{
|
||||
mDemodulator.setSourceEventListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* De-registers the listener
|
||||
*/
|
||||
@Override
|
||||
public void removeSourceEventListener()
|
||||
{
|
||||
mDemodulator.setSourceEventListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitors sample rate change source event(s) to setup the initial I/Q filter and passes squelch threshold
|
||||
* change requests down to the demodulator.
|
||||
*/
|
||||
public class SourceEventProcessor implements Listener<SourceEvent>
|
||||
{
|
||||
@Override
|
||||
public void receive(SourceEvent sourceEvent)
|
||||
{
|
||||
if(sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_SAMPLE_RATE_CHANGE)
|
||||
{
|
||||
if(mIQFilter != null)
|
||||
{
|
||||
mIQFilter.dispose();
|
||||
mIQFilter = null;
|
||||
}
|
||||
|
||||
double sampleRate = sourceEvent.getValue().doubleValue();
|
||||
|
||||
if((sampleRate < (2.0 * mChannelBandwidth)))
|
||||
{
|
||||
throw new IllegalStateException("FM Demodulator with channel bandwidth [" + mChannelBandwidth +
|
||||
"] requires a channel sample rate of [" + (2.0 * mChannelBandwidth + "] - sample rate of [" +
|
||||
sampleRate + "] is not supported"));
|
||||
}
|
||||
|
||||
int passBandStop = (int)(mChannelBandwidth * .8);
|
||||
int stopBandStart = (int)mChannelBandwidth;
|
||||
|
||||
float[] filterTaps = null;
|
||||
|
||||
FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder()
|
||||
.sampleRate(sampleRate)
|
||||
.gridDensity(16)
|
||||
.oddLength(true)
|
||||
.passBandCutoff(passBandStop)
|
||||
.passBandAmplitude(1.0)
|
||||
.passBandRipple(0.01)
|
||||
.stopBandStart(stopBandStart)
|
||||
.stopBandAmplitude(0.0)
|
||||
.stopBandRipple(0.005) //Approximately 90 dB attenuation
|
||||
.build();
|
||||
|
||||
try
|
||||
{
|
||||
filterTaps = FilterFactory.getTaps(specification);
|
||||
}
|
||||
catch(FilterDesignException fde)
|
||||
{
|
||||
mLog.error("Couldn't design FM demodulator remez filter for sample rate [" + sampleRate +
|
||||
"] pass frequency [" + passBandStop + "] and stop frequency [" + stopBandStart +
|
||||
"] - using sinc filter");
|
||||
}
|
||||
|
||||
if(filterTaps == null)
|
||||
{
|
||||
filterTaps = FilterFactory.getLowPass(sampleRate, passBandStop, stopBandStart, 60,
|
||||
Window.WindowType.HAMMING, true);
|
||||
}
|
||||
|
||||
mIQFilter = new ComplexFIRFilter2(filterTaps);
|
||||
|
||||
mResampler = new RealResampler(sampleRate, mOutputSampleRate, 2000, 1000);
|
||||
|
||||
mResampler.setListener(reusableFloatBuffer ->
|
||||
{
|
||||
if(mResampledReusableBufferListener != null)
|
||||
{
|
||||
mResampledReusableBufferListener.receive(reusableFloatBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
reusableFloatBuffer.decrementUserCount();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(sourceEvent.getEvent() == SourceEvent.Event.REQUEST_CHANGE_SQUELCH_THRESHOLD)
|
||||
{
|
||||
//Send request for squelch threshold change to the demodulator/squelch controller.
|
||||
mDemodulator.receive(sourceEvent);
|
||||
}
|
||||
else if(sourceEvent.getEvent() == SourceEvent.Event.REQUEST_CURRENT_SQUELCH_THRESHOLD)
|
||||
{
|
||||
mDemodulator.receive(sourceEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.nbfm;
|
||||
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.channel.state.DecoderState;
|
||||
import io.github.dsheirer.channel.state.DecoderStateEvent;
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierClass;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.identifier.string.SimpleStringIdentifier;
|
||||
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEvent;
|
||||
import io.github.dsheirer.module.decode.p25.identifier.channel.StandardChannel;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.ISourceEventListener;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Narrow Band FM decoder channel state - provides the minimum channel state functionality
|
||||
*/
|
||||
public class NBFMDecoderState extends DecoderState implements ISourceEventListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(NBFMDecoderState.class);
|
||||
private Listener<SourceEvent> mSourceEventListener = new SourceEventListener();
|
||||
private String mChannelName;
|
||||
private DecodeEvent mDecodeEvent;
|
||||
private Identifier mChannelNameIdentifier;
|
||||
private Identifier mTalkgroupIdentifier;
|
||||
private IChannelDescriptor mChannelDescriptor = null;
|
||||
|
||||
public NBFMDecoderState(String channelName, DecodeConfigNBFM decodeConfig)
|
||||
{
|
||||
mChannelName = (channelName != null && !channelName.isEmpty()) ? channelName : "NBFM CHANNEL";
|
||||
mChannelNameIdentifier = new SimpleStringIdentifier(mChannelName, IdentifierClass.CONFIGURATION, Form.CHANNEL_NAME, Role.ANY);
|
||||
mTalkgroupIdentifier = new NBFMTalkgroup(decodeConfig.getTalkgroup());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivitySummary()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("Activity Summary\n");
|
||||
sb.append("\tDecoder: NBFM");
|
||||
sb.append("\n\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(IMessage t)
|
||||
{
|
||||
/* Not implemented */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveDecoderStateEvent(DecoderStateEvent event)
|
||||
{
|
||||
switch(event.getEvent())
|
||||
{
|
||||
case REQUEST_RESET ->
|
||||
{
|
||||
getIdentifierCollection().update(mChannelNameIdentifier);
|
||||
}
|
||||
case START ->
|
||||
{
|
||||
if(event.getState() == State.CALL)
|
||||
{
|
||||
startCallEvent();
|
||||
}
|
||||
}
|
||||
case END ->
|
||||
{
|
||||
if(event.getState() == State.CALL)
|
||||
{
|
||||
endCallEvent();
|
||||
}
|
||||
}
|
||||
case CONTINUATION ->
|
||||
{
|
||||
if(event.getState() == State.CALL)
|
||||
{
|
||||
continueCallEvent();
|
||||
}
|
||||
else
|
||||
{
|
||||
endCallEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates/starts a decode call evnet.
|
||||
*/
|
||||
private void startCallEvent()
|
||||
{
|
||||
getIdentifierCollection().update(mTalkgroupIdentifier);
|
||||
|
||||
if(mDecodeEvent == null)
|
||||
{
|
||||
mDecodeEvent = DecodeEvent.builder(System.currentTimeMillis())
|
||||
.channel(mChannelDescriptor)
|
||||
.eventDescription("CALL")
|
||||
.details("NBFM")
|
||||
.identifiers(new IdentifierCollection(getIdentifierCollection().getIdentifiers()))
|
||||
.build();
|
||||
|
||||
broadcast(mDecodeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues (or starts) the call decode event and updates the current timestamp
|
||||
*/
|
||||
private void continueCallEvent()
|
||||
{
|
||||
if(mDecodeEvent == null)
|
||||
{
|
||||
startCallEvent();
|
||||
}
|
||||
|
||||
mDecodeEvent.update(System.currentTimeMillis());
|
||||
broadcast(mDecodeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the call decode event
|
||||
*/
|
||||
private void endCallEvent()
|
||||
{
|
||||
if(mDecodeEvent != null)
|
||||
{
|
||||
mDecodeEvent.end(System.currentTimeMillis());
|
||||
broadcast(mDecodeEvent);
|
||||
mDecodeEvent = null;
|
||||
}
|
||||
|
||||
//Remote any user identifiers from the identifier collection
|
||||
resetState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoderType getDecoderType()
|
||||
{
|
||||
return DecoderType.NBFM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
getIdentifierCollection().update(mChannelNameIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<SourceEvent> getSourceEventListener()
|
||||
{
|
||||
return mSourceEventListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitors source events to capture the channel frequency for use in decode events.
|
||||
*/
|
||||
private class SourceEventListener implements Listener<SourceEvent>
|
||||
{
|
||||
@Override
|
||||
public void receive(SourceEvent sourceEvent)
|
||||
{
|
||||
if(sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_FREQUENCY_CHANGE)
|
||||
{
|
||||
mChannelDescriptor = new StandardChannel(sourceEvent.getValue().longValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.github.dsheirer.module.decode.nbfm;
|
||||
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
|
||||
import io.github.dsheirer.protocol.Protocol;
|
||||
|
||||
/**
|
||||
* Narrowband FM talkgroup. Note: this is a logical identifier that is assignable from a user-specified
|
||||
* configuration so that NBFM audio events are compatible with other features of the sdrtrunk system.
|
||||
*/
|
||||
public class NBFMTalkgroup extends TalkgroupIdentifier
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param value 1-65,535
|
||||
*/
|
||||
public NBFMTalkgroup(int value)
|
||||
{
|
||||
super(value, Role.TO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protocol getProtocol()
|
||||
{
|
||||
return Protocol.NBFM;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user