CODE: Remove Whitespace;

This commit is contained in:
lwvmobile
2025-03-17 16:38:04 -04:00
parent 237cb3ffa5
commit fdbc2ef0e2
73 changed files with 1624 additions and 1624 deletions

View File

@@ -31,7 +31,7 @@ void NXDN_SACCH_Full_decode(dsd_opts * opts, dsd_state * state)
{
memcpy(&SACCH[i * 18], state->nxdn_sacch_frame_segment[i], 18);
/* Check CRC */
/* Check CRC */
if (state->nxdn_sacch_frame_segcrc[i] != 0) CrcCorrect = 0;
}
@@ -90,9 +90,9 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
/*
//Note: CAC Message with same Message Type -- This is a private call request and rejection (TODO: Seperate handling depending on CAC, FACCH< Sacch, etc)
20:56:15 Sync: NXDN96 RCCH Data RAN 01 CAC VCALL (VCALL_REQ)
Private Call - Half Duplex 9600bps/EHR (02) - Src=211 - Dst/TG=1603
Private Call - Half Duplex 9600bps/EHR (02) - Src=211 - Dst/TG=1603
20:56:15 Sync: NXDN96 RCCH Data RAN 01 CAC DISC (VCALL_REJECTION)
Private Call - Disconnect - Src=1603 - Dst/TG=211
Private Call - Disconnect - Src=1603 - Dst/TG=211
*/
//Debug: Disable DUP messages if they cause random issues with Type-C trunking (i.e. changing SRC ang TGT IDs, hopping in the middle of calls, etc)
@@ -107,7 +107,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
case 0x04:
//DCALL_ASSGN
case 0x0E:
case 0x0E:
NXDN_decode_VCALL_ASSGN(opts, state, ElementsContent);
break;
@@ -166,14 +166,14 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
memset(state->active_channel, 0, sizeof(state->active_channel));
opts->p25_is_tuned = 0;
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
state->nxdn_last_rid = 0;
state->nxdn_last_tg = 0;
if (state->M == 0)
state->nxdn_cipher_type = 0;
sprintf (state->nxdn_call_type, "%s", "");
}
//rtl
else if (opts->audio_in_type == 3)
@@ -205,7 +205,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
break;
//VCALL_IV
case 0x03:
case 0x03:
NXDN_decode_VCALL_IV(opts, state, ElementsContent);
break;
@@ -222,28 +222,28 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
void nxdn_location_id_handler (dsd_state * state, uint32_t location_id, uint8_t type)
{
//6.5.2 Location ID
uint8_t category_bit = location_id >> 22;
uint8_t category_bit = location_id >> 22;
uint32_t sys_code = 0;
uint16_t site_code = 0;
char category[14]; //G, R, or L
char category[14]; //G, R, or L
if (category_bit == 0)
{
sys_code = ( (location_id & 0x3FFFFF) >> 12); //10 bits
site_code = location_id & 0x3FF; //12 bits
site_code = location_id & 0x3FF; //12 bits
sprintf (category, "%s", "Global");
}
}
else if (category_bit == 2)
{
sys_code = ( (location_id & 0x3FFFFF) >> 8); //14 bits
site_code = location_id & 0xFF; //8 bits
site_code = location_id & 0xFF; //8 bits
sprintf (category, "%s", "Regional");
}
}
else if (category_bit == 1)
{
sys_code = ( (location_id & 0x3FFFFF) >> 5); //17 bits
site_code = location_id & 0x1F; //5 bits
site_code = location_id & 0x1F; //5 bits
sprintf (category, "%s", "Local");
}
else
@@ -256,11 +256,11 @@ void nxdn_location_id_handler (dsd_state * state, uint32_t location_id, uint8_t
if (type == 0)
{
state->nxdn_last_ran = site_code % 64; //Table 6.3-4 RAN for Trunked Radio Systems
if (site_code != 0) state->nxdn_location_site_code = site_code;
if (site_code != 0) state->nxdn_location_site_code = site_code;
if (sys_code != 0) state->nxdn_location_sys_code = sys_code;
sprintf (state->nxdn_location_category, "%s", category);
}
sprintf (state->nxdn_location_category, "%s", category);
}
if (type == 0) fprintf (stderr, "\n Location Information - Cat: %s - Sys Code: %d - Site Code %d ", category, sys_code, site_code);
else fprintf (stderr, "\n Adjacent Information - Cat: %s - Sys Code: %d - Site Code %d ", category, sys_code, site_code);
@@ -310,7 +310,7 @@ void nxdn_rst_info_handler (dsd_state * state, uint32_t rst_info)
//Access cycle interval (Octet 0, Bits 3 to 0)
fprintf (stderr, " ACI:");
uint8_t frames = (rst_info >> 16) & 0xF;
uint8_t frames = (rst_info >> 16) & 0xF;
if (frames) fprintf (stderr, " %d Frame Restriction;", frames * 20);
// else fprintf (stderr, " No Restriction;");
@@ -328,7 +328,7 @@ void nxdn_rst_info_handler (dsd_state * state, uint32_t rst_info)
//Restriction group ratio specification (Octet 2, Bits 7 to 6)
fprintf (stderr, " RT:");
uint8_t ratio = (rst_info >> 22) & 0x3;
uint8_t ratio = (rst_info >> 22) & 0x3;
if (ratio == 1) fprintf (stderr, " 50 Restriction;");
else if (ratio == 2) fprintf (stderr, " 75 Restriction;");
else if (ratio == 3) fprintf (stderr, " 87.5 Restriction;");
@@ -336,7 +336,7 @@ void nxdn_rst_info_handler (dsd_state * state, uint32_t rst_info)
//Delay time extension specification (Octet 2, Bits 5 to 4)
fprintf (stderr, " DT:");
uint8_t dt = (rst_info >> 20) & 0x3;
uint8_t dt = (rst_info >> 20) & 0x3;
if (dt == 0) fprintf (stderr, " Timer T2 max x 1;");
else if (dt == 1) fprintf (stderr, " Timer T2 max x 2;");
else if (dt == 2) fprintf (stderr, " Timer T2 max x 3;");
@@ -363,10 +363,10 @@ void nxdn_ca_info_handler (dsd_state * state, uint32_t ca_info)
//set state variable here to tell us to use DFA or Channel Versions
if (RCN == 1)
{
state->nxdn_rcn = RCN;
state->nxdn_rcn = RCN;
state->nxdn_step = step;
state->nxdn_base_freq = base;
}
}
}
@@ -428,7 +428,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
state->NxdnElementsContent.DestinationID = DestinationID;
/* Decode "Call Timer" */ //unsure of format of call timer, not required info for trunking
CallTimer = (uint8_t)ConvertBitIntoBytes(&Message[56], 6);
CallTimer = (uint8_t)ConvertBitIntoBytes(&Message[56], 6);
/* Decode "Channel" */
Channel = (uint16_t)ConvertBitIntoBytes(&Message[62], 10);
@@ -436,7 +436,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
/* Decode DFA-only variables*/
if (state->nxdn_rcn == 1)
{
bw = (uint8_t)ConvertBitIntoBytes(&Message[62], 2);
bw = (uint8_t)ConvertBitIntoBytes(&Message[62], 2);
OFN = (uint16_t)ConvertBitIntoBytes(&Message[64], 16);
IFN = (uint16_t)ConvertBitIntoBytes(&Message[80], 16);
}
@@ -445,7 +445,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
//While I've only seen Busy Repeater Message on the SCCH message (different format)
//The manual suggests this message exists on Type-D systems with this configuration
//On Type-D systems, need to truncate to an 11-bit value
//On Type-D systems, need to truncate to an 11-bit value
//other 5-bits are repeater or prefix value
// uint8_t idas = 0;
// uint8_t rep1 = 0;
@@ -457,12 +457,12 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
// rep2 = (DestinationID >> 11) & 0x1F;
// SourceUnitID = SourceUnitID & 0x7FF;
// DestinationID = DestinationID & 0x7FF;
// //assign source prefix/rep1 as the tune to channel?
// //assign source prefix/rep1 as the tune to channel?
// //In normal VCALL, both prefix/rep values are the same on the Type-D samples I have
// Channel = rep1;
// Channel = rep1;
// }
if (MessageType == 0x4 || MessageType == 0x5)
if (MessageType == 0x4 || MessageType == 0x5)
fprintf (stderr, "%s", KGRN); //VCALL_ASSGN
else fprintf (stderr, "%s", KCYN); //DCALL_ASSGN
@@ -474,7 +474,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
if(CCOption & 0x20) fprintf(stderr, "Priority Paging ");
/* Print the "Call Type" */
fprintf(stderr, "%s - ", NXDN_Call_Type_To_Str(CallType));
fprintf(stderr, "%s - ", NXDN_Call_Type_To_Str(CallType));
/* Print the "Voice Call Option" */
if (MessageType == 0x4 || MessageType == 0x5) NXDN_Voice_Call_Option_To_Str(VoiceCallOption, DuplexMode, TransmissionMode);
@@ -490,14 +490,14 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
/* Print Channel */
if (state->nxdn_rcn == 0)
fprintf(stderr, "- Channel [%03X][%04d] ", Channel & 0x3FF, Channel & 0x3FF);
if (state->nxdn_rcn == 1)
if (state->nxdn_rcn == 1)
fprintf(stderr, "- DFA Channel [%04X][%05d] ", OFN, OFN);
//test VCALL_ASSGN_DUP, if no voice sync activity (by trunk_hangtime), then convert to assgn and allow tuning
//VCALL_ASSGN_DUP has been seen in the middle of calls, but also on the tail end instead of a TX_REL or DISC
if (MessageType == 0x5 && opts->p25_is_tuned == 1 && opts->p25_trunk == 1)
{
if ( (time(NULL) - state->last_vc_sync_time) > opts->trunk_hangtime )
if ( (time(NULL) - state->last_vc_sync_time) > opts->trunk_hangtime )
{
MessageType = 0x04; //convert to VCALL
opts->p25_is_tuned = 0; //open tuning back up to tune
@@ -507,7 +507,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
//TG Hold during VCALL_ASSGN_DUP, allow tuning to TG hold channel assignment
if (MessageType == 0x5 && opts->p25_is_tuned == 1 && opts->p25_trunk == 1)
{
if ( state->tg_hold != 0 && state->tg_hold == DestinationID )
if ( state->tg_hold != 0 && state->tg_hold == DestinationID )
{
MessageType = 0x04; //convert to VCALL
// opts->p25_is_tuned = 0; //open tuning back up to tune
@@ -544,10 +544,10 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
}
if (tune == 0) goto END_ASSGN;
//run process to figure out frequency value from the channel import or from DFA
long int freq = 0;
if (state->nxdn_rcn == 0)
if (state->nxdn_rcn == 0)
freq = nxdn_channel_to_frequency(opts, state, Channel);
if (state->nxdn_rcn == 1)
freq = nxdn_channel_to_frequency(opts, state, OFN);
@@ -556,7 +556,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
if (opts->p25_trunk == 1 && state->p25_cc_freq == 0)
{
long int ccfreq = 0;
//if not available, then poll rigctl if its available
if (opts->use_rigctl == 1)
{
@@ -613,7 +613,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
//TG hold on NXDN -- block non-matching target, allow matching DestinationID
if (state->tg_hold != 0 && state->tg_hold != DestinationID) sprintf (mode, "%s", "B");
if (state->tg_hold != 0 && state->tg_hold == DestinationID)
if (state->tg_hold != 0 && state->tg_hold == DestinationID)
{
sprintf (mode, "%s", "A");
opts->p25_is_tuned = 0; //unlock tuner at this stage and not above check
@@ -630,11 +630,11 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
state->lastsynctype = -1;
state->lastsynctype = -1;
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = time(NULL);
//
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, freq);
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
@@ -659,7 +659,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
fprintf (stderr, " %s", KYEL);
fprintf (stderr, " Key Loaded: %lld", state->rkey_array[DestinationID]);
state->payload_miN = state->R; //should be okay to load here, will test
}
}
if (state->M == 1) state->nxdn_cipher_type = 0x1;
}
//rtl
@@ -669,19 +669,19 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
state->lastsynctype = -1;
state->lastsynctype = -1;
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = time(NULL);
//
rtl_dev_tune (opts, freq);
rtl_dev_tune (opts, freq);
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
opts->p25_is_tuned = 1;
//set rid and tg when we actually tune to it
//only assign rid if not spare and not reserved (happens on private calls, unsure of its significance)
if ( (VoiceCallOption & 0xF) < 4) //ideally, only want 0, 2, or 3
state->nxdn_last_rid = SourceUnitID;
state->nxdn_last_rid = SourceUnitID;
state->nxdn_last_tg = DestinationID;
sprintf (state->nxdn_call_type, "%s", NXDN_Call_Type_To_Str(CallType));
@@ -701,8 +701,8 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
if (state->M == 1) state->nxdn_cipher_type = 0x1;
#endif
}
}
}
}
END_ASSGN: ; //do nothing
@@ -718,19 +718,19 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message)
uint8_t Alias2 = 0x20;
uint8_t Alias3 = 0x20;
uint8_t Alias4 = 0x20;
uint8_t blocknumber = 0;
uint8_t blocknumber = 0;
uint8_t total = 0;
uint8_t unk1 = 0;
uint8_t unk2 = 0;
uint8_t CrcCorrect = 0;
//alias can also hit on a facch1 -- do we still need this checkdown?
if (state->nxdn_sacch_non_superframe == FALSE)
{
CrcCorrect = state->NxdnElementsContent.VCallCrcIsGood;
}
else CrcCorrect = 1; //FACCH1 with bad CRC won't make it this far anyways, so set as 1
//FACCH Payload [3F][68][82][04][2 <- block number4] "[69][6F][6E][20]" <- 4 alias octets [00][7F][1C]
blocknumber = (uint8_t)ConvertBitIntoBytes(&Message[32], 4) & 0x7; // & 0x7, might just be three bits, unsure
@@ -790,14 +790,14 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message)
//crc errs in one repitition may occlude an otherwise good alias, so test and change if needed
//completed alias should still appear in ncurses terminal regardless, so this may be okay
if (CrcCorrect)
{
if (CrcCorrect)
{
fprintf (stderr, " "); //spacer
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
fprintf (stderr, "%s", state->nxdn_alias_block_segment[i][j]);
fprintf (stderr, "%s", state->nxdn_alias_block_segment[i][j]);
}
}
fprintf (stderr, " ");
@@ -816,7 +816,7 @@ void NXDN_decode_cch_info(dsd_opts * opts, dsd_state * state, uint8_t * Message)
long int freq1 = 0;
long int freq2 = 0;
UNUSED2(channel2sts, freq2);
//DFA
uint8_t bw1 = 0;
uint16_t OFN1 = 0;
@@ -849,7 +849,7 @@ void NXDN_decode_cch_info(dsd_opts * opts, dsd_state * state, uint8_t * Message)
freq1 = nxdn_channel_to_frequency (opts, state, channel1);
freq2 = nxdn_channel_to_frequency (opts, state, channel2);
}
//DFA version
if (state->nxdn_rcn == 1)
{
@@ -898,7 +898,7 @@ void NXDN_decode_cch_info(dsd_opts * opts, dsd_state * state, uint8_t * Message)
}
}
fprintf (stderr, "%s", KNRM);
}
@@ -982,7 +982,7 @@ void NXDN_decode_site_info(dsd_opts * opts, dsd_state * state, uint8_t * Message
nxdn_ca_info_handler (state, ca_info);
fprintf (stderr, "%s", KYEL);
fprintf (stderr, "\n Location ID [%06X] CSC [%04X] SVC [%04X] RST [%06X] \n CA [%06X] V[%X] ADJ [%01X] ",
fprintf (stderr, "\n Location ID [%06X] CSC [%04X] SVC [%04X] RST [%06X] \n CA [%06X] V[%X] ADJ [%01X] ",
location_id, cs_info, svc_info, rst_info, ca_info, version_num, adj_alloc);
nxdn_location_id_handler(state, location_id, 0);
@@ -1022,7 +1022,7 @@ void NXDN_decode_adj_site(dsd_opts * opts, dsd_state * state, uint8_t * Message)
//will want to monitor this PDU for potential overflow related issues with the Message or ElementContent size
//up to four adj_site_location_ids can be conveyed -- see 6.4.3.4 for more information
uint32_t adj1_site = 0;
uint32_t adj1_site = 0;
uint32_t adj2_site = 0;
uint32_t adj3_site = 0;
//options -- 6.5.38. Adjacent Site Option -- 4 LSB are Site Number, 2 MSB are spares
@@ -1193,7 +1193,7 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
DestinationID = (uint16_t)ConvertBitIntoBytes(&Message[40], 16);
state->NxdnElementsContent.DestinationID = DestinationID;
//On Type-D systems, need to truncate to an 11-bit value
//On Type-D systems, need to truncate to an 11-bit value
//other 5-bits are repeater or prefix value
uint8_t idas = 0;
uint8_t rep1 = 0;
@@ -1240,7 +1240,7 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
}
/* Print the "Call Type" */
fprintf (stderr, "%s - ", NXDN_Call_Type_To_Str(CallType));
fprintf (stderr, "%s - ", NXDN_Call_Type_To_Str(CallType));
sprintf (state->nxdn_call_type, "%s", NXDN_Call_Type_To_Str(CallType));
/* Print the "Voice Call Option" */
@@ -1311,7 +1311,7 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
{
//only assign rid if not spare and not reserved (happens on private calls, unsure of its significance)
if ( (VoiceCallOption & 0xF) < 4) //ideally, only want 0, 2, or 3
state->nxdn_last_rid = SourceUnitID;
state->nxdn_last_rid = SourceUnitID;
state->nxdn_last_tg = DestinationID;
state->nxdn_key = KeyID;
state->nxdn_cipher_type = CipherType;
@@ -1366,7 +1366,7 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
}
//Craft a fake DISC Message send it to return to CC
uint8_t dbits[96]; memset (dbits, 0, sizeof(dbits)); dbits[3] = 1; dbits[7] = 1; //DISC = 0x11;
uint8_t dbits[96]; memset (dbits, 0, sizeof(dbits)); dbits[3] = 1; dbits[7] = 1; //DISC = 0x11;
if ( (strcmp(gm, "DE") == 0) && (strcmp(gn, "ENC LO") == 0) )
NXDN_Elements_Content_decode (opts, state, 1, dbits);
@@ -1379,7 +1379,7 @@ void NXDN_decode_VCALL_IV(dsd_opts * opts, dsd_state * state, uint8_t * Message)
UNUSED(opts);
state->payload_miN = 0; //zero out
unsigned long long int IV = 0;
unsigned long long int IV = 0;
//NOTE: On Type-D systems, the FACCH1 version of message only carries a 4-octet payload and also only carries a 22-bit IV
//which makes no sense since you still have the full 80-bits of FACCH1 to use
@@ -1441,12 +1441,12 @@ void NXDN_decode_VCALL_IV(dsd_opts * opts, dsd_state * state, uint8_t * Message)
} /* End NXDN_decode_VCALL_IV() */
//SCCH messages have a unique format that can be used in a super frame, but each 'unit'
//SCCH messages have a unique format that can be used in a super frame, but each 'unit'
//can also (mostly) be decoded seperately, except an enc IV
void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uint8_t direction)
{
uint8_t sf = (uint8_t)ConvertBitIntoBytes(&Message[0], 2);
uint8_t opcode = (direction << 2 | sf);
uint8_t opcode = (direction << 2 | sf);
fprintf (stderr, "\n " ); //initial line break
@@ -1466,7 +1466,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
//elements used will be determined by other elements in the ISM/OSM messages
//OSM 4 elements
uint8_t area = Message[2];
uint8_t area = Message[2];
uint8_t rep1 = (uint8_t)ConvertBitIntoBytes(&Message[3], 5); //repeater 1 value
uint8_t rep2 = (uint8_t)ConvertBitIntoBytes(&Message[8], 5); //repeater 2 value
uint16_t id = (uint16_t)ConvertBitIntoBytes(&Message[13], 11); //id is context dependent
@@ -1486,14 +1486,14 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
uint8_t DuplexMode[32] = {0};
uint8_t TransmissionMode[32] = {0};
//ISM messages are seemingly exactly the same info as OSM, so just going to use OSM versions
//ISM messages are seemingly exactly the same info as OSM, so just going to use OSM versions
//(manual doesn't specify other than that ISM 4 is the same as ISM2, but probably doesn't have IDLE/HALT/SITE ID messages)
//set category to "Type-D" to alert users this is an a Distributed Trunking System
sprintf (state->nxdn_location_category, "Type-D");
//placeholder numbers, using 99 if these aren't set by the Site ID Message (single sites)
// if (state->nxdn_location_site_code == 0) state->nxdn_location_site_code = 99;
// if (state->nxdn_location_site_code == 0) state->nxdn_location_site_code = 99;
// if (state->nxdn_location_sys_code == 0) state->nxdn_location_sys_code = 99;
// if (state->nxdn_last_ran == -1) state->nxdn_last_ran = 99;
@@ -1520,7 +1520,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
sprintf (state->active_channel[rep1], "%s", "");
sprintf (state->active_channel[rep2], "%s", "");
}
}
else if (id == 2045)
{
fprintf (stderr, "Halt Repeater Message - ");
@@ -1528,7 +1528,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
fprintf (stderr, "Repeater 1: %d; ", rep1);
fprintf (stderr, "Repeater 2: %d; ", rep2);
}
}
else if (id == 2044)
{
fprintf (stderr, "Free Repeater Message - ");
@@ -1536,7 +1536,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
fprintf (stderr, "Free Repeater 1: %d; ", rep1);
fprintf (stderr, "Free Repeater 2: %d; ", rep2);
}
}
else if (id == 2041)
{
fprintf (stderr, "Site ID Message - ");
@@ -1550,15 +1550,15 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
if (rep2 == 0) fprintf (stderr, "Reserved; ");
else if (rep2 < 251) fprintf (stderr, "Open Access; "); //Usable voluntary every TRS...?
else fprintf (stderr, "Reserved; ");
state->nxdn_location_site_code = sitet;
state->nxdn_location_sys_code = sitet;
state->nxdn_location_site_code = sitet;
state->nxdn_location_sys_code = sitet;
state->nxdn_last_ran = sitet;
}
}
else //Busy Repeater Message is essentially our 'call in progess' message for a repeater
{
if (gu && rep1 == 0) fprintf (stderr, "REG_COMM; ");
else fprintf (stderr, "Busy Repeater Message - ");
else fprintf (stderr, "Busy Repeater Message - ");
fprintf (stderr, "Area: %d; ", area);
fprintf (stderr, "Go to Repeater: %d; ", rep1);
fprintf (stderr, "Home Repeater: %d; ", rep2);
@@ -1568,8 +1568,8 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
fprintf (stderr, "\n%s ", KRED);
state->nxdn_last_tg = 0;
state->nxdn_last_rid = 0;
}
else
}
else
{
fprintf (stderr, "\n%s ", KGRN);
//only set this is during a voice tx, and not a data tx
@@ -1577,14 +1577,14 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
state->nxdn_last_tg = id;
}
fprintf (stderr, " Channel Update - CH: %d - TGT: %d ", rep1, id);
fprintf (stderr, " Channel Update - CH: %d - TGT: %d ", rep1, id);
if (gu == 0) fprintf (stderr, "Group Call ");
else fprintf (stderr, "Private Call ");
if (rep1 == 31) fprintf (stderr, "Termination ");
//add current active to display string -- may need tweaking on if to use rep1 (active ch), or rep2 (home prefix)
if (rep1 != 0 && rep1 != 31)
if (rep1 != 0 && rep1 != 31)
{
if (gu == 0) sprintf (state->active_channel[rep1], "Active Group Ch: %d TG: %d-%d; ", rep1, rep2, id); //Group TG
else sprintf (state->active_channel[rep1], "Active Private Ch: %d TGT: %d-%d; ", rep1, rep2, id); //Private TGT
@@ -1604,7 +1604,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
if (rep1 == 31) tune = 1;
//begin tuning
if (tune == 1 && rep1 != 0)
if (tune == 1 && rep1 != 0)
{
//check for control channel frequency in the channel map if not available
if (state->trunk_chan_map[31] != 0) state->p25_cc_freq = state->trunk_chan_map[31]; //user provided channel to go to for '31' -- may change to 0 later?
@@ -1631,7 +1631,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
//TG hold on IDAS -- block non-matching target, allow matching DestinationID
if (state->tg_hold != 0 && state->tg_hold != id) sprintf (mode, "%s", "B");
if (state->tg_hold != 0 && state->tg_hold == id)
if (state->tg_hold != 0 && state->tg_hold == id)
{
sprintf (mode, "%s", "A");
opts->p25_is_tuned = 0; //unlock tuner at this stage and not above check
@@ -1644,7 +1644,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0)) //DE is digital encrypted, B is block
{
//will need to monitor, 1 second may be too long on idas, may need to try 0 or manipulate another way
if (state->p25_cc_freq != 0 && ((time(NULL) - state->last_vc_sync_time) > 1) && freq != 0)
if (state->p25_cc_freq != 0 && ((time(NULL) - state->last_vc_sync_time) > 1) && freq != 0)
{
//rigctl
if (opts->use_rigctl == 1)
@@ -1652,7 +1652,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
state->lastsynctype = -1;
state->lastsynctype = -1;
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = time(NULL); //should we use this here, or not?
//
@@ -1672,11 +1672,11 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
state->lastsynctype = -1;
state->lastsynctype = -1;
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = time(NULL); //should we use this here, or not?
//
rtl_dev_tune (opts, freq);
rtl_dev_tune (opts, freq);
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
opts->p25_is_tuned = 1;
//check the rkey array for a scrambler key value
@@ -1685,8 +1685,8 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
if (state->M == 1) state->nxdn_cipher_type = 0x1;
#endif
}
}
}
}
} //end tuning -- NOTE: since we are only going by last time voice sync detected, tuning here is always 'unlocked'
@@ -1698,7 +1698,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
{
fprintf (stderr, "Source Message - ");
fprintf (stderr, "Area: %d; ", area);
fprintf (stderr, "Free Repeater 1: %d; ", rep1);
fprintf (stderr, "Free Repeater 1: %d; ", rep1);
if (id == 31)
{
@@ -1719,7 +1719,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
if (opcode == 0x6 || opcode == 0x2) //OSM INFO 2 -- same as 4
{
fprintf (stderr, "Target Message - ");
fprintf (stderr, "Target Message - ");
fprintf (stderr, "Area: %d; ", area);
fprintf (stderr, "Go to Repeater: %d; ", rep1);
if (id == 31)
@@ -1727,14 +1727,14 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
fprintf (stderr, "\n%s ", KYEL);
fprintf (stderr, " Call IV A: %04llX; ", iv_a); //MSB 0-11
//zero out IV storage and append this chunk to MSB position
state->payload_miN = 0;
state->payload_miN = 0;
state->payload_miN = state->payload_miN | (iv_a << 11); //MSB 11, so shift 11 (22 total bits).
}
else
{
//rep2 is the home repeater/source prefix in this instance
fprintf (stderr, "\n%s ", KGRN);
fprintf (stderr, " Target Update - Prefix CH: %d SRC: %d - (%d-%d) ", rep2, id, rep2, id); //rep2
fprintf (stderr, " Target Update - Prefix CH: %d SRC: %d - (%d-%d) ", rep2, id, rep2, id); //rep2
//only set this is during a voice tx, and not a data tx
if ( time(NULL) - state->last_vc_sync_time < 1 )
state->nxdn_last_tg = id;