mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 01:07:24 -05:00
commit 833e0173f24b12a12ff80f9a35fb43107d355cc3 Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 22:51:02 2024 -0400 Fix Slot Preference Depending on Build; commit 716577ab09c0cee68bca3bcdcbaaa7cfa3be4f97 Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 22:27:24 2024 -0400 M17 - Voice Playback Only If Enabled; Misc; commit c0f9818cf38ce7f127370f19ec4afa2457cef19a Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 17:39:34 2024 -0400 Add DMR/P25p2 Stereo Channel Patch; commit 1a0baf0a17ccf8cc0eb0a01a809269354480d1d1 Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 17:37:46 2024 -0400 Add DMR Cap+ Faster Rest Patch; commit 9f5b52aa8f20bfe3eab5413f2c3fa41003d53b3c Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 17:36:24 2024 -0400 Disable EDACS Analog Debug; commit 7dd0de67b602f0acd111200f838fbb1a0541a8bf Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 17:36:04 2024 -0400 Squashed commit of the following: commit 95d46fb35d6cb6fb0a9825084f4c2accf8edad4a Author: lwvmobile <lwvmobile@gmail.com> Date: Mon Mar 25 17:48:57 2024 -0400 Enable HPF_D by default; Increase manual analog gain to 50; commit 1f37837664e16760b5cbf5653fc4d829ee6cce83 Author: lwvmobile <lwvmobile@gmail.com> Date: Mon Mar 25 08:43:17 2024 -0400 Enable HPF_D on M17 Voice; commit9bbe4de7fdAuthor: lwvmobile <lwvmobile@gmail.com> Date: Sun Mar 24 16:08:16 2024 -0400 EDACS: Digitize Analog For Analysis of 'Data Burst' Like Behavior; commit9249b7a943Author: lwvmobile <lwvmobile@gmail.com> Date: Sun Mar 24 12:28:26 2024 -0400 Simply Mono Short Playback; commit89ad0f17e3Author: lwvmobile <lwvmobile@gmail.com> Date: Sat Mar 23 21:12:44 2024 -0400 Add HPF to SS4, SS3, and SS Audio Methods; commite8184c7fbdAuthor: lwvmobile <lwvmobile@gmail.com> Date: Sat Mar 23 17:13:44 2024 -0400 RTL - Add The Sample / Volume Multiplier as a user configurable option; commitee04d11116Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 23:15:04 2024 -0400 Fix HPF_D so it actually works correctly; commite549b21497Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 20:11:34 2024 -0400 Make Analog Auto Gain Control Mostly Tolerable; commit2f9e0525feAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 18:20:38 2024 -0400 User Toggle HPF on Digital; commitff58d3a6faAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 18:10:15 2024 -0400 User Toggles and Displays for Filters; commitb6fc17c506Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 15:55:09 2024 -0400 More Analog Manual Audio Gain Tweaks; commit076b9fbf04Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 06:26:10 2024 -0400 Add SQL Hit on EDACS if Colors Disabled; commit59fe47ef05Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 02:23:08 2024 -0400 Disable HPF Test on Digital Voice; commit4a63068ce1Author: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 23:39:43 2024 -0400 Misc Code Organizing; audio_gainA Tweaks; commit3585e7e594Author: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 13:18:31 2024 -0400 Test Tweak to RTL Sample Multiplier; commitfa5b25283fAuthor: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 13:18:07 2024 -0400 Adjust Manual Mic Gain on M17 Encoder; Ncurses Display; commitc985fea035Author: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 12:34:01 2024 -0400 Misc Notes on using raw_rms values during testing; commitb273e5b7beAuthor: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 12:31:33 2024 -0400 Bugfix for EDACS Analog Segfault when using the digitize function for an extended period; commiteadf3fdf23Author: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 10:12:04 2024 -0400 Analog Gain Has Own Variable; Ncurses Keys; Misc; commit0debcc647eAuthor: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 08:49:51 2024 -0400 Filtering Misc Cleanup; commit98e10b2627Author: lwvmobile <lwvmobile@gmail.com> Date: Thu Mar 21 00:02:21 2024 -0400 Automatic Gain On Analog WIP; Manual Gain Control; commit89736ae543Author: lwvmobile <lwvmobile@gmail.com> Date: Wed Mar 20 10:22:20 2024 -0400 Passband Filter Testing on Raw Analog / EDACS / M17 Encoder; commit43f6218129Author: lwvmobile <lwvmobile@gmail.com> Date: Wed Mar 20 09:03:02 2024 -0400 Passband and Notch Filter Setup; Debug Output; commit35a1b53867Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 22:35:36 2024 -0400 HPF: Only Use On RTL Input when M17 Encoder Uses It; commitb9949f0d80Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 17:31:59 2024 -0400 Disable LFP on EDACS Analog Out; commit3666740674Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 13:42:07 2024 -0400 Test HPF On Digital Voice Out; commitef13343925Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 12:46:27 2024 -0400 RTL_FM Input for Analog/M17 Encoder; commit2b7de90474Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 11:03:55 2024 -0400 New Analog Audio Filters WIP; commit 3b9f9f5a3befb295da284379262323fad7d69c7a Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 26 17:33:34 2024 -0400 Squashed commit of the following: commit a5c5be3b955a82cc72f1486ff87d7c1b4893295f Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Tue Mar 26 17:28:35 2024 -0400 EDACS: Standard display rewrite, parsing/RE fixes, tune i-calls and all-calls (#246) * EDACS EA: Fix reversed TDMA/data calls * EDACS: deduplicate ncurses printing logic * EDACS: pass call state via new state struct field * EDACS: RE some differences from Standard spec * EDACS: show state for data calls * EDACS: tune individual calls on Standard * EDACS: tune all-calls on Standard * EDACS: properly identify emergency on channel updates * EDACS: fix build break * EDACS: fix conditions for refreshing the display source * EDACS EA: Identify calls as voice for display * EDACS: voice channel update emergency refactor * EDACS: Show interconnect calls in call log * EDACS EA: show unknown data channel assignments in log * EDACS: check LCN is not 0 before assigning it * EDACS: C operator precedence is dumb * Initialize edacs_vc_call_type * use j and not i in call_matrix for call history; --------- Co-authored-by: lwvmobile <lwvmobile@gmail.com> commitc8d00846b1Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sun Mar 24 17:48:46 2024 -0400 EDACS: Display cached call source on Standard, tune group calls on assignment (#241) * Trim trailing whitespace * EDACS: Display cached call source on Standard The logic in `edacs-fme.c` didn't work, in retrospect, because it would have depended on getting back-to-back messages for the same call. In practice, that is unlikely even on an idle system as system state gets displayed. Instead, cache on the display end, for a "better" user experience. * EDACS: Pad channel freq to "000.000000 MHz" * EDACS: Process/tune group calls on assignment commit8d432e8b3eAuthor: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sun Mar 24 12:29:22 2024 -0400 EDACS: ESK fixes, RE of standard channel assignments, cleanups (#238) * EDACS: Make i-calls very obvious on standard * EDACS: abstract target for Interconnect Channel Assignment * EDACS: little shortcut example updates * EDACS: Apply ESK to both FR1 and FR4 * EDACS: Group channel assignment by mode * EDACS: Merge MT-A 0/1 and 2/3 cases commit0440dea1deAuthor: lwvmobile <lwvmobile@gmail.com> Date: Sun Mar 24 02:47:09 2024 -0400 EDACS: Fix Call History For Standard Maybe; commit208f188e55Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 23 21:35:42 2024 -0400 EDACS: Speculative RE of MT-A value 0, pretty colours (#231) * EDACS: fix log formatting * EDACS: Speculative RE of MT-A value 0 * EDACS: CC message pretty colours * EDACS: little formatting * EDACS: eh make interconnect magenta commit36f76a7e21Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 23 17:35:45 2024 -0400 EDACS: Fix copy/paste error (#230) I went through by hand and I'm confident this is the last of the `get_lcn_status_string()` errors. commit4bc73d8c68Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 23 17:24:32 2024 -0400 EDACS: Rewrite Standard/Networked parsing per TIA/EIA TSB 69.3 (#229) * EDACS EA: refactor log messages for consistency * EDACS: Log LCN status values * EDACS EA: channel assignment vs update * EDACS: Implement TIA/EIA TSB 69.3 * EDACS: clean up Site ID message * EDACS: Actually process call for Channel Update * EDACS: Update display for Standard calls * EDACS: Format of Voice Group Channel Assignment * EDACS Standard: Log LCN status values * EDACS: Rebase and fix some issues * EDACS: Fix copy/paste error commit03507055a4Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 23 16:05:09 2024 -0400 EDACS: add EA messages / start mass Standard refactor (#226) * EDACS EA: refactor log messages for consistency * EDACS EA: channel assignment command (unknown data) * EDACS EA: status/message command * EDACS Standard: Refactor variable declarations * EDACS Standard: log raw payloads for debugging * EDACS: Fix typing * EDACS EA: update status/message CC command * EDACS: Log LCN status values * EDACS: String format * EDACS EA: channel assignment vs update * EDACS: fix syntax error * EDACS: change string for reserved LCN status commitfbe5fd2093Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Fri Mar 22 15:26:50 2024 -0400 EDACS EA: emergency calls, MT1 fixes, logging improvements (#221) * EDACS EA: Fix i-call MT1 after ESK changes * EDACS EA: Fix all-call ncurses display * EDACS EA: Make detailed log slightly more readable * EDACS EA: Improve colours in logs * EDACS EA: Space in logs for consistency * EDACS EA: Fix MT1 for analog group voice after ESK change * EDACS EA: add parsing for emergency calls commit413e5f76a2Merge:de9127c388a57dAuthor: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Fri Mar 22 06:59:31 2024 -0400 Merge pull request #220 from lwvmobile/edacs_manual_modes Edacs manual modes commit388a57d8fcAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 05:28:11 2024 -0400 EDACS: Re-enable the -9 switch to maintain user compatability; Fix Missing Bracket on non color mode; commit058099f1aaAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 03:24:57 2024 -0400 EDACS: Tweak Mode Toggle Display; Add Frame Dump on No Mode Set; commit68aa6b018eAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 02:19:38 2024 -0400 EDACS: Update Docs to Reflect Changes; commitc404f3c48cAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 02:01:09 2024 -0400 EDACS: Ncurses Display Working Mode Tweaks; commitb2d1608eb7Author: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 01:08:28 2024 -0400 EDACS: Toggle Keys A and S for Mode Selection; commita4553a0a0aAuthor: lwvmobile <lwvmobile@gmail.com> Date: Fri Mar 22 00:45:37 2024 -0400 EDACS: Remove Auto Detect Code; Make CLI Switches; commitde9127cfb4Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Thu Mar 21 21:02:53 2024 -0400 EDACS: support for EA system all-calls (#214) * Refactor debug printing a bit * Clean up group call logic * Minor changes to debug printing * EDACS EA: support for system all-calls * EDACS: split out MT1 for TDMA call since we can't decode it anyway * Refactor identifying call mode (digital/analog) * Maintain consistent indentation for all MT1 * EDACS: Fix Compiler Error. Had an extra right bracket on line 383 --------- Co-authored-by: lwvmobile <59371473+lwvmobile@users.noreply.github.com> commitc85dd60399Author: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 17:38:30 2024 -0400 EDACS: NET/STD LCN > 0 Check; commitbed766a86eAuthor: lwvmobile <lwvmobile@gmail.com> Date: Tue Mar 19 09:34:10 2024 -0400 EDACS: STD/NET Don't Tune Unless CC LCN Set; commit69f532a022Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Mon Mar 18 11:41:58 2024 -0400 EDACS: EA I-Call decoding improvements (#205) * EDACS: formatting nit * EDACS: add name to credits * EDACS: Handle initial grant vs grant update for i-call * EDACS: consistency for group vs i-call * EDACS: file naming for i-call recordings * EDACS: EA refactor when MT1 is 0x1F * EDACS: check we know CC LCN before leaving it * EDACS: fix breaking change for Standard Revert mistake inf68367c4f3* Fix patent number * EDACS: Fix Compiler Error 1; Fix Rogue Copy Paste * EDACS: Add MT1, MT2, and FR1 and FR4 Dumps on Payload; --------- Co-authored-by: lwvmobile <59371473+lwvmobile@users.noreply.github.com> commita7de24c47bAuthor: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Mon Mar 18 07:47:34 2024 -0400 EDACS: fixes and improvements to EA analog and i-call parsing (#204) * Fix MT1 math given esk_mask value is 0xA0 * EDACS: Clean up formatting for I-Calls * EDACS: typo, fix the TGID for group calls Fix copy-pasta * EDACS: Fix MT2 for I-Calls Incorrectly copied decimal values as hex - obviously MT2 is only 4 bits so it cannot be greater than 15. * EDACS: check LCN is > 0 before trying to tune An EA CC sometimes includes commands that parse as LCN 0 - but otherwise valid - analog call voice grants for TG 1. Since LCN 0 is not valid, ensure that we don't try to tune to them while we try to figure out what they're about. * EDACS: Process "login" message on CC Log "login" messages sent on the CC. Verified behaviour against UniTrunker. commit10eacd99ccAuthor: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sun Mar 17 18:56:41 2024 -0400 EDACS: Clean up formatting for I-Calls (#203) * Fix MT1 math given esk_mask value is 0xA0 * EDACS: Clean up formatting for I-Calls commitebe6e8fc65Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sun Mar 17 18:02:12 2024 -0400 Fix MT1 math given esk_mask value is 0xA0 (#202) commit8619612b76Author: lwvmobile <lwvmobile@gmail.com> Date: Sat Mar 16 22:42:44 2024 -0400 EDACS: Setup Analog Calls and WAVs on EA and ICALL; commit9ac1573f0bAuthor: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 16 17:17:14 2024 -0400 EDACS: Add MT1 value / logging for analog group calls (#198) * Add MT1 value / logging for analog group calls * Respect user preference for tuning to group calls * Revert "Respect user preference for tuning to group calls" This reverts commit83ac8feab7. commit0aa01a45efAuthor: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 16 17:16:52 2024 -0400 EDACS: Respect user preference for tuning to group calls (#201) commitf68367c4f3Author: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Sat Mar 16 17:16:20 2024 -0400 EDACS: Add parsing for individual calls (#200) * EDACS: Add parsing for individual calls This change adds parsing for I-Calls on EA systems. Both analog and ProVoice modes are parsed and processed. See related issue for discussion. * Respect user preference for tuning to private calls * EDACS: Respect user preference for tuning to private calls * EDACS: Handle i-call target in ProVoice logging * EDACS: Show i-calls distinctly from group calls
832 lines
24 KiB
C
832 lines
24 KiB
C
/*-------------------------------------------------------------------------------
|
|
* p25p2_xcch.c
|
|
* Phase 2 SACCH/FACCH/LCCH Handling
|
|
*
|
|
* LWVMOBILE
|
|
* 2022-09 DSD-FME Florida Man Edition
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
#include "dsd.h"
|
|
|
|
void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180])
|
|
{
|
|
//Figure out which PDU we are looking at, see above info on 8.4.1
|
|
//reorganize bits into bytes and process accordingly
|
|
|
|
//new slot variable with flipped assignment for SACCH
|
|
uint8_t slot = (state->currentslot ^ 1) & 1;
|
|
|
|
unsigned long long int SMAC[24] = {0}; //22.5 bytes for SACCH MAC PDUs
|
|
int byte = 0;
|
|
int k = 0;
|
|
for (int j = 0; j < 22; j++)
|
|
{
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
byte = byte << 1;
|
|
byte = byte | payload[k];
|
|
k++;
|
|
}
|
|
SMAC[j] = byte;
|
|
byte = 0; //reset byte
|
|
}
|
|
SMAC[22] = (payload[176] << 7) | (payload[177] << 6) | (payload[178] << 5) | (payload[179] << 4);
|
|
|
|
int opcode = 0;
|
|
opcode = (payload[0] << 2) | (payload[1] << 1) | (payload[2] << 0);
|
|
int mac_offset = 0;
|
|
mac_offset = (payload[3] << 2) | (payload[4] << 1) | (payload[5] << 0);
|
|
int res = (payload[6] << 1) | (payload[7] << 0);
|
|
int b = 9;
|
|
b = (payload[8] << 1) | (payload[9] << 0); //combined b1 and b2
|
|
int mco_a = 69;
|
|
//mco will tell us the number of octets to use in variable length MAC PDUs, need a table or something
|
|
mco_a = (payload[10] << 5) | (payload[11] << 4) | (payload[12] << 3) | (payload[13] << 2) | (payload[14] << 0) | (payload[15] << 0);
|
|
UNUSED3(mac_offset, b, mco_a);
|
|
|
|
//get the second mco after determining first message length, see what second mco is and plan accordingly
|
|
int mco_b = 69;
|
|
UNUSED(mco_b);
|
|
|
|
//attempt CRC12 check to validate or reject PDU
|
|
int err = -2;
|
|
if (state->p2_is_lcch == 0)
|
|
{
|
|
err = crc12_xb_bridge(payload, 180-12);
|
|
if (err != 0) //CRC Failure, warn or skip.
|
|
{
|
|
if (SMAC[1] == 0x0) //NULL PDU Check, pass if NULL type
|
|
{
|
|
//fprintf (stderr, " NULL ");
|
|
}
|
|
else
|
|
{
|
|
fprintf (stderr, " CRC12 ERR S");
|
|
//if (state->currentslot == 0) state->dmrburstL = 14;
|
|
//else state->dmrburstR = 14;
|
|
goto END_SMAC;
|
|
}
|
|
}
|
|
}
|
|
if (state->p2_is_lcch == 1)
|
|
{
|
|
int len = 0;
|
|
//int len = mac_msg_len[SMAC[1]] * 8;
|
|
//if (len > 164) len = 164; //prevent potential stack smash or other issue.
|
|
len = 164;
|
|
err = crc16_lb_bridge(payload, len);
|
|
if (err != 0) //CRC Failure, warn or skip.
|
|
{
|
|
if (SMAC[1] == 0x0) //NULL PDU Check, pass if NULL type
|
|
{
|
|
//fprintf (stderr, " NULL ");
|
|
state->p2_is_lcch = 0; //turn flag off here
|
|
goto END_SMAC;
|
|
}
|
|
else //permit MAC_SIGNAL on CRC ERR if -F option called
|
|
{
|
|
if (opts->aggressive_framesync == 1)
|
|
{
|
|
fprintf (stderr, " CRC16 ERR L");
|
|
state->p2_is_lcch = 0; //turn flag off here
|
|
//if (state->currentslot == 0) state->dmrburstL = 14;
|
|
//else state->dmrburstR = 14;
|
|
goto END_SMAC;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//remember, slots are inverted here, so set the opposite ones
|
|
//monitor, test, and remove these if they cause issues due to inversion
|
|
if (opcode == 0x0)
|
|
{
|
|
fprintf (stderr, " MAC_SIGNAL ");
|
|
//warn user instead of failing
|
|
if (err != 0)
|
|
{
|
|
fprintf (stderr, "%s", KRED);
|
|
fprintf (stderr, "CRC16 ERR ");
|
|
}
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
//do not permit MAC_PTT with CRC errs, help prevent false positives on calls
|
|
if (opcode == 0x1 && err == 0)
|
|
{
|
|
fprintf (stderr, " MAC_PTT ");
|
|
fprintf (stderr, "%s", KGRN);
|
|
//remember, slots are inverted here, so set the opposite ones
|
|
if (state->currentslot == 1)
|
|
{
|
|
//reset fourv_counter and dropbyte on PTT
|
|
state->fourv_counter[0] = 0;
|
|
state->voice_counter[0] = 0;
|
|
state->dropL = 256;
|
|
|
|
state->dmrburstL = 20;
|
|
fprintf (stderr, "\n VCH 0 - ");
|
|
|
|
state->lastsrc = (SMAC[13] << 16) | (SMAC[14] << 8) | SMAC[15];
|
|
state->lasttg = (SMAC[16] << 8) | SMAC[17];
|
|
|
|
fprintf (stderr, "TG %d ", state->lasttg);
|
|
fprintf (stderr, "SRC %d ", state->lastsrc);
|
|
|
|
/*
|
|
When the talker radio is initiating an individual call (unit to unit or telephone interconnect), the reserved group ID of zero
|
|
is used in the group address portion of the MAC_PTT PDU and the source ID is that of the talker radio.
|
|
|
|
The outbound SACCH for the talker radio containing the talker ID information is required at the
|
|
talker radio site and optional at other sites. (So, if its from an external site, then it can be zero?)
|
|
|
|
*/
|
|
|
|
// if (state->lastsrc == 0) fprintf (stderr, "External ");
|
|
|
|
state->payload_algid = SMAC[10];
|
|
state->payload_keyid = (SMAC[11] << 8) | SMAC[12];
|
|
state->payload_miP = (SMAC[1] << 56) | (SMAC[2] << 48) | (SMAC[3] << 40) | (SMAC[4] << 32) |
|
|
(SMAC[5] << 24) | (SMAC[6] << 16) | (SMAC[7] << 8) | (SMAC[8] << 0);
|
|
|
|
if (state->payload_algid != 0x80 && state->payload_algid != 0x0)
|
|
{
|
|
fprintf (stderr, "%s", KYEL);
|
|
fprintf (stderr, "\n ALG ID 0x%02X", state->payload_algid);
|
|
fprintf (stderr, " KEY ID 0x%04X", state->payload_keyid);
|
|
fprintf (stderr, " MI 0x%016llX", state->payload_miP);
|
|
if (state->R != 0 && state->payload_algid == 0xAA) fprintf (stderr, " Key 0x%010llX", state->R);
|
|
fprintf(stderr, " MPTT");
|
|
// fprintf (stderr, " %s", KRED);
|
|
// fprintf (stderr, "ENC");
|
|
}
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gain = opts->audio_gain;
|
|
|
|
}
|
|
|
|
if (state->currentslot == 0)
|
|
{
|
|
//reset fourv_counter and dropbyte on PTT
|
|
state->fourv_counter[1] = 0;
|
|
state->voice_counter[1] = 0;
|
|
state->dropR = 256;
|
|
state->payload_algidR = 0; //zero this out as well
|
|
|
|
state->dmrburstR = 20;
|
|
fprintf (stderr, "\n VCH 1 - ");
|
|
|
|
state->lastsrcR = (SMAC[13] << 16) | (SMAC[14] << 8) | SMAC[15];
|
|
state->lasttgR = (SMAC[16] << 8) | SMAC[17];
|
|
|
|
fprintf (stderr, "TG %d ", state->lasttgR);
|
|
fprintf (stderr, "SRC %d ", state->lastsrcR);
|
|
|
|
// if (state->lastsrcR == 0) fprintf (stderr, "External ");
|
|
|
|
state->payload_algidR = SMAC[10];
|
|
state->payload_keyidR = (SMAC[11] << 8) | SMAC[12];
|
|
state->payload_miN = (SMAC[1] << 56) | (SMAC[2] << 48) | (SMAC[3] << 40) | (SMAC[4] << 32) |
|
|
(SMAC[5] << 24) | (SMAC[6] << 16) | (SMAC[7] << 8) | (SMAC[8] << 0);
|
|
|
|
if (state->payload_algidR != 0x80 && state->payload_algidR != 0x0)
|
|
{
|
|
fprintf (stderr, "%s", KYEL);
|
|
fprintf (stderr, "\n ALG ID 0x%02X", state->payload_algidR);
|
|
fprintf (stderr, " KEY ID 0x%04X", state->payload_keyidR);
|
|
fprintf (stderr, " MI 0x%016llX", state->payload_miN);
|
|
if (state->RR != 0 && state->payload_algidR == 0xAA) fprintf (stderr, " Key 0x%010llX", state->RR);
|
|
fprintf(stderr, " MPTT");
|
|
// fprintf (stderr, " %s", KRED);
|
|
// fprintf (stderr, "ENC");
|
|
}
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gainR = opts->audio_gain;
|
|
|
|
}
|
|
|
|
if (opts->payload == 1)
|
|
{
|
|
fprintf (stderr, "\n MAC_PTT_PAYLOAD_S OFFSET: %d RES: %d \n ", mac_offset, res);
|
|
for (int i = 0; i < 24; i++)
|
|
{
|
|
if (i == 12) fprintf (stderr, "\n ");
|
|
fprintf (stderr, "[%02llX]", SMAC[i]);
|
|
}
|
|
}
|
|
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
//do not permit MAC_PTT_END with CRC errs, help prevent false positives on calls
|
|
if (opcode == 0x2 && err == 0)
|
|
{
|
|
fprintf (stderr, " MAC_END_PTT ");
|
|
fprintf (stderr, "%s", KRED);
|
|
//remember, slots are inverted here, so set the opposite ones
|
|
if (state->currentslot == 1)
|
|
{
|
|
|
|
state->fourv_counter[0] = 0;
|
|
state->voice_counter[0] = 0;
|
|
state->dropL = 256;
|
|
state->dmrburstL = 23;
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
|
|
fprintf (stderr, "\n VCH 0 - ");
|
|
fprintf (stderr, "TG %d ", state->lasttg);
|
|
fprintf (stderr, "SRC %d ", state->lastsrc);
|
|
|
|
//print it and then zero out
|
|
state->lastsrc = 0;
|
|
state->lasttg = 0;
|
|
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
|
|
|
//blank the call string here -- slot variable is already flipped accordingly for sacch
|
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces -- wrong placement!
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gain = opts->audio_gain;
|
|
|
|
}
|
|
if (state->currentslot == 0)
|
|
{
|
|
|
|
state->fourv_counter[1] = 0;
|
|
state->voice_counter[1] = 0;
|
|
state->dropR = 256;
|
|
state->dmrburstR = 23;
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
|
|
fprintf (stderr, "\n VCH 1 - ");
|
|
fprintf (stderr, "TG %d ", state->lasttgR);
|
|
fprintf (stderr, "SRC %d ", state->lastsrcR);
|
|
|
|
//print it and then zero out
|
|
state->lastsrcR = 0;
|
|
state->lasttgR = 0;
|
|
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
|
|
|
//blank the call string here -- slot variable is already flipped accordingly for sacch
|
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces -- wrong placement!
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gainR = opts->audio_gain;
|
|
|
|
}
|
|
|
|
//Return to CC on MAC_END_PTT if other slot is idle
|
|
//TODO: Look at the source address of the END_PTT, if it is 0xFFFFFF, then its from the FNE?
|
|
//if from the FNE, that may be when we know channel teardown will really occur vs using MAC_END_PTT directly
|
|
|
|
/*
|
|
Upon receipt of a MAC_END_PTT PDU on the assigned VCH, and having verified it contains the
|
|
correct color code, the SU shall return to the idle state on the control channel.
|
|
*/
|
|
|
|
//NOTE: Disable return later on if not desirable to use
|
|
|
|
//end_ptt in this slot, idle in the other slot (Normal Slots)
|
|
if ( ((state->currentslot == 0) && (state->dmrburstL == 24)) ||
|
|
((state->currentslot == 1) && (state->dmrburstR == 24)) )
|
|
{
|
|
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1)
|
|
{
|
|
|
|
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
|
|
if (state->p25_cc_is_tdma == 0)
|
|
{
|
|
state->samplesPerSymbol = 10;
|
|
state->symbolCenter = 4;
|
|
//re-enable both slots
|
|
opts->slot1_on = 1;
|
|
opts->slot2_on = 1;
|
|
}
|
|
|
|
//rigctl
|
|
if (opts->use_rigctl == 1)
|
|
{
|
|
state->lasttg = 0;
|
|
state->lastsrc = 0;
|
|
state->lasttgR = 0;
|
|
state->lastsrcR = 0;
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
// state->payload_miP = 0;
|
|
//reset some strings
|
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
|
sprintf (state->active_channel[0], "%s", "");
|
|
sprintf (state->active_channel[1], "%s", "");
|
|
opts->p25_is_tuned = 0;
|
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
|
}
|
|
//rtl
|
|
else if (opts->audio_in_type == 3)
|
|
{
|
|
#ifdef USE_RTLSDR
|
|
state->lasttg = 0;
|
|
state->lastsrc = 0;
|
|
state->lasttgR = 0;
|
|
state->lastsrcR = 0;
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
// state->payload_miP = 0;
|
|
//reset some strings
|
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
|
sprintf (state->active_channel[0], "%s", "");
|
|
sprintf (state->active_channel[1], "%s", "");
|
|
opts->p25_is_tuned = 0;
|
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
|
rtl_dev_tune (opts, state->p25_cc_freq);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
if (opcode == 0x3 && err == 0)
|
|
{
|
|
if (state->currentslot == 1) state->dmrburstL = 24;
|
|
else state->dmrburstR = 24;
|
|
fprintf (stderr, " MAC_IDLE ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
|
|
// if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1)
|
|
// {
|
|
// if (state->currentslot == 1)
|
|
// {
|
|
// opts->slot1_on = 0;
|
|
// opts->slot2_on = 1;
|
|
// }
|
|
// else
|
|
// {
|
|
// opts->slot1_on = 1;
|
|
// opts->slot2_on = 0;
|
|
// }
|
|
// }
|
|
|
|
//blank the call string here -- slot variable is already flipped accordingly for sacch
|
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
|
|
|
}
|
|
if (opcode == 0x4 && err == 0)
|
|
{
|
|
//disable to prevent blinking in ncurses terminal due to OSS preemption shim
|
|
#ifdef AERO_BUILD
|
|
if (opts->audio_out_type != 5)
|
|
{
|
|
if (state->currentslot == 1) state->dmrburstL = 21;
|
|
else state->dmrburstR = 21;
|
|
}
|
|
#else
|
|
if (state->currentslot == 1) state->dmrburstL = 21;
|
|
else state->dmrburstR = 21;
|
|
#endif
|
|
|
|
fprintf (stderr, " MAC_ACTIVE ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
if (opcode == 0x6 && err == 0)
|
|
{
|
|
if (state->currentslot == 1)
|
|
{
|
|
state->dmrburstL = 22;
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
|
}
|
|
else
|
|
{
|
|
state->dmrburstR = 22;
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
|
}
|
|
fprintf (stderr, " MAC_HANGTIME ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
|
|
END_SMAC:
|
|
if (1 == 2)
|
|
{
|
|
//CRC Failure!
|
|
}
|
|
|
|
}
|
|
|
|
void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156])
|
|
{
|
|
//Figure out which PDU we are looking at, see above info on 8.4.1
|
|
//reorganize bits into bytes and process accordingly
|
|
|
|
//new slot variable
|
|
uint8_t slot = state->currentslot;
|
|
|
|
unsigned long long int FMAC[24] = {0}; //19.5 bytes for FACCH MAC PDUs, add padding to end
|
|
int byte = 0;
|
|
int k = 0;
|
|
for (int j = 0; j < 19; j++)
|
|
{
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
byte = byte << 1;
|
|
byte = byte | payload[k];
|
|
k++;
|
|
}
|
|
FMAC[j] = byte;
|
|
byte = 0; //reset byte
|
|
}
|
|
FMAC[19] = (payload[152] << 7) | (payload[153] << 6) | (payload[154] << 5) | (payload[155] << 4);
|
|
|
|
//add padding bytes so we can have a unified variable MAC PDU handler
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
FMAC[i+20] = 0;
|
|
}
|
|
|
|
int opcode = 0;
|
|
opcode = (payload[0] << 2) | (payload[1] << 1) | (payload[2] << 0);
|
|
int mac_offset = 0;
|
|
mac_offset = (payload[3] << 2) | (payload[4] << 1) | (payload[5] << 0);
|
|
int res = (payload[6] << 1) | (payload[7] << 0);
|
|
UNUSED(mac_offset);
|
|
|
|
//attempt CRC check to validate or reject PDU
|
|
int err = -2;
|
|
if (state->p2_is_lcch == 0)
|
|
{
|
|
err = crc12_xb_bridge(payload, 156-12);
|
|
if (err != 0) //CRC Failure, warn or skip.
|
|
{
|
|
if (FMAC[1] == 0x0) //NULL PDU Check, pass if NULL
|
|
{
|
|
//fprintf (stderr, " NULL ");
|
|
}
|
|
else
|
|
{
|
|
fprintf (stderr, " CRC12 ERR F");
|
|
//if (state->currentslot == 0) state->dmrburstL = 14;
|
|
//else state->dmrburstR = 14;
|
|
goto END_FMAC;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Not sure if a MAC Signal will come on a FACCH or not, so disable to prevent falsing
|
|
// if (opcode == 0x0)
|
|
// {
|
|
// fprintf (stderr, " MAC_SIGNAL ");
|
|
// fprintf (stderr, "%s", KYEL);
|
|
// process_MAC_VPDU(opts, state, 0, FMAC);
|
|
// fprintf (stderr, "%s", KNRM);
|
|
// }
|
|
|
|
if (opcode == 0x1 && err == 0)
|
|
{
|
|
|
|
fprintf (stderr, " MAC_PTT ");
|
|
fprintf (stderr, "%s", KGRN);
|
|
if (state->currentslot == 0)
|
|
{
|
|
//reset fourv_counter and dropbyte on PTT
|
|
state->fourv_counter[0] = 0;
|
|
state->voice_counter[0] = 0;
|
|
state->dropL = 256;
|
|
|
|
state->dmrburstL = 20;
|
|
fprintf (stderr, "\n VCH 0 - ");
|
|
|
|
state->lastsrc = (FMAC[13] << 16) | (FMAC[14] << 8) | FMAC[15];
|
|
state->lasttg = (FMAC[16] << 8) | FMAC[17];
|
|
|
|
fprintf (stderr, "TG %d ", state->lasttg);
|
|
fprintf (stderr, "SRC %d ", state->lastsrc);
|
|
|
|
// if (state->lastsrc == 0) fprintf (stderr, "External ");
|
|
|
|
state->payload_algid = FMAC[10];
|
|
state->payload_keyid = (FMAC[11] << 8) | FMAC[12];
|
|
state->payload_miP = (FMAC[1] << 56) | (FMAC[2] << 48) | (FMAC[3] << 40) | (FMAC[4] << 32) |
|
|
(FMAC[5] << 24) | (FMAC[6] << 16) | (FMAC[7] << 8) | (FMAC[8] << 0);
|
|
|
|
if (state->payload_algid != 0x80 && state->payload_algid != 0x0)
|
|
{
|
|
fprintf (stderr, "%s", KYEL);
|
|
fprintf (stderr, "\n ALG ID 0x%02X", state->payload_algid);
|
|
fprintf (stderr, " KEY ID 0x%04X", state->payload_keyid);
|
|
fprintf (stderr, " MI 0x%016llX", state->payload_miP);
|
|
if (state->R != 0 && state->payload_algid == 0xAA) fprintf (stderr, " Key 0x%010llX", state->R);
|
|
fprintf(stderr, " MPTT");
|
|
// fprintf (stderr, " %s", KRED);
|
|
// fprintf (stderr, "ENC");
|
|
}
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gain = opts->audio_gain;
|
|
|
|
}
|
|
|
|
if (state->currentslot == 1)
|
|
{
|
|
//reset fourv_counter and dropbyte on PTT
|
|
state->fourv_counter[1] = 0;
|
|
state->voice_counter[1] = 0;
|
|
state->dropR = 256;
|
|
|
|
state->dmrburstR = 20;
|
|
fprintf (stderr, "\n VCH 1 - ");
|
|
|
|
state->lastsrcR = (FMAC[13] << 16) | (FMAC[14] << 8) | FMAC[15];
|
|
state->lasttgR = (FMAC[16] << 8) | FMAC[17];
|
|
|
|
fprintf (stderr, "TG %d ", state->lasttgR);
|
|
fprintf (stderr, "SRC %d ", state->lastsrcR);
|
|
|
|
// if (state->lastsrcR == 0) fprintf (stderr, "External ");
|
|
|
|
state->payload_algidR = FMAC[10];
|
|
state->payload_keyidR = (FMAC[11] << 8) | FMAC[12];
|
|
state->payload_miN = (FMAC[1] << 56) | (FMAC[2] << 48) | (FMAC[3] << 40) | (FMAC[4] << 32) |
|
|
(FMAC[5] << 24) | (FMAC[6] << 16) | (FMAC[7] << 8) | (FMAC[8] << 0);
|
|
|
|
if (state->payload_algidR != 0x80 && state->payload_algidR != 0x0)
|
|
{
|
|
fprintf (stderr, "%s", KYEL);
|
|
fprintf (stderr, "\n ALG ID 0x%02X", state->payload_algidR);
|
|
fprintf (stderr, " KEY ID 0x%04X", state->payload_keyidR);
|
|
fprintf (stderr, " MI 0x%016llX", state->payload_miN);
|
|
if (state->RR != 0 && state->payload_algidR == 0xAA) fprintf (stderr, " Key 0x%010llX", state->RR);
|
|
fprintf(stderr, " MPTT");
|
|
// fprintf (stderr, " %s", KRED);
|
|
// fprintf (stderr, "ENC");
|
|
}
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gainR = opts->audio_gain;
|
|
|
|
}
|
|
|
|
if (opts->payload == 1)
|
|
{
|
|
fprintf (stderr, "\n MAC_PTT_PAYLOAD_F OFFSET: %d RES: %d \n ", mac_offset, res);
|
|
for (int i = 0; i < 24; i++)
|
|
{
|
|
if (i == 12) fprintf (stderr, "\n ");
|
|
fprintf (stderr, "[%02llX]", FMAC[i]);
|
|
}
|
|
}
|
|
fprintf (stderr, "%s", KNRM);
|
|
|
|
}
|
|
if (opcode == 0x2 && err == 0)
|
|
{
|
|
fprintf (stderr, " MAC_END_PTT ");
|
|
fprintf (stderr, "%s", KRED);
|
|
if (state->currentslot == 0)
|
|
{
|
|
|
|
state->fourv_counter[0] = 0;
|
|
state->voice_counter[0] = 0;
|
|
state->dropL = 256;
|
|
state->dmrburstL = 23;
|
|
state->payload_algid = 0; //zero this out as well
|
|
state->payload_keyid = 0;
|
|
|
|
fprintf (stderr, "\n VCH 0 - ");
|
|
fprintf (stderr, "TG %d ", state->lasttg);
|
|
fprintf (stderr, "SRC %d ", state->lastsrc);
|
|
|
|
//print it and then zero out
|
|
state->lastsrc = 0;
|
|
state->lasttg = 0;
|
|
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
|
|
|
//blank the call string here
|
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gain = opts->audio_gain; //reset
|
|
|
|
}
|
|
if (state->currentslot == 1)
|
|
{
|
|
|
|
state->fourv_counter[1] = 0;
|
|
state->voice_counter[1] = 0;
|
|
state->dropR = 256;
|
|
state->dmrburstR = 23;
|
|
state->payload_algidR = 0; //zero this out as well
|
|
state->payload_keyidR = 0;
|
|
|
|
fprintf (stderr, "\n VCH 1 - ");
|
|
fprintf (stderr, "TG %d ", state->lasttgR);
|
|
fprintf (stderr, "SRC %d ", state->lastsrcR);
|
|
|
|
//print it and then zero out
|
|
state->lastsrcR = 0;
|
|
state->lasttgR = 0;
|
|
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
|
|
|
//reset gain
|
|
if (opts->floating_point == 1)
|
|
state->aout_gainR = opts->audio_gain;
|
|
}
|
|
|
|
//Return to CC on MAC_END_PTT if other slot is idle
|
|
//NOTE: Disable return later on if not desirable to use
|
|
|
|
//end_ptt in this slot, idle in the other slot (Normal Slots)
|
|
if ( ((state->currentslot == 0) && (state->dmrburstR == 24)) ||
|
|
((state->currentslot == 1) && (state->dmrburstL == 24)) )
|
|
{
|
|
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1)
|
|
{
|
|
|
|
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
|
|
if (state->p25_cc_is_tdma == 0)
|
|
{
|
|
state->samplesPerSymbol = 10;
|
|
state->symbolCenter = 4;
|
|
//re-enable both slots
|
|
opts->slot1_on = 1;
|
|
opts->slot2_on = 1;
|
|
}
|
|
|
|
//rigctl
|
|
if (opts->use_rigctl == 1)
|
|
{
|
|
state->lasttg = 0;
|
|
state->lastsrc = 0;
|
|
state->lasttgR = 0;
|
|
state->lastsrcR = 0;
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
// state->payload_miP = 0;
|
|
//reset some strings
|
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
|
sprintf (state->active_channel[0], "%s", "");
|
|
sprintf (state->active_channel[1], "%s", "");
|
|
opts->p25_is_tuned = 0;
|
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
|
}
|
|
//rtl
|
|
else if (opts->audio_in_type == 3)
|
|
{
|
|
#ifdef USE_RTLSDR
|
|
state->lasttg = 0;
|
|
state->lastsrc = 0;
|
|
state->lasttgR = 0;
|
|
state->lastsrcR = 0;
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
// state->payload_miP = 0;
|
|
//reset some strings
|
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
|
sprintf (state->active_channel[0], "%s", "");
|
|
sprintf (state->active_channel[1], "%s", "");
|
|
opts->p25_is_tuned = 0;
|
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
|
rtl_dev_tune (opts, state->p25_cc_freq);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
if (opcode == 0x3 && err == 0)
|
|
{
|
|
//what else should we zero out here?
|
|
//disable any of the lines below if issues are observed
|
|
if (state->currentslot == 0)
|
|
{
|
|
state->payload_algid = 0;
|
|
state->payload_keyid = 0;
|
|
state->dmrburstL = 24;
|
|
state->fourv_counter[0] = 0;
|
|
state->voice_counter[0] = 0;
|
|
state->lastsrc = 0;
|
|
state->lasttg = 0;
|
|
|
|
}
|
|
else
|
|
{
|
|
state->payload_algidR = 0;
|
|
state->payload_keyidR = 0;
|
|
state->dmrburstR = 24;
|
|
state->fourv_counter[1] = 0;
|
|
state->voice_counter[1] = 0;
|
|
state->lastsrcR = 0;
|
|
state->lasttgR = 0;
|
|
|
|
}
|
|
fprintf (stderr, " MAC_IDLE ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 0, FMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
|
|
// if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1)
|
|
// {
|
|
// if (state->currentslot == 0)
|
|
// {
|
|
// opts->slot1_on = 0;
|
|
// opts->slot2_on = 1;
|
|
// }
|
|
// else
|
|
// {
|
|
// opts->slot1_on = 1;
|
|
// opts->slot2_on = 0;
|
|
// }
|
|
// }
|
|
|
|
//blank the call string here
|
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
|
|
|
}
|
|
if (opcode == 0x4 && err == 0)
|
|
{
|
|
//disable to prevent blinking in ncurses terminal due to OSS preemption shim
|
|
#ifdef AERO_BUILD
|
|
if (opts->audio_out_type != 5)
|
|
{
|
|
if (state->currentslot == 0) state->dmrburstL = 21;
|
|
else state->dmrburstR = 21;
|
|
}
|
|
#else
|
|
if (state->currentslot == 0) state->dmrburstL = 21;
|
|
else state->dmrburstR = 21;
|
|
#endif
|
|
|
|
fprintf (stderr, " MAC_ACTIVE ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 0, FMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
if (opcode == 0x6 && err == 0)
|
|
{
|
|
if (state->currentslot == 0)
|
|
{
|
|
state->dmrburstL = 22;
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
|
}
|
|
else
|
|
{
|
|
state->dmrburstR = 22;
|
|
//close any open MBEout files
|
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
|
}
|
|
fprintf (stderr, " MAC_HANGTIME ");
|
|
fprintf (stderr, "%s", KYEL);
|
|
process_MAC_VPDU(opts, state, 0, FMAC);
|
|
fprintf (stderr, "%s", KNRM);
|
|
}
|
|
|
|
END_FMAC:
|
|
if (1 == 2)
|
|
{
|
|
//CRC Failure!
|
|
}
|
|
|
|
} |