mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
P25 Decoder work in progress
This commit is contained in:
81
src/decode/p25/reference/Digit.java
Normal file
81
src/decode/p25/reference/Digit.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package decode.p25.reference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public enum Digit
|
||||
{
|
||||
D0( "0", "A" ),
|
||||
D1( "1", "B" ),
|
||||
D2( "2", "C" ),
|
||||
D3( "3", "D" ),
|
||||
D4( "4", "-" ),
|
||||
D5( "5", "-" ),
|
||||
D6( "6", "-" ),
|
||||
D7( "7", "-" ),
|
||||
D8( "8", "-" ),
|
||||
D9( "9", "-" ),
|
||||
D10( "*", "-" ),
|
||||
D11( "#", "-" ),
|
||||
D12( "-", "-" ),
|
||||
D13( "HOOK FLASH", "-" ),
|
||||
D14( "PAUSE", "-" ),
|
||||
D15( "ESC", "NULL" ),
|
||||
DUNK( "?", "?" );
|
||||
|
||||
private String mValue;
|
||||
private String mEscapedValue;
|
||||
|
||||
private Digit( String value, String escapedValue )
|
||||
{
|
||||
mValue = value;
|
||||
mEscapedValue = escapedValue;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public String getEscapedValue()
|
||||
{
|
||||
return mEscapedValue;
|
||||
}
|
||||
|
||||
public static Digit fromValue( int value )
|
||||
{
|
||||
if( 0 <= value && value <= 15 )
|
||||
{
|
||||
return values()[ value ];
|
||||
}
|
||||
|
||||
return DUNK;
|
||||
}
|
||||
|
||||
public static String decode( List<Integer> values )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
boolean escape = false;
|
||||
|
||||
for( Integer value: values )
|
||||
{
|
||||
Digit d = Digit.fromValue( value );
|
||||
|
||||
if( d == Digit.D15 )
|
||||
{
|
||||
escape = true;
|
||||
}
|
||||
else if( escape )
|
||||
{
|
||||
sb.append( d.getEscapedValue() );
|
||||
escape = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( d.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user