feat(dmr): decode CACH and slot type

This commit is contained in:
2026-07-14 18:46:49 +03:00
parent 3fcf737685
commit 23596d0565
5 changed files with 367 additions and 6 deletions
+28 -3
View File
@@ -18,7 +18,7 @@ unit DMRDecoder;
interface
uses
Classes, SysUtils, SyncObjs, Math, DMRBindings;
Classes, SysUtils, SyncObjs, Math, DMRBindings, DMRProtocol;
const
DMR_INPUT_RATE = 48000;
@@ -49,6 +49,13 @@ type
SignalRMS: Single;
LastSyncAgeMs: QWord;
VocoderAvailable: Boolean;
CACHValid: Boolean;
Slot: Integer;
LCSS: Integer;
SlotTypeValid: Boolean;
ColorCode: Integer;
DataType: Integer;
SlotTypeCorrectedBits: Integer;
end;
TDMRDecoder = class;
@@ -90,9 +97,10 @@ type
FMagSum: array[0..DMR_SAMPLES_PER_SYM - 1] of Double;
FBestSyncQuality: Double;
FTrackPhase: Integer;
FCurrentBurst: array[0..DMR_BURST_DIBITS - 1] of Byte;
FCurrentBurst: TDMRDibitBurst;
FCurrentBurstPos: Integer;
FLastBurst: array[0..DMR_BURST_DIBITS - 1] of Byte;
FLastBurst: TDMRDibitBurst;
FLastBurstInfo: TDMRBurstInfo;
FBurstCount: QWord;
FRMSSq: Double;
@@ -250,6 +258,7 @@ begin
FBestSyncQuality := 0;
FillChar(FCurrentBurst, SizeOf(FCurrentBurst), 0);
FillChar(FLastBurst, SizeOf(FLastBurst), 0);
FillChar(FLastBurstInfo, SizeOf(FLastBurstInfo), 0);
FTrackPhase := -1;
FCurrentBurstPos := 0;
FBurstCount := 0;
@@ -435,6 +444,7 @@ end;
procedure TDMRDecoder.CompleteBurst;
begin
Move(FCurrentBurst[0], FLastBurst[0], SizeOf(FLastBurst));
DMRParseBurst(FLastBurst, FLastBurstInfo);
Inc(FBurstCount);
FCurrentBurstPos := 0;
end;
@@ -494,6 +504,21 @@ begin
(S.LastSyncAgeMs <= DMR_SYNC_HOLD_MS);
S.SignalRMS := Sqrt(FRMSSq);
S.VocoderAvailable := FMbe <> nil;
// CACH exists on base-station bursts. On MS/direct bursts the same
// positions are payload/guard symbols and can accidentally form a
// syntactically valid Hamming word.
S.CACHValid := FLastBurstInfo.CACH.Valid and
(FSyncKind in [dskBSData, dskBSVoice]);
S.Slot := FLastBurstInfo.CACH.Slot;
S.LCSS := FLastBurstInfo.CACH.LCSS;
// Voice sync replaces the centre Slot Type field. Do not expose a
// chance Golay match from AMBE bits as a real colour/data type.
S.SlotTypeValid := FLastBurstInfo.SlotType.Valid and
(FSyncKind in [dskBSData, dskMSData,
dskDirectTS1Data, dskDirectTS2Data]);
S.ColorCode := FLastBurstInfo.SlotType.ColorCode;
S.DataType := FLastBurstInfo.SlotType.DataType;
S.SlotTypeCorrectedBits := FLastBurstInfo.SlotType.CorrectedBits;
finally
FStatusLock.Leave;
end;