DMR Additions

--Easier to use key entry for privacy modes
---Serpen'tera' 10 mode now available
--Slightly improved dmr dibit buffering/inverted dibit buffering
--Tweaks to console and ncurses output regarding FID, SVC, and privacy key values
--fix for RTL optional support (think I have all the ifdef covered now)
--TGT, SRC, FID, SVC, now set on Voice LC Header (not sure why I wasn't before)
--other misc tweaks that I can't recall
This commit is contained in:
lwvmobile
2022-08-21 23:45:00 -04:00
committed by GitHub
parent 7f34ff9340
commit df6d7a6609
11 changed files with 457 additions and 114 deletions

View File

@@ -1918,7 +1918,7 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
DmrDataBit[j + 6] = (DmrDataByte[i] >> 1) & 0x01;
DmrDataBit[j + 7] = (DmrDataByte[i] >> 0) & 0x01;
}
//fprintf (stderr, "\nDDB = 0x%X \n", DmrDataBit);
/* Store the Protect Flag (PF) bit */
TSVoiceSupFrame->FullLC.ProtectFlag = (unsigned int)(DmrDataBit[0]);
@@ -1930,7 +1930,6 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
/* Store the Feature set ID (FID) */
TSVoiceSupFrame->FullLC.FeatureSetID = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[8], 8);
//state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
/* Store the Service Options */
TSVoiceSupFrame->FullLC.ServiceOptions = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[16], 8);
@@ -1940,7 +1939,6 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
/* Store the Source address */
TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[48], 24);
//state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress;
if((IrrecoverableErrors == 0) && CRCCorrect)
{
@@ -1948,24 +1946,36 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
TSVoiceSupFrame->FullLC.DataValidity = 1;
if (state->currentslot == 0)
{
state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress;
state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress;
}
if (state->currentslot == 1)
{
state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress;
state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress;
}
}
else if(IrrecoverableErrors == 0)
{
//FEC okay? Set SVCop code anyways
TSVoiceSupFrame->FullLC.DataValidity = 0; //shouldn't matter in this context
//FEC okay. Set all variables anyways.
TSVoiceSupFrame->FullLC.DataValidity = 0;
if (state->currentslot == 0)
{
state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress;
state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress;
}
if (state->currentslot == 1)
{
state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress;
state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress;
}
}
else
@@ -1973,19 +1983,12 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
/* CRC checking error, so consider the Full LC data as invalid */
TSVoiceSupFrame->FullLC.DataValidity = 0;
}
//Full, amateur callsigns and labels not on this,
if (opts->payload == 1)
{
//fprintf (stderr, "\nFull VoiceLC Payload ");
for (i = 0; i < 12; i++)
{
//fprintf (stderr, "[%02X]", DmrDataByte[i]);
}
}
/* Print the destination ID (TG) and the source ID */
fprintf (stderr, "%s \n", KGRN);
fprintf (stderr, " Slot %d ", state->currentslot+1);
fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf (stderr, " SLOT %d ", state->currentslot+1);
fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions);
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40)
@@ -2186,16 +2189,26 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19
{
state->payload_algid = 0;
state->payload_keyid = 0;
//state->payload_mfid = 0;
state->payload_mi = 0;
// state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
//state->dmr_fid = 0;
//state->dmr_so = 0; //leave disabled so will persist to aid in muting or unmuting when required
state->lastsrc = 0;
state->lasttg = 0;
}
if (state->currentslot == 1)
{
state->payload_algidR = 0;
state->payload_keyidR = 0;
//state->payload_mfid = 0;
state->payload_miR = 0;
// state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
//state->dmr_fidR = 0;
//state->dmr_soR = 0;
state->lastsrcR = 0;
state->lasttgR = 0;
}
@@ -2203,31 +2216,33 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19
if((IrrecoverableErrors == 0) && CRCCorrect) //amateur DMR seems to only set radio ID up here I think, figure out best way to set without messing up other DMR types
{
fprintf (stderr, "%s \n", KRED);
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
//fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, " SLOT %d ", state->currentslot+1);
fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions);
fprintf (stderr, "%s ", KNRM);
//fprintf(stderr, "(CRC OK ) ");
if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc.
{
if (state->currentslot == 0)
{
state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
// state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
//zero out src and tgt here as well, or will that cause issues with ncurses terminal and per call?
}
if (state->currentslot == 1)
{
state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
// state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
//zero out src and tgt here as well, or will that cause issues with ncurses terminal and per call?
}
}
}
else if(IrrecoverableErrors == 0)
{
fprintf (stderr, "%s \n", KRED);
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
//fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, " SLOT %d ", state->currentslot+1);
fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions);
fprintf(stderr, "RAS (FEC OK/CRC ERR)"); //tlc
fprintf (stderr, "%s ", KNRM);
if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc.
@@ -2235,13 +2250,13 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19
{
if (state->currentslot == 0)
{
state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
// state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions;
}
if (state->currentslot == 1)
{
state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
// state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID;
// state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions;
}
}
}
@@ -2306,11 +2321,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
uint8_t CRCComputed;
uint32_t CRCCorrect = 0;
/* Remove warning compiler */
//UNUSED_VARIABLE(opts);
/* Check the current time slot */
if(state->currentslot == 0)
{
TSVoiceSupFrame = &state->TS1SuperFrame;
@@ -2320,7 +2330,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
TSVoiceSupFrame = &state->TS2SuperFrame;
}
/* First step : Reconstitute the BPTC 16x8 matrix */
Burst = 1; /* Burst B to E contains embedded signaling data */
k = 0;
@@ -2395,7 +2404,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
/* Store the Source address */
TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&LC_DataBit[48], 24);
//state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress;
/* Check the CRC values */
if((IrrecoverableErrors == 0))// && CRCCorrect)
@@ -2440,7 +2448,7 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
{
fprintf(stderr, "\n");
}
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf (stderr, " Embedded Alias Header and Blocks: [%s%s%s%s%s]", state->dmr_callsign[state->currentslot][0],
state->dmr_callsign[state->currentslot][1], state->dmr_callsign[state->currentslot][2],
state->dmr_callsign[state->currentslot][3], state->dmr_callsign[state->currentslot][4] );
@@ -2467,7 +2475,7 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
{
fprintf(stderr, "\n");
}
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf (stderr, " Embedded GPS: [%s]", state->dmr_callsign[state->currentslot][5] );
fprintf (stderr, "%s ", KNRM);
}
@@ -2483,11 +2491,45 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
{
fprintf(stderr, "\n");
}
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
//fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, " SLOT %d ", state->currentslot+1);
fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions);
fprintf (stderr, "%s ", KNRM);
//fprintf(stderr, "(CRC OK ) ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40)
{
fprintf (stderr, "%s ", KRED);
fprintf(stderr, "Encrypted ");
//fprintf (stderr, "%s ", KNRM);
}
else
{
fprintf (stderr, "%s ", KGRN);
fprintf(stderr, "Clear/Unencrypted ");
//fprintf (stderr, "%s ", KNRM);
}
/* Check the "Reserved" bits */
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x30)
{
/* Experimentally determined with DSD+, when the "Reserved" bit field
* is equal to 0x2, this is a TXI call */
if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) == 0x20) fprintf(stderr, "TXI ");
else fprintf(stderr, "Reserved=%d ", (TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) >> 4);
}
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x08) fprintf(stderr, "Broadcast ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x04) fprintf(stderr, "OVCM ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x03)
{
if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x01) fprintf(stderr, "Priority 1 ");
else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x02) fprintf(stderr, "Priority 2 ");
else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x03) fprintf(stderr, "Priority 3 ");
else fprintf(stderr, "No Priority "); /* We should never go here */
}
fprintf(stderr, "Call ");
fprintf (stderr, "%s ", KNRM);
if (state->currentslot == 0)
{
state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress;
@@ -2516,12 +2558,47 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
{
fprintf(stderr, "\n");
}
fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
//fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, " SLOT %d ", state->currentslot+1);
fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions);
fprintf (stderr, "%s ", KRED);
fprintf(stderr, "RAS (FEC OK/CRC ERR) ");
fprintf (stderr, "%s ", KNRM);
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40)
{
fprintf (stderr, "%s ", KRED);
fprintf(stderr, "Encrypted ");
//fprintf (stderr, "%s ", KNRM);
}
else
{
fprintf (stderr, "%s ", KGRN);
fprintf(stderr, "Clear/Unencrypted ");
//fprintf (stderr, "%s ", KNRM);
}
/* Check the "Reserved" bits */
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x30)
{
/* Experimentally determined with DSD+, when the "Reserved" bit field
* is equal to 0x2, this is a TXI call */
if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) == 0x20) fprintf(stderr, "TXI ");
else fprintf(stderr, "Reserved=%d ", (TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) >> 4);
}
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x08) fprintf(stderr, "Broadcast ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x04) fprintf(stderr, "OVCM ");
if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x03)
{
if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x01) fprintf(stderr, "Priority 1 ");
else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x02) fprintf(stderr, "Priority 2 ");
else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x03) fprintf(stderr, "Priority 3 ");
else fprintf(stderr, "No Priority "); /* We should never go here */
}
fprintf(stderr, "Call ");
fprintf (stderr, "%s ", KNRM);
if (state->currentslot == 0)
{
state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress;