diff --git a/P25/lc/TSBKBase.cs b/P25/lc/TSBKBase.cs
index 3b78b82..ad0e200 100644
--- a/P25/lc/TSBKBase.cs
+++ b/P25/lc/TSBKBase.cs
@@ -27,6 +27,8 @@ namespace fnecore.P25.LC
protected byte Lco;
protected byte MfId;
+ protected internal byte[] Payload = new byte[P25Defines.P25_TSBK_LENGTH_BYTES - 4];
+
///
/// Creates an instance of
///
@@ -42,7 +44,7 @@ namespace fnecore.P25.LC
///
///
///
- public virtual bool Decode(byte[] data, ref byte[] payload, bool rawTSBK)
+ public virtual bool Decode(byte[] data, bool rawTSBK)
{
byte[] tsbk = new byte[P25Defines.P25_TSBK_LENGTH_BYTES];
FneUtils.Memset(tsbk, 0x00, tsbk.Length);
@@ -83,7 +85,7 @@ namespace fnecore.P25.LC
LastBlock = (tsbk[0] & 0x80) == 0x80; // Last Block Marker
MfId = tsbk[1]; // Manufacturer ID
- Array.Copy(tsbk, 1, payload, 0, P25Defines.P25_TSBK_LENGTH_BYTES - 4);
+ Array.Copy(tsbk, 1, Payload, 0, Payload.Length);
return true;
}
@@ -95,13 +97,13 @@ namespace fnecore.P25.LC
///
///
///
- public virtual void Encode(ref byte[] data, ref byte[] payload, bool rawTSBK, bool noTrellis)
+ public virtual void Encode(ref byte[] data, bool rawTSBK, bool noTrellis)
{
byte[] tsbk = new byte[P25Defines.P25_TSBK_LENGTH_BYTES];
FneUtils.Memset(tsbk, 0x00, tsbk.Length);
- Array.Copy(payload, 0, tsbk, 2, P25Defines.P25_TSBK_LENGTH_BYTES - 4);
+ Array.Copy(Payload, 0, tsbk, 2, Payload.Length);
tsbk[0] = Lco; // LCO
tsbk[0] |= LastBlock ? (byte)0x80 : (byte)0x00; // Last Block Marker
diff --git a/P25/lc/tsbk/IOSP_ACK_RSP.cs b/P25/lc/tsbk/IOSP_ACK_RSP.cs
index b709de7..4335456 100644
--- a/P25/lc/tsbk/IOSP_ACK_RSP.cs
+++ b/P25/lc/tsbk/IOSP_ACK_RSP.cs
@@ -48,22 +48,18 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public bool Decode(byte[] data, bool rawTSBK)
+ public override bool Decode(byte[] data, bool rawTSBK = true)
{
- byte[] tsbk = new byte[P25Defines.P25_TSBK_LENGTH_BYTES];
- FneUtils.Memset(tsbk, 0x00, tsbk.Length);
-
- bool ret = base.Decode(data, ref tsbk, rawTSBK);
- if (!ret)
+ if (!base.Decode(data, rawTSBK))
return false;
- ulong tsbkValue = FneUtils.ToUInt64(tsbk, 0);
+ ulong tsbkValue = FneUtils.ToUInt64(Payload, 0);
Aiv = ((tsbkValue >> 56) & 0x80U) == 0x80U; // Additional Info Flag
Service = (byte)((tsbkValue >> 56) & 0x3FU); // Service Type
- DstId = FneUtils.Bytes3ToUInt32(tsbk, 3); // Target Radio Address
- SrcId = FneUtils.Bytes3ToUInt32(tsbk, 0); // Source Radio Address
+ DstId = FneUtils.Bytes3ToUInt32(Payload, 3); // Target Radio Address
+ SrcId = FneUtils.Bytes3ToUInt32(Payload, 0); // Source Radio Address
return true;
}
@@ -75,7 +71,7 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public override void Encode(ref byte[] data, ref byte[] payload, bool rawTSBK, bool noTrellis)
+ public override void Encode(ref byte[] data, bool rawTSBK = true, bool noTrellis = true)
{
ulong tsbkValue = 0;
@@ -95,10 +91,10 @@ namespace fnecore.P25.LC.TSBK
tsbkValue = (tsbkValue << 24) + SrcId; // Source Radio Address
- FneUtils.Memset(payload, 0x00, payload.Length);
- FneUtils.WriteBytes(tsbkValue, ref payload, 0);
+ FneUtils.Memset(Payload, 0x00, Payload.Length);
+ FneUtils.WriteBytes(tsbkValue, ref Payload, 0);
- base.Encode(ref data, ref payload, rawTSBK, noTrellis);
+ base.Encode(ref data, rawTSBK, noTrellis);
}
} // public class IOSP_ACK_RSP
} // namespace fnecore.P25.LC.TSBK
diff --git a/P25/lc/tsbk/IOSP_CALL_ALRT.cs b/P25/lc/tsbk/IOSP_CALL_ALRT.cs
index 29d2e94..ea9ea13 100644
--- a/P25/lc/tsbk/IOSP_CALL_ALRT.cs
+++ b/P25/lc/tsbk/IOSP_CALL_ALRT.cs
@@ -39,17 +39,13 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public bool Decode(byte[] data, bool rawTSBK)
+ public override bool Decode(byte[] data, bool rawTSBK = true)
{
- byte[] tsbk = new byte[P25Defines.P25_TSBK_LENGTH_BYTES];
- FneUtils.Memset(tsbk, 0x00, tsbk.Length);
-
- bool ret = base.Decode(data, ref tsbk, rawTSBK);
- if (!ret)
+ if (!base.Decode(data, rawTSBK))
return false;
- DstId = FneUtils.Bytes3ToUInt32(tsbk, 3); // Target Radio Address
- SrcId = FneUtils.Bytes3ToUInt32(tsbk, 0); // Source Radio Address
+ DstId = FneUtils.Bytes3ToUInt32(Payload, 3); // Target Radio Address
+ SrcId = FneUtils.Bytes3ToUInt32(Payload, 0); // Source Radio Address
return true;
}
@@ -61,16 +57,16 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public override void Encode(ref byte[] data, ref byte[] payload, bool rawTSBK, bool noTrellis)
+ public override void Encode(ref byte[] data, bool rawTSBK = true, bool noTrellis = true)
{
ulong tsbkValue = 0;
- tsbkValue = (tsbkValue << 40) + DstId; // Target Radio Address
- tsbkValue = (tsbkValue << 24) + SrcId; // Source Radio Address
+ tsbkValue = (tsbkValue << 40) + DstId; // Target Radio Address
+ tsbkValue = (tsbkValue << 24) + SrcId; // Source Radio Address
- FneUtils.Memset(payload, 0x00, payload.Length);
- FneUtils.WriteBytes(tsbkValue, ref payload, 0);
+ FneUtils.Memset(Payload, 0x00, Payload.Length);
+ FneUtils.WriteBytes(tsbkValue, ref Payload, 0);
- base.Encode(ref data, ref payload, rawTSBK, noTrellis);
+ base.Encode(ref data, rawTSBK, noTrellis);
}
} // public class IOSP_CALL_ALRT
} // namespace fnecore.P25.LC.TSBK
diff --git a/P25/lc/tsbk/IOSP_EXT_FNCT.cs b/P25/lc/tsbk/IOSP_EXT_FNCT.cs
index 88db2cd..d4b0c0e 100644
--- a/P25/lc/tsbk/IOSP_EXT_FNCT.cs
+++ b/P25/lc/tsbk/IOSP_EXT_FNCT.cs
@@ -42,16 +42,12 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public bool Decode(byte[] data, bool rawTSBK)
+ public override bool Decode(byte[] data, bool rawTSBK = true)
{
- byte[] tsbk = new byte[P25Defines.P25_TSBK_LENGTH_BYTES];
- FneUtils.Memset(tsbk, 0x00, tsbk.Length);
-
- bool ret = base.Decode(data, ref tsbk, rawTSBK);
- if (!ret)
+ if (!base.Decode(data, rawTSBK))
return false;
- ulong tsbkValue = FneUtils.ToUInt64(tsbk, 0);
+ ulong tsbkValue = FneUtils.ToUInt64(Payload, 0);
ExtendedFunction = (ushort)((tsbkValue >> 48) & 0xFFFF); // Extended Function
SrcId = (uint)((tsbkValue >> 24) & 0xFFFFFF); // Argument
@@ -67,18 +63,18 @@ namespace fnecore.P25.LC.TSBK
///
///
///
- public override void Encode(ref byte[] data, ref byte[] payload, bool rawTSBK, bool noTrellis)
+ public override void Encode(ref byte[] data, bool rawTSBK = true, bool noTrellis = true)
{
ulong tsbkValue = 0;
- tsbkValue = (tsbkValue << 16) + ExtendedFunction; // Extended Function
- tsbkValue = (tsbkValue << 24) + SrcId; // Argument
- tsbkValue = (tsbkValue << 24) + DstId; // Target Radio Address
+ tsbkValue = (tsbkValue << 16) | ExtendedFunction; // Extended Function
+ tsbkValue = (tsbkValue << 24) | SrcId; // Argument
+ tsbkValue = (tsbkValue << 24) | DstId; // Target Radio Address
- FneUtils.Memset(payload, 0x00, payload.Length);
- FneUtils.WriteBytes(tsbkValue, ref payload, 0);
+ FneUtils.Memset(Payload, 0x00, Payload.Length);
+ FneUtils.WriteBytes(tsbkValue, ref Payload, 0);
- base.Encode(ref data, ref payload, rawTSBK, noTrellis);
+ base.Encode(ref data, rawTSBK, noTrellis);
}
} // public class IOSP_EXT_FNCT
} // namespace fnecore.P25.LC.TSBK