1073 Commits

Author SHA1 Message Date
lwvmobile
1bf60caa6f Merge pull request #313 from arancormonk/perf/rtl-sdr-fm-resampler-simd-rotate90
rtl_sdr_fm: fix FLL feedback and rotate_90 tail; aligned/SIMD resampler; safer defaults and logs
2025-09-08 01:27:29 -04:00
arancormonk
dc055c6585 rtl_sdr_fm: fix implementation of FLL, actually feedback error...other minor bug fixes and optimizations 2025-09-07 22:17:49 -04:00
arancormonk
eb02148491 rtl_sdr_fm: optimize resampler/DSP (aligned buffers, restrict/assumed alignment, optional SSE2/NEON); fix rotate_90 tail; add errno to RT logs; correct downsample_passes calc. 2025-09-07 21:00:27 -04:00
lwvmobile
6cdcac5db2 Merge pull request #312 from arancormonk/rtl_overhaul_cygwin_fix_1
Fix CPU affinity on Cygwin builds
2025-09-07 10:24:15 -04:00
arancormonk
a2a70bbb15 Fix Cygwin build 2025-09-07 10:13:03 -04:00
lwvmobile
e2a6e351c5 Merge pull request #311 from arancormonk/rtl_overhaul_arm_fix_2
Silence unused variable warning on ARM 32bit compilation
2025-09-05 20:57:19 -04:00
arancormonk
4dfe095a7c Silence unused variable warning on ARM 32bit compilation 2025-09-05 20:50:11 -04:00
lwvmobile
fede9b4e20 Merge pull request #310 from arancormonk/rtl_overhaul_arm_fix_1
RTL-SDR overhaul: Fix NEON widening code, move x86 vars into x86 block to silence compile warnings on ARM
2025-09-05 20:01:47 -04:00
arancormonk
493800a0f3 Fix NEON widening code to avoid using vsubl_u8 (which returns uint16x8_t) and instead zero-extend with vmovl_u8, reinterpret to int16x8_t, then subtract 127 with vsubq_s16. This should fix the type mismatch and produce correct signed results. Moved use_avx2, use_sse2, and use_ssse3 declarations inside the #if defined(__x86_64__) || defined(__i386__) block. 2025-09-05 19:21:57 -04:00
lwvmobile
c0b6f186bd Merge pull request #308 from arancormonk/perf/rtlsdr-demod-optimizations
RTL‑SDR demod overhaul: runtime SIMD, lock‑free ring, L/M resampler, power‑domain squelch, and DSP/perf fixes
2025-09-05 15:51:54 -04:00
arancormonk
8b423a2f42 rtl_sdr_fm: fix potential race condition, zero int all demod init funcs, add timeouts to prevent indefinite blocking, remove producer-side tail advancement, harden udp socket read loop 2025-09-04 19:11:25 -04:00
arancormonk
8ec385fdf2 ensure all old references of rms have been updated to pwr, we avoid sqrt calculations and squelch comparisons are using the same units with updated default level 2025-09-04 14:08:22 -04:00
arancormonk
da8b9b6116 rtl_sdr_fm: add additional bounds checks and cleanup extra line 2025-09-04 12:53:54 -04:00
arancormonk
a866d98e75 rtl_sdr_fm: comment cleanup 2025-09-04 12:38:41 -04:00
arancormonk
e094f95b03 rtl_sdr_fm: FLL rotator - improve sine/cos approximation 2025-09-04 10:20:39 -04:00
arancormonk
f052271a16 rtl_sdr_fm: fix mean_power - integer-only implementation 2025-09-04 10:13:05 -04:00
arancormonk
09bf040810 rtl_sdr_fm: fix low_pass_simple - normalize to avoid amplitude growth/clipping 2025-09-04 10:06:11 -04:00
arancormonk
48b032e47a rtl_sdr_fm: fix Gardner timing interpolation cost and gating 2025-09-04 10:01:17 -04:00
arancormonk
046846337a rtl_sdr_fm: fix half-band decimator - exploit symmetry/zeros and consider SIMD 2025-09-04 09:57:50 -04:00
arancormonk
836da1f556 rtl_sdr_fm: fix USB callback - avoid extra copy when enqueuing into input ring. 2025-09-04 09:48:17 -04:00
arancormonk
dd8620bc39 rtl_sdr_fm: remove per-sample memmove from resampler, use ring buffer. 2025-09-04 09:34:09 -04:00
arancormonk
283d000b59 rtl_sdr_fm: fix critical correctness bug: +1 DC bias in rotate+widen paths 2025-09-04 09:27:59 -04:00
arancormonk
5834127ff7 rtl_sdr_fm: fix rotate+widen tail handling (scalar/AVX2/NEON) to preserve 90° rotation and add SSSE3 rotate+widen with runtime dispatch on x86. Also include tmmintrin and clarify SSE2 fallback comment. 2025-09-03 23:33:32 -04:00
arancormonk
2ce089ccf8 rtl_sdr_fm: make SIMD runtime dispatch thread-safe with pthread_once and ensure AVX2/SSE2 paths compile by relying on function-level target attributes (remove AVX2/SSE2 guards). Gate NEON rotate to AArch64 (ARMv7 falls back to scalar) while retaining NEON widen for portability and performance. 2025-09-03 23:21:37 -04:00
arancormonk
4e64ef1c11 rtl_sdr_fm: add runtime SIMD dispatch for widen/rotate paths, selecting AVX2/SSE2/NEON via CPUID/XGETBV (x86) or getauxval (ARM) with scalar fallbacks. Replace compile-time guards with lazy-initialized function-pointer wrappers so binaries run optimally across CPUs without changing call sites. 2025-09-03 23:06:55 -04:00
arancormonk
c764cf0eda rtl_sdr_fm: replace USB→demod double-buffer/condvar handoff with a lock-free SPSC ring; enqueue widened blocks and drop oldest on overflow to keep the callback non-blocking. Demod now reads ring blocks; ring is initialized/cleaned up, reducing wakeups and latency. 2025-09-03 22:45:18 -04:00
arancormonk
8b4fa81711 rtl_sdr_fm: consume HB cascade output in-place to avoid the final memcpy. Track the current buffer and assign lowpassed to the last stage’s output, preserving correctness while reducing memory traffic. 2025-09-03 22:38:50 -04:00
arancormonk
106aae1814 rtl_sdr_fm: fuse interleaved complex half-band decimation to avoid deinterleave/reinterleave in full_demod, reducing memory traffic and copies. Maintain per‑stage histories and equivalent output while improving throughput. 2025-09-03 22:35:34 -04:00
arancormonk
391048a45a rtl_sdr_fm: vectorize rotate+widen path: add AVX2/NEON implementations for widen_rotate90_u8_to_s16_bias127 with scalar tail fallback. This applies the 90° rotation and bias-127 widening in vectors to reduce callback CPU without changing behavior. 2025-09-03 22:23:05 -04:00
arancormonk
1b9c3aa659 rtl_sdr_fm: add residual-CFO FLL and optional Gardner timing correction before discriminator (TED disabled by default and applied only to non-FM unless forced), with linear interpolation, nominal 1/sps advance, and env-tunable gains. 2025-09-03 22:18:20 -04:00
arancormonk
e9b12b8bc6 rtl_sdr_fm: add polyphase rational resampler (L/M) enabled by default at 48 kHz (override via DSD_FME_RESAMP), integrate post-demod and update output.rate while keeping legacy upsampler as fallback. Implement tap design with L-phase gain compensation. 2025-09-03 22:02:19 -04:00
arancormonk
9e9ae95219 rtl_sdr_fm: use fast atan2 discriminator for analog mode to reduce quantization noise 2025-09-03 21:33:04 -04:00
arancormonk
86d91512bb rtl_sdr_fm: add AVX2 widening, optional combined rotate+widen, and fixed‑point linear upsampler with env flags; preserve legacy behavior by default. Fix decoding by matching legacy upsample length (NM) with tail fill and reproducing unsigned rotate semantics. 2025-09-03 21:20:41 -04:00
arancormonk
0b00832b1f rtl_sdr_fm: enable env-gated intra-block multithreading with a tiny 2-thread pool and preallocated buffers. Parallelize HB I/Q decimation and linear upsampler; add debug log when enabled. 2025-09-03 20:52:06 -04:00
arancormonk
2655fccdea rtl_sdr_fm: ring signaling and atomic annotations 2025-09-03 20:30:32 -04:00
arancormonk
ac8f17bf20 rtl_sdr_fm: guard and document bandwidth_multiplier behavior 2025-09-03 20:23:52 -04:00
arancormonk
0cb38d2c25 rtl_sdr_fm: SIMD optimize USB byte→int16 widening in callback 2025-09-03 20:20:43 -04:00
arancormonk
6fc327c3b6 rtl_sdr_fm: avoid sqrt in RMS utility (use power-domain) 2025-09-03 20:15:27 -04:00
arancormonk
00e7c51a21 rtl_sdr_fm: add a light post-demod audio low-pass filter 2025-09-03 19:19:25 -04:00
arancormonk
e2402d0328 rtl_sdr_fm: correct deemphasis coefficient derivation and make it configurable 2025-09-03 19:08:22 -04:00
arancormonk
402cef34a9 rtl_sdr_fm: improve decimation filters (half-band FIR cascade) 2025-09-03 18:53:44 -04:00
arancormonk
29be104345 rtl_sdr_fm: replace sample duplication with simple resampling (linear interpolation) 2025-09-03 18:30:38 -04:00
arancormonk
f3ec024000 rtl_sdr_fm: replace DC block with leaky integrator high-pass (IIR) 2025-09-03 18:18:00 -04:00
arancormonk
412a4dc3b1 rtl_sdr_fm: add saturating arithmetic for decimation and volume scaling 2025-09-03 18:05:28 -04:00
arancormonk
2eedcc125b rtl_sdr_fm: fix deemphasis state race 2025-09-03 18:01:06 -04:00
arancormonk
9b399f31da rtl_sdr_fm: enable vectorization and alignment for DSP arrays 2025-09-03 16:25:15 -04:00
arancormonk
2ec3f9a263 rtl_sdr_fm: hoist divisions and use integer scalers in hot loops 2025-09-03 16:14:26 -04:00
arancormonk
0decc5934c rtl_sdr_fm: add batch operations and thread scheduling 2025-09-03 15:58:33 -04:00
arancormonk
7dd9cd7566 rtl_sdr_fm: add batched consumer API 2025-09-03 15:51:45 -04:00
arancormonk
30766b34bd rtl_sdr_fm: fix timespec normalization in timed wait 2025-09-03 15:21:50 -04:00
arancormonk
e700e418be rtl_sdr_fm: make RMS squelch incremental and decimated 2025-09-03 15:17:07 -04:00
arancormonk
c6d3e4cea0 rtl_sdr_fm: removed the obsolete rwlock and lock sites 2025-09-03 15:08:19 -04:00
arancormonk
62a9372d61 rtl_sdr: make async buffer params explicit and safe 2025-09-03 15:03:38 -04:00
arancormonk
cc200ea82c rtl_sdr: make RMS squelch sqrt-free 2025-09-03 14:48:33 -04:00
arancormonk
03c6b28de3 rtl_sdr_fm: initialize async buffer length and consider buffer count 2025-09-03 14:36:26 -04:00
arancormonk
3fe14f3b1d rtl_sdr_fm: double-buffer the I/Q handoff and remove memcpy/locks between callback and demod 2025-09-03 14:30:32 -04:00
arancormonk
3adcf5f449 rtl_sdr_fm: replace std::queue + locks with a single-producer single-consumer ring buffer 2025-09-03 13:21:47 -04:00
arancormonk
b81e1e6d22 rtl_sdr_fm: fix atan2/LUT discriminator — use precise π, quadrant-correct LUT saturation, clamp ±π at wrap, and mutex-protect LUT free. 2025-09-03 10:38:52 -04:00
lwvmobile
9acd8c981e Merge pull request #307 from arancormonk/fix/nxdn-cac-temp-buffer-overflow
Fix NXDN CAC decoder temp buffer overflow in nxdn_deperm_cac causing segfaults under -O2/-O3
2025-09-02 22:10:42 -04:00
lwvmobile
9353c489aa Merge pull request #306 from arancormonk/fix/p25p2-tdma-voice-vector-oob
Fix OOB writes in ez.cpp HB/HBS vectors causing P25p2 TDMA voice segfault
2025-09-02 21:22:54 -04:00
arancormonk
bc95dc1a1d Fix NXDN CAC decoder temp buffer overflow in nxdn_deperm_cac causing segfaults under -O2/-O3. 2025-09-02 15:53:26 -04:00
arancormonk
1ecd32e017 Fix OOB writes in ez.cpp HB/HBS vectors causing P25p2 TDMA voice segfault 2025-09-02 15:07:51 -04:00
lwvmobile
6ef823347b Fix Bug with -F switch requiring an argument;
Bug was introduced in commitc 888dfc1d6569c42aa45ca86aad00ed630410ddd ;
2025-08-30 04:31:21 -04:00
lwvmobile
bd75c1ab83 MBE: Prepare for changes to P25p1 ESS in SDRTrunk .mbe files (version, ks application); #298
MBE: Make tweaks to audio and wav file handling, allow writing to static wav files even if audio out device is NULL (writeSynthesizedVoiceMS);

DSTAR: Fix Issue with DSTAR where double writes would occur in single static .wav files;
2025-08-23 20:31:32 -04:00
lwvmobile
b3b943d330 Update Docs; 2025-08-22 14:27:13 -04:00
lwvmobile
a5151686ec Add Generic Static AMBE Keystream Support; #303
Adding a new method to allow a user to enter a generic keystream len and static keystream via a string that is loaded into a bit array to xor against ambe frames;

This method is intended to be used to allow
2025-08-22 14:02:09 -04:00
lwvmobile
24c1dd97df DMR: Add 16-bit Anytone BP Support; #303
Reset static_ks_counter as various places in code;

Remove the static_ks_counter reset from KWD SCR link control and tweak SO bits;

Fix Forced KS application to work in both slots;

Allow Static Wav File or Per Call Wav File in SDRTrunk MBE format playback; #298

Same as above for .amb, .dmb, and .imb format playback;

Update Usage and Docs;
2025-08-20 23:12:57 -04:00
lwvmobile
6f171620dc DMR: Reorganize TYT and KEN encrytion modes, putting them into the proper files; #302 #303 2025-08-19 19:18:01 -04:00
lwvmobile
7428a87d80 WAV: Fix Issues with Per Call;
Fix Per Call Issue introduced with commit re-enabling single static wav file where single channel audio decode types would not write to per call temp wav files and be deleted after event history cycled them;

Fix Issue with YSF where double writes would occur in .wav files;

Fix Issue with M17 where incorrect rate audio would write to static .wav file by converting to stereo output;

Seperate Per Call and Create Method to Allow EDACS Analog Calls to be written to static wav file by downsampling and stereo interleaving audio to proper spec;

Issues were introduced in commit # c7b25c60af
2025-08-19 02:35:17 -04:00
lwvmobile
79084f26c6 DMR: Fix Kenwood Scrambler SVC OPT muting call when key is forced; #303 2025-08-17 21:17:14 -04:00
lwvmobile
d5cd4b4273 DMR: Fix Kenwood Scrambler Flag in FLC #303; 2025-08-17 21:11:34 -04:00
lwvmobile
bafd74b225 DMR: Fix Wformat Warning; #303 2025-08-17 20:06:34 -04:00
lwvmobile
8df8ce85f2 DMR: Add 15-bit scrambler method for Kenwood Radios; #303 2025-08-17 18:57:32 -04:00
lwvmobile
a5b9984d78 TYT EP: Fix User Key to Input Register; #302
Bytes used as input register for TYT EP are loaded by byte reverse order, was undetected on some key patterns like all F's or all A's, but found out on 1234... patterns;
2025-08-17 15:24:22 -04:00
lwvmobile
4dd68f2221 Update Help / Usage; 2025-08-16 10:25:43 -04:00
lwvmobile
21c02acd8c WAV: Re-enable -w option for single file .wav for all decoded speech; 2025-08-16 10:22:31 -04:00
lwvmobile
c7b25c60af DMR TYT BP (16-bit) Encryption Mode; #302
Above Commit is by Anonymous Submission;
2025-08-16 10:18:10 -04:00
lwvmobile
41865f3af7 DMR TYT EP (AES128) Encryption Mode; #302
Above Commit is by Anonymous Submission;
2025-08-15 20:29:34 -04:00
lwvmobile
8f092e293f DMR TYT BP16 Encryption Mode WIP; #302
Code is not working as-is, committed for anonymous submitter to have access to certain items in code;
2025-08-15 12:21:27 -04:00
lwvmobile
c888dfc1d6 DMR TYT AP (PC4) Encryption Mode Support; #302
Above Commit is by Anonymous Submission;
2025-08-15 11:14:46 -04:00
lwvmobile
6ebe3eff58 NXDN: Fix Wformat Warnings 32; #299 2025-07-27 14:17:03 -04:00
lwvmobile
2ca3f0a356 NXDN: Fix Wformat Warnings; #299 2025-07-23 19:16:27 -04:00
lwvmobile
698a991262 NXDN: Misc #299
Fix Perpetual Sync Bug unless Squelch Break;

Add DCR MFID 30 F.C.R Data Preamble and Precoded Message PDU;

Misc Payload Tweaks;
2025-07-14 22:42:35 -04:00
lwvmobile
352bb98bc6 DMR: Fix UTF16 Talker Alias locale to allow Chinese or similar Non-Roman Charsets;
Note: This will only work to the console output, since ncurses wide chars are different. The alias string will replace extended utf16 chars with an * for now.
2025-07-14 06:15:55 -04:00
lwvmobile
8c34313720 NXDN: #299
Additional check for LICH "offbits" that should all be 1's as sync condition;

Add 7-bit Parity Check for known DCR Lich ("RICH") Codes;

Make Tweaks to Help Incorporate Lich Parity and Offbits into NXDN Sync Determination;
2025-07-13 11:32:15 -04:00
lwvmobile
ce805a7860 NXDN: Add DCR TCH / PICH Lich 0x48 Payload Only; #299
Misc Tweaks to Payload Format;
2025-07-13 10:25:40 -04:00
lwvmobile
86b8900b3d NXDN: Fix and Decode Some DCR Elements; #299
Elements include scrambler bits, UC bits, and other misc items;

Tweaks to payload output;
2025-07-08 00:59:41 -04:00
lwvmobile
eb1bcee301 NXDN: Disable Attempted Decoding of SACCH frames on Icom DCR; #299 2025-07-04 17:24:01 -04:00
lwvmobile
fd3b4b6a66 NXDN: DCR Payload Tweaks 2; #299 2025-07-02 15:33:06 -04:00
lwvmobile
b09de5f112 NXDN: DCR Payload Tweaks; #299 2025-07-01 17:00:02 -04:00
lwvmobile
8d1c92c490 NXDN: Add Lich Code 0x46 for Icom DCR Voice and SACCH Payload; #299 2025-06-30 20:25:47 -04:00
lwvmobile
bd98e3befb Re-enable the custom wav file directory option -7 for per-call wav files;
When playing back .amb or .imb files, print AMBE or IMBE when dumping payload on them;
2025-06-29 15:56:52 -04:00
lwvmobile
1aa71811b0 SDRTrunk .mbe File Replay: #298
Mute Audio if enc and no key provided;

Tweak Verbose Payload vs No Verbose Payload Output to console;

Misc Tweaks;
2025-06-24 13:34:45 -04:00
lwvmobile
4e1b1ac98e SDRTrunk .mbe File Replay:
Tweak RC4 Keystream Creation to only create second keystream when P25p1, and only make as much keystream as needed; #298
2025-06-23 02:37:45 -04:00
lwvmobile
ccbaef8541 SDRTrunk .mbe File Replay:
Fix P25p1 RC4 Decryption via keystream juggle and reverse LSFR for IV; #298
2025-06-23 02:27:03 -04:00
lwvmobile
8a30115398 SDRTrunk .mbe File Replay Initial Commit; #298 2025-06-22 15:16:19 -04:00
lwvmobile
3a1d393a0f Fix Playback Speed in Cygwin for .imb/.amb files; #297 2025-06-20 16:05:30 -04:00
lwvmobile
66844b1d4c P25: Provide a temporary fix to the issue of .imb files not writing when a key is presented during an encrypted voice session; #297 2025-06-19 17:03:07 -04:00
lwvmobile
722d7b77fb DMR: Yet Even More RC_TESTING Tweaks; #292 2025-05-29 20:27:15 -04:00
lwvmobile
5a2575c9a0 DMR: Even More RC_TESTING Tweaks; #292 2025-05-29 20:09:55 -04:00
lwvmobile
daad012466 DMR: More RC_TESTING Tweaks; #292 2025-05-29 19:47:25 -04:00
lwvmobile
f2cc686189 DMR: Fix CallTimers CSBK; #293 2025-05-29 15:55:27 -04:00
lwvmobile
175ccff7e9 DMR: Fix BParm Issues Mentioned in #293
Make some tweaks to DMR BS RC_TESTING; #292

Fix Talker Alias Block Num Enumeration (+1) on Valid Blocks;

Misc Typo and Format Fixes;

Tweak for NXDN Keyloading on VCALL;
2025-05-29 14:44:37 -04:00
lwvmobile
4a1e6f1540 Revert Previous Change Regarding DMR Talker Alias; #290 2025-05-22 22:52:39 -04:00
lwvmobile
d285865de5 DMR: Don't append spaces to talker alias string if encoded character is 0; #290
(usually indicates the full talker alias has yet to arrive and only doing a partial in progress decode);
2025-05-22 06:17:19 -04:00
lwvmobile
4bcc9f8aec Fix Coding Error for Compiler Warning / Error for ncursesClose; 2025-05-21 22:23:32 -04:00
lwvmobile
c6b2320cbd Ncurses:
Don't display the lines for Pulse Digital Output if it isn't opened (when using analog only -fA);
2025-05-17 15:00:09 -04:00
lwvmobile
87be5aa72e DMR:
Add FLCO 0x29 FID 0x10 to Unknown Moto Link Control Value to prevent it from setting incorrect tgt, src, svc values;
2025-05-17 01:59:41 -04:00
lwvmobile
3f0f675fd5 Pulse Audio:
Don't Open Audio Stream for Synthesized Digital Voice when using the -fA Analog Only Output Option;
2025-05-16 23:16:32 -04:00
lwvmobile
7c56fb836b Fix Wformat-overflow Issues Regarding Previous Commit; 2025-05-15 16:49:53 -04:00
lwvmobile
2891d7314b Dibit/Symbol Capture File:
When initiated from the ncurses 'R' key, it now rotates every hour;

Above is logged to event history when it occurs;
2025-05-15 16:42:21 -04:00
lwvmobile
ed13bb34d8 YSF: Fix Event History Placing Blank Entries between calls; Fix No Entries when sourced signal is inverted; 2025-05-14 23:03:26 -04:00
lwvmobile
b9097d9462 Event History Setup: #287;
P25p1: Set currentslot to 0 when decoding phase 1 specific duids (HDU, TDU, TDULC, LDU, TSBK, MPDU) so that we don't have a potential stale phase 2 slot value present when writing to event history, etc.

Update Glamor Shot to include the Event History Update;
2025-05-12 21:41:20 -04:00
lwvmobile
59fcfdae81 Event History Setup: #287
Allow Event History to be cycled from short string on, long string on, or of with the 'h' shortcut keyf;
2025-05-12 17:12:10 -04:00
lwvmobile
f85304471f Event History Setup: #287
P25p2: Misc Tweaks for Harris Things; Misc Event History P2 Tweaks;
2025-05-11 12:08:39 -04:00
lwvmobile
3fc67a5694 Event History Setup: #287;
Add customizable event history line (in ncurses) for various items, but left colors as the default cyan. (Remus Request);
2025-05-11 01:16:31 -04:00
lwvmobile
2314900829 Event History Setup: #287
Update Glamor Shots to Show new Event History; Update Misc Items and Examples;
2025-05-10 17:17:48 -04:00
lwvmobile
680b792b19 Event History Setup: #287
Fix Some GPS formats not writing to the event history gps_s string due to mismatching src values (UDT NMEA and LIP);

Fix bug in ComputeCrcCCITT16d where the len value cannot exceed 255 by recasting len as uint32_t instead of uint8_t; #288

Clarify when UDT Data Blocks (R12) is Confirmed or Unconfirmed Data;
2025-05-10 02:09:56 -04:00
lwvmobile
0d734b753f Event History Setup: #287
Fix Flicker Bug in Ncurses Printer by casting lls as static int;

Further Tweak to NcursesPrinter for responsiveness;
2025-05-09 21:11:23 -04:00
lwvmobile
fae33ca0a1 Event History Setup: #287;
Seperate dsd_ncurses.c into dsd_ncurses_printer.c , dsd_ncurses_menu.c , and dsd_ncurses_handler.c files;

Make adjustments as needed to accomodate above;

Work on Handling Special Escape Characters with Ncurses Input Handling to prevent rogue things from happening with scrool wheel, etc;
2025-05-09 18:36:22 -04:00
lwvmobile
dc7ff1136e Event History Setup: #287
Prepare to Seperate Ncurses Code and Event History Code into seperate .c files; Move common items to a .h file;

Move event history code to dsd_events.c; Move AFS code to edacs-fme.c; Move beeper code to dsd_audio2.c
2025-05-09 17:12:31 -04:00
lwvmobile
67ab05da63 Event History Setup: #287;
Trial Fix for ncurses randomly lagging when sync condition with printer vs no sync condition with printer and key input;
2025-05-09 16:18:05 -04:00
lwvmobile
54ba3b6513 Event History Setup: #287
Run ncursesPrinter more frequently during nosync condition to make ncurses user input a lot more responsive during quiet times.
2025-05-09 16:02:56 -04:00
lwvmobile
13739b18aa Event History Setup: #287
Expand Event History for EDACS to Include More Call Information; Misc Tweaks regarding;

Add watchdog and wav file closure to EOT_CC when returning from EDACS Analog or Digital Calls;

Fix local event_string size in watchdog_event_current;

Add watchdog to cleanupAndExit to catch any calls in progress when closing and push them out to event_history log;
2025-05-09 02:20:09 -04:00
lwvmobile
7a198e62f9 Fix UDT Mixed String Format Issue when assigned to event_history text_message; #288 2025-05-09 01:04:13 -04:00
lwvmobile
e37955448e Tweak Event History String Regarding Mixed Address and UTF Text Data; #288 2025-05-08 15:18:00 -04:00
lwvmobile
2dc9db17ab Fix UDT Data Misc Items found by mastodon987; #288 2025-05-08 14:35:22 -04:00
lwvmobile
a3eb6dd552 Event History Setup #287;
Clear some values on Trunking when nocarrier that weren't previously cleared right away;

Write User Lockout of TG to event history; Run noCarrier when Trunking and User Locks Out, prompting return to CC;
2025-05-07 18:19:06 -04:00
lwvmobile
35b782a10f Event History Setup: #287
Tweaks to P25p1 TDU and TDU/LC don't clear out items before they get into event log (bugfix for no crypt info logging);
2025-05-07 13:57:59 -04:00
lwvmobile
8c4dc6ed36 Hytera Enhanced Encrypt: Refresh When bad CACH or TACT forces resync(Run LFSR); 2025-05-06 23:50:00 -04:00
lwvmobile
1532fdcc8e Event History Setup: #287
Include a simple sh file to startup dsd-fme with opts line, and open log files for multi linux terminal support;

Fix bug with P25p1 MPDU Trunking Blocks setting address values to trigger event history watchdog;

Add an internal string into event history to log internal events of note (ENC LO, errors, etc);

Add a watchdog during any ENC LO event so the event_history will log the call with ENC LO;

Disable AHOY and RSP PDU's from Event History (clogs up the event history with extra info);

Fix DMR p_clear trigger to zero out src and tg values when tuning away;

Fix Hytera Enhanced RC4 (verified working); Misc Tweaks Regarding;
2025-05-06 21:19:11 -04:00
lwvmobile
68d959cb7a Event History Setup: #287;
Fix P25p1 LCW Unit to Unit to Private Call in Call History; Misc Tweaks in TDU and LCW;

Add DMR AHOY Info from CSBK and UDT from Data Bursts to Event History;

Send UDT Text Messages to textmessage string in event history and not to the event string; Fix UDT Text Len values;

Fix Misc Issues noted in #288 (IP6, Mixed Add/Text, NMEA ss3 * 10);
2025-05-06 15:06:19 -04:00
lwvmobile
c364117fc0 Event History Setup; #287
Fix NXDN site_code and sys_code order in event_history; Reset correct call type string on TX_REL,  TX_REL_EXT, and DISC messages when stale;

Have P25p1 PDUs write to event_history, regardless of decoded state; Include Enc info if available and not decrypted or decoded; Event History and Log RSP Packets;

Tweak and Add DMR RSP Packets to Event History and Log

Fix Event History Log File Display on Startup;

Add UDP Port 4069 for TRBOnet SCADA; (no decode of data);
2025-05-04 14:53:13 -04:00
lwvmobile
d376fcc227 Event History Setup: #287;
Misc Tweaks Regarding How Trunking Elements May Indirectly Interact with Event History;

DMR Alias Tweak: Allow Extra UTF8 characters (grave, diacritical leters, etc); Allow any UTF16 character that isn't an ASCII special char;

Add GI String (GROUP or PRIVATE) to wav file names, if set and known at close;

Add Encrypted PDU ALG/KID values if not decrypted/decoded;

Allow Manual RTL Input PPM Error Adjustment with { and } keys;

LRRP: Simple Request Handling; Report Handling Tweaks; Simple Handling for Unknown Formats;

Don't reset DMR Color Code on NoCarrier;
2025-05-03 15:59:45 -04:00
lwvmobile
93b297c2d5 Event History Setup: #287;
Don't write Short Data UTF8 to event log or event history in ncurses(garbage text);

Add unknown IP port and protocol lines for event_history;

Add GI from the ILLEGALLY_PARKED CSBK on standard DMR T3 trunking to make sure we get one set;
2025-05-02 17:01:57 -04:00
lwvmobile
d158db618d Fix Misc Minor Bugs and Clang Compiler Warnings; 2025-05-01 22:12:19 -04:00
lwvmobile
934b95cde8 Event History Setup: #287
Make Tweaks / Fixes to DMR Talker Alias;

Setup for Hytera Enhanced RC4 Cipher (LFSR Works, Cipher Untested / Unknown Working State);
2025-05-01 20:40:35 -04:00
lwvmobile
3563399126 Event History Setup Misc; #287
Change the -~ switch to debug mode and -J to the event history file;

Pass slot and swrite value to write_event_to_log_file; Add Slot value to written event log file when swrite is 1 (DMR BS and P25p2);

Misc Consistency Nits;
2025-04-30 19:47:06 -04:00
lwvmobile
6364009e45 Event History Setup; #287
Fix -Wformat-overflow warning regarding writing imported names into a char array;
2025-04-29 14:07:32 -04:00
lwvmobile
1739017303 Event History Setup; #287
Scrub call_matrix items form ncurses, rename for edacs use only;

Scrub a lot of unused local variables out of the ncurses printer;

Add NXDN Talker Aliases to Event History;

Add Remus' suggestion for Tone ID and AD values on the call alert beeper;
2025-04-29 13:58:20 -04:00
lwvmobile
27d416f38b Event History Setup; #287
Add groupName csv import items into the Event History;
2025-04-28 23:12:26 -04:00
lwvmobile
f9dac1c226 Double Duration of beeper function calls so that it actually will play reliably when using OSS audio output (Cygwin); #287 2025-04-28 15:40:56 -04:00
lwvmobile
d1334038df Migrate Call Alert Beeper to New Event Function; Ring different tones on voice start, end, and data calls; #287
Fix and Tweak Calloc Size to the size_t of Event_History * 600 total events (little extra overhead) ;
2025-04-28 15:01:33 -04:00
lwvmobile
4ebc6ab6c9 Event History, Add New .bat file for cygwin portable that will also open and tail an event_log file; #287
Add an initial system event for users to see when started;
2025-04-27 23:13:15 -04:00
lwvmobile
76905b095b Event History Bug Fix; #287
Initialize src_str and tgt_str properly each pass of watchdog_event_current so that wav files do not have a blank string instead of the correct numerical number for src and tgt when applicable; Fix tgt and src string to correct position;

Add dPMR string value to src and tgt for wav files + bugfix; Add Enc if applicable to event history for it;

Misc Nits;
2025-04-27 21:42:09 -04:00
lwvmobile
daf014df6a New Event History Setup and Logging to a Log File, part 3; #287
M17, YSF, DSTAR to save wav files with src and dst as call sign string value and not a numerical value;

Add P25p1 Tier 1 Location and DMR Short Data LOCN Report to Event History; Add MNIS sourced LRRP to Event History;

Don't append truncated TEXT strings to Event String since its full display is directly below it in the Event History;

Add new items to Event History to accomodate above feature;

Tweak misc items regarding above;
2025-04-27 20:30:50 -04:00
lwvmobile
ff4dd03379 Fix Misc Size and Format Warnings Regarding Last Push; #287 2025-04-26 23:39:01 -04:00
lwvmobile
114e305e25 New Event History Setup and Logging to a Log File, part 3; #287
Add Extra Call Information to Event History and Display to Ncurses and Write to Event Log;

Add P25 Known Talker Alias Formats to Event History and Display to Ncurses and Write to Event Log;

Remake the DMR Talker Alias Decoder for 7, 8, and 16 bit chars and go to Event History and Display and to Ncurses and Write to Event Log;

Add Some Embeddded and Misc (Non Data Call) GPS Formats to Event History and Display to Ncurses and Write to Event Log;

Add DMR UDT Data Calls to Event History;

Make Misc Tweaks to Event Item Strings;
2025-04-26 23:34:15 -04:00
lwvmobile
4e04d99780 New Event History Setup and Logging to a Log File, part 2; #287
Rework all Per Call Wav files to tie into Event History; Auto Delete Empty Wav files created; Wav Files in progress have no extension and have no hard set name until closing;

Delete all OLD patch files that are resolved directly or indirectly by new Event History, or have previously been incorporated into code.
2025-04-25 13:33:17 -04:00
lwvmobile
a9a88c5b13 Event History Better Scrolling in Ncurses; #287 2025-04-24 00:14:52 -04:00
lwvmobile
71d4d30f3a Event History: Move event_history_s from the stack to the heap; Calloc Plenty of Memory for it; #287 2025-04-23 16:27:25 -04:00
lwvmobile
8cbfb96141 TMS: Fix Termination / Overflow Issue; #287 2025-04-23 14:40:26 -04:00
lwvmobile
919100daad Fix Current Warnings Regarding, try 2. #287; 2025-04-23 00:05:48 -04:00
lwvmobile
d2f4c1ddd9 Fix Current Warnings Regarding #287; 2025-04-23 00:03:58 -04:00
lwvmobile
cb89fb69c1 New Event History Setup and Logging to a Log File, part 1; #186 2025-04-22 23:50:07 -04:00
lwvmobile
51727b815d P25: Initialize sap_string and rsp_string; 2025-04-17 16:15:04 -04:00
lwvmobile
8bfdeeebd0 P25: Fix printFrameInfo state->nac compiler warning on fprintf; 2025-04-07 22:42:18 -04:00
lwvmobile
b963b08469 P25: Redo printFrameInfo to make it consistent across Phase 1 and Phase 2; 2025-04-07 22:40:18 -04:00
lwvmobile
177551e081 DMR: Display Alg Type on Late Entry Single Burst; 2025-04-06 21:01:37 -04:00
lwvmobile
7ab5ec8b40 DMR: Fix More Lingering DMRA PI lfsr128 Mismatch Issues due to int to ulli conversion errors; 2025-04-06 21:00:57 -04:00
lwvmobile
8fd9c64c0c DMR: Change PDU MI to ulli to match and prevent possible issues related to int to ulli change in mi storage;
PI Header Display Nit;
2025-04-06 18:53:16 -04:00
lwvmobile
a9af3b9380 DMR: Fix Lingering DMRA PI and lfsr32 Mismatch Issues due to int to ulli conversion errors;
(0xFFFFFFFF12345678 vs 0x12345678) issue in display and late entry mismatch;
2025-04-06 18:50:14 -04:00
lwvmobile
fc21063652 Fix Variable Types for print;
Remove Unused Code;
2025-04-06 16:57:58 -04:00
lwvmobile
19864225f6 DMR: Fix Hytera Enhanced Not Muting Properly (OR SVC OPT enc bit); 2025-04-05 07:18:03 -04:00
lwvmobile
3312e14422 DMR: Fix DES Alg (0x22) Set;
Fix Late Entry Mismatch Bug due to variable type change (int to ulli);

More Fixes Tweaks for Hytera Enhanced Encryption Setup;
2025-04-04 17:35:48 -04:00
lwvmobile
425d477168 DMR: Fix common slot counter (csc) variable found in slow link control sys_parms; #285 2025-04-01 20:36:37 -04:00
lwvmobile
b351b6a20d P25p1: Fix Relationship of PDU Extended Addressing Header and ESS Header; 2025-03-31 05:03:14 -04:00
lwvmobile
4b75211ad0 DMR: Reconfigure dmr_le;
Reconfigure dmr_le so that it can be completely disabled for Hytera Enhanced, or Late Entry MI only for DMRA, or Late Entry MI and Key/Alg for DMRA;

Misc Hytera Enhanced Setup Tweaks;
2025-03-26 00:54:08 -04:00
lwvmobile
88c76c4a6c DMR: Enhanced Encryption PI / FLC Setup;
Fix some PI Elements for Consistency and List Known Alg Types;
2025-03-25 18:14:33 -04:00
lwvmobile
cfbd859d9e DMR: Fix PDU AlgID for AES; 2025-03-25 13:55:36 -04:00
lwvmobile
5851abbce8 Fix AES Key Segment (ULLI) Array Size; 2025-03-21 15:45:16 -04:00
lwvmobile
d35bed4348 Move MBP to header file; 2025-03-20 18:34:20 -04:00
lwvmobile
4e77bb05b9 CODE: Remove Whitespace (ezpwd); 2025-03-17 17:22:22 -04:00
lwvmobile
fdbc2ef0e2 CODE: Remove Whitespace; 2025-03-17 16:38:04 -04:00
lwvmobile
237cb3ffa5 P25p1: Fix Moto APX GPS LCW; 2025-03-17 13:57:12 -04:00
lwvmobile
7ed1a79b5b Misc; 2025-03-17 13:53:38 -04:00
lwvmobile
e36672f54c Fix Some Tab Alignment Issues;
NXDN: Make seperate AES IV expansion function;
2025-03-15 20:26:25 -04:00
lwvmobile
eac360571e YOLO:
Congratulations for clicking this link, you are now reading this description;

Add DES-OFB Decryption Support for P25, NXDN, DMR (Tested);

Add DES-XL Decryption Support for P25p1 (Tested);

Add AES-OFB Decryption Support for P25, DMR (Tested); NXDN(untested);

Add P25p1 PDU Decryption Support; (Untested)(Known Modes);

Add Remaining (AES, DES) DMR PDU Decryption Support (Known DMRA Modes)(Untested);

Decrypt Tytera 16-bit BP (works depending on model);

Add AES Keys example csv file for import;

Probably a few bugs that'll need to be massaged out now with all the code additions for several years of stashed code;
2025-03-14 23:54:58 -04:00
lwvmobile
9f59729fb1 Disable Debug Catch All UTF8 Decode on unknown PDU types; 2025-03-13 14:55:08 -04:00
lwvmobile
9f063cb4da Fix Some UTF8 String Overflow Issues; 2025-03-13 14:45:02 -04:00
lwvmobile
f593453328 PDU: Misc Catch All UTF8 Decodes on Unknown Format Types; 2025-03-13 13:58:09 -04:00
lwvmobile
871bdf5a82 TMS: Better Parsing (WIP); 2025-03-13 13:45:07 -04:00
lwvmobile
fbf40335aa DMR: Fix TDMA Direct Mode voice handling; 2025-03-13 12:43:03 -04:00
lwvmobile
0c8a11c607 P25p1: More Misc PDU Tweaks; 2025-03-12 12:16:31 -04:00
lwvmobile
c13ffbc9b2 P25p1: Misc PDU Tweaks; (WIP);
DMR: Fix TMS Message String for Ncurses & Tweaks;

Make the IP PDU more generic;

Make Cellocator and ARS decoder placeholder functions;

Add port for P25 Tier 2 Location Services (LRRP);
2025-03-11 11:59:55 -04:00
lwvmobile
31f9edefa5 P25p1: Reorganize Multiblock PDU Handling; 2025-03-10 10:11:13 -04:00
lwvmobile
fe0195ad10 DMR: Ncurses Display For Unknown IP / UDP Based Calls (port or protocol); 2025-03-05 14:57:39 -05:00
lwvmobile
e3e2fff6e5 DMR: Fix Rate 1 Encoded Packet Data Assembly; Fix Rate 1 Confirmed Data CRC9 Check; 2025-03-05 14:39:19 -05:00
lwvmobile
3b67ff52d5 DMR: Add Data Call Type to Ncurses; TMS to truncated ASCII range string for ncurses; UTF8 and UTF16 tweaks; 2025-03-05 10:47:02 -05:00
lwvmobile
17789f03f9 DMR: Bypass CRC Error on MNIS Data; Reset SAP and Format Storage After Use; #283 2025-03-05 05:13:34 -05:00
lwvmobile
6fb464f57d DMR: Add Support for the MNIS Header; #283 2025-03-05 02:35:42 -05:00
lwvmobile
6c277da869 DMR: Fix Corrected KS Offset Application on Chained P_Head for BP; 2025-03-04 07:03:50 -05:00
lwvmobile
4d5af32ce7 DMR: Add Handling for IPv4 UDP / ICMP / UNK Protocol PDUs; 2025-03-04 06:56:42 -05:00
lwvmobile
16a84b8d3e DMR: Fix Incorrect SRC and TGT on DPF 15 for ncurses display; 2025-03-04 04:09:03 -05:00
lwvmobile
eebb251d2f DMR: Tidy Up PDU Enc Code; 2025-03-03 23:09:02 -05:00
lwvmobile
4255a2f9ba DMR: Correct KS Offset Application on Chained P_Head; 2025-03-03 22:58:52 -05:00
lwvmobile
5fcfb141a6 DMR: Fix PDU MI variable type; 2025-03-03 21:53:52 -05:00
lwvmobile
304baca7c5 DMR: Fix Bug on PDU Info Display; 2025-03-03 09:09:38 -05:00
lwvmobile
fb2de46d88 Cygwin:
Add Linebreak to copy and paste installer prompts in Install_Notes.md;
2025-03-03 06:56:54 -05:00
lwvmobile
f551952bf6 Cygwin:
Remove the portable release builder code from download-and-install-cygwin.sh script, call cyg_portable.sh from said script instead (simplify);

Remove old .bat files or rename pulseaudio ones in case of need for referencing them;

Include a simple example_options.txt file so users can get an idea of options to pass to dsd-fme as opposed to having a bunch of bat files;
2025-03-03 06:17:52 -05:00
lwvmobile
ec8d74fabd Cygwin:
Cmake -DNOCOLORSLOGS=OFF for Cygwin Builds (or user option)

Tweak cygwin scripts to include touch.exe in portable release builder.

Rework original 1aa bat file to be a simplified / unified .bat file (old bat files still available in examples folder);
2025-03-03 05:17:04 -05:00
lwvmobile
f732ad9639 Add Float Symbol Input File Support (.raw or .sym); 2025-03-02 23:44:19 -05:00
lwvmobile
31bfd6a235 DMR: Misc Code Cleanup; 2025-03-02 08:14:43 -05:00
lwvmobile
a44c81a6bb Fix Compiler Warning; 2025-03-01 13:20:44 -05:00
lwvmobile
df56d421f8 DMR: Setup a KS start (offset) value to apply specifically for chained p_head where the second p_head is only partially encrypted; 2025-03-01 12:57:25 -05:00
lwvmobile
f5fad8d5e0 DMR: Misc PDU Tweaks/Fixes/Cleanup; 2025-03-01 03:32:16 -05:00
lwvmobile
f92c64c4d3 DMR: Fix Data Assembly on Moto Ext Header;
Make appropriate adjustments based on above;

Additional Tweaks for some LRRP Tokens;
2025-02-28 11:33:23 -05:00
lwvmobile
2ca15d8b53 DMR: Decode Additional IP Header Elements;
Adjustments to Moto EXT Header and its LRRP Variant;

Make additional adjustments to LRRP PDUs based on above;
2025-02-28 07:39:14 -05:00
lwvmobile
bc18db2bc2 DMR: Fix NMEA / LOCN:
Use DD.MMmmmm format;

Dump to File;

Disable Reponse Data Header (dpf == 1) to ncurses string;
2025-02-26 01:45:25 -05:00
lwvmobile
a006074459 DMR: Only Print LRRP Data to file if lat/lon is present; 2025-02-25 22:54:15 -05:00
lwvmobile
141eac9bc3 Remove pavucontrol from installer scripts; Add note under virtual sinks; #280 2025-02-25 15:01:23 -05:00
lwvmobile
69dd1d167b DMR: Fix LRRP Report to File Format; #281 2025-02-25 11:11:28 -05:00
lwvmobile
f6aba4a5a4 DMR: Fix Potential Overflo/Underflow in UTF8 Text; 2025-02-23 23:52:28 -05:00
lwvmobile
f0b5f2737f DMR: Disable break statement on UTF8 text; 2025-02-23 21:03:05 -05:00
lwvmobile
5c177d671c DMR: Disable LOCN unless SD PDU first octet is 0x01; 2025-02-23 20:34:30 -05:00
lwvmobile
1d112a21cc Merge pull request #278 from thesamesam/cmake
CMakeLists.txt: fix build w/ split tinfo
2025-02-23 18:10:44 -05:00
Sam James
13bbf08e6c CMakeLists.txt: further future-proofing of FindCurses use
`CURSES_INCLUDE_DIR` -> `CURSES_INCLUDE_DIRS` as `_DIR` is deprecated
per the `FindCurses` docs. It shouldn't matter like the `_LIBRARY` issue
though as it seems to gracefully populate both with the same value.
2025-02-23 23:08:24 +00:00
Sam James
7c180113cd CMakeLists.txt: fix build w/ split tinfo
Gentoo ships "split tinfo" (with `tinfo` in `libtinfo`). This is fine
if pkg-config or similar is used, but FindCurses unfortunately misbehaves
(see https://gitlab.kitware.com/cmake/cmake/-/issues/23236).

dsd-fme applies the workaround needed for that already since c917c61b85
but `CURSES_LIBRARY` was used instead of `CURSES_LIBRARIES`. Despite the
CMake docs only indicating that it's a deprecated alias, `_LIBRARY` indeed
only contains some of the needed libraries instead of all.

Fix that by using `CURSES_LIBRARIES` instead.

Closes: https://github.com/lwvmobile/dsd-fme/issues/276
2025-02-23 22:58:14 +00:00
lwvmobile
2ba4641796 DMR: Reset some elements on TD_LC; 2025-02-23 16:40:03 -05:00
lwvmobile
d11de2cbac DMR: PDU Misc Tweaks and Fixes; 2025-02-23 16:14:19 -05:00
lwvmobile
1725e45793 DMR: PDU RC4 and BP Decryption; 2025-02-23 02:58:45 -05:00
lwvmobile
035df461e1 Cygwin: Remove 'mode con: cols=90 lines=50' from bat files since its broken in PowerShell; 2025-02-22 23:02:34 -05:00
lwvmobile
f6f5380df4 DMR: Rework PDU Assembly; 2025-02-22 22:50:53 -05:00
lwvmobile
d8df5ceab5 DMR: PDU / LRRP Misc Fixes, Tweaks, and Cleanup; 2025-02-22 14:28:09 -05:00
lwvmobile
dfe744ef13 DMR: Rework PDUs; 2025-02-22 09:04:07 -05:00
lwvmobile
2fbdf46fd6 Fix .bat file permissions and home folder location for cygwin portable build; 2025-02-14 23:54:53 -05:00
lwvmobile
2c100dd121 Update Cygwin Scripts for:
Make a portable cygwin release as a user option in the shell script;

Add the bat files from the precompiled releases to the examples folder;

Add rebuild_cygwin.bat so cygwin users can easily update their versions;

Standalone cygwin_portable.sh version creator;
2025-02-14 23:13:43 -05:00
lwvmobile
42cb14b9d9 Cygwin SH Tweaks for multithread; 2025-02-12 19:35:56 -05:00
lwvmobile
c5cded87b1 Update Cygwin Instructions; 2025-02-12 12:22:27 -05:00
lwvmobile
b2ee4e1df0 Fix Cygwin Instructions; 2025-02-11 22:33:58 -05:00
lwvmobile
db73166da7 Cygwin SH File Tweaks; 2025-02-11 22:15:34 -05:00
lwvmobile
8d21574a93 Fixes For Cygwin Builds:
Remove AERO Build Define; Replace with __CYGWIN__;

Fix extern optarg,optind on __CYGWIN__;

Fix GIT_TAG versioning for __CYGWIN__;

Add Experimental Install sh script;
2025-02-11 19:17:30 -05:00
lwvmobile
35bd5ccc55 Code Arrangement and Additions:
Migrate Harris Alias for vPDU;

Setup Harris Alias for LCW;

Working Harris GPS for LCW;

Harris GRG Bitmap(speculative);

Migrate Tait Alias for LCW;

Misc Tweaks;
2025-02-10 23:45:56 -05:00
lwvmobile
6dd1410faf Moto Alias Dump Function;
Misc Tweaks for displaying and writing various P25 Aliases to File and Ncurses for display;

Misc String Safety Tweaks on Aliases and writing to csv files / display;
2025-02-07 17:33:08 -05:00
lwvmobile
0cbf42e4e6 P25 Moto Alias vPDU Working; Tweaks and Fixes; 2025-02-06 21:36:01 -05:00
lwvmobile
f0657ee5a8 Change P25 Moto Alias Block bn to num_bits value to make it work with multiple bit per block values; Misc Cleanup and Tweaks; 2025-02-06 00:11:46 -05:00
lwvmobile
29ee3a5f3a Moto Alias for MAC vPDU Setup;
Seperate P25 Moto Alias Block Function from Alias Decode Function;

Move Code to dsd_alias.c;
2025-02-05 23:39:25 -05:00
lwvmobile
8cfaced4b4 P25 Moto Talker Alias LCW WIP; 2025-02-05 09:52:30 -05:00
lwvmobile
61673222db Merge branch 'p25_moto_alias_setup' into aw_dev 2025-02-05 07:13:18 -05:00
lwvmobile
f59f0cbb7f P25 Moto Talker Alias LCW Setup and Test; 2025-02-05 07:12:41 -05:00
lwvmobile
20af28597d Fix Variable Print Format; 2025-02-04 17:26:00 -05:00
lwvmobile
942d83f54d Merge pull request #275 from pizzolante/fix/locale-independent-package-check
FIX: Locale indipendent libitpp-dev package check
2025-02-03 23:41:08 -05:00
lwvmobile
0c6f132520 Merge pull request #272 from VasylSamoilov/patch-1
Fix example file group.csv syntax
2025-02-03 23:40:13 -05:00
Leo Pizzolante
6319508937 FIX: Locale indipendent libitpp-dev package check 2025-02-03 23:56:42 +01:00
lwvmobile
ae6525e986 P25 Tait Talker Alias LCW; 2025-02-02 00:49:23 -05:00
lwvmobile
51d1690edc Fix Misc vPDU Manufacturer Len Values; 2025-02-01 16:32:54 -05:00
lwvmobile
14d00f9228 New Tag; 2025-01-26 13:34:40 -05:00
lwvmobile
5ad9f4107c P25: Add Tait (mfid: D8) Slot Count vPDU (op: B5); 2025-01-26 13:31:54 -05:00
VasylSamoilov
6afa4ed327 Fix example file group.csv syntax 2024-12-25 16:18:24 +02:00
lwvmobile
bc140ec081 Add ES Aux Header to r12 MPDU; Fix Format Security Warning on Debug UTF16 Prints; 2024-12-13 23:39:21 -05:00
lwvmobile
d904289060 Fix Several P25p1 LCW regardless of MFID presence; 2024-12-13 23:21:34 -05:00
lwvmobile
e13bd4f323 More P25p1 MPDU Payload Fixes; 2024-12-13 15:40:48 -05:00
lwvmobile
5752f1b84a Fix P25p1 Confirmed Data Payload Output; 2024-12-13 15:31:24 -05:00
lwvmobile
5e516ed6d1 Fix P25p1 ADJSS BCST LCW; 2024-12-13 12:35:54 -05:00
lwvmobile
2ceeeb82af Add Text Debug PDU Code for P25 and DMR PDUs; 2024-12-12 05:18:33 -05:00
lwvmobile
2883e44a9d Fix P25p1 SCC BCST LCW; 2024-12-10 14:06:12 -05:00
lwvmobile
20747db2cc Fix DSP output for DMR SB/RC;
Fix DSP output order on BS voice loop;
RC PDU Format Line Break;
Debug RC data testing on BS VC-F;
2024-12-08 16:55:33 -05:00
lwvmobile
c2f22ac399 Add Some More P25p1 PDU SAPs;
Add P25p1 PDU Aux ES Info;

Fix Misc Formatting and Cleanup on P25p1 PDU Blocks;
2024-12-07 14:40:45 -05:00
lwvmobile
b8beede921 Remove Unused Bits of Code for DMR/RS Sync Pattern (Fixes Bug if RES Sync is detected and flag tripped); #270 2024-11-17 08:43:11 -05:00
lwvmobile
cd32158a73 Fix len on unpack_ambe function; 2024-11-13 15:11:51 -05:00
lwvmobile
a8ec6dbe37 Add Frame Number to dPMR with Payload Verbosity; 2024-11-11 14:45:18 -05:00
lwvmobile
f22af7c5fc Fix Mono to Stereo Interleave Audio Gain on YSF/DMR MS; 2024-10-24 00:24:34 -04:00
lwvmobile
a4b53f88a1 Disable PV Debug Output; 2024-10-23 23:31:17 -04:00
lwvmobile
4567e2f4a4 DMR: Con+ Call/Slot Termination; 2024-10-23 23:21:00 -04:00
lwvmobile
8a3fd87784 PV: Remove Spacer Bits; Misc Cleanup; 2024-10-23 22:41:33 -04:00
lwvmobile
c428ce32b2 Merge branch 'pv_diag' into aw_dev_merge 2024-10-23 22:34:24 -04:00
lwvmobile
2ae9c50d47 Merge pull request #269 from volo-zyko/fix-compiler-warnings
Fix some compiler warnings and add corresponding compiler flags
2024-08-30 11:12:23 -04:00
Volo Zyko
dfcc8d513d Fix some compiler warnings and add corresponding compiler flags 2024-08-29 15:05:52 +03:00
lwvmobile
7c9d032c99 PVDebug Testing; 2024-07-21 10:08:39 -04:00
lwvmobile
f6fc91a051 Include pack_ambe and unpack_ambe functions and use during certain keystream applications; 2024-07-20 16:41:35 -04:00
lwvmobile
8b76daa35f Fix/Simplify AMBE and IMBE Print Code; Include Bit/Byte Utility Functions; 2024-07-20 16:41:07 -04:00
lwvmobile
8b883f556f M17: Packet Decode Fix Sanity Check So It Doesn't Break CRC; 2024-06-15 01:18:47 -04:00
lwvmobile
beefaae0fa M17: Disable Debug Print on PKT Assembly; 2024-06-15 00:56:31 -04:00
lwvmobile
13e778b123 M17: Fix Potential Core Dump (overflow) on Packet Assembly on Bad Packet Decode; 2024-06-15 00:47:16 -04:00
lwvmobile
7f7c13a72a M17: Don't Attempt To Decode Encrypted Packet Data; Disable Annoying Nonce TS Warning; 2024-06-15 00:21:20 -04:00
lwvmobile
f2312e63eb M17: Disable Duplicate (Debug) LSF and Change Default DST Value;
M17: Fix Examples in Usage;

M17: Disable Nonce/IV Warning;

M17: Add Support For OTAKD Recognition (skip decode);
2024-06-13 16:21:25 -04:00
lwvmobile
d6adaa87c7 M17: Fix Meta Text Decoding to skip control byte on string, but display len/seg number; LSF Payload CRC Line Break Nit; 2024-06-13 15:36:14 -04:00
lwvmobile
20e35a00ba M17: Adjustments to PKT Data CRC; 2024-06-10 04:36:55 -04:00
lwvmobile
8610ee8956 M17: Fix Bugs With SRC/DST Values in Meta Extended CSD; 2024-06-09 05:47:04 -04:00
lwvmobile
92fbdabbe5 M17: Tweaks to Meta Decode Conditions; 2024-06-08 13:45:18 -04:00
lwvmobile
25659ba920 M17: Tweak Output on GNSS Position Data; 2024-06-08 03:07:35 -04:00
lwvmobile
b2ce60b843 Update Install Notes to Mention Debian 12; 2024-06-07 22:22:42 -04:00
lwvmobile
c87ad08371 M17: Fix META Decode when not IV and Decode META Text as UTF-8 and Not RAW; 2024-06-07 22:20:36 -04:00
lwvmobile
94688fddd4 Change Download For Ubuntu 24.04 Script from aw_dev to audio_work branch; 2024-06-06 15:17:57 -04:00
lwvmobile
e29eba9943 Fix Error in Manual Install Packages For Ubuntu; 2024-06-06 15:15:10 -04:00
lwvmobile
920dce96fe Add Auto Installer Script For Ubuntu 24.04 LTS; #262 2024-06-05 04:23:27 -04:00
lwvmobile
e2747525a6 Patch: Remove Outdated G Patch (Again); 2024-05-31 03:44:27 -04:00
lwvmobile
a5989486ae Patch: Fix g_dmr patch to work properly with new call string and append .wav properly in Linux; 2024-05-31 01:58:38 -04:00
lwvmobile
9c58273832 DMR: Fix Per Call String on DMR Tier 3 When Trunking; 2024-05-31 01:04:39 -04:00
lwvmobile
9a9fa0c182 Patch: Delete Older Version of G Patch; Add Cretu DMR no idle print patch; 2024-05-27 20:12:28 -04:00
lwvmobile
319d0b9866 OSS: Quick Bugfix for hpf_d when TDMA slot 1/2 volume issues; Updated g_dmr patch; 2024-05-27 20:02:48 -04:00
lwvmobile
5dbccaadf6 Add Per Call String For NXDN Conventional / Type-D; 2024-05-21 09:42:46 -04:00
lwvmobile
28a6777d83 DMR: Tweak to Call String Options for Display and Per Call; #258 2024-05-21 09:06:22 -04:00
lwvmobile
21afa4ba97 Add Call String To Per Call Files (group/private/emergency/enc); WIP; #258 2024-05-21 01:49:23 -04:00
lwvmobile
d60dfa7ff3 Update Usage to reflect changes to the -7 directory option; 2024-05-19 18:03:37 -04:00
lwvmobile
5d3b2ec56f Fix Some Absolute Directory Path Issues(WIP); #261 2024-05-19 16:32:27 -04:00
lwvmobile
2c55a9caab Ncurses: Device Display Spacing Nit; 2024-05-19 15:32:32 -04:00
lwvmobile
6daedf198f Update Docs: Add Audio Plumbing Information; 2024-05-19 06:26:09 -04:00
lwvmobile
8d52ce2ac9 Add Pulse Input / Output Sink / Source Name to Ncurses Terminal; 2024-05-19 05:59:10 -04:00
lwvmobile
63e484cc91 Optional User Input Argument for Pulse Audio Sink / Source Use; 2024-05-19 05:34:56 -04:00
lwvmobile
e3ecace5db Pulse Audio Sink and Source Enumeration WIP; 2024-05-19 04:59:26 -04:00
lwvmobile
f9add0b997 M17: Misc Fixes and Tweaks; 2024-05-10 12:33:39 -04:00
lwvmobile
d3c942d475 Phase 1 Non-standard IMBE Log Tweaking and Notes; 2024-05-10 12:32:42 -04:00
lwvmobile
3d1e28fb3a Fix Error Handling and Error String on Pulse Input and Output Opening #259 2024-05-10 12:08:38 -04:00
lwvmobile
c07fa3a0bc Cast &err into pa_simple_new on ALL calls to the function (missed a few in haste); 2024-05-08 09:33:38 -04:00
lwvmobile
ef94b311fa Add Error Handling and Error String on Pulse Input and Output Opening #259 ; Change Input 'Name' on M17 Voice Input so it doesn't default to same source as RF Signal Input; 2024-05-06 21:46:29 -04:00
lwvmobile
79d5b795e3 Merge pull request #257 from ilyacodes/aw-dev/standard-test
EDACS: Correctly identify test calls on standard
2024-04-27 11:08:13 -04:00
ilyacodes
d0c20be7f3 EDACS: Correctly identify test calls on standard 2024-04-27 09:54:59 -04:00
lwvmobile
6833275960 Merge pull request #256 from lwvmobile/aw_dev_timefix
Consolidate and Fix Time and Date Functions #255
2024-04-26 21:47:47 -04:00
lwvmobile
601a1ad2d1 TIME: Fix printFrameSync Oopsie; NULL PTR on Debug symbolfile; 2024-04-25 21:23:20 -04:00
lwvmobile
db036f4dfc TIME: Set Allocated Pointers to NULL after free()'d; 2024-04-25 18:22:28 -04:00
lwvmobile
7bcd29abec NCURSES: Move timestr/datestr around; 2024-04-25 16:15:44 -04:00
lwvmobile
c5b36af672 Add .bin loop 'debug mode' on -J; 2024-04-25 16:14:59 -04:00
lwvmobile
9da8544408 TIME: malloc and HHmmss Nits; Remove Unneeded time/date strings from Ncurses; 2024-04-25 11:27:26 -04:00
lwvmobile
ab9a9ddab3 TIME: NULL Check Before free(timestr); 2024-04-25 11:06:13 -04:00
lwvmobile
ceb695af01 NCURSES: Remove Extra Fence Post on EDACS Call History; 2024-04-25 09:24:01 -04:00
lwvmobile
1ffddf823f Fix and Consolidate Date and Time Functions (WIP); #255 2024-04-24 16:42:25 -04:00
lwvmobile
499134bc2d DMR: Reset Color Code If Not Trunking and NoCarrier; 2024-04-24 13:01:45 -04:00
lwvmobile
7a9763c6c7 DMR: Init Payload Buffer; Fix MS Data Collection; 2024-04-24 13:00:13 -04:00
lwvmobile
db7bc75739 DMR: Fix EMB_PDU CC Assignment; 2024-04-24 12:33:04 -04:00
lwvmobile
bd1dcd2a7f DMR: Set CC on MS Voice; QR Correction Limit; 2024-04-21 18:18:14 -04:00
lwvmobile
bc205cfe00 DMR: Fix Color Code Assignment, Display, and Logging; 2024-04-21 17:49:46 -04:00
lwvmobile
0f3dcf47ea Merge pull request #254 from ilyacodes/aw_dev-colour
EDACS: Fix colour for test channel updates
2024-04-21 12:43:13 -04:00
ilyacodes
3f165571d2 EDACS: Fix colour for test channel updates 2024-04-21 09:52:09 -04:00
lwvmobile
b2450b1924 Merge pull request #253 from ilyacodes/trbo-bp
DMR: Fix incorrect MotoTRBO Basic Privacy mask
2024-04-19 22:58:15 -04:00
ilyacodes
061703db7b DMR: Fix incorrect MotoTRBO Basic Privacy mask
Tested with an R7.

Basic Privacy key: `73_dec`
Encrypted silent voice: `860DD7D3F2AC80`
Mask: `7E0C7E4C7E4C00`
2024-04-19 21:01:55 -04:00
lwvmobile
50f4327306 PA: Adjust Input Fragsize / Latency;
M17: Misc Notes About UDP Audio;
2024-04-18 11:15:42 -04:00
lwvmobile
90206eac92 Patch: Add the AFD "April Fools Day" Ghost Box Gag Update as a patch to bring back around Halloween; 2024-04-16 22:43:22 -04:00
lwvmobile
f1a5d6f870 Patch: Make the Moto Type II Starter Pack a Patch so I can delete the branch for it and prevent having to do a bunch of rebase / merge conflict resolutions on between those branches later; #247 2024-04-16 22:40:00 -04:00
lwvmobile
ca506672a8 Merge pull request #251 from ilyacodes/testcall
EDACS: Test Call improvements
2024-04-16 09:00:24 -04:00
lwvmobile
3041713eb3 M17: Fix Compiler Error if librtlsdr not found / installed; 2024-04-16 06:03:05 -04:00
lwvmobile
dbc645e7b0 EDACS: Fix Unk4 Value EA Dynamic Regrouping; #252 2024-04-15 09:40:53 -04:00
lwvmobile
5d205800aa EDACS: Fix Bit Shift on EA Patch Info; Misc; #252 2024-04-15 09:30:22 -04:00
lwvmobile
e5d11c81f3 EDACS: More WIP/Tests on EA Dynamic Regrouping2; #252 2024-04-15 07:47:15 -04:00
lwvmobile
d86c520509 EDACS: More WIP/Tests on EA Dynamic Regrouping; #252 2024-04-15 07:17:07 -04:00
ilyacodes
854b421235 EDACS: fix group patch shift size 2024-04-14 11:03:50 -04:00
ilyacodes
8206a5f3f4 EDACS: print agency/fleet calls in logs 2024-04-14 10:05:09 -04:00
ilyacodes
0568475d59 EDACS: custom format for custom AFS patterns 2024-04-14 10:04:52 -04:00
ilyacodes
b5a43031f9 EDACS: rename functions to lowerCamelCase style
It's, like, mildly more consistent... and is subtly shorter, which is handy for some cases.

Though yeah we have functions with both styles in the same file.
2024-04-14 09:52:22 -04:00
ilyacodes
ba41ba57f6 EDACS: fix vc_call_type for EDACS_IS_TEST_CALL 2024-04-14 09:42:43 -04:00
ilyacodes
d84136dc92 EDACS: show agency/fleet call on channel updates too 2024-04-14 09:40:03 -04:00
ilyacodes
ad78373b43 EDACS: fix width of source for non-EA data calls 2024-04-14 09:12:26 -04:00
ilyacodes
8980207fd6 EDACS: fix wrong comment 2024-04-14 09:12:01 -04:00
ilyacodes
33d8ee70d9 EDACS: compute AFS masks using math, not copy/paste 2024-04-13 17:15:44 -04:00
ilyacodes
b86cd1bc3c EDACS: agency call and fleet call are mutually-exclusive 2024-04-13 16:52:16 -04:00
ilyacodes
57c22b484d EDACS: ugh have to pass state too 2024-04-13 16:31:27 -04:00
ilyacodes
834bd57ea6 EDACS: logging nit 2024-04-13 16:23:32 -04:00
ilyacodes
7e26b7b902 EDACS: Show agency and fleet calls based on AFS 2024-04-13 16:22:52 -04:00
lwvmobile
4eb2e770c8 EDACS: Redo Parts of EA Patch / Regroup Based on Newer Observations and Remove Overlapping Bit Range; 2024-04-13 16:19:52 -04:00
ilyacodes
0208f6240c EDACS: Fix copypasta typo in new AFS logic 2024-04-13 15:38:31 -04:00
ilyacodes
db88bfff8d EDACS: missing space 2024-04-13 14:48:32 -04:00
ilyacodes
a78b88cb90 EDACS EA: tiny log string change 2024-04-13 14:19:10 -04:00
ilyacodes
a42dd9db83 EDACS: update line telling user to specify EDACS type 2024-04-13 10:58:49 -04:00
ilyacodes
a7d7cf1c2e EDACS EA: Dynamic Regroup log consistency 2024-04-13 10:56:51 -04:00
ilyacodes
1ec8bb5c8b ncurses: trim trailing whitespace 2024-04-13 10:51:04 -04:00
ilyacodes
d8e672f796 EDACS EA: make System Dynamic Regroup KWHT so it doesn't conflict with test calls 2024-04-13 10:48:07 -04:00
ilyacodes
b577397d22 EDACS ncurses: remove extra printf argument 2024-04-13 10:44:37 -04:00
ilyacodes
832afa6c5a EDACS EA: comment 2024-04-13 10:42:26 -04:00
ilyacodes
b667d25f2a EDACS EA: cosmetic updates to I-Call/Test Call logging 2024-04-13 10:41:56 -04:00
ilyacodes
e237b5541b EDACS: Test calls should be KMAG(enta) 2024-04-13 10:40:32 -04:00
ilyacodes
bf62106953 EDACS: Differentiate test call update from individual call update on standard 2024-04-13 10:36:40 -04:00
ilyacodes
09b181449f EDACS: Differentiate test call from individual call on standard 2024-04-13 10:27:37 -04:00
ilyacodes
c073bc49c1 EDACS: Consistency for CC LCN message logging 2024-04-13 10:25:38 -04:00
ilyacodes
7b2a2031a2 EDACS: Consistency for Initiate Test Call message logging 2024-04-13 10:25:22 -04:00
ilyacodes
a90a2dadd4 EDACS: Prettier test call display 2024-04-13 10:24:10 -04:00
ilyacodes
c21aa98034 EDACS: Fix incorrect indexer for test call 2024-04-13 10:20:53 -04:00
ilyacodes
c967e1500c EDACS: Rename EDACS_IS_TESTCALL flag 2024-04-13 10:19:36 -04:00
lwvmobile
99212cc139 EDACS: Differentiate EA Test Call Assignment and Update; 2024-04-13 03:50:07 -04:00
lwvmobile
caab348a39 EDACS: Fix EA Test Call in Call History; 2024-04-13 03:21:59 -04:00
lwvmobile
f799374183 EDACS: EA Test Call Continuation (I-CALL zero); Ncurses Display of Test Call; Test Call Type; Notes; 2024-04-13 02:55:38 -04:00
lwvmobile
1f8a129137 M17: Fix Misc Cosmetic Output on IP Frame; 2024-04-13 01:39:55 -04:00
lwvmobile
ba11725087 EDACS: EA Adjacent Site Index Values and Definitions; 2024-04-12 18:01:04 -04:00
lwvmobile
79f8503c09 EDACS: Tweak EA Patch / Regroup Message; Add Comments; 2024-04-12 17:37:59 -04:00
lwvmobile
5c7f285b9d EDACS: Tweak Regroup Message Verbosity; Tweak Patch Verbosity; 2024-04-12 16:05:18 -04:00
lwvmobile
b7415e1855 EDACS: Better EA Patch Message Decoding(WIP); 2024-04-12 15:04:06 -04:00
lwvmobile
3def1f59e5 M17: Misc Output Tweaks; 2024-04-12 11:54:08 -04:00
lwvmobile
7b8a79b8ea Merge pull request #250 from ilyacodes/voting
EDACS: implement voting error-correction algorithm, add new EA commands, refactor message parsing
2024-04-12 11:52:10 -04:00
ilyacodes
9695438fcd EDACS EA: system info and site info parsing 2024-04-11 07:57:55 -04:00
ilyacodes
49cd974dcb EDACS EA: log formatting 2024-04-10 22:32:43 -04:00
ilyacodes
739d373204 Merge branch 'voting' of https://github.com/ilyacodes/dsd-fme into voting 2024-04-10 22:09:36 -04:00
ilyacodes
896cb83eb2 EDACS EA: log and file formatting 2024-04-10 22:09:35 -04:00
ilyacodes
22f1261efa EDACS EA: log and file formatting 2024-04-10 22:07:45 -04:00
ilyacodes
4648b9c8eb EDACS EA: correct log output format 2024-04-10 22:04:00 -04:00
ilyacodes
e77770f608 EDACS: trim trailing whitespace 2024-04-10 19:59:08 -04:00
ilyacodes
bfa2ae8bc4 EDACS EA: Add System Dynamic Regroup Plan Bitmap command 2024-04-10 19:58:54 -04:00
ilyacodes
9c13d21f69 EDACS EA: add Unit Disable/Enable command ("kick") 2024-04-10 19:58:42 -04:00
ilyacodes
16ce501582 EDACS EA: remove dead "kick" command code 2024-04-10 19:58:27 -04:00
ilyacodes
61617db239 EDACS: remove BCH from messages prior to parsing them 2024-04-10 19:58:11 -04:00
ilyacodes
ac74a9c80e EDACS: start using new voting (for real) 2024-04-10 19:32:31 -04:00
ilyacodes
c8812db585 EDACS: remove comparison to pre-voting BCH check logic 2024-04-10 19:22:49 -04:00
ilyacodes
95aaa8fc2e EDACS: implement voting algorithm for FR BCH checks 2024-04-10 19:22:04 -04:00
lwvmobile
deb9dbed61 M17: Fix SRC Values in IP Frame Headers and Decode them; 2024-04-10 18:47:58 -04:00
lwvmobile
0feb8dc73c M17: MPKT Decode LSF Info; Misc Output Tweaks; 2024-04-10 09:36:16 -04:00
lwvmobile
6bfbdbd9df M17: MPKT Buffer Size Fix; CRC Fix; 2024-04-10 09:17:44 -04:00
lwvmobile
2160b369bb M17: Send / Receive PKTs with IP Frame WIP; 2024-04-10 08:15:36 -04:00
lwvmobile
de91defc20 DMR Con+ Output Tweaks; Complier Warning Fix; 2024-04-09 21:39:13 -04:00
lwvmobile
3fbff95b2b Initialize RRC Input Filter Memory; Misc Work; Change input/output CLI for M17 UDP IP Frames to prevent accidental triggers on input files that are named with m17; 2024-04-09 18:45:53 -04:00
lwvmobile
6facababd7 EDACS: Move TG Hold Display; Fix TG Hold Override when I-Call; 2024-04-09 13:38:07 -04:00
lwvmobile
dc3dc80d8f M17: Tweak Ncurses Display on Encoder; 2024-04-09 12:07:23 -04:00
lwvmobile
202fbf3dbc M17: Make IP Frame UDP Input/Output Configurable via CLI -i and -o; 2024-04-09 11:43:41 -04:00
lwvmobile
f6283f4807 M17: Enable Ncurses Terminal for IP Frame; Misc; 2024-04-09 10:04:39 -04:00
lwvmobile
1f7ddbecdf M17: UDP Socket Receiver and IP Frame Tweaks; 2024-04-09 01:20:22 -04:00
lwvmobile
129af0ba9e M17: Misc Handling / Display Tweaks; 2024-04-08 18:04:39 -04:00
lwvmobile
eed267ed3f EDACS: Fix TG Hold Value Display if AFS; 2024-04-08 17:34:40 -04:00
lwvmobile
e195770181 M17: Cleanup / Decode IP Frame CONN and DISC; 2024-04-08 16:31:46 -04:00
lwvmobile
cbddea701a M17: Clean Misc Comments / Code / Typos; 2024-04-08 03:50:32 -04:00
lwvmobile
3eefa3365f M17: IP Frame Encoder / Decoder Fixes; 2024-04-08 02:45:47 -04:00
lwvmobile
d22f9ddfe3 M17: UDP IP Frame Decoder over STDIN; 2024-04-07 14:14:44 -04:00
lwvmobile
5c9416313a M17: Decode Extended CSD in Meta; 2024-04-07 04:31:20 -04:00
lwvmobile
4b063aaf97 M17: Decode META Field; 2024-04-07 03:29:37 -04:00
lwvmobile
bbfd4967cf M17: Misc Tweaks with Stream 1600; Misc Other; 2024-04-07 02:22:11 -04:00
lwvmobile
c5742350d1 M17: Use 3200 or 1600 Voice in STR Encoder; 1600 Arbitrary Data Encoder / Decoder; 2024-04-06 22:45:13 -04:00
lwvmobile
753286cdf6 EDACS: Add AFS Configuration Display to Ncurses; 2024-04-06 22:16:47 -04:00
lwvmobile
22028b37ed Variable AFS bit values and shift / mask calculations using -fh344 or -fH434; 2024-04-06 21:26:26 -04:00
lwvmobile
3483c736ba Merge pull request #248 from ilyacodes/afs
EDACS: fix AFS 4:4:3 display
2024-04-06 19:52:36 -04:00
ilyacodes
20989c31c8 EDACS: fix AFS 4:4:3 display 2024-04-06 12:47:46 -04:00
lwvmobile
cee797017b M17 - Misc Code / Comment Cleanup; 2024-04-04 09:20:08 -04:00
lwvmobile
bceac916fe M17 - Tweaks to LSF Frame Decoding; 2024-04-04 08:39:13 -04:00
lwvmobile
7d8a081e3f Convolutional Decoder Init / Tweaks; 2024-04-04 08:38:37 -04:00
lwvmobile
4bd36ece9a M17 - Change -Q / DSP output format to match expected float input to m17-packet-decode; 2024-04-03 00:18:19 -04:00
lwvmobile
b95644d5e5 Re-Enable Analog PBF as default; 2024-04-02 13:56:29 -04:00
lwvmobile
791cc17b27 socat note in example usage 2024-04-02 12:37:00 -04:00
lwvmobile
40b1b67b29 Ncurses Misc Cosmetic Fixes on Analog; 2024-04-02 11:39:35 -04:00
lwvmobile
b8cb4ad521 Add Analog Displays to UDP and OSS Output; 2024-04-02 11:33:28 -04:00
lwvmobile
6b50ca034b Add Note About netcat; 2024-04-02 11:21:33 -04:00
lwvmobile
43df9c3ff5 Set RTL Sample Multiplier Default to 2X; 2024-04-02 10:04:02 -04:00
lwvmobile
dff48692ca Disable Analog PBF as default; 2024-04-01 13:51:24 -04:00
lwvmobile
44a8085463 Seperate CLI switch for Analog Audio Out Gain; 2024-04-01 13:29:10 -04:00
lwvmobile
934eb8264e Fix Audio Smoothing Variable Type; 2024-04-01 13:15:08 -04:00
lwvmobile
dc1bb6a55e CLI Options for Audio Filtering; 2024-04-01 13:11:23 -04:00
lwvmobile
fe9b5b51e8 Reconfigure RTL Volume Multiplier to be more dynamic; 2024-04-01 11:20:25 -04:00
lwvmobile
f35aa046c1 Tweak Ncurses Display Alignment for HPF; Document Keyboard Shortcuts for Filters; 2024-04-01 10:58:26 -04:00
lwvmobile
a708fa5f6e P25: Fix Warnings on MPDU UU_V Ext Grant; 2024-03-30 17:29:08 -04:00
lwvmobile
bb78b1bf27 P25: Fix Extended Channel Grants/Updates/Full SUID Values; 2024-03-30 17:21:10 -04:00
lwvmobile
931fae62c6 NCURSES: '3' Key Slot Preference Cycle; 2024-03-29 18:46:49 -04:00
lwvmobile
c1e657a5e3 DMR: Simplify CON+ Tune Away Logic; 2024-03-29 17:52:31 -04:00
lwvmobile
1e2d42ce23 EDACS: Fix No Color Build Compile Error; 2024-03-28 14:18:12 -04:00
lwvmobile
5d367a5c27 Upload Correct Updated Patches; 2024-03-28 14:17:16 -04:00
lwvmobile
1d03f7efbf Delete Broken / Incomplete Patches Uploaded Last Night; 2024-03-28 14:17:05 -04:00
lwvmobile
5125fd4d6c Delete Outdated Patches; 2024-03-28 14:16:56 -04:00
lwvmobile
d079035adf Update Patches For Easy Application; 2024-03-28 14:16:46 -04:00
lwvmobile
06bfcdacc2 Remove Integrated Patches; 2024-03-28 14:16:30 -04:00
lwvmobile
ab844202bc Squashed commit of the following:
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;

    commit 9bbe4de7fd
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sun Mar 24 16:08:16 2024 -0400

        EDACS: Digitize Analog For Analysis of 'Data Burst' Like Behavior;

    commit 9249b7a943
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sun Mar 24 12:28:26 2024 -0400

        Simply Mono Short Playback;

    commit 89ad0f17e3
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sat Mar 23 21:12:44 2024 -0400

        Add HPF to SS4, SS3, and SS Audio Methods;

    commit e8184c7fbd
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sat Mar 23 17:13:44 2024 -0400

        RTL - Add The Sample / Volume Multiplier as a user configurable option;

    commit ee04d11116
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 23:15:04 2024 -0400

        Fix HPF_D so it actually works correctly;

    commit e549b21497
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 20:11:34 2024 -0400

        Make Analog Auto Gain Control Mostly Tolerable;

    commit 2f9e0525fe
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 18:20:38 2024 -0400

        User Toggle HPF on Digital;

    commit ff58d3a6fa
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 18:10:15 2024 -0400

        User Toggles and Displays for Filters;

    commit b6fc17c506
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 15:55:09 2024 -0400

        More Analog Manual Audio Gain Tweaks;

    commit 076b9fbf04
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 06:26:10 2024 -0400

        Add SQL Hit on EDACS if Colors Disabled;

    commit 59fe47ef05
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 02:23:08 2024 -0400

        Disable HPF Test on Digital Voice;

    commit 4a63068ce1
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 23:39:43 2024 -0400

        Misc Code Organizing; audio_gainA Tweaks;

    commit 3585e7e594
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 13:18:31 2024 -0400

        Test Tweak to RTL Sample Multiplier;

    commit fa5b25283f
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 13:18:07 2024 -0400

        Adjust Manual Mic Gain on M17 Encoder; Ncurses Display;

    commit c985fea035
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 12:34:01 2024 -0400

        Misc Notes on using raw_rms values during testing;

    commit b273e5b7be
    Author: 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;

    commit eadf3fdf23
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 10:12:04 2024 -0400

        Analog Gain Has Own Variable; Ncurses Keys; Misc;

    commit 0debcc647e
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 08:49:51 2024 -0400

        Filtering Misc Cleanup;

    commit 98e10b2627
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Thu Mar 21 00:02:21 2024 -0400

        Automatic Gain On Analog WIP; Manual Gain Control;

    commit 89736ae543
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Wed Mar 20 10:22:20 2024 -0400

        Passband Filter Testing on Raw Analog / EDACS / M17 Encoder;

    commit 43f6218129
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Wed Mar 20 09:03:02 2024 -0400

        Passband and Notch Filter Setup; Debug Output;

    commit 35a1b53867
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 22:35:36 2024 -0400

        HPF: Only Use On RTL Input when M17 Encoder Uses It;

    commit b9949f0d80
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 17:31:59 2024 -0400

        Disable LFP on EDACS Analog Out;

    commit 3666740674
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 13:42:07 2024 -0400

        Test HPF On Digital Voice Out;

    commit ef13343925
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 12:46:27 2024 -0400

        RTL_FM Input for Analog/M17 Encoder;

    commit 2b7de90474
    Author: 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>

    commit c8d00846b1
    Author: 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

    commit 8d432e8b3e
    Author: 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

    commit 0440dea1de
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sun Mar 24 02:47:09 2024 -0400

        EDACS: Fix Call History For Standard Maybe;

    commit 208f188e55
    Author: 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

    commit 36f76a7e21
    Author: 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.

    commit 4bc73d8c68
    Author: 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

    commit 03507055a4
    Author: 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

    commit fbe5fd2093
    Author: 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

    commit 413e5f76a2
    Merge: de9127c 388a57d
    Author: 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

    commit 388a57d8fc
    Author: 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;

    commit 058099f1aa
    Author: 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;

    commit 68aa6b018e
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 02:19:38 2024 -0400

        EDACS: Update Docs to Reflect Changes;

    commit c404f3c48c
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 02:01:09 2024 -0400

        EDACS: Ncurses Display Working Mode Tweaks;

    commit b2d1608eb7
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 01:08:28 2024 -0400

        EDACS: Toggle Keys A and S for Mode Selection;

    commit a4553a0a0a
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Fri Mar 22 00:45:37 2024 -0400

        EDACS: Remove Auto Detect Code; Make CLI Switches;

    commit de9127cfb4
    Author: 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>

    commit c85dd60399
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 17:38:30 2024 -0400

        EDACS: NET/STD LCN > 0 Check;

    commit bed766a86e
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Tue Mar 19 09:34:10 2024 -0400

        EDACS: STD/NET Don't Tune Unless CC LCN Set;

    commit 69f532a022
    Author: 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 in f68367c4f3

        * 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>

    commit a7de24c47b
    Author: 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.

    commit 10eacd99cc
    Author: 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

    commit ebe6e8fc65
    Author: 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)

    commit 8619612b76
    Author: lwvmobile <lwvmobile@gmail.com>
    Date:   Sat Mar 16 22:42:44 2024 -0400

        EDACS: Setup Analog Calls and WAVs on EA and ICALL;

    commit 9ac1573f0b
    Author: 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 commit 83ac8feab7.

    commit 0aa01a45ef
    Author: 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)

    commit f68367c4f3
    Author: 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
2024-03-26 22:59:05 -04:00
ChronosXYZ
f05ddf8fcd Add Nix flake for the project (#232)
* Add Nix flake for the project

* Add `codec2` library for M17 encoding support
2024-03-23 22:13:12 -04:00
lwvmobile
f36df3ea09 NCURSES - Voice Error as Trunc Value to perserve display uniformity; 2024-03-19 18:05:36 -04:00
lwvmobile
df28ebe573 M17 - PKT CRC Immediately Following Terminator Byte and Fixes; 2024-03-17 19:28:53 -04:00
lwvmobile
3a44affc63 Fix/Simplify/Trash Legacy 48k Upsample Functions; 2024-03-15 22:22:06 -04:00
lwvmobile
19be1db46c M17 - IP Frame WIP2; 2024-03-15 19:16:44 -04:00
lwvmobile
7101c3588a M17 - Enable Vox Mode for Voice Stream (testing); 2024-03-15 17:43:53 -04:00
lwvmobile
5573244583 M17 - Transmuting Examples; Add Passive Analog Monitor Mode -fA; 2024-03-15 13:09:56 -04:00
lwvmobile
ad1db34c86 M17 - Make Input Rate Configurable via -M M17 User String. 2024-03-15 11:31:33 -04:00
lwvmobile
379cc25099 M17 - Update Example Page to Include Using M17 Encoder/Decoder; 2024-03-14 19:58:41 -04:00
lwvmobile
df6a6ce066 M17 - Persistent TCP Retry When M17 Decoding Enabled; 2024-03-14 19:32:07 -04:00
lwvmobile
27735ccc01 Merge pull request #197 from LZ2DMV/patch-1
Update Example_Usage.md
2024-03-14 17:48:14 -04:00
LZ2DMV
d614eb088e Update Example_Usage.md
Add example for recording 48k/1 audio with rtl_fm
2024-03-14 22:47:29 +02:00
lwvmobile
f1088e9471 M17 - Fix Symbol Stream to be compatible with m17-packet-encode.c from m17_implelemtations; 2024-03-14 07:10:43 -04:00
lwvmobile
f6b8cc71cc M17 - Fix Binary Output to Append; 2024-03-13 10:29:13 -04:00
lwvmobile
d35144e0e9 M17 - Fix PKT CRC +1 on len value; Output Binary Bitstream to file with -Q option; 2024-03-13 10:22:55 -04:00
lwvmobile
f7fe1e066c M17 - Fix Char Array Size Compiler Warnings; 2024-03-12 22:19:13 -04:00
lwvmobile
18366dd294 M17 - Fix PKT Decoder PBC to Internal Counter; 2024-03-12 22:05:17 -04:00
lwvmobile
106d717157 M17 - Implement RRC Filtering; 2024-03-12 21:22:29 -04:00
lwvmobile
296775d231 M17 - Do not include Data Type Byte in PKT CRC; 2024-03-12 17:48:58 -04:00
lwvmobile
114d8d7dfc M17 - Fix / Initialize User Input Strings and Fix CAN Value; 2024-03-12 17:48:38 -04:00
lwvmobile
2392f57d62 M17 - Check Caps and Special CSD Values; 2024-03-12 14:20:58 -04:00
lwvmobile
a0b199d208 M17 - Allow LSF Decode on CRC Err if AF Bypass Enabled; 2024-03-12 14:05:20 -04:00
lwvmobile
6c4584a00a M17 - User CAN/DST/SRC and SMS at CLI; 2024-03-12 13:46:55 -04:00
lwvmobile
5d565c55a7 M17 - Fix PKT CRC to only include significant bytes; 2024-03-12 09:16:15 -04:00
lwvmobile
fbc902d16e M17 - Misc Cleanup and Disable Debug Messages; 2024-03-11 09:23:53 -04:00
lwvmobile
051a65f0bb M17 - Fix Misc PKT/SMS Encoding/Decoding Issues; 2024-03-11 09:09:14 -04:00
lwvmobile
ffc311e0e9 M17 - Fix CSD Encode For Reserved Values; 2024-03-11 06:45:55 -04:00
lwvmobile
d738eee5d9 M17 - Fix Cygwin M17 FrameSync Woes; (Initialize Synctest); 2024-03-10 20:31:30 -04:00
lwvmobile
58a00106d3 M17 - Packet Encoder and Decoder Misc Fixes; 2024-03-10 04:51:08 -04:00
lwvmobile
d0617714ca M17 - Packet Decoder WIP3; SMS Decoder; Fix Encoder strlen value; 2024-03-10 04:00:25 -04:00
lwvmobile
6ae3316cd1 M17 - Packet Decoder WIP2; 2024-03-10 03:43:30 -04:00
lwvmobile
c1577905cd M17 - Packet Decoder WIP; 2024-03-10 01:39:42 -05:00
lwvmobile
d12f6a1191 M17 - Simple Packet Encoder; 2024-03-10 00:56:27 -05:00
lwvmobile
0f5612fdd4 M17 - Simple BRT Encoder; Setup for PKT Encoder; 2024-03-09 19:38:09 -05:00
lwvmobile
a77fa83c80 M17 - Add PKT/BRT FS on Encoder; Reorganize RF Type Numbers; 2024-03-09 17:27:08 -05:00
lwvmobile
75bc2b7b35 M17 - Tweak Dead Air; Disable Non-Zero Fill; 2024-03-08 16:34:22 -05:00
lwvmobile
ac6284819a M17 - Misc Tweaks; 2024-03-08 11:13:05 -05:00
lwvmobile
2e09e5fdfa M17 - Non Zero Fill on LSF Meta Field; 2024-03-08 10:37:29 -05:00
lwvmobile
5c09130782 M17 - Implement libM17 Viterbi Decoder for LSF; 2024-03-08 09:41:19 -05:00
lwvmobile
677b064e97 M17 - Include libM17 Viterbi Decoder and Misc Math; 2024-03-07 22:22:19 -05:00
lwvmobile
a30512f4e4 M17 - Debug LSF Frame; Pack/Repack CRC; 2024-03-07 21:21:06 -05:00
lwvmobile
e20229208f M17 - Update Ncurses Terminal manually if not using internal decoder; 2024-03-07 13:40:40 -05:00
lwvmobile
f67bb81de2 M17 - Tweak Encoder Output WAV during deadair; 2024-03-07 12:29:09 -05:00
lwvmobile
f98cdfeb0f M17 - Encoder Add Forgotten Lines; 2024-03-07 11:50:30 -05:00
lwvmobile
ba264c1557 M17 - Audio RF Modulation(WIP2); Disable Current M17 Filter; Misc; 2024-03-07 11:19:59 -05:00
lwvmobile
11a08298ff M17 - Audio RF Modulation(WIP); 2024-03-07 01:24:59 -05:00
lwvmobile
72ac2f628b M17 - Fix FSN Variable Type; 2024-03-06 20:18:10 -05:00
lwvmobile
dd87bf77f8 M17 - Tweak Nonce/IV Warning; 2024-03-06 14:45:26 -05:00
lwvmobile
d730ca2c25 M17 - Flush Stored Decoder Meta when not Encoding; 2024-03-06 13:21:27 -05:00
lwvmobile
0d09baee3c M17 - Repack LSF Frame Before New Encoding Session; 2024-03-06 13:14:07 -05:00
lwvmobile
7ea26b68e7 M17 - Send New LSF on new Encode; EOT Bit Fixes; Cleanup; 2024-03-06 12:59:54 -05:00
lwvmobile
e7334a6c4f M17 - Misc Cleanup and Reference Updates; 2024-03-06 11:52:53 -05:00
lwvmobile
404dc772d4 M17 - IP Frame EOT/FN Fix; EncodeRF Prototype; Misc; 2024-03-06 10:44:30 -05:00
lwvmobile
7754123e30 M17 - LSF Encode (WIP); Initial FSN Bug Fix; Misc; 2024-03-05 22:23:08 -05:00
lwvmobile
16b950d5a0 M17 - Fix Encoder Nonce Refresh; 2024-03-05 20:32:29 -05:00
lwvmobile
0ba3fee968 M17 - IP Frame and UDP Socket Connect/Blaster(WIP); 2024-03-05 16:00:35 -05:00
lwvmobile
a2113fcdcc M17 - AES IV Replay Warning; 2024-03-05 12:44:19 -05:00
lwvmobile
ec7fbeeb22 M17 - Add Nonce to Encoder; 2024-03-05 12:27:40 -05:00
lwvmobile
5f969bf4aa M17 - Cleanup; Audio Tweaks; Fix Conv; Misc; 2024-03-02 19:26:48 -05:00
lwvmobile
8a197aea45 M17 - M17 STR Encoder Nucrses Support; 2024-03-02 02:21:38 -05:00
lwvmobile
c6bc10f1ba M17 - M17 STR Encoder and Playback (WIP); 2024-03-01 23:55:09 -05:00
lwvmobile
5830dfa991 M17 - Fix UDP Audio Output Type; 2024-03-01 23:29:28 -05:00
lwvmobile
fc44edb0fc Remove Old/Obsoleted Patches; 2024-02-27 09:04:25 -05:00
lwvmobile
cb02c0328c P25 - Better Handling of Trunking ENC Call Lockout; Fix Duplicate Channel Listing in Multi Grant Updates; 2024-02-27 08:57:15 -05:00
lwvmobile
71d79ff45b Update Patch For Testing; Remove Old Patches; 2024-02-21 15:57:48 -05:00
lwvmobile
c4e2730ced P25p2 - Trunking Slot Enabled Tweak; 2024-02-21 15:28:07 -05:00
lwvmobile
65fdd7c5b4 UDP Analog Audio Output; 2024-02-21 10:29:06 -05:00
lwvmobile
42fee3bd3e Merge pull request #191 from axpe95/audio_work
In MBE calls set err2 to hold accumulated value of errors
2024-02-21 09:33:50 -05:00
axpe95
b4d45af268 MBE calls set err2 to hold accumulated value of errors 2024-02-20 17:45:54 -08:00
lwvmobile
7125f2fa5e DMR - Con+ Fix Setting CC Frequency Condition; 2024-02-20 07:34:52 -05:00
lwvmobile
4993ed00a2 DMR - Con+ Call Grant TS Value Fix; 2024-02-19 14:45:53 -05:00
lwvmobile
a2b622a343 DMR - Con+ Tune Timeout / Return to CC Tweaks; 2024-02-19 14:32:11 -05:00
lwvmobile
c401035209 NXDN - Rolling CAC CRC fix (reset demodulator state); Scrambler SEED Fix Each PF; 2024-02-14 18:03:07 -05:00
lwvmobile
4324afc593 Merge pull request #189 from axpe95/decrypt_fix
fix nxdn scramber roll on facch1 after superframe
2024-02-14 13:17:16 -05:00
lwvmobile
de5b99dbb9 EDACS and Analog Monitoring - Apply Filtering Stack (DE,DC,PE, CL); Misc; 2024-02-12 13:18:56 -05:00
lwvmobile
374999df1f EDACS - Implement TCP Connection Error Checking on Analog; Misc Cleanup; 2024-02-11 14:08:23 -05:00
lwvmobile
ba7455c99e EDACS - Analog Audio and EOT Tweaks; Fix Rigctl SetMod; 2024-02-11 08:42:32 -05:00
axpe95
ad592cdc59 fix nxdn scramber roll on facch1 after superframe 2024-02-09 16:19:42 +02:00
lwvmobile
78b2dac71c Upload Experimental Patches For Testing; 2024-02-09 09:13:53 -05:00
lwvmobile
5d5f224f66 Merge pull request #188 from axpe95/audio_out_fix
Fix output to stdout
2024-02-09 08:56:47 -05:00
axpe95
c70762fbee Fix output to stdout 2024-02-09 15:07:17 +02:00
lwvmobile
166bbbbc72 DMR - P_Clear wait by trunk hangtime; RC PDU tweak; 2024-02-05 23:24:59 -05:00
lwvmobile
8bdcaa047a DMR - P_Clear Wait One Second on Initial Tune; 2024-02-05 14:17:48 -05:00
lwvmobile
ee557cc552 DMR - P_Clear Reorder TG Hold Priority; 2024-02-05 13:14:03 -05:00
lwvmobile
d7b99be51f Update Screenshots; Remove Old Patches; 2024-02-05 12:18:31 -05:00
lwvmobile
ed85d508ed DMR rc crc7 fix and rc element decode #187; fix/revamp p_clear and p_protect trunking logic; MTL patch; g_dmr patch; Misc; 2024-02-05 11:11:56 -05:00
lwvmobile
ffa8b053d7 Fix minor memory leak on timestr; 2024-01-30 23:43:32 -05:00
lwvmobile
c39ddbc7a7 P25p1 MFID90 Channel User; TG Hold CLI; DMR BS Stablilization and LE Fix; Updated Patches; OSS Jank Fix; Ncurses Keyboard Shortcuts for Return to CC and Manual Channel Cycling; Misc; 2024-01-27 16:54:01 -05:00
lwvmobile
fa7fd116a7 Update/Fix Some Docs; 2023-12-28 17:38:18 -05:00
lwvmobile
199913ce53 Remove Colon (:) from mbe output files (hh:mm:ss); 2023-12-28 17:20:47 -05:00
lwvmobile
1ac2d84dc0 DMR - Fix TIII Adj/Vote Online Offline Indicators; 2023-12-28 03:22:08 -05:00
lwvmobile
c55128fc21 Patch - Restore Correct Wolf Patch; 2023-12-27 18:26:01 -05:00
lwvmobile
a6cb8b6989 Patch - Delete Broken Wolf Patch; 2023-12-27 18:24:50 -05:00
lwvmobile
676c5f0f09 Patch - Cleanup Old/Obsolete Patches; 2023-12-27 18:08:52 -05:00
lwvmobile
9acc014274 Patch - Even More TDMA (DMR/P2) Mono Stereo Tests; 2023-12-27 18:05:23 -05:00
lwvmobile
2237d16696 Patch - More TDMA (DMR/P2) Mono Stereo Tests; 2023-12-27 05:26:24 -05:00
lwvmobile
180fd1bfb0 DMR - More Compact Vendor/Site Info Ncurses; 2023-12-27 04:05:46 -05:00
lwvmobile
77bcff0dcc Patch - Fix g_dmr patch for current updates; 2023-12-26 21:08:56 -05:00
lwvmobile
b43e566f98 Patch - Test DMR Mono/Stereo Interleaving; #181 2023-12-26 20:55:59 -05:00
lwvmobile
f4e0412368 DMR - Rework C_ALOHA, SYSCODE and C_BCAST; #182 2023-12-26 15:54:18 -05:00
lwvmobile
18ec24f0e8 P25 -- TSBK Payloads on MFID90/A4 Known Opcodes; 2023-12-26 02:26:33 -05:00
lwvmobile
bf10289223 DMR - Con+ CSBK and Tuning Tweaks; Data Grant; 2023-12-24 20:55:11 -05:00
lwvmobile
e3c3d15dce DMR - Move CSBK Acknowledgements to Non MFID10; 2023-12-23 15:04:01 -05:00
lwvmobile
b726cc8faf DMR - Fix UDT Dialer Digit Values; 2023-12-23 13:45:27 -05:00
lwvmobile
133746d3a3 DMR - Acknowledgement CSBKs; 2023-12-23 12:34:23 -05:00
lwvmobile
56adbfe6fd DMR - Fix Line Break on SLC CRC ERR; 2023-12-23 06:28:59 -05:00
lwvmobile
c2e5b919d6 DMR - PROP_PDU Block Count Sanity Checks; 2023-12-23 05:47:12 -05:00
lwvmobile
b675a8fbcd DMR - Moto Data Channel CSBK; 2023-12-22 18:21:44 -05:00
lwvmobile
d5d84d598e DMR - Fix Data Header Padding Octet Count(try 2); 2023-12-22 18:05:33 -05:00
lwvmobile
aac17ca47d DMR - Fix Data Header Padding Octet Count; 2023-12-22 17:57:08 -05:00
lwvmobile
ead9bb77ec DMR - Only Apply LE MI if CRC4 is Good; 2023-12-22 14:09:40 -05:00
lwvmobile
91aac9b61a DMR - Clarify UDT Data Types; #177 2023-12-20 16:20:33 -05:00
lwvmobile
d0aa9e66ca DMR - Tweak T3 Tuning Conditions; 2023-12-20 12:42:17 -05:00
lwvmobile
b8f92e9661 DMR - Moto Data Announcement CSBK; 2023-12-19 18:28:42 -05:00
lwvmobile
78cb583a4d DMR - DPF 15 P_SAP 1 (prop pdu reserved) Tweaks; 2023-12-19 18:19:34 -05:00
lwvmobile
69f6710898 DMR - Enable LIP Protocol Decoder on UDT; 2023-12-18 20:37:35 -05:00
lwvmobile
ca3c648e3a Remove Some Duplicate FEC Functions (fec.h); 2023-12-18 20:37:31 -05:00
lwvmobile
cc581637c5 Fix Misc Format/Tab Issues on dsd_gps.c; 2023-12-18 18:42:47 -05:00
lwvmobile
5a05011992 DMR - Inplement LIP; Reorganize Various GPS Reports; 2023-12-18 18:35:53 -05:00
lwvmobile
daa200d655 Misc NMEA and Harris 'NMEA' GPS Fixes/Tweaks; 2023-12-17 22:58:59 -05:00
lwvmobile
34b0040b04 P25 - Harris GPS WIP3; 2023-12-17 18:52:13 -05:00
lwvmobile
24c08dfbbd Misc Cleaning; 2023-12-17 15:29:44 -05:00
lwvmobile
390c7939f9 DMR - Fix Inbound CSBK BS_DWN_ACT and Outbound TD_GRANT; 2023-12-17 15:05:11 -05:00
lwvmobile
fa6fe06068 DMR - Misc UDT / NMEA Cleanup; 2023-12-16 22:48:40 -05:00
lwvmobile
7193bca136 DMR - UDT Fixes and NMEA Support; #177 2023-12-16 20:06:10 -05:00
lwvmobile
67b7272b05 DMR - UDT Format Handling WIP2; #177 2023-12-16 08:49:05 -05:00
lwvmobile
88c9959e8e DMR - UDT Format Handling WIP; #177 2023-12-16 08:24:19 -05:00
lwvmobile
e4dcad7873 Patch -- DMR Per Call Ext Custom Dir Fix; #172 2023-12-15 09:11:32 -05:00
lwvmobile
bd1f6881ce DMR - Fix UDT Block Assembly; #177 2023-12-15 09:04:27 -05:00
lwvmobile
4b7b5d5a29 Fix Readme Links; 2023-12-13 12:20:15 -05:00
lwvmobile
42c5bd16cd Update Misc Docs/Scripts/Pics; 2023-12-13 12:17:50 -05:00
lwvmobile
501e7c762c P25 -- TSBK Status Dibit; Misc Cleanup; 2023-12-12 16:07:36 -05:00
lwvmobile
a01a01b533 P25 -- Fix MPDU Valid Dibit/Status Dibit Gathering; 2023-12-12 13:39:40 -05:00
lwvmobile
6d56db17f4 P25 - Harris GPS WIP2; SYNC_BCST Misc; 2023-12-11 11:15:15 -05:00
lwvmobile
d0040fd2a1 LRRP - Fix Speed Variable; Tweak Output; 2023-12-09 13:07:52 -05:00
lwvmobile
e5dd5eed5d P25p2 -- Harris GPS vPDU (WIP); 2023-12-04 07:39:57 -05:00
lwvmobile
dda84e74bc Fix Audio_Work Debian Installer Script; 2023-12-01 09:21:50 -05:00
lwvmobile
19712bf401 P25 - Fix SNDCP Ann vPDU + Misc LCW/TSBK/MPDU; 2023-11-27 11:42:18 -05:00
lwvmobile
76b6aa46bd DMR/P25 - 34 Point[0] fix; crc_valid array size; 2023-11-26 12:01:07 -05:00
lwvmobile
20ca710523 Symbol Sample Edge; YSF/DMR Edge Tweak; RTL Tweak; 2023-11-26 07:22:21 -05:00
lwvmobile
f98bad18b9 P25 - Phase 2 CC to Phase 1 SNDCP Channel Timing; 2023-11-24 16:18:56 -05:00
lwvmobile
0ecc9765dd P25 - R34 MPDU Format WIP2; 2023-11-24 15:52:54 -05:00
lwvmobile
5d26333676 P25 - R34 MPDU Format WIP; 2023-11-23 20:48:53 -05:00
lwvmobile
2d2af754c5 P25 - SNDCP Data Channel vPDU/TSBK WIP; 2023-11-23 02:51:30 -05:00
lwvmobile
3939a5b1cf Patch - DMR Voice and Data Call Presist Upd; #174 2023-11-22 16:13:53 -05:00
lwvmobile
fc99153c80 RTL LP Tweaks; 2023-11-22 12:42:37 -05:00
lwvmobile
076c7d669b DMR - Cap+/XPT Misc Tuning/Reset Tweaks; 2023-11-22 12:21:41 -05:00
lwvmobile
c8020c76ae Sample/Symbol Tweaks; 2023-11-22 07:50:53 -05:00
lwvmobile
696c9663dd Raw Signal Monitor Tweak; 2023-11-22 06:48:56 -05:00
lwvmobile
92144ee482 Patch - DMR Voice and Data Call Presistency; #174 2023-11-21 18:35:22 -05:00
lwvmobile
bd0b3f2856 P25 - MFID90 Moto Talker EOT ; Misc; 2023-11-20 21:49:58 -05:00
lwvmobile
529148ee18 Patch - Fix DMR TII Per Call for G; #172 2023-11-19 13:57:01 -05:00
lwvmobile
810aa04eb0 Fix Quiet WAV file on AERO/OSS when dual voices; 2023-11-19 03:27:39 -05:00
lwvmobile
20abfd4b8e NXDN -- Secondary 1/2 on F2, F3, and SCCH; Misc; 2023-11-18 22:26:26 -05:00
lwvmobile
bb76449560 NXDN -- Fill Out VoiceCallOption; Misc Tweaks; 2023-11-17 22:15:58 -05:00
lwvmobile
fc6b35c7f5 EDACS - Misc Tweaks; 2023-11-17 17:26:43 -05:00
lwvmobile
e6da485117 NXDN -- Implement Secondary 1/2 Decoder; Misc; 2023-11-15 16:21:25 -05:00
lwvmobile
d6160f7b7a NXDN - Zero TG/RID on TX_REL; Misc; 2023-11-15 12:30:01 -05:00
lwvmobile
2aedef7e77 NXDN - Rework Portions of Alias and Call History; 2023-11-14 21:20:55 -05:00
lwvmobile
11fd605d6b Misc Line Break Fixes; SB/RC FEC Output Fix; 2023-11-13 14:37:17 -05:00
lwvmobile
7b87ecca87 DMR - Decode ACT_UPDT SLC; 2023-11-12 08:45:31 -05:00
lwvmobile
ea996f6442 patch - add autodiag's dmr key by cc patch; 2023-11-10 18:53:42 -05:00
lwvmobile
e0182068b2 DMR -- initialize dmr_color_code variable; 2023-11-10 15:08:54 -05:00
lwvmobile
cd01902023 DMR and P25p1 - Tweak Output on Embedded GPS; 2023-11-07 13:10:33 -05:00
lwvmobile
5e386e90e0 Ncurses - Fix DMR MS Display 'Uniformity'; 2023-11-07 12:41:20 -05:00
lwvmobile
e28121f5b3 P25p2 -- Dual Voice Slots when Trunking patch; 2023-11-03 16:17:37 -04:00
lwvmobile
7a25e5d998 EDACS -- Fix/Tweak Analog Calls and Ncurses; 2023-11-03 16:13:04 -04:00
lwvmobile
c6488a4a26 EDACS - Fix Wav File Names, Display AFS as Dec; 2023-11-03 09:10:41 -04:00
lwvmobile
f32d18a5a3 P25p1 -- Fix Bad Copy/Paste Job in LDU1/LDU2; 2023-11-02 12:02:11 -04:00
lwvmobile
3297bd1e9e Patch Folder; NXDN Alias to gN; Patch Docs; 2023-10-31 23:35:27 -04:00
lwvmobile
6f9ce1f7ad NXDN -- Fix Tune Blocking on SRC ID; 2023-10-30 20:44:49 -04:00
lwvmobile
a21d0ac05e P25p1 -- Disable SoftID to gN if Trunking; #166 2023-10-30 15:57:51 -04:00
lwvmobile
584ca9e17a NXDN -- Fix ENC LO; Tweaks/Misc; #121 2023-10-30 10:58:52 -04:00
lwvmobile
fb1abfbd26 P25p1 -- Tweak APX(Moto) LCW GPS Output; 2023-10-28 17:30:09 -04:00
lwvmobile
e6dd71f338 Fix Potential Compiler Error on isch_map; 2023-10-28 17:11:43 -04:00
lwvmobile
46bf41fe15 P25/DMR -- Fix P1 APX GPS; Revert DMR GPS; 2023-10-28 17:11:06 -04:00
lwvmobile
01b6eccf4c NXDN - Misc Tweaks (Ncurses, DISC) and 96Filter; 2023-10-28 01:10:32 -04:00
lwvmobile
e1924db1ff DSTAR - More Eternal Darkness on APRS; #164 2023-10-25 15:22:25 -04:00
lwvmobile
76309399b0 DSTAR - Fix some SD Format Issues; Lose My Mind; 2023-10-25 10:49:36 -04:00
lwvmobile
9cbb4ec36b DMR/P25 - Fix EGPS Lat; Dump to LRRP file; #163 2023-10-24 18:27:36 -04:00
lwvmobile
973af860cf P25p1 -- Soft ID to groupName ifdef; #166 2023-10-24 17:50:35 -04:00
lwvmobile
bc90ade337 Aero -- Fix Date/Time on Per Call Wav Files; #168 2023-10-24 14:36:23 -04:00
lwvmobile
ab54b2f6f8 P25 MFID90 Misc TSBK/LCW and Tweaks; #164 2023-10-24 13:18:05 -04:00
lwvmobile
72626546c5 P25 - Fix MPDU TELE_INT_CH_GRANT elseif condition; 2023-10-21 14:40:49 -04:00
lwvmobile
c08dcb064c P25p1 - Zero LSD if Enc Voice; #166 2023-10-21 13:38:28 -04:00
lwvmobile
7525735df1 P25 - TELE_INT_CH_GRANT; Add/Tweak Misc vPDUs; 2023-10-21 10:37:19 -04:00
lwvmobile
f28559ae6b P25 -- Harris GRG TSBK and vPDU P/S Fix; 2023-10-19 18:43:15 -04:00
lwvmobile
e8957aa90f Multi -- Indicate Mute Code On TG Hold; #132 2023-10-19 12:42:24 -04:00
lwvmobile
4fdc302809 NXDN48 Filter to dPMR Filter; 2023-10-18 17:01:36 -04:00
lwvmobile
c32b2bd7aa WIP: Mute Audio from Blocked TG; 2023-10-17 17:29:58 -04:00
lwvmobile
a121f33be8 Tweak some Verbage regarding the 'Scan' Function; 2023-10-14 09:28:53 -04:00
lwvmobile
f65e65fb47 P25 -- Harris TA to groupName/group.csv; Tweaks; 2023-10-14 08:59:20 -04:00
lwvmobile
a4ddcd4220 P25 -- Tweak to Synchronization Broadcast PDU; 2023-10-13 16:27:20 -04:00
lwvmobile
481dd0adb5 Misc Audio2/Frame Tweaks; 2023-10-12 23:34:40 -04:00
lwvmobile
001d28aaf8 P25p2 -- Disable Slot Synthesis when MAC_SIGNAL; 2023-10-10 09:12:28 -04:00
lwvmobile
86e0a3ad77 Version Update; Compiler Warning Fix; 2023-10-09 17:48:30 -04:00
lwvmobile
a6a300e7c5 P25p1 -- LSD Parity Check; #166 2023-10-09 17:35:11 -04:00
lwvmobile
55a1d5a9f3 P25p2 -- Harris Talker Alias; Misc Frame Tweaks; 2023-10-09 07:46:28 -04:00
lwvmobile
81f9cd6ee6 P25p1 -- WIP: Dump LSD and Soft ID; #166 2023-10-09 07:43:08 -04:00
lwvmobile
459151b4bf P25p2 -- Revert Frame Tweak (SACCH vs Voice); 2023-10-07 01:45:40 -04:00
lwvmobile
fcad1789dc TG Hold: Fix EDACS/NXDN Display and Set; #132 2023-10-06 12:01:36 -04:00
lwvmobile
1c3204e5d7 P25p1 -- Re-Enable Slots on Call Termination; 2023-10-06 10:52:49 -04:00
lwvmobile
84df9bbca7 P25p2 -- Slot ON/OFF During Realtime Tuning; 2023-10-06 10:43:13 -04:00
lwvmobile
d073e7cae8 P25p2 -- Misc Frame Tweaks; 2023-10-06 09:09:31 -04:00
lwvmobile
3c2ce0bb18 P25 -- Disable UU_V Grants when TG Hold; 2023-10-06 08:54:00 -04:00
lwvmobile
9aee34a501 P25p1 -- Disable Heuristics (again) 2023-10-06 07:00:55 -04:00
lwvmobile
cc5248e958 P25p2 -- MAC_END_PTT go to CC conditions; 2023-10-05 15:34:05 -04:00
lwvmobile
d880d05ea5 EDACS/PV -- Dotting Sequence Tweaks; 2023-10-05 13:22:55 -04:00
lwvmobile
d882962b9c NXDN Type-C -- LO Trunked Enc Calls WIP; #121 2023-10-05 10:35:25 -04:00
lwvmobile
241cc05f80 P25 -- TG Hold Support; #132 2023-10-05 10:13:39 -04:00
lwvmobile
cdcdc106ef EDACS -- TG Hold Support; #132 2023-10-05 08:35:04 -04:00
lwvmobile
a6bb5ed28d NXDN -- TG Hold Support for Type-D; #132 2023-10-05 08:29:51 -04:00
lwvmobile
e1348b838b NXDN -- TG Hold Support for Type-C; #132 2023-10-05 08:28:24 -04:00
lwvmobile
677ad50f79 DMR -- LO Trunked Enc Calls WIP; #121 2023-10-04 14:06:52 -04:00
lwvmobile
6903d230fa DMR -- Data Call String Tweak; 2023-10-04 10:31:29 -04:00
lwvmobile
b2cc2d4c11 DMR -- Tweak P_CLEAR Return to CC Conditions; 2023-10-02 12:23:04 -04:00
lwvmobile
763d28981c P25 -- Remove old 1/2 Block Code; Misc; 2023-10-02 09:55:52 -04:00
lwvmobile
f274f74f44 P25 -- Cleanup 1/2 Rate Decoding; 2023-10-02 08:58:03 -04:00
lwvmobile
9dfbcc886f DMR -- Implement Best/Surviving Path on 3/4 Rate; 2023-10-02 08:32:34 -04:00
lwvmobile
5e0f64a7c2 Update Install Scripts with ki4hyf tweaks; 2023-10-01 17:02:13 -04:00
lwvmobile
18f24215e5 Convolutional Decoder Tweaks/Tests; 2023-09-28 11:27:18 -04:00
lwvmobile
23e1c23789 P25 -- Fix SSB vPDU/TSBK; 2023-09-26 19:21:32 -04:00
lwvmobile
a46523ee84 P25 -- Attempt to Fix vpdu.c Tab Alignment; 2023-09-26 18:20:21 -04:00
lwvmobile
dc9aa270e5 P25 -- Misc Tweaks to MFIDA4/90 MAC PDUs; 2023-09-26 18:10:34 -04:00
lwvmobile
ae528f844f P25 -- Tweak MFID A4 MAC GRG Exp Enc; 2023-09-26 17:39:52 -04:00
lwvmobile
d52c2b6426 P25 -- Add MFID90 GRG Call Grant TSBK/MPDU; 2023-09-26 16:54:17 -04:00
lwvmobile
29cd61fdcd P25 -- Fix Alignment; Fix Compiler Warning; 2023-09-26 08:54:08 -04:00
lwvmobile
daecac1612 P25 -- Check MFID 90/A4 Opcode/Payload; Tweaks; 2023-09-26 08:44:57 -04:00
lwvmobile
abbf153785 P25 -- Fix Minor Annoyance, Take 2; 2023-09-25 16:48:44 -04:00
lwvmobile
1667019662 P25 -- NAC/CC Minor Annoyance Fix; 2023-09-25 16:40:52 -04:00
lwvmobile
e2fbece993 P25p1 -- Tweak to 1/2 Rate Decoder; 2023-09-25 15:12:08 -04:00
lwvmobile
d157dee956 DMR - Tweak/Fix T3 Active Data Ch String CSBK_O; 2023-09-20 18:49:04 -04:00
lwvmobile
9506bd5f77 Fix Compiler Errors if librtlsdr not found; 2023-09-20 03:39:03 -04:00
lwvmobile
2222d86e02 P25 - SITE/RFSS Values Decimal in Console/Log; 2023-09-18 11:21:59 -04:00
lwvmobile
2161c3d762 RTL RMS Tests to Reduce CPU Usage; 2023-09-18 10:51:22 -04:00
lwvmobile
eb5de342ba DMR - Cap+/XPT Set TG on Tune for Hold Handling; 2023-09-17 02:40:42 -04:00
lwvmobile
2ca9117783 DMR - Tweak to P_CLEAR Return to CC; Tuner Status; 2023-09-17 02:17:15 -04:00
lwvmobile
b1809e9403 DMR - Add TG Hold Handling To XPT SLC; 2023-09-17 02:09:30 -04:00
lwvmobile
d1b11bc53c DMR - Add TG Hold Handling To Cap+ SLC; 2023-09-17 02:08:37 -04:00
lwvmobile
c61d2dd35d Revert DMR 34 Rate FEC Tests; 2023-09-16 22:34:59 -04:00
lwvmobile
d8958662d9 Disable Debug Output on DMR 34 Rate FEC Tests; 2023-09-16 05:33:33 -04:00
lwvmobile
801cdead80 Test FEC on P25 12 Rate Data; 2023-09-16 05:30:07 -04:00
lwvmobile
5098cdb445 Test FEC on DME 34 Rate Data; 2023-09-16 05:28:09 -04:00
lwvmobile
f229f0d648 Testing Simpler P25 1/2 Decoder and Heuristics; 2023-09-15 10:30:49 -04:00
lwvmobile
cbaed9337b Fix Compiler Error on RTL Dev Enum; 2023-09-13 13:19:05 -04:00
lwvmobile
66ff2551e9 Add RTL Device Enum and SN support to Ncurses; 2023-09-13 11:09:01 -04:00
lwvmobile
0a7e86a8fa Add RTL Device Enum and SN support to CLI; 2023-09-13 11:05:28 -04:00
lwvmobile
e3c96f2d5d Fix OSS 48k1 Slot On/Off Toggle; 2023-09-12 18:36:00 -04:00
lwvmobile
24741ed420 Update Version Number for PC Aero AW Build; 2023-09-12 18:28:17 -04:00
lwvmobile
1f6f8f194b DMR - Tweak to CSBK (BTV_GRANT) and FLC (BTV); 2023-09-12 17:14:43 -04:00
lwvmobile
102966482b DMR - Add T3 Multi Item Data Call Grants; Tweaks; 2023-09-12 16:38:36 -04:00
lwvmobile
eb7929e758 DMR T3 -- Add P_MAINT Decode; 2023-09-12 15:59:05 -04:00
lwvmobile
8bbfdf2671 Tweaks to DMR LE for mismatching key/alg; 2023-09-12 00:23:41 -04:00
lwvmobile
958400eaf6 DMR C_AHOY and Special Address Identifiers; 2023-09-11 23:28:31 -04:00
lwvmobile
20e862a6a0 Fix Line Break Issue on DMR SLC Err; 2023-09-11 09:13:39 -04:00
lwvmobile
8cbb30b036 DMR T3 Tweak to TG and SRC Values when Tuning; 2023-09-10 21:15:56 -04:00
lwvmobile
9696042156 Fix Keyring Loader to allow KeyID of 0 (P25); 2023-09-10 21:01:16 -04:00
lwvmobile
56b27dd055 Fix NXDN Ncurses Call TG:0 History Bug; 2023-09-09 20:47:48 -04:00
lwvmobile
a388e9ad85 Enable TG Hold Tests on DMR Cap+, Con+, XPT; #132 2023-09-09 20:12:40 -04:00
lwvmobile
2e93cca73a Test Trunk P_CLEAR return to CC on DMR T3; #132 2023-09-09 19:50:07 -04:00
lwvmobile
6a694444c5 Test TG Trunking Hold on DMR T3 Systems; #132; 2023-09-09 19:48:25 -04:00
lwvmobile
8227b49b59 Tweak DMR T3 Channel Numbering Information; 2023-09-08 19:41:32 -04:00
lwvmobile
dd483c3300 Init Group Mode Str; Tweak Group List Conditions; 2023-09-07 12:02:32 -04:00
lwvmobile
f217f17c52 Fix EDACS AFS Reporting on PV Console Output; 2023-09-06 19:03:44 -04:00
lwvmobile
be3f69a2d0 Raw Signal Wav File Saving; #163 2023-09-04 22:17:46 -04:00
lwvmobile
bf96b96fdf Fix Indent; 2023-09-04 19:28:33 -04:00
lwvmobile
c7537cca96 EDACS Analog Call Dotting Sequence Detection; 2023-09-04 17:20:42 -04:00
lwvmobile
14a87465ce Fix/Tweak EDACS Dotting Sequence; 2023-09-04 15:42:28 -04:00
lwvmobile
8c8df5b1b4 EDACS Dotting Sequence FS Detection and CC Jump; 2023-09-04 01:47:22 -04:00
lwvmobile
a56c736c06 ENC Audio Mute Checkdowns; Misc; 2023-08-28 09:21:28 -04:00
lwvmobile
7ff3e3e79b Disable Test Alert on Ncurses Startup for OSS; 2023-08-27 16:29:07 -04:00
lwvmobile
c5713c52da AW Version Update; 2023-08-27 14:59:26 -04:00
lwvmobile
5bea494193 Disable DMR MS/Simplex When Trunking Enabled; 2023-08-26 21:21:28 -04:00
lwvmobile
e48b715f4f DMR SB TXI Tweaks; Add CRC4 Check to LE MI; 2023-08-26 17:19:53 -04:00
lwvmobile
12ac9460b9 DMR LE Minor Code Fix; Print Tweaks; 2023-08-26 09:30:53 -04:00
lwvmobile
c8c72eadab Fix M17 IV; 2023-08-25 09:15:47 -04:00
lwvmobile
cd476bb463 Fix M17 Enc Type Values; 2023-08-25 09:11:18 -04:00
lwvmobile
53617bd366 Fix EDACS Analog Call Preemption Conditions; 2023-08-22 09:16:28 -04:00
lwvmobile
99f2606d4d UDP Audio Output -- Fix Typo; 2023-08-22 09:07:56 -04:00
lwvmobile
2aebdf79f3 UDP Audio Output -- Socket Code, Example Tweaks; 2023-08-22 09:04:47 -04:00
lwvmobile
c840544d25 UDP Audio Output -- Clarify and Add Example; 2023-08-21 17:40:28 -04:00
lwvmobile
927df66e9a Fix Warning; 2023-08-21 16:12:16 -04:00
lwvmobile
7f4443c77f UDP Audio Output -- Old Audio Handler Fix; 2023-08-21 15:54:03 -04:00
lwvmobile
1600e6c0d4 UDP Audio Output -- Audio Implementation; 2023-08-21 15:23:03 -04:00
lwvmobile
0c86ba29fc UDP Audio Output -- Initial Setup; 2023-08-21 15:20:53 -04:00
lwvmobile
b2f6b158e3 Disable RTL RMS Function on ARM Devices (RPi); 2023-08-19 20:48:34 -04:00
lwvmobile
6ab2f69111 Temp Fix for EDACS Standard/Networked; 2023-08-19 12:47:01 -04:00
lwvmobile
0097942732 DMR increase BF and block storage; R1 Pad Bit Fix; 2023-08-19 10:04:09 -04:00
lwvmobile
3686e7fdd2 DMR 3/4 Simple Error Correction; 2023-08-19 07:21:25 -04:00
lwvmobile
0e8f3362b9 P25p2 I-ISCH/DUID Error Correction; 2023-08-17 13:42:35 -04:00
lwvmobile
078142bd3f Misc; 2023-08-17 05:14:07 -04:00
lwvmobile
304817b68e Create Some Temp Files For Code Organization; 2023-08-17 04:53:35 -04:00
lwvmobile
e48c05a0ab AGF Tests/Tweaks; 2023-08-13 11:34:08 -04:00
lwvmobile
4cdcefb980 Analog Monitor Hold on SQL Break; Misc; 2023-08-13 11:30:21 -04:00
lwvmobile
dcc818e9c3 More NCurses Cosmetic Tweaks/Type Fix; 2023-08-11 20:17:40 -04:00
lwvmobile
0037064958 Ncurses Cosmetic Tweaks; 2023-08-11 20:08:08 -04:00
lwvmobile
c0ccbf73d0 More Cygwin M17 Related Bandaids; 2023-08-11 15:18:37 -04:00
lwvmobile
500d0387fd Prevent Possible Overflow in lbuf and lbuf2; 2023-08-11 15:15:47 -04:00
lwvmobile
0f077832cf Update Install Notes and Include Arch Installer; 2023-08-11 12:58:22 -04:00
lwvmobile
449468f566 Fix Some NXDN Array Sizes and Chainbacks; 2023-08-11 12:13:16 -04:00
lwvmobile
fd2444f2cd M17 Misc Cleanup; 2023-08-11 10:56:26 -04:00
lwvmobile
d6968dffdd Misc Code Cleanup; 2023-08-10 13:57:50 -04:00
lwvmobile
b50119e0bc Simplify DMR Trellis Decoder; 2023-08-10 03:43:37 -04:00
lwvmobile
58e90298eb Add M17 CAN Value to Ncurses; Misc; 2023-08-09 20:55:29 -04:00
lwvmobile
224dc1e68c Allow OSS Audio Source Monitoring when 48k1; 2023-08-09 03:58:10 -04:00
lwvmobile
e9262f18db Fix RTL Source Audio Monitoring Bug; 2023-08-09 03:37:54 -04:00
lwvmobile
14b4af8b33 WIP: Working Analog/Raw Source Audio Monitoring; 2023-08-08 22:52:32 -04:00
lwvmobile
af271f62f3 Analog RMS Compiler Warning Fix; 2023-08-08 01:12:45 -04:00
lwvmobile
6f9fba9fbf EDACS Tweaks to Analog Call Handling; 2023-08-08 00:46:20 -04:00
lwvmobile
afa329b5e4 Experimental EDACS Analog Voice Monitoring; 2023-08-07 04:55:58 -04:00
lwvmobile
d8395fff59 Fix RTL RMS so it does't return Jank Values; 2023-08-07 04:32:01 -04:00
lwvmobile
81abd65da1 Fix Some DateName Issues for dates in Aero; 2023-08-07 04:29:41 -04:00
lwvmobile
a48c197ecc Update Example_Usage for Icecast; #159 2023-08-07 04:28:49 -04:00
lwvmobile
85d53896de Update Example_Usage.md 2023-08-07 04:27:21 -04:00
lwvmobile
8b844aa6e3 Disable Float Mono Audio Decimation; 2023-08-04 23:14:00 -04:00
lwvmobile
578117d82a Add patch files to gitignore; 2023-08-04 19:11:24 -04:00
lwvmobile
363c99ceca Fix Float Baseline; Notes on P25p2 Audio; 2023-08-04 18:46:49 -04:00
lwvmobile
a93177eb61 Ncurses Terminal Minor Cleanup and Term Tweaks; 2023-08-04 17:07:40 -04:00
lwvmobile
d6181e2dcd P25 Fix Some Logic Regarding Symbol Rate Switch; 2023-08-04 17:07:18 -04:00
lwvmobile
f9b74cf7e2 More Tweaking on AGF and Float Audio; 2023-08-03 15:38:44 -04:00
lwvmobile
d4740550e4 Fix Bug w/ Manual Gain in Ncurses; 2023-08-03 10:43:57 -04:00
lwvmobile
d91c44f6f3 Doc and Ncurses Cleanup; 2023-08-02 23:03:40 -04:00
lwvmobile
e59b46448a More Work/Tweaks on AGF and Ncurses Gain Control; 2023-08-02 22:48:17 -04:00
lwvmobile
d826391d16 Ncurses and Misc Tweaks; 2023-08-02 17:17:15 -04:00
lwvmobile
5406960f26 Fix Warning and Clarify Short/Float Manual Gain; 2023-08-02 16:42:13 -04:00
lwvmobile
8f1d1e4934 Tweaks to AGF function; Misc; 2023-08-02 14:35:10 -04:00
lwvmobile
54b6fd67e7 Change Defaults; Reorder Ncurses Menu; Fix X2; 2023-08-01 16:03:38 -04:00
lwvmobile
1568ee6176 Random Alignment Fixes; 2023-07-31 20:01:11 -04:00
lwvmobile
6978ac9cd3 DSTAR Fix CRC on Slow Data Header; Cleanup; 2023-07-31 19:50:12 -04:00
lwvmobile
1961eb832a DSTAR Slow Data Decoding WIP; 2023-07-31 16:50:25 -04:00
lwvmobile
c38423c251 DMR Stereo Tweak; Clear Stale Audio Buffers; 2023-07-30 13:41:25 -04:00
lwvmobile
ecd3ec1c61 Fix VoiceFS4 Slot On/Off Issue; 2023-07-29 22:02:03 -04:00
lwvmobile
66e8bcd86a Audio Mono Audio to Stereo Channel Tweaks; 2023-07-29 21:48:28 -04:00
lwvmobile
23b1036c6b Rewrite and Simplify DSTAR Handling; 2023-07-29 21:46:11 -04:00
lwvmobile
0d4ab17d0a Reorganize MBE handling -- initial commit; 2023-07-29 21:43:53 -04:00
lwvmobile
b38a692fc5 Rewrite Call Alert; Switch to Generated Tone; 2023-07-29 21:16:02 -04:00
lwvmobile
2ff96a6b91 Version Update; 2023-07-29 00:16:38 -04:00
lwvmobile
9089d6568a Cleanup; 2023-07-29 00:14:33 -04:00
lwvmobile
73c43b030e Rename XDMA to AUTO; Disable Legacy Auto; 2023-07-29 00:02:17 -04:00
lwvmobile
42fa737844 Configure OSS Output to be more Dynamic; 2023-07-28 23:32:17 -04:00
lwvmobile
e4f61115c6 M17 Cleanup and M17/Aero Jank Fixes; 2023-07-28 23:22:13 -04:00
lwvmobile
3bb9994589 Tweak Toggle Voice Synthesis for FDMA Sources; 2023-07-28 20:53:56 -04:00
lwvmobile
23f6c75257 Ncurses Tweak for TDMA Slot ON/OFF; 2023-07-28 19:26:53 -04:00
lwvmobile
3bac7ba99b Round of Code Cleanup; 2023-07-28 17:47:33 -04:00
lwvmobile
56a5df86a0 Fix Some Slot Preference Clashes; 2023-07-28 17:25:16 -04:00
lwvmobile
50d707a8e3 Rewrite OSS Handling (depending on use case); 2023-07-28 16:06:58 -04:00
lwvmobile
aa49e5869b User Enable/Disable Slots for Voice; 2023-07-28 15:56:06 -04:00
lwvmobile
d982a2b91e Temp Commit WIP; 2023-07-26 15:53:55 -04:00
lwvmobile
a92736bb3a Fix dPMR, pV, and MBEplayback for new audio; 2023-07-26 15:06:33 -04:00
lwvmobile
54386285cc Tweaks to DMR MS Audio Handling; 2023-07-26 15:04:02 -04:00
lwvmobile
676027a56f Tweak Float Auto Gain; Make User Configurable; 2023-07-26 07:21:25 -04:00
lwvmobile
cdc0d9e012 Tweak Install Notes; 2023-07-25 18:54:13 -04:00
lwvmobile
32d4c0ed72 AGF by Left/Right Channel/Slot; 2023-07-25 13:10:19 -04:00
lwvmobile
16959cac7a WIP: audio_work 2; 2023-07-24 18:32:09 -04:00
lwvmobile
f2f20f8f94 Fix P25p2 SACCH PDU Issue; 2023-07-22 18:34:54 -04:00
lwvmobile
1a8efd5835 YSF Decoded Wav File Saving on V/D2 Voice; 2023-07-20 10:12:17 -04:00
lwvmobile
5a01c7a4db Version; 2023-07-20 00:32:54 -04:00
lwvmobile
1b18139e41 Custom User Wav File with -7 option; 2023-07-20 00:32:44 -04:00
lwvmobile
263b3bbeda Fix Some Tab Alignment in dsd_main.c; 2023-07-13 13:59:21 -04:00
lwvmobile
cba01aaa59 Add Exitflag to DMR BS Loop; Update Readme; 2023-07-13 13:57:55 -04:00
lwvmobile
d4599b05a0 Appease Volo - God of Compiler Warnings; 2023-07-10 20:09:42 -04:00
lwvmobile
200287316d Fix Random Warnings on #152 2023-07-10 19:25:14 -04:00
lwvmobile
1d05f3d851 M17 More Work and Fixes; #152 2023-07-10 19:25:06 -04:00
lwvmobile
8e8d987686 NXDN LZ Tweak on RCCH Disc; #123 2023-07-10 19:24:54 -04:00
lwvmobile
343512e9bf Fix OSS Input/Output on M17 8K Sample; #152 2023-07-09 00:13:12 -04:00
lwvmobile
af612c058b M17 Dbuf Temp Bug Fix; Misc; #152 2023-07-09 00:13:01 -04:00
lwvmobile
d81e8be3cf Fix Cmake for Codec2 in Cygwin; #152 2023-07-09 00:12:49 -04:00
lwvmobile
fb93289538 Fix M17 3200bps Voice; Misc M17 Tweaks; #152 2023-07-07 02:17:50 -04:00
lwvmobile
92a2217e80 M17 Support (Partially Working Now); 2023-07-06 21:58:24 -04:00
lwvmobile
b6d41260e7 M17 Initial Support (Non-Working State); 2023-07-06 21:55:13 -04:00
lwvmobile
bb6b54990f Ncurses NXDN RAN/History Lazy Bug Fix; 2023-07-05 16:24:39 -04:00
lwvmobile
016d27e22d Minor Ncurses Fixes; 2023-07-05 14:38:06 -04:00
lwvmobile
17a336e27d Misc Minor Fixes; 2023-07-05 14:33:43 -04:00
lwvmobile
c3f3573a99 Merge pull request #151 from volo-zyko/fix-emptyBodyAndPointerSignWarnings
Fix warnings from -Wempty-body, -Wunused-label, and -Wpointer-sign
2023-07-05 13:58:44 -04:00
Volo Zyko
81dab2f0b6 Fix warnings from -Wempty-body, -Wunused-label, and -Wpointer-sign 2023-07-04 12:07:30 +03:00
lwvmobile
a80e534179 DMR LE ENC Identifiers Tweak; 2023-07-03 12:41:55 -04:00
lwvmobile
8310f87504 Merge pull request #150 from volo-zyko/fix-unusedParameterWarnings
Fix more warnings, now with unused parameters
2023-07-03 12:25:28 -04:00
lwvmobile
f27057c790 Merge pull request #148 from volo-zyko/ZDev3
Set exitflag before cleaning up
2023-07-03 12:25:17 -04:00
Volo Zyko
649d267fa5 Fix more warnings, now with unused parameters 2023-07-03 15:37:43 +03:00
Volo Zyko
d8a7e5d366 Set exitflag before cleaning up
This will signal to all related code that the program
is about to exit.
2023-07-03 11:03:51 +03:00
lwvmobile
8ccc241743 Fix Compiler error: parameter name omitted; 2023-07-02 15:42:32 -04:00
lwvmobile
af922d209d Fix ysf.c Unused Variables Warnings; 2023-07-01 22:59:32 -04:00
lwvmobile
958d0debbb Fix Trellis.c Unused Variables Warnings; 2023-07-01 22:59:13 -04:00
lwvmobile
2016891bd5 Fix NXDN de-scrambling bug; 2023-07-01 22:21:20 -04:00
lwvmobile
412cb26c0f Fix Ncurses Exitflag; 2023-07-01 22:06:49 -04:00
lwvmobile
3fc983f273 Add YSF to default decoding class; #143 2023-07-01 18:51:00 -04:00
lwvmobile
b5d24f9c00 Merge pull request #147 from volo-zyko/fix-unusedVariableWarning
Fix warnings related to unused variables
2023-07-01 13:27:49 -04:00
Volo Zyko
a432173cd6 Fix warnings related to unused variables 2023-07-01 13:48:38 +03:00
lwvmobile
5440161ff9 YSF Fix CM Variable; Line Break; #146 2023-06-30 18:43:32 -04:00
lwvmobile
bb542c475c YSF Radio ID Mode; Element Tweaks; #143 2023-06-30 16:48:43 -04:00
lwvmobile
aef834e914 Fix Line #137 2023-06-30 11:00:23 -04:00
lwvmobile
fd44120874 Merge pull request #145 from volo-zyko/fix-cleanupAndExit
Add signal handlers for a proper cleanup
2023-06-30 10:53:14 -04:00
Volo Zyko
0e9b2b245d Add signal handlers for a proper cleanup
Fix locking problem in get_rtlsdr_sample when it waits indefinitely
even when exitflag is non-zero; cleanup the code.
2023-06-30 14:12:48 +03:00
lwvmobile
eacbd21c50 Refine/Fix YSF FICH Element Decode #143 2023-06-30 01:15:05 -04:00
lwvmobile
deca8e74a8 Fix YSF Full Rate Voice #143 2023-06-29 22:55:22 -04:00
lwvmobile
9eefbb26d8 Fix Code Tab Alignment #143 2023-06-29 18:16:48 -04:00
lwvmobile
b637462ee8 WIP: YSF Decoding; #143 2023-06-29 18:07:43 -04:00
lwvmobile
7fc513e09e Symbolbin Display Fix in Ncurses; #138 2023-06-29 16:01:18 -04:00
lwvmobile
802e1c96bd Merge pull request #142 from volo-zyko/cleanup-symbolOutFileAPI
Cleanup symbol out file api
2023-06-29 15:45:04 -04:00
Volo Zyko
0bc75f6f78 Cleanup code related to symbol out (logic did not change) 2023-06-29 18:51:58 +03:00
lwvmobile
32a3ba535b Merge pull request #141 from lwvmobile/main
upstream
2023-06-29 10:37:22 -04:00
lwvmobile
2e898d997b Merge pull request #139 from volo-zyko/main
Fix potential issues in closeSymbolOutFile
2023-06-29 09:45:51 -04:00
Volo Zyko
817b335349 Fix potential issues in closeSymbolOutFile 2023-06-29 16:21:39 +03:00
lwvmobile
e9d551f4cb Fix Exitflag Variable #136 2023-06-28 16:54:59 -04:00
lwvmobile
33933e914e DMR LE/CAP+/Misc Tweaks; 2023-06-28 16:53:36 -04:00
lwvmobile
8e230a08b5 Misc; 2023-06-20 04:15:51 -04:00
lwvmobile
dfc4f6f304 TXI FLC and Misc; 2023-06-19 10:01:22 -04:00
lwvmobile
5a3061f942 Merge pull request #134 from lwvmobile/zDEV
Zdev Updates
2023-06-19 06:42:26 -04:00
lwvmobile
b40281fda3 Renable DMR Late Entry SB; Misc; 2023-06-19 06:40:21 -04:00
lwvmobile
966fbf8c6a Fix Alignment 3; 2023-06-18 20:15:12 -04:00
lwvmobile
ca65f1b209 Fix Alignment 2; 2023-06-18 20:12:37 -04:00
lwvmobile
a5d73f06d2 DMR - SB TXI Information and ENC Identifiers Fix; 2023-06-18 19:54:18 -04:00
lwvmobile
56b0e8440e Initialize/Zero Some Arrays; 2023-06-17 17:32:59 -04:00
lwvmobile
b6a12b6ceb Fix RC4 'Pop' on DMR when VC6 is Null; Fix Align; 2023-06-17 17:29:03 -04:00
lwvmobile
15a12acfd3 Update Cmake for zDEV; 2023-06-15 17:47:58 -04:00
lwvmobile
c534e0f1fe Merge pull request #133 from lwvmobile/zDEV
Updates;
2023-06-15 17:39:51 -04:00
lwvmobile
5e68580fa6 DMR - Minor Cosmetic Tweaks; 2023-06-15 17:35:42 -04:00
lwvmobile
e6d83e7305 Fix CMake Options error; Update Readme; 2023-06-15 17:29:33 -04:00
lwvmobile
d56cf106b4 DMR Late Entry ENC Fix; Switch to User Option; 2023-06-12 12:38:32 -04:00
lwvmobile
4279ccf292 DMR Anytone RC4 Fix; 2023-06-12 12:35:32 -04:00
lwvmobile
846b202192 Fix P25p1 -f1 Unmute on RC4 Key; Misc; 2023-06-11 19:43:49 -04:00
lwvmobile
330ebe2bf3 Fix Aero OSS Slot Preemption Issues; #127 2023-06-11 03:09:32 -04:00
lwvmobile
79b4a5e720 Fix DMR LE Alg/Key on SB; 2023-06-11 02:22:41 -04:00
lwvmobile
8186b62a91 RC4 Support (DMR, P25p1, P25p2); 2023-06-11 00:11:55 -04:00
lwvmobile
20f0c852aa NXDN Frame Print Tweaks; #123 2023-06-07 18:27:41 -04:00
lwvmobile
9e4ae23c0b Lit Fix and Tones Fix; #127 2023-06-06 20:32:09 -04:00
lwvmobile
585f6f2fa5 Staging for Main Branch #127 Lit Update; 2023-06-06 20:15:34 -04:00
lwvmobile
a4fba3b19c More Codeset Consolidation #127 Location of tones; 2023-06-06 19:53:30 -04:00
lwvmobile
a2180eb5d3 Switch to New NXDN FS (again) #123 2023-06-06 19:01:37 -04:00
lwvmobile
514161fefa NXDN Frame Tweaks; Late Nite FS Testing III; #123 2023-06-05 23:23:32 -04:00
lwvmobile
bba059f35f Late Nite FS Testing II; #123 2023-06-05 03:29:06 -04:00
lwvmobile
5977f865e3 Remove Min/Max Test (mixed results); #123 2023-06-05 02:43:37 -04:00
lwvmobile
ade7c0477f Late Nite FS Testing; #123 2023-06-05 02:17:38 -04:00
lwvmobile
a2fded8340 Revert Change to new NXDN FS; #123 2023-06-04 20:41:16 -04:00
lwvmobile
005e15c45f cmake remove 'zdev' #127 2023-06-04 18:56:41 -04:00
lwvmobile
e9962a8923 NXDN Switch to New FS; Payload Tweaks; #123 2023-06-04 18:45:05 -04:00
lwvmobile
c6611eae9c Update Some Documentation; 2023-06-03 03:55:43 -04:00
lwvmobile
261193959c Restore Documentation and Examples; 2023-06-02 19:21:25 -04:00
lwvmobile
e7a71eabb6 Minor Fix to Call String; 2023-06-02 16:42:38 -04:00
lwvmobile
afba84e584 Cap+ Call String Blink Fix; Minor Tweaks; #125 2023-05-30 14:52:44 -04:00
lwvmobile
96faff7711 RTL Verbosity Tweaks and Thread Safety; #125 2023-05-24 09:17:50 -04:00
lwvmobile
94166b493c Misc; #123 #125; 2023-05-23 06:21:58 -04:00
lwvmobile
6a0b1b2dcf RTL/NCURSES - Clear Queue and Dibit Buffer; #125 2023-05-21 20:19:56 -04:00
lwvmobile
5c8e3d95a7 Ncurses Tweaks; Revert RTL BW changes; #125 2023-05-21 13:39:49 -04:00
lwvmobile
4c91588af6 Re-enable P1 Heuristics On TCH and Non CS modes; 2023-05-21 09:14:02 -04:00
lwvmobile
35c05654a5 Fix NXDN/Scanner Bug; 2023-05-19 19:03:20 -04:00
lwvmobile
fbc9b5fab8 Reverting a few minor RTL tweaks; #125 2023-05-19 18:10:12 -04:00
lwvmobile
1126ab6578 P25 - Allow P2 6000sps on C4FM and QPSK; 2023-05-19 17:39:39 -04:00
lwvmobile
0842613b24 RTL - RMS based soft squelch and tweaks; #125 2023-05-19 11:27:13 -04:00
lwvmobile
bf4a4b574c RTL Misc; Disable Offset and Double BW; #125 2023-05-19 06:42:55 -04:00
lwvmobile
380657679e More LZ Tweaks; #123 2023-05-18 18:55:14 -04:00
lwvmobile
0a214af29b RTL ifdef tag additions; #125 2023-05-18 18:47:16 -04:00
lwvmobile
b008122149 More RTL Tweaks; #125 2023-05-18 10:22:05 -04:00
lwvmobile
7b6feb9e4f Attempt Fix/Clean on RTL input code; #125 2023-05-18 09:29:44 -04:00
lwvmobile
e4861bf94c Fix Idas Trunking Issue; #115 2023-05-17 16:23:22 -04:00
lwvmobile
587a3f01a2 Lima Zulu Tweaks III; #123 2023-05-17 07:37:28 -04:00
lwvmobile
8d5c82356e Initial Main/Aero Code Consolidation; #127 2023-05-15 15:06:34 -04:00
lwvmobile
df039ab1c1 Denny's Cap+ 0x90 Data Flag; #116 2023-05-15 12:14:50 -04:00
lwvmobile
f5e3c6eddd DMR Cap+ Block Counter Fix; #126 2023-05-15 03:00:21 -04:00
lwvmobile
fc01712132 Tweaks to NXDN FSW Tests II; #123 2023-05-14 13:59:29 -04:00
lwvmobile
7ec0bf83b4 Ncurses No Color Trunking Tweaks; #114 2023-05-13 20:11:39 -04:00
lwvmobile
504476c5db Misc Tweaks and Clear Stale Active Ch Values; #120 2023-05-13 01:39:16 -04:00
lwvmobile
f78dbd57bc Fix LimaZulu NXDN Tweaks #123 2023-05-12 02:44:18 -04:00
lwvmobile
d2b27fdf25 Tweaks to NXDN FSW Tests; #123 2023-05-05 18:32:06 -04:00
lwvmobile
3aa20f82b9 pV Conventional Frame Sync and pV Tweaks; #122 2023-05-05 06:34:42 -04:00
lwvmobile
402b2f0264 NXDN Frame Sync Tests and Cmake Option #123 2023-05-05 06:15:03 -04:00
lwvmobile
4dd2328e10 Various uint64_t/ul/ulli fixes for 32-bit; 2023-05-04 23:58:47 -04:00
lwvmobile
98bcdd203e Misc Tweaks and Fixes; 2023-05-03 23:45:04 -04:00
lwvmobile
741ed51d08 NCURSES Active Ch Display Tweaks; #120 2023-05-02 18:34:33 -04:00
lwvmobile
5d8e07228e DMR Active Channel Display; CSBK Tweaks; #120 2023-05-02 18:32:01 -04:00
lwvmobile
4a43a48b2e P25 ENC Trunk Toggle and Active Tweaks; #120 #121 2023-05-02 18:25:28 -04:00
lwvmobile
0ef3b4ab4b Active Channel Display NXDN Setup and Misc; #120 2023-05-02 18:20:51 -04:00
lwvmobile
00e0f00974 NXDN Tweaks to clear stale key values on keyload; 2023-04-29 17:02:55 -04:00
lwvmobile
91181f9e93 TCP Audio Retry on Disc; Ncurses Key '8'; #119 2023-04-29 16:06:41 -04:00
lwvmobile
5c42c50a40 Version Naming Update; 2023-04-25 17:18:35 -04:00
lwvmobile
36399386c5 More NXDN/IDAS Tweaks and Fixes; #115 and #118 2023-04-25 16:00:16 -04:00
lwvmobile
8eee4cd699 NXDN Type-D Decoding/Trunking; NXDN Tweaks; #115 2023-04-23 19:52:36 -04:00
lwvmobile
1410e8bd81 Cap Plus Expansion; Minor DMR Tweaks; #116 2023-04-23 19:50:06 -04:00
lwvmobile
915375fb1c Initial NXDN Type D - 'IDAS' Support; #115 2023-04-13 18:20:58 -04:00
lwvmobile
52fff28dc4 NXDN Array Expansion and Message Tweaks; #113 2023-04-13 11:00:37 -04:00
lwvmobile
bd035622b8 No Color Cmake Build Option #114 2023-04-13 11:00:00 -04:00
lwvmobile
44163710f9 More XPT Work; #110 2023-04-12 18:12:10 -04:00
lwvmobile
44b1ccdeae Hashed DMR TG Multi Key Loading Fix; #112 2023-04-12 13:10:13 -04:00
lwvmobile
34113cb782 housekeeping; 2023-04-09 14:30:05 -04:00
lwvmobile
2a336a9275 Hytera XPT WIP #110 2023-04-08 19:15:33 -04:00
lwvmobile
5c08a9193c Yet Another Cmake Warning Fix #107 2023-03-28 23:33:20 -04:00
lwvmobile
2cae7f9c18 NXDN -- DFA Base Freq Fix; ADJ_SITE_INFO; #106 2023-03-28 17:30:02 -04:00
lwvmobile
e056c97d9d Issue #105 - Make Work with Named Pipe (FIFO) 2023-03-22 20:07:02 -04:00
lwvmobile
dc49e0d08b NXDN DFA Support; 2023-03-22 20:00:41 -04:00
lwvmobile
b639f6af28 Fix Cmake Warnings; 2023-03-21 22:42:09 -04:00
lwvmobile
6b45c4ba9b Issue #105 Segfault Bugfix; 2023-03-21 21:09:45 -04:00
lwvmobile
2062502a59 P2 - TDMA-CC Tuning Bugfix and callstring tweak; 2023-03-21 20:58:44 -04:00
lwvmobile
a490d9ead2 Merge pull request #104 from lwvmobile/lite
NXDN48/96 Tweak;
2023-03-12 15:55:12 -04:00
lwvmobile
c73832ac2c NXDN48/96 Tweak; 2023-03-12 15:42:49 -04:00
lwvmobile
fe1fa79f70 More XPT Tweaks and Notes; 2023-03-09 19:12:57 -05:00
lwvmobile
f2f29f2287 Line Space OCD; 2023-03-09 18:40:36 -05:00
lwvmobile
3181e58b19 Lite to Aero Rebrand; 2023-03-08 02:25:51 -05:00
lwvmobile
6204aec2a5 P25 P1 LCW re-write and updates; 2023-03-08 02:25:29 -05:00
lwvmobile
267180ed0e NCurses LO Return to CC; 2023-03-08 02:04:56 -05:00
lwvmobile
8d9cbb3720 XPT Trunking Tweak; 2023-03-08 02:04:09 -05:00
lwvmobile
8af6d2e185 P25 P1 QPSK MSIZE/SSIZE Tweak; 2023-03-08 02:03:01 -05:00
lwvmobile
abeb92ff8a Fix trunk_hangtime lf to f; Ncurses Fixes; 2023-03-06 03:07:27 -05:00
lwvmobile
be47075611 Fix Fast Scanner and NCurses Display (again) 2023-03-05 05:54:23 -05:00
lwvmobile
1640b58ae4 Fix unintended bug in iden_up_vu; 2023-03-04 20:54:52 -05:00
lwvmobile
7a34d531b1 Literature Update 2023-03-04 19:28:58 -05:00
lwvmobile
0af814c72f P25 TSBK PDU Fix; vPDU PDU Fixes; Scanner Freq Fix 2023-03-04 19:26:44 -05:00
lwvmobile
1477190dea Fast Scan Ncurses Tweak; Update Literature; 2023-03-03 15:38:39 -05:00
lwvmobile
b0cd1881bb P25 - P1 MBF Format Addition; TSBK/vPDU Tweaks; 2023-03-03 15:15:42 -05:00
lwvmobile
44ad75ec17 NXDN Trunking Tweaks and Misc Tweaks; 2023-03-02 22:13:49 -05:00
lwvmobile
1ce487dc13 Trunking -- Faster CC Hunt; 2023-03-01 18:32:29 -05:00
lwvmobile
ed9a96fdc8 Experimental -- Fast Scanner Feature; 2023-03-01 17:56:10 -05:00
lwvmobile
c677efda49 P25 - Remove Test Code; NXDN - Remove Freq Calc; 2023-03-01 17:49:52 -05:00
lwvmobile
fea4f97b89 DMR - XPT Tweaks; Data Header Tweaks; 2023-02-25 16:08:55 -05:00
lwvmobile
f2e3834e0a FID 0x10 - FLCO 0x14, 0x15, 0x16, 0x17, 0x18; 2023-02-24 20:51:47 -05:00
lwvmobile
b8b62ef69a Disable remaining setmod_bw as safety precaution; 2023-02-24 20:46:33 -05:00
lwvmobile
4a8a4a088a NXDN Trunking Tweak - Snap Back to CC on Disc; 2023-02-24 18:41:02 -05:00
lwvmobile
9308c5b251 Fix P_Protect CSBK GI indicator; 2023-02-24 18:39:56 -05:00
lwvmobile
cdfe9435d3 Fix NCurses **tera key display when loaded; 2023-02-24 18:39:01 -05:00
lwvmobile
f6cd915f4d Misc Tweaks; Multi BP; More CapMax FLCO; XPT; 2023-02-23 21:59:08 -05:00
lwvmobile
1dfd59801e Literature Update; 2023-02-22 20:00:24 -05:00
lwvmobile
c4513fab7a NXDN Tweaks and SACCH/FACCH CRC Fixes; 2023-02-22 19:46:06 -05:00
lwvmobile
a3b8839897 Minor Cap+ and XPT Fix; 2023-02-21 13:55:15 -05:00
lwvmobile
9e009867ff Disable/Tweak some setmod_bw defaults; 2023-02-20 17:59:53 -05:00
lwvmobile
e95e2218d9 Cap+ NL; Hytera XPT Trunk Support (experimental) 2023-02-20 12:47:30 -05:00
lwvmobile
a9742043b8 General DMR Tweaks; 64-bit IV from 32-bit MI; 2023-02-20 12:43:16 -05:00
lwvmobile
05eef039c9 DMR - LRRP tweaks; Add LOCN PDU. 2023-02-20 12:41:20 -05:00
lwvmobile
818e952b7b DMR - dheader rewrite; UDT/USBD fix; block tweaks; 2023-02-20 12:40:42 -05:00
lwvmobile
38b962aacf P25 Dibit, Block and PDU Payload Tweaks; 2023-02-20 12:35:44 -05:00
lwvmobile
0217202801 DMR - Fix Cap+ CSBK; Various Minor Fixes; 2023-02-05 16:47:58 -05:00
lwvmobile
ef07b48540 DMR Minor Code Fixes; 2023-02-04 20:10:38 -05:00
lwvmobile
db67a8b227 NCurses Compiler Warning and Call Alert Fix; 2023-02-04 04:35:06 -05:00
lwvmobile
4e2c4577d5 DMR Cap+ CSBK Improvements; 2023-02-03 22:15:13 -05:00
lwvmobile
e581c96560 DMR FLCO Tweaks; P25 Site/RFSS Display; 2023-02-02 20:03:52 -05:00
lwvmobile
f3505269d0 DMR Conf Data CRC9; Message CRC32; Tweaks; 2023-02-01 05:35:21 -05:00
lwvmobile
20ccdbbced DMR FLC Tweaks; CSBK Cleaning; 2023-02-01 05:31:40 -05:00
lwvmobile
fc2fb99502 P25P2 OSS Bugfix; 2023-01-29 18:41:03 -05:00
lwvmobile
143c560958 DMR FLCO - Check PF First; 2023-01-29 16:09:47 -05:00
lwvmobile
d122d7e935 DMR Unknown FLCO Tweaks; PI Tweaks; 2023-01-28 21:00:13 -05:00
lwvmobile
d0f9bb4bad Fix DMR FEC/CRC/RAS Implementation Issues; 2023-01-21 05:43:42 -05:00
lwvmobile
ac752029bd Tweak RAS/CRC; Other Misc Tweaks; 2023-01-19 09:42:42 -05:00
lwvmobile
5b994f5129 NXDN Multi-Key CSV Import; Example Updt; 2023-01-18 12:18:56 -05:00
lwvmobile
ec7d7c24a5 DMR SB/RC Additions; Cap+ LC/CSBK; RAS; 2023-01-17 23:58:52 -05:00
lwvmobile
1d49481f2d Fix/Restore MBEout Files; 'DSP' CACH; Tweaks; 2023-01-17 02:25:53 -05:00
lwvmobile
7ca8cb421c Cap+ FLC/CSBK Tweaks; 2023-01-17 02:08:25 -05:00
lwvmobile
4eb44b3c67 'DSP' File Output for OKDMR - Initial Commit; 2023-01-15 22:04:04 -05:00
lwvmobile
e16e4b61fc Cap+ Things; 2023-01-15 21:22:28 -05:00
lwvmobile
fbd04fa869 Allow Standard BP Key on MBE File Playback; 2023-01-15 18:13:48 -05:00
lwvmobile
7f9b852f36 Fix Audio Gain/Device Out on MBE File Playback; 2023-01-15 18:12:15 -05:00
lwvmobile
f5a7ab2b77 P25 P2 ISCH Var Fix; 2023-01-15 18:09:47 -05:00
lwvmobile
ffe6098fb8 DMR Cap+ Rest Channel FLCO/SLCO Fix; 2023-01-09 19:39:05 -05:00
lwvmobile
157ca8c043 RTL Input Tuning Fix (UDP); Minor Tweaks; 2023-01-09 14:13:00 -05:00
lwvmobile
b722e43a3a dPMR Scrambler Key Support; 2023-01-07 18:41:44 -05:00
lwvmobile
2ba9953d33 'Lite' Optimizations and Tweaks for Win32CYG Build 2023-01-05 18:38:12 -05:00
lwvmobile
bb2199ee84 Con+ CSBK and Tuning Fixes; Group Call Options; 2023-01-02 08:04:22 -05:00
lwvmobile
4efec4e4ef Capacity Plus 'Things'; CSBK PF Check; 2022-12-30 07:22:30 -05:00
lwvmobile
12cf9aa80f Ncurses Call Toggle; T3 Call Safeguard; Lit Updt; 2022-12-29 10:06:15 -05:00
lwvmobile
e5a42dbb11 Literature Update; Minor Tweaks; CSBK update; 2022-12-28 08:43:00 -05:00
lwvmobile
67eaeadc03 Update Readme; 2022-12-27 11:27:03 -05:00
lwvmobile
acb5c16c30 Update README.md 2022-12-27 10:25:40 -05:00
lwvmobile
d16e775e46 Update README.md 2022-12-27 09:23:57 -05:00
lwvmobile
11d4c8c49c More Staging; 2022-12-27 09:18:07 -05:00
lwvmobile
1477880720 Staging for Promotion to Master Branch; 2022-12-27 08:32:34 -05:00
lwvmobile
9290098081 TCP/RIG Err Handling; Ncurses Menu Entries; 2022-12-27 07:04:49 -05:00
lwvmobile
eeb6924369 Default Smoothing Off; Upsample 8k Audio to 48k; 2022-12-26 09:37:37 -05:00
lwvmobile
c02d7c0ba0 DMR Trunking VC/CC Sync Time Tweaks; 2022-12-26 08:44:13 -05:00
lwvmobile
324191d79f Disable Audio Smoothing TCP/RTL; Make User Toggle; 2022-12-23 18:27:13 -05:00
lwvmobile
e613b85829 Lockout TG Audio Playback and Keyboard Shortcuts; 2022-12-21 22:02:13 -05:00
lwvmobile
49f81da4df Trunking White List, Private and Data Calls; 2022-12-21 21:20:57 -05:00
lwvmobile
826c99d563 Minor CSBK/CC Freq Tweak; Literature Tweak; 2022-12-20 21:15:37 -05:00
lwvmobile
2441664b19 RIGCTL hostname to mirror TCP Audio Link Hostname; 2022-12-19 18:24:37 -05:00
lwvmobile
5c733c0660 Remus Ncurses Call String Stuff; 2022-12-19 05:30:48 -05:00
lwvmobile
73824084ad Overcook DMRLA and T3 Site ID Things; 2022-12-19 04:59:00 -05:00
lwvmobile
209d4e039e DMR Con+ Site Id Bugfix/Revert; 2022-12-18 23:23:23 -05:00
lwvmobile
fa4e84bc77 DMR LRRP and T3 Site Id Work; 2022-12-18 21:52:59 -05:00
lwvmobile
4946897914 Minor DMR Trunk/Site Tweaks; Update Readme w demo; 2022-12-17 23:39:45 -05:00
lwvmobile
57e3f518dd DMR T3 DX Calls; RTL Input Frequency Check; 2022-12-15 19:22:54 -05:00
lwvmobile
08a548339c LRRP and Caputre Bin CLI Switches L and c; 2022-12-15 03:09:27 -05:00
lwvmobile
36c337ede8 Update Readme and Example Files; 2022-12-15 01:41:43 -05:00
lwvmobile
f6bb325dac DMR RTL Trunking Code Fix; 2022-12-14 18:06:50 -05:00
lwvmobile
626869992e DMR Con+ VC Sync Time Fix; SetMod_BW Fix; 2022-12-14 17:12:21 -05:00
lwvmobile
5422b337bb RTL work; Reassign CLI Switches; Fix CTRL+C; 2022-12-14 16:21:30 -05:00
lwvmobile
b6f270be05 NXDN Check for CC Freq Tweak; 2022-12-14 13:09:26 -05:00
lwvmobile
3ea813ebbc DMR Trunking VC Hangtime Tweaks; TG Block Tweak; 2022-12-14 00:04:36 -05:00
lwvmobile
53980c98ed DMR Con+ VC Hangtime Tweaks; 2022-12-13 20:20:28 -05:00
lwvmobile
536372d877 Set CC Frequency from RIGCTL if not specified; 2022-12-12 21:30:18 -05:00
lwvmobile
896f3a8533 User Configurable TCP Audio and SetMod BW; 2022-12-12 08:32:41 -05:00
lwvmobile
68bbea64d5 P25 Yellow PDUs; 2022-12-12 08:31:54 -05:00
lwvmobile
711a4cb871 More DMR Trunking Tweaks; MFID tweaks; 2022-12-11 16:33:25 -05:00
lwvmobile
8fd1d8fe35 DMR T3 Tweak; DMR Voice Tweak; Ncurses Reset Fix; 2022-12-10 20:35:14 -05:00
lwvmobile
23c396cbe8 DMR Cap+ Trunking RC Increment Reversion; 2022-12-09 23:41:10 -05:00
lwvmobile
e91c21fadb Fix Hangtime/CC Return Bug; 2022-12-09 22:39:37 -05:00
lwvmobile
15a8f80344 Assign Chan Map Import to LCN Freq for CC Hunting; 2022-12-09 18:23:20 -05:00
lwvmobile
5130899a67 DMR Con+ and Cap+ Trunking Fixes; 2022-12-09 18:03:53 -05:00
lwvmobile
f5ac9ff0b2 LRRP Temp Disable Most Reporting Types; 2022-12-09 18:02:15 -05:00
lwvmobile
14dd045312 Remus; 2022-12-09 08:36:42 -05:00
lwvmobile
fbb00f78fe Roman NCurses EGPS/LRRP/Data Display Fix; 2022-12-08 12:35:34 -05:00
lwvmobile
a5d23d9e12 MBC Header and Blocks CRC; 2022-12-07 22:58:57 -05:00
lwvmobile
a2b3da5b5a NCurses LRRP Tweak and Roman Data Header Stuff; 2022-12-07 18:00:09 -05:00
lwvmobile
a9417afd67 DMR EGPS, LRRP, Data Block Tweaks; 2022-12-07 04:26:11 -05:00
lwvmobile
438f89bf4c Add Date to Per Call Time Stamp; 2022-12-07 02:06:26 -05:00
lwvmobile
2f2eecddfc Various Trunking Tweaks; 2022-12-06 08:47:46 -05:00
lwvmobile
2fceee5a2f Reverse Mute 2022-12-04 19:15:33 -05:00
lwvmobile
62c70cbf92 Update Readme and Images; 2022-12-04 18:40:49 -05:00
lwvmobile
b97014ff0b DMR Cap+ Trunk Logic 2022-12-04 17:10:19 -05:00
lwvmobile
68edb9463c DMR NCurses Tweaks and Additions; E-GPS; 2022-12-04 14:35:26 -05:00
lwvmobile
178f88a28f DMR Reorganization; Initial Trunking Support; 2022-12-03 20:16:43 -05:00
lwvmobile
f7d103c6a2 NXDN Sync Type Tweak; 2022-12-03 17:08:01 -05:00
lwvmobile
10d10063f0 Additional Trunking Checkdown; 2022-12-02 18:45:25 -05:00
lwvmobile
dba3b79266 Disable Debug Frame Sync Prints; 2022-11-28 15:20:44 -05:00
lwvmobile
0441b8fdbd Hangtime Safety Parenthesis 2022-11-28 09:23:56 -05:00
lwvmobile
ea399e50a8 NXDN Preamble + FSW Sync; 2022-11-24 18:43:51 -05:00
lwvmobile
66f710e877 Channel to Frequency Map CSV Importer; 2022-11-23 09:08:32 -05:00
lwvmobile
0f227e40c3 Remove Unused OP25 NXDN Trellis Decoder; 2022-11-23 08:59:56 -05:00
lwvmobile
136ed75342 NCurses Display Group Labels in P25 and DMR; Tweak 2022-11-20 07:31:02 -05:00
lwvmobile
61cefa6a87 Trunking Hangtime and Tweaks; NXDN F2U Tweak; 2022-11-19 19:43:48 -05:00
lwvmobile
cc7504c280 Route /dev/dsp and pa input/output to pulse; 2022-11-18 11:06:42 -05:00
lwvmobile
07139b3d7d P25p2 QPSK Optimization Tweaks; 2022-11-18 09:44:53 -05:00
lwvmobile
638f212525 Update Readme and Screenshots; Keyboard Shortcuts; 2022-11-17 11:23:10 -05:00
lwvmobile
9f624e0b62 NXDN CAC/CCH Messages; Initial Trunking Support; 2022-11-17 05:50:14 -05:00
lwvmobile
eefe1bac5e Minor Cleanup and Tweaks; 2022-11-16 17:00:26 -05:00
lwvmobile
532c1cc3b6 P25 Trunking Additions; 2022-11-16 16:10:37 -05:00
lwvmobile
b1c40ed6e7 Roman DMR End Call Alert 2022-11-13 23:35:17 -05:00
lwvmobile
94dbd1512d P25 Trunking Initial Commit; 2022-11-13 23:04:50 -05:00
lwvmobile
c73d45d553 EDACS tweaks; 2022-11-12 03:34:21 -05:00
lwvmobile
d1efa05164 NXDN Permissed Data Conditional Check; 2022-11-11 22:45:33 -05:00
lwvmobile
7af5ffe9fa NXDN FSW and Lich Based Decoding; 2022-11-11 22:12:37 -05:00
lwvmobile
8141ea2e78 T_Max Frame Sync Work; Reorganizing; 2022-11-11 22:07:37 -05:00
lwvmobile
ec4ace1514 EDACS; Init Tr; RIGCTL; TCP and WAV in; 2022-11-09 23:51:58 -05:00
lwvmobile
eb5cbaad93 DEV BUILD designation 2022-11-09 15:32:45 -05:00
lwvmobile
f5d0575978 Update README.md 2022-11-06 00:39:34 -04:00
164 changed files with 60343 additions and 19957 deletions

9
.gitignore vendored
View File

@@ -2,3 +2,12 @@
*.so*
*.dylib
build
*.sh
*.csv
examples
*.bin
*.ans
*.patch
*.zip
result
.cache

View File

@@ -1,11 +1,52 @@
#Ubuntu 20.04 uses 3.16.3
#Ubuntu 22.04 uses 3.22.1
#Arch currently on 3.26.3
#Cygwin currently using 3.23.2 (or newer)
cmake_minimum_required(VERSION 3.10.2)
project(dsd-fme)
cmake_minimum_required(VERSION 2.8.11)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
#Set curses to ncurses, and wide true for ascii
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
#use cmake option -DCOLORS=OFF to disable color output (ncurses)
option(COLORS
"Build with Colors Enabled" ON)
if (COLORS)
add_definitions(-DPRETTY_COLORS)
endif ()
#use cmake option -DCOLORSLOGS=OFF to disable color output (terminal/logs)
option(COLORSLOGS
"Build with Colors Enabled" ON)
if (COLORSLOGS)
add_definitions(-DPRETTY_COLORS_LOGS)
endif ()
#use cmake option -DPVC=ON to enable Provoice Conventional Frame Sync
option(PVC
"Build with Provoice Conventional Frame Sync Enabled" OFF)
if (PVC)
add_definitions(-DPVCONVENTIONAL)
endif ()
#use cmake option -DLZ=ON to enable LimaZulu Requested NXDN Tweaks
option(LZ
"Build with new LimaZulu Requested NXDN Tweaks Enabled" OFF)
if (LZ)
add_definitions(-DLIMAZULUTWEAKS)
endif ()
#use cmake option -DSID=ON to enable P25p1 Soft ID decoding -- Experimental
option(SID
"Build with P25p1 LSD/Soft ID Enabled" OFF)
if (SID)
add_definitions(-DSOFTID)
endif ()
include(git_revision)
git_describe(GIT_TAG)
@@ -13,11 +54,12 @@ find_package(LibSndFile REQUIRED)
find_package(MBE REQUIRED)
find_package(ITPP REQUIRED)
find_package(RTLSDR)
find_package(Curses REQUIRED)
find_package(PULSEAUDIO REQUIRED)
find_package(Curses REQUIRED)
find_package(PulseAudio REQUIRED)
find_package(CODEC2)
include_directories(SYSTEM ${LIBSNDFILE_INCLUDE_DIR} ${MBE_INCLUDE_DIR} ${ITPP_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR})
set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${CURSES_LIBRARY})
include_directories(SYSTEM ${LIBSNDFILE_INCLUDE_DIR} ${MBE_INCLUDE_DIR} ${ITPP_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIRS} ${CURSES_INCLUDE_DIRS})
set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${PULSEAUDIO_LIBRARY} ${CURSES_LIBRARIES})
if(RTLSDR_FOUND)
find_package(Threads)
@@ -26,6 +68,12 @@ if(RTLSDR_FOUND)
add_definitions(-DUSE_RTLSDR)
endif(RTLSDR_FOUND)
if(CODEC2_FOUND)
include_directories(SYSTEM ${CODEC2_INCLUDE_DIRS})
list(APPEND LIBS ${CODEC2_LIBRARIES})
add_definitions(-DUSE_CODEC2)
endif(CODEC2_FOUND)
FILE(GLOB SRCS src/*.c src/*.cpp)
FILE(GLOB HEADERS include/*.h include/*.hpp)
@@ -41,6 +89,11 @@ include_directories("${PROJECT_SOURCE_DIR}/include")
ADD_EXECUTABLE(dsd-fme ${SRCS} ${HEADERS})
TARGET_LINK_LIBRARIES(dsd-fme ${LIBS})
target_compile_options(dsd-fme PRIVATE -Wunused-but-set-variable -Wunused-variable -Wunused-parameter
-Wempty-body -Wunused-label $<$<COMPILE_LANGUAGE:C>:-Wpointer-sign>
-Wmisleading-indentation -Wparentheses -Wunused-value -Wreturn-type
-Wtautological-compare)
include(GNUInstallDirs)
install(TARGETS dsd-fme DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@@ -27,3 +27,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
# Digital Speech Decoder - Florida Man Edition
This version of DSD is a flavor blend of [szechyjs](https://github.com/szechyjs/dsd "szechyjs") RTL branch and some of my own additions, along with portions of DMR and NXDN code from the [LouisErigHerve](https://github.com/LouisErigHerve/dsd "LouisErigHerve") branch. This code also borrows snippets, inspiration, and ideas from other open source works including [Boatbod OP25](https://github.com/boatbod/op25 "Boatbod OP25"), [DSDcc](https://github.com/f4exb/dsdcc "DSDcc"), [SDTRunk](https://github.com/DSheirer/sdrtrunk "SDRTrunk"), [MMDVMHost](https://github.com/g4klx/MMDVMHost "MMDVMHost"), [LFSR](https://github.com/mattames/LFSR "LFSR"), and [EZPWD-Reed-Solomon](https://github.com/pjkundert/ezpwd-reed-solomon "EZPWD"). This project wouldn't be possible without a few good people providing me plenty of sample audio files to run over and over again. Special thanks to jurek1111, KrisMar, noamlivne, racingfan360, iScottyBotty, LimaZulu and hrh17 for the many hours of wav samples submitted by them.

244
README.md
View File

@@ -1,248 +1,17 @@
# Notice - This branch is now considered 'legacy' and the master branch will be considered the 'main' branch going forward.
# Digital Speech Decoder - Florida Man Edition
This version of DSD is a flavor blend of [szechyjs](https://github.com/szechyjs/dsd "szechyjs") RTL branch and some of my own additions, along with portions of DMR and NXDN code from the [LouisErigHerve](https://github.com/LouisErigHerve/dsd "LouisErigHerve") branch. This code also borrows snippets, inspiration, and ideas from other open source works including [Boatbod OP25](https://github.com/boatbod/op25 "Boatbod OP25"), [DSDcc](https://github.com/f4exb/dsdcc "DSDcc"), [SDTRunk](https://github.com/DSheirer/sdrtrunk "SDRTrunk"), [MMDVMHost](https://github.com/g4klx/MMDVMHost "MMDVMHost"), [LFSR](https://github.com/mattames/LFSR "LFSR"), and [EZPWD-Reed-Solomon](https://github.com/pjkundert/ezpwd-reed-solomon "EZPWD"). This project wouldn't be possible without a few good people providing me plenty of sample audio files to run over and over again. Special thanks to jurek1111, KrisMar, noamlivne, racingfan360, iScottyBotty, LimaZulu and hrh17 for the many hours of wav samples submitted by them.
DSD-FME is an evolution of the original DSD project from 'DSD Author' using the base code of [szechyjs](https://github.com/szechyjs/dsd "szechyjs"), some code and ideas from [LouisErigHerve](https://github.com/LouisErigHerve/dsd "LouisErigHerve"), [Boatbod OP25](https://github.com/boatbod/op25 "Boatbod OP25") and [Osmocom OP25](https://gitea.osmocom.org/op25/op25 "Osmocom OP25"), along with other snippets of code, information, and inspirations from other projects including [DSDcc](https://github.com/f4exb/dsdcc "DSDcc"), [SDRTRunk](https://github.com/DSheirer/sdrtrunk "SDRTrunk"), [MMDVMHost](https://github.com/g4klx/MMDVMHost "MMDVMHost"), [LFSR](https://github.com/mattames/LFSR "LFSR"), [OK-DMRlib](https://github.com/OK-DMR/ok-dmrlib "OK-DMRlib"), and [EZPWD-Reed-Solomon](https://github.com/pjkundert/ezpwd-reed-solomon "EZPWD"), Eric Cottrell, SP5WWP and others. Finally, this is all brought together with original code to extend the fuctionality and add new features including NCurses Terminal and Menu system, Pulse Audio, TCP Direct Link Audio, RIGCTL, Trunking Features, LRRP/GPS Mapping, P25 Phase 2, EDACS, YSF, M17, OP25 Capture Bin compatability, etc. DSD-FME is primarily focused with Linux Desktop users in mind, so please understand that this version may not compile, compile easily, or run correctly in other environments.
## 2022.10.01 Update ##
This project wouldn't be possible without a few good people providing me plenty of sample audio files to run over and over again. Special thanks to jurek1111, KrisMar, noamlivne, racingfan360, iScottyBotty, LimaZulu, Forts, thewraithe2008, RayAir, Cretu, ilyacodes, and others for the many hours of wav samples and information provided by them. Most importantly, HRH17, whose insight, information, samples, and willingness to let me remote into a computer half-way across the globe in order to test trunking features are what make DSD-FME what it has become. I'd also like to thank mrscanner2008 for providing an additional remote where additional NXDN Type-C, 'Idas' Type-D, and XPT decoding and trunking could be sorted out. Thanks to volo-zyko for cleaning up a lot of code. Thank you everybody.
Very Experimental (Mostly Just Sampling Speed and using built in QPSK demodulator) for Phase 2 CQPSK 6000 sps input over disc tap inputs (SDR++, GQRX, WAV files). Promising results, but some errors in decoding as expected. I've had some pretty good luck using SDR++ to listen to and decode Duke Energy TDMA Control Channel through the virtual sink. Experimental CQPSK can be toggled in Ncurses Menu and also via command line switch `-f2 -m2` but keep in mind this will only work with Phase 2 RF channels using CQPSK, and not a combined decoding.
![DSD-FME](https://github.com/lwvmobile/dsd-fme/blob/audio_work/dsd-fme2.png)
Also, added some new iden_up PDUs and other odd and end P25 PDU's (still far from complete). Ncurses Terminal and Console output will now show relevant frequencies for CC and Voice channels if iden_up commands are present.
![DSD-FME](https://github.com/lwvmobile/dsd-fme/blob/audio_work/dsd-fme3.png)
DSD-FME, and The Florida Man Labs will be taking a hiatus period from straigth development of this project. Currently, I feel we are at a bit of a stand still as far as what can be done with the project without new demodulation, dibit buffer, audio, and input methods. DSD-FME will continue to receive maintenance updates for simple bug fixes and also any major bug issues that cause crashing, etc., but I am reluctant to continue developing with the current underlying issues mentioned above. I am going to go into a period of hiatus with this project and do lots of experimentation, learning, and testing to see what viable options are out there or need to be created from scratch. I feel like I've learned a lot, achieved a lot, made tons of mistakes, learned from a few of them, but ultimately improved on the DSD project. DSD-FME will continue to receive replies and support in any opened issues but will currently only extend to help in setting up and using the software, on top of regular minor maintenance and any crash related issues.
## Information
## 2022.09.28 Mini Update ##
Back by popular demand, I've re-implemented DMR Stereo as a standalone decoder. DMR Stereo is also still available in XDMA decoding for P25 1, 2, and DMR BS/MS Simplex as well.
DMR Stereo `dsd-fme -fs`
XDMA `dsd-fme -ft`
It can also be selected in the NCurses Terminal Menu. Sadly I had to remove the X2-TDMA decoder option in the menu, I'm sure nobody will miss it.
## 2022.09.17 Update ##
P25 Phase 2 Audio decoding has been implemented into DSD-FME. Currently, Phase 2 will only work from OP25 symbol capture bin files, or from wav files/SDR applications/RTL input that are sourced from FSK4 sources. CQPSK (LSM/H-D8PSK) will not work from audio sources. With the addition of Phases 2 audio, a new default decoder class has been implemented, XDMA, which is P25 Phase 1, Phase 2, DMR BS and MS (DMR Stereo). Furthermore, very limited Phase 1 TSBK support and Phase 2 FACCH/SACCH/LCCH has been worked in just to get Network Status Broadcasts, which can fill in the required P2 parameters for WACN, SYSID, and CC for Phase 2 frame de-scrambling, and active voice call information.
With the implementation of the XDMA decoder class (default decoder), the CLI switches for DMR Stereo has been repurposed. -T option will now open a per call wav file saving when used with NCurses Terminal, otherwise it will write wav files to slot 1 and slot 2 wav files.
Anybody using `dsd-fme -fr -T` ...... should now just use `dsd-fme -ft` instead!
To see the up to date CLI options, please look at the help options with the -h CLI option.
## 2022.08.12 Update ##
A new menu system has been introduced in the NCURSES Terminal. Also includes support for LRRP to text file type of choice and reading OP25 symbol capture bin files.
[![DSD-FME](https://github.com/lwvmobile/dsd-fme/blob/pulseaudio/dsd-fme.png)](https://www.youtube.com/watch?v=TqTfAfaPJ4s "DSD-FME Update 2022.08.12")
To get started with the new menu system, simply launch with:
`dsd-fme -N 2> log.txt`
## 2022.06.20 Update - Current Users Please Read!! ##
The executable for this project has been changed from `dsd` to `dsd-fme` so after pulling or cloning the lastest version, make sure to call the software with `dsd-fme`.
## 2022.05.05 Update ##
DMR Stereo method added for listening to voice audio in both TDMA channels/slots simultaneously.
### Example Usage and Note!
`dsd-fme` or `./dsd-fme` may need to be used in your usage, depending on if you are running it from the build folder, or if you have run make install. You will need to tweak the examples to your particular usage. Users can always check `dsd-fme -h` for help and all command line switches to use.
`dsd-fme` is all you need to run for pulse input, pulse output, and auto detect for DMR BS/MS, P25 (1 and 2) and X2-TDMA decoding. To use other decoding methods which cannot be auto detected, please use the following command line switches. Make sure to route audio into and out of DSD-FME using pavucontrol and virtual sinks as needed.
```
-ft XDMA decoder class (P25 1 and 2, DMR BS/MS, X2-TDMA)
-fs DMR Stereo BS/MS Simplex
-fa Legacy Auto
-fi NXDN48
-fn NXDN96
-fp ProVoice
-fm dPMR, also may need to use -xd if inverted dPMR.
-fr DMR, also may need to use -xr if inverted DMR.
-f1 P25P1
-fx X2-TDMA
```
## Example Usage - New XDMA Decoder, Ncurses Terminal, Pulse Input/Output, and Log Console to file
`dsd-fme -ft -N 2> voice.log`
and in a second terminal tab, same folder, run
`tail -n 40 -f voice.log`
Then you can open up your pavucontrol "Pulse Audio Volume Control" or "Volume Control" application and route input into DSD-FME from any application and DSD-FME output to the left and right speakers respectively. (unlock the channel in the application stream and adjust left and right independently)
## Example Usage - RTL2832 Dongle Input
`dsd-fme -fi -i rtl -c 154.9875M -P -2 -D 1 -G 36 -L 70 -U 6021 -Y 12`
```
-i rtl to use rtl_fm (default is -i pulse for pulse audio)
-o pulse to set output to pulse audio (excluded, is default anyways)
-c Set frequency
-P set PPM error (default = 0)
-D set device index number (default = 0; first device detected)
-G set device gain (0-49) (default = 0 Auto Gain)
-L set rtl squelch to 70 (default = 0; off)
-U set UDP port for rtl_fm remote control (default = 6020)
-Y 12 set rtl VFO bandwidth in kHz, (default = 12)(6, 8, 12, 16, 24, 48)
```
## Example STDIN UDP from GQRX or SDR++, output to Pulse Audio, and append decoded audio to wav file
Be sure to first start UDP output sink in GQRX or SDR++ and set VFO appropriately
`socat stdio udp-listen:7355 | dsd-fme -fi -i - -w nxdn.wav`
## Example Usage - Extra Information for Academic Study and Logging
`dsd-fme -Z -N 2>> voice.log`
and in a second terminal tab, same folder, run
`tail -n 40 -f voice.log`
![DSD-FME](https://github.com/lwvmobile/dsd-fme/blob/pulseaudio/dsd-fme2.png)
## Roadmap
The Current list of objectives include:
1. New demodulators and input method(s) (considering liquid-dsp).
2. Graphical User Interface (may need to migrate to new project).
3. Lots of experimentation.
## How to clone, check out, and build this branch
### Ubuntu 22.04/20.04/LM20/Debian Bullseye or Newer:
Using the included download-and-install.sh should make for a simple and painless clone, build, and install on newer Debian/Ubuntu/Mint/Pi systems. Simply acquire or copy the script, and run it. Update: Ubuntu 22.04 and RPi Bullseye 64-bit has been tested working with the installer script and functions appropriately.
If you need all dependencies build and installed first (only on Debian/Ubuntu/Mint/Pi), run:
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/pulseaudio/download-and-install.sh
chmod +x download-and-install.sh
./download-and-install.sh
```
If you have dependencies already installed (i.e. need a fresh clean install on a system with DSD-FME already or using system other than Debian/Ubuntu, etc), please run this instead:
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/pulseaudio/download-and-install-nodeps.sh
chmod +x download-and-install-nodeps.sh
./download-and-install-nodeps.sh
```
### Ubuntu 18.04/LM19/Buster Note:
The above install.sh should now function on older system types. You can elect to manually follow the steps down below. Do NOT Manually build and install ITPP 4.3.1 on older systems, it is currently not wanting to build on Ubuntu 18.04 and Linux Mint 19. Install it from the repository instead.
## Manual Install
First, install dependency packages. This guide will assume you are using Debian/Ubuntu based distros. Check your package manager for equivalent packages if different.
```
sudo apt update
sudo apt install libpulse-dev pavucontrol libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev
```
## Headless
If running headless, swap out pavucontrol for pulsemixer, and also install pulseaudio as well. Attempting to install pavucontrol in a headless environment may attempt to install a minimal desktop environment. Note: Default behavior of pulseaudio in a headless environment may be to be muted, so check by opening pulsemixer and unmuting and routing audio appropriately.
```
sudo apt install libpulse-dev libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev pulsemixer pulseaudio
```
### Build and Install ITPP - ONLY IF NOT IN REPO!!
```
wget -O itpp-latest.tar.bz2 http://sourceforge.net/projects/itpp/files/latest/download?source=files
tar xjf itpp*
#if you can't cd into this folder, double check folder name first
cd itpp-4.3.1
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
```
MBELib is considered a requirement in this build. You must read this notice prior to continuing. [MBElib Patent Notice](https://github.com/lwvmobile/mbelib#readme "MBElib Patent Notice") This version of MBELib is 1.3.1 and prints to STDERR, using the stock 1.3.0 MBElib may cause problems with print alignments if paired with this version of DSD-FME, or cause issues with printing over the screen in future builds.
```
git clone https://github.com/lwvmobile/mbelib
cd mbelib
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
```
Finish by running these steps to clone and build DSD-FME w/ pulseaudio support.
```
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
git branch -a
git checkout remotes/origin/pulseaudio
git checkout -b pulseaudio
git branch -a #double check to see if you are on pulseaudio branch
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
mkdir build
cd build
cmake ..
make -j `nproc`
##only run make install if you don't have another version already installed##
sudo make install
sudo ldconfig
```
Optional 'Virtual Sinks' for routing audio from SDR++ or GQRX, Media Players, etc. into DSD-FME
You may wish to direct sound into DSD-FME via Virtual Sinks. You may set up a Virtual Sink or two on your machine for routing audio in and out of applications to other applications using the following command, and opening up pavucontrol "PulseAudio Volume Control" in the menu (or `pulsemixer` in headless mode) to change line out of application to virtual sink, and line in of DSD-FME to monitor of virtual sink. This command will not persist past a reboot, so you will need to invoke them each time you reboot, or search for how to add this to your conf files for persistency if desired.
```
pacmd load-module module-null-sink sink_name=virtual_sink sink_properties=device.description=Virtual_Sink
pacmd load-module module-null-sink sink_name=virtual_sink2 sink_properties=device.description=Virtual_Sink2
```
Already have this branch, and just want to pull the latest build? You can run the rebuild.sh file in the dsd-fme folder, or manually do the pull with the commands:
```
##Open your clone folder##
git pull https://github.com/lwvmobile/dsd-fme pulseaudio
##cd into your build folder##
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
```
If the call alert wav files aren't playing, then make sure to run the following in the dsd-fme folder to copy the wav files to the /usr/share/ folder and give them adequate permission to be accessed.
```
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
```
See the [examples](https://github.com/lwvmobile/dsd-fme/tree/audio_work/examples "examples") folder for information on [cloning and installing](https://github.com/lwvmobile/dsd-fme/blob/audio_work/examples/Install_Notes.md "cloning and installing"), [example usage](https://github.com/lwvmobile/dsd-fme/blob/audio_work/examples/Example_Usage.md "example usage"), and [trunking examples](https://github.com/lwvmobile/dsd-fme/blob/audio_work/examples/trunking.sh "trunking examples").
## License
Copyright (C) 2010 DSD Author
@@ -259,3 +28,4 @@ GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

31
cmake/FindCODEC2.cmake Normal file
View File

@@ -0,0 +1,31 @@
# - Try to find CODEC2
# Once done this will define
#Seems to work on Cygwin as well now -- more testing for may be required
# Not sure what causes the 'Package 'codec2', required by 'virtual:world', not found' message, but seems to work anyways
# -- Checking for module 'codec2'
# -- Package 'codec2', required by 'virtual:world', not found
# -- Found CODEC2: /usr/local/lib/libcodec2.dll.a
if (NOT CODEC2_FOUND)
find_package(PkgConfig)
pkg_check_modules(CODEC2_PKG codec2)
set(CODEC2_DEFINITIONS ${PC_CODEC2_CFLAGS_OTHER})
find_path(CODEC2_INCLUDE_DIR
NAMES codec2/codec2.h codec2.h
HINTS ${CODEC2_PKG_INCLUDE_DIRS})
find_library(CODEC2_LIBRARY
NAMES codec2/codec2 codec2
HINTS ${CODEC2_PKG_LIBRARY_DIRS})
set(CODEC2_LIBRARIES ${CODEC2_LIBRARY})
set(CODEC2_INCLUDE_DIRS ${CODEC2_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CODEC2 DEFAULT_MSG CODEC2_LIBRARY CODEC2_INCLUDE_DIR)
mark_as_advanced(CODEC2_INCLUDE_DIR CODEC2_LIBRARY)
endif (NOT CODEC2_FOUND)

View File

@@ -1,4 +1,4 @@
#
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)

248
cyg_portable.sh Normal file
View File

@@ -0,0 +1,248 @@
#! /bin/bash
#
cdir=$(pwd)
clear
printf "DSD-FME Digital Speech Decoder - Florida Man Edition Portable Cygwin Creator\n"
printf "Only use this in a Cygwin64 Environment. Will not work in a Linux Environment!\n"
read -p "Do you want to make a portable copy? y/N " RELEASE
RELEASE=$(printf "$RELEASE"|tr '[:upper:]' '[:lower:]')
if [ "$RELEASE" = "y" ]; then
printf "Copying files to dsd-fme-portable folder and making zip file. Please wait!\n"
cd ~
#create a dsd-fme-portable folder and copy all the needed items for a portable release version
mkdir dsd-fme-portable
cd dsd-fme-portable
#all of these folders may not be necessary
mkdir sourcecode
mkdir bin
mkdir dev
cd dev
mkdir shm
cd ..
mkdir dsd-fme
mkdir logs
mkdir WAV
mkdir etc
mkdir home
mkdir lib
mkdir tmp
mkdir usr
cd usr
mkdir share
cd share
mkdir terminfo
cd ~
#start copying things
#terminfo is needed for ncurses
cp -r /usr/share/terminfo/* dsd-fme-portable/usr/share/terminfo
#copy required items from the root bin folder to release bin folder
cp /bin/ls.exe dsd-fme-portable/bin/
cp /bin/bash.exe dsd-fme-portable/bin/
cp /bin/ncurses6-config dsd-fme-portable/bin/
cp /bin/ncursesw6-config dsd-fme-portable/bin/
cp /bin/pacat.exe dsd-fme-portable/bin/
cp /bin/pactl.exe dsd-fme-portable/bin/
cp /bin/padsp dsd-fme-portable/bin/
cp /bin/pamon dsd-fme-portable/bin/
cp /bin/paplay dsd-fme-portable/bin/
cp /bin/parec dsd-fme-portable/bin/
cp /bin/parecord dsd-fme-portable/bin/
cp /bin/pulseaudio.exe dsd-fme-portable/bin/
cp /bin/tty.exe dsd-fme-portable/bin/
#start copying things from the etc folder
cp -r /etc/pulse/ dsd-fme-portable/etc/
#start copying things to the lib folder
cp -r /lib/pulseaudio/ dsd-fme-portable/lib/
#start copying things into the dsd-fme folder
cp dsd-fme/build/dsd-fme.exe dsd-fme-portable/dsd-fme/
cp -r dsd-fme/examples dsd-fme-portable/dsd-fme/
cp .bash_profile dsd-fme-portable/dsd-fme/
cp .bashrc dsd-fme-portable/dsd-fme/
cp .inputrc dsd-fme-portable/dsd-fme/
cp .profile dsd-fme-portable/dsd-fme/
#move (cut) the bat files to the portable folder root and delete the other ones so users won't get confused
mv dsd-fme-portable/dsd-fme/examples/cygwin_bat/start-dsd-fme.bat dsd-fme-portable/
mv dsd-fme-portable/dsd-fme/examples/cygwin_bat/example_options.txt dsd-fme-portable/
mv dsd-fme-portable/dsd-fme/examples/cygwin_bat/complete_usage_options.txt dsd-fme-portable/
rm -rf dsd-fme-portable/dsd-fme/examples/cygwin_bat
#change .bat files permissions to be read/write/executable by all users (for some reason, this is not preserved)
chmod 777 dsd-fme-portable/*.bat
#copy the license, copyright, source code, and things that should be included in all portable releases
cp dsd-fme/COPYRIGHT dsd-fme-portable/sourcecode/
cp dsd-fme/DSD_Author.pgp dsd-fme-portable/sourcecode/
cp dsd-fme/dsd-fme-qgis-map.qgz dsd-fme-portable/sourcecode/
cp dsd-fme/README.md dsd-fme-portable/sourcecode/
cp dsd-fme/dsd-fme2.png dsd-fme-portable/sourcecode/
cp dsd-fme/dsd-fme3.png dsd-fme-portable/sourcecode/
cp dsd-fme/CMakeLists.txt dsd-fme-portable/sourcecode/
cp -r dsd-fme/src dsd-fme-portable/sourcecode/
cp -r dsd-fme/include dsd-fme-portable/sourcecode/
cp -r dsd-fme/cmake dsd-fme-portable/sourcecode/
cp -r dsd-fme/patch dsd-fme-portable/sourcecode/
#compiled items into release dsd-fme folder
cp codec2/build/src/cygcodec2* dsd-fme-portable/dsd-fme/
cp itpp-4.3.1/build/itpp/cygitpp* dsd-fme-portable/dsd-fme/
cp rtl-sdr/build/src/cyg* dsd-fme-portable/dsd-fme/
cp mbelib/build/cygmbe* dsd-fme-portable/dsd-fme/
#bin items into release dsd-fme folder (uisng * where version numbering may exist, those may be upgraded if hard coded)
cp /bin/bash.exe dsd-fme-portable/dsd-fme/
cp /bin/cut.exe dsd-fme-portable/dsd-fme/
cp /bin/cygao* dsd-fme-portable/dsd-fme/
cp /bin/cygarchive* dsd-fme-portable/dsd-fme/
cp /bin/cygargp* dsd-fme-portable/dsd-fme/
cp /bin/cygassuan* dsd-fme-portable/dsd-fme/
cp /bin/cygasyncns* dsd-fme-portable/dsd-fme/
cp /bin/cygatomic* dsd-fme-portable/dsd-fme/
cp /bin/cygattr* dsd-fme-portable/dsd-fme/
cp /bin/cygavahi-client* dsd-fme-portable/dsd-fme/
cp /bin/cygavahi-common* dsd-fme-portable/dsd-fme/
cp /bin/cygavahi-wrap* dsd-fme-portable/dsd-fme/
cp /bin/cygblkid* dsd-fme-portable/dsd-fme/
cp /bin/cygbrotlicommon* dsd-fme-portable/dsd-fme/
cp /bin/cygbrotlidec* dsd-fme-portable/dsd-fme/
cp /bin/cygbz2* dsd-fme-portable/dsd-fme/
cp /bin/cygcares* dsd-fme-portable/dsd-fme/
cp /bin/cygcheck.exe dsd-fme-portable/dsd-fme/
cp /bin/cygcli.dll dsd-fme-portable/dsd-fme/
cp /bin/cygcom_err* dsd-fme-portable/dsd-fme/
cp /bin/cygcrypt* dsd-fme-portable/dsd-fme/
cp /bin/cygcrypto* dsd-fme-portable/dsd-fme/
cp /bin/cygcurl* dsd-fme-portable/dsd-fme/
cp /bin/cygdb_cxx* dsd-fme-portable/dsd-fme/
cp /bin/cygdb_sql* dsd-fme-portable/dsd-fme/
cp /bin/cygdb* dsd-fme-portable/dsd-fme/
cp /bin/cygdbus* dsd-fme-portable/dsd-fme/
cp /bin/cygedit* dsd-fme-portable/dsd-fme/
cp /bin/cygexpat* dsd-fme-portable/dsd-fme/
cp /bin/cygfam* dsd-fme-portable/dsd-fme/
cp /bin/cygfdisk* dsd-fme-portable/dsd-fme/
cp /bin/cygffi* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3_threads* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3f_threads* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3f* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3l_threads* dsd-fme-portable/dsd-fme/
cp /bin/cygfftw3l* dsd-fme-portable/dsd-fme/
cp /bin/cygfido2* dsd-fme-portable/dsd-fme/
cp /bin/cygFLAC* dsd-fme-portable/dsd-fme/
cp /bin/cygformw* dsd-fme-portable/dsd-fme/
cp /bin/cyggc* dsd-fme-portable/dsd-fme/
cp /bin/cyggdbm_compat* dsd-fme-portable/dsd-fme/
cp /bin/cyggdbm*.dll dsd-fme-portable/dsd-fme/
cp /bin/cyggio* dsd-fme-portable/dsd-fme/
cp /bin/cygglib* dsd-fme-portable/dsd-fme/
cp /bin/cyggmodule* dsd-fme-portable/dsd-fme/
cp /bin/cyggmp* dsd-fme-portable/dsd-fme/
cp /bin/cyggnutls* dsd-fme-portable/dsd-fme/
cp /bin/cyggobject* dsd-fme-portable/dsd-fme/
cp /bin/cyggomp* dsd-fme-portable/dsd-fme/
cp /bin/cyggpg-error* dsd-fme-portable/dsd-fme/
cp /bin/cyggpgme* dsd-fme-portable/dsd-fme/
cp /bin/cyggsasl* dsd-fme-portable/dsd-fme/
cp /bin/cyggsm* dsd-fme-portable/dsd-fme/
cp /bin/cyggssapi_krb5* dsd-fme-portable/dsd-fme/
cp /bin/cyggthread* dsd-fme-portable/dsd-fme/
cp /bin/cygguile* dsd-fme-portable/dsd-fme/
cp /bin/cyghistory* dsd-fme-portable/dsd-fme/
cp /bin/cyghogweed* dsd-fme-portable/dsd-fme/
cp /bin/cygICE* dsd-fme-portable/dsd-fme/
cp /bin/cygiconv* dsd-fme-portable/dsd-fme/
cp /bin/cygid3tag* dsd-fme-portable/dsd-fme/
cp /bin/cygidn* dsd-fme-portable/dsd-fme/
cp /bin/cygintl* dsd-fme-portable/dsd-fme/
cp /bin/cygisl* dsd-fme-portable/dsd-fme/
cp /bin/cygjsoncpp* dsd-fme-portable/dsd-fme/
cp /bin/cygk5crypto* dsd-fme-portable/dsd-fme/
cp /bin/cygkrb5* dsd-fme-portable/dsd-fme/
cp /bin/cyglber* dsd-fme-portable/dsd-fme/
cp /bin/cygldap* dsd-fme-portable/dsd-fme/
cp /bin/cygltdl* dsd-fme-portable/dsd-fme/
cp /bin/cyglz* dsd-fme-portable/dsd-fme/
cp /bin/cygma* dsd-fme-portable/dsd-fme/
cp /bin/cygmenuw* dsd-fme-portable/dsd-fme/
cp /bin/cygmeta* dsd-fme-portable/dsd-fme/
cp /bin/cygmp* dsd-fme-portable/dsd-fme/
cp /bin/cygncurses* dsd-fme-portable/dsd-fme/
cp /bin/cygnettle* dsd-fme-portable/dsd-fme/
cp /bin/cygnghttp* dsd-fme-portable/dsd-fme/
cp /bin/cygntlm* dsd-fme-portable/dsd-fme/
cp /bin/cygobjc* dsd-fme-portable/dsd-fme/
cp /bin/cygogg* dsd-fme-portable/dsd-fme/
cp /bin/cygopus* dsd-fme-portable/dsd-fme/
cp /bin/cygorc* dsd-fme-portable/dsd-fme/
cp /bin/cygp11* dsd-fme-portable/dsd-fme/
cp /bin/cygpanel* dsd-fme-portable/dsd-fme/
cp /bin/cygpath.exe dsd-fme-portable/dsd-fme/
cp /bin/cygpcre* dsd-fme-portable/dsd-fme/
cp /bin/cygperl* dsd-fme-portable/dsd-fme/
cp /bin/cygpipe* dsd-fme-portable/dsd-fme/
cp /bin/cygpkg* dsd-fme-portable/dsd-fme/
cp /bin/cygpng* dsd-fme-portable/dsd-fme/
cp /bin/cygpopt* dsd-fme-portable/dsd-fme/
cp /bin/cygprotocol* dsd-fme-portable/dsd-fme/
cp /bin/cygpsl* dsd-fme-portable/dsd-fme/
cp /bin/cygpulse* dsd-fme-portable/dsd-fme/
cp /bin/cygquadmath* dsd-fme-portable/dsd-fme/
cp /bin/cygreadline* dsd-fme-portable/dsd-fme/
cp /bin/cygrhash* dsd-fme-portable/dsd-fme/
cp /bin/cygrunsrv.exe dsd-fme-portable/dsd-fme/
cp /bin/cygsamplerate* dsd-fme-portable/dsd-fme/
cp /bin/cygsasl* dsd-fme-portable/dsd-fme/
cp /bin/cygserver* dsd-fme-portable/dsd-fme/
cp /bin/cygSM* dsd-fme-portable/dsd-fme/
cp /bin/cygsmart* dsd-fme-portable/dsd-fme/
cp /bin/cygsndfile* dsd-fme-portable/dsd-fme/
cp /bin/cygsox* dsd-fme-portable/dsd-fme/
cp /bin/cygspeex* dsd-fme-portable/dsd-fme/
cp /bin/cygsqlite* dsd-fme-portable/dsd-fme/
cp /bin/cygssh* dsd-fme-portable/dsd-fme/
cp /bin/cygssl* dsd-fme-portable/dsd-fme/
cp /bin/cygstart.exe dsd-fme-portable/dsd-fme/
cp /bin/cygstdc* dsd-fme-portable/dsd-fme/
cp /bin/cygtasn* dsd-fme-portable/dsd-fme/
cp /bin/cygtdb* dsd-fme-portable/dsd-fme/
cp /bin/cygticw* dsd-fme-portable/dsd-fme/
cp /bin/cygtwo* dsd-fme-portable/dsd-fme/
cp /bin/cygunistring* dsd-fme-portable/dsd-fme/
cp /bin/cygusb* dsd-fme-portable/dsd-fme/
cp /bin/cyguuid* dsd-fme-portable/dsd-fme/
cp /bin/cyguv* dsd-fme-portable/dsd-fme/
cp /bin/cygvorbis* dsd-fme-portable/dsd-fme/
cp /bin/cygwavpack* dsd-fme-portable/dsd-fme/
cp /bin/cygwin1.dll dsd-fme-portable/dsd-fme/
cp /bin/cygwrap* dsd-fme-portable/dsd-fme/
cp /bin/cygX* dsd-fme-portable/dsd-fme/
cp /bin/cygx* dsd-fme-portable/dsd-fme/
cp /bin/cygz* dsd-fme-portable/dsd-fme/
cp /bin/grep.exe dsd-fme-portable/dsd-fme/
cp /bin/ls.exe dsd-fme-portable/dsd-fme/
cp /bin/mintty.exe dsd-fme-portable/dsd-fme/
cp /bin/pacat.exe dsd-fme-portable/dsd-fme/
cp /bin/pacmd.exe dsd-fme-portable/dsd-fme/
cp /bin/pactl.exe dsd-fme-portable/dsd-fme/
cp /bin/padsp dsd-fme-portable/dsd-fme/
cp /bin/pamon dsd-fme-portable/dsd-fme/
cp /bin/paplay dsd-fme-portable/dsd-fme/
cp /bin/parec dsd-fme-portable/dsd-fme/
cp /bin/pulseaudio.exe dsd-fme-portable/dsd-fme/
cp /bin/tail.exe dsd-fme-portable/dsd-fme/
cp /bin/touch.exe dsd-fme-portable/dsd-fme/
cp /bin/tty.exe dsd-fme-portable/dsd-fme/
zip -r dsd-fme-x86-64-cygwin-portable.zip dsd-fme-portable
fi

14
cyg_rebuild.sh Normal file
View File

@@ -0,0 +1,14 @@
#! /bin/bash
#
clear
printf "DSD-FME Digital Speech Decoder - Florida Man Edition
Automatic Git Pull and Rebuild for Cygwin\n\n"
sleep 1
##Open your clone folder##
git pull
sleep 2
##cd into your build folder##
cd build
cmake ..
make -j $(nproc)
make install

View File

@@ -0,0 +1,52 @@
#! /bin/bash
#
cdir=$(pwd)
clear
printf "Digital Speech Decoder: Florida Man Edition - Auto Installer For Arch Linux\n
This will install the required packages, clone, build, and install DSD-FME only.
This has been tested on Arch 2023.08.01 and Manjaro XFCE 22.1.3 Minimal.\n
MBELib is considered a requirement on this build.
You must view the Patent Notice prior to continuing.
The Patent Notice can be found at the site below.
https://github.com/lwvmobile/mbelib#readme
Please confirm that you have viewed the patent notice by entering y below.\n\n"
read -p "Have you viewed the patent notice? y/N " ANSWER
ANSWER=$(printf "$ANSWER"|tr '[:upper:]' '[:lower:]')
if [ "$ANSWER" = "y" ]; then
sudo pacman -Syu #always run a full update first, partial upgrades aren't supported in Arch -- including downloading dependencies, that may require an updated dependency, and breaks same dependency on another package, a.k.a, dependency hell
sudo pacman -S libpulse cmake ncurses lapack perl fftw rtl-sdr codec2 base-devel libsndfile git wget
printf "Installing itpp 4.3.1 from Arch Strike --Tested on Arch 2023.08.01 and Manjaro XFCE 22.1.3 Minimal\n"
wget https://mirror.archstrike.org/x86_64/archstrike/itpp-4.3.1-3-x86_64.pkg.tar.xz
sudo pacman -U itpp-4.3.1-3-x86_64.pkg.tar.xz
sudo rm -R itpp-4.3.1-3-x86_64.pkg.tar.xz
git clone https://github.com/lwvmobile/mbelib
cd mbelib
git checkout ambe_tones
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
sudo cp /usr/local/lib/libmbe.so /usr/lib/libmbe.so
cd $cdir
git clone https://github.com/lwvmobile/dsd-fme
### For branch audio_work - git clone --branch audio_work https://github.com/lwvmobile/dsd-fme
cd dsd-fme
#git checkout audio_work
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
printf "Any issues, Please report to either:\nhttps://github.com/lwvmobile/dsd-fme/issues or\nhttps://forums.radioreference.com/threads/dsd-fme.438137/\n\n"
else
printf "Sorry, you cannot build DSD-FME without acknowledging the Patent Notice.\n\n"
fi

View File

@@ -0,0 +1,89 @@
#! /bin/bash
#
cdir=$(pwd)
clear
printf "Digital Speech Decoder: Florida Man Edition - Auto Installer For Cygwin\n
This will install the required packages, clone, build, and install DSD-FME only.
This has been tested on Cygwin x86-64 as of 20250211. This may take a while!\n
MBELib is considered a requirement on this build.
You must view the Patent Notice prior to continuing.
The Patent Notice can be found at the site below.
https://github.com/lwvmobile/mbelib#readme
Please confirm that you have viewed the patent notice by entering y below.\n\n"
read -p "Have you viewed the patent notice? y/N " ANSWER
ANSWER=$(printf "$ANSWER"|tr '[:upper:]' '[:lower:]')
if [ "$ANSWER" = "y" ]; then
#is this needed?
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
#ITPP
cd $cdir
printf "Installing itpp 4.3.1 from source http://sourceforge.net/projects/itpp/files/latest/download?source=files\n Please wait!\n"
wget -O itpp-latest.tar.bz2 http://sourceforge.net/projects/itpp/files/latest/download?source=files
tar xjf itpp-latest.tar.bz2
cd itpp-4.3.1/
mkdir build
cd build
cmake ..
make -j $(nproc)
make install
#MBELIB
cd $cdir
printf "Installing mbelib\n Please wait!\n"
git clone https://github.com/lwvmobile/mbelib.git
cd mbelib
git checkout ambe_tones
mkdir build
cd build
cmake ..
make -j $(nproc)
make install
cp cygmbe-1.dll /bin
#CODEC2
cd $cdir
printf "Installing codec2\n Please wait!\n"
git clone https://github.com/drowe67/codec2.git
cd codec2
mkdir build
cd build
cmake ..
make -j $(nproc)
make install
#RTL-SDR
cd $cdir
printf "Installing RTL-SDR\n Please wait!\n"
git clone https://github.com/lwvmobile/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ..
make -j $(nproc)
make install
#DSD-FME
cd $cdir
printf "Installing DSD-FME\n Please wait!\n"
git clone https://github.com/lwvmobile/dsd-fme.git
cd dsd-fme
#git checkout aw_dev
mkdir build
cd build
cmake -DCOLORSLOGS=OFF ..
make -j $(nproc)
make install
cd $cdir
#call the cyg_portable script
sh dsd-fme/cyg_portable.sh
printf "Any issues, Please report to either:\nhttps://github.com/lwvmobile/dsd-fme/issues or\nhttps://forums.radioreference.com/threads/dsd-fme.438137/\n\n"
else
printf "Sorry, you cannot build DSD-FME without acknowledging the Patent Notice.\n\n"
fi

View File

@@ -1,26 +1,17 @@
#! /bin/bash
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition Auto Installer
echo This will clone, build, and install DSD-FME only.
echo If you need dependencies installed, please run download-and-install.sh instead.
echo
read -p "Press enter to continue"
printf "\nDigital Speech Decoder: Florida Man Edition - Auto Installer\n
This will clone, build, and install DSD-FME only.
If DSD-FME has never been installed on this machine,
then you will need to install the dependencies first!
Please run download-and-install.sh instead.\n\n"
read -p "Press Enter to continue..." x
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
git branch -a
git checkout remotes/origin/pulseaudio
git checkout -b pulseaudio
git branch -a #double check to see if you are on pulseaudio branch
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
#git checkout audio_work
mkdir build
cd build
cmake ..
make -j `nproc`
##only run make install if you don't have another version already installed##
make -j $(nproc)
sudo make install
sudo ldconfig
sudo ldconfig

View File

@@ -0,0 +1,44 @@
#! /bin/bash
#
cdir=$(pwd)
clear
printf "Digital Speech Decoder: Florida Man Edition - Auto Installer\n
MBELib is considered a requirement on this build.
You must view the Patent Notice prior to continuing.
The Patent Notice can be found at the site below.
https://github.com/lwvmobile/mbelib#readme
Please confirm that you have viewed the patent notice by entering y below:\n\n"
read -p "Have you viewed the patent notice? y/N " ANSWER
ANSWER=$(printf "$ANSWER"|tr '[:upper:]' '[:lower:]')
if [ "$ANSWER" = "y" ]; then
sudo apt update
sudo apt install libpulse-dev libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncurses-dev libncurses6 libcodec2-dev
chkitpp=$(dpkg -l libitpp-dev 2>/dev/null | awk '/^ii/ {print 1} END {if (NR == 0) print 0}')
if [ "$chkitpp" -lt "1" ];then
printf "\nFor some reason, ITPP did NOT install!\nYou may have to manually install it.\n\n"
read -p "Press Enter to exit..." x
exit 1
fi
git clone https://github.com/lwvmobile/mbelib
cd mbelib
git checkout ambe_tones
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
cd $cdir
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
#git checkout audio_work
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
else
printf "\nSorry, you cannot build DSD-FME without acknowledging the Patent Notice.\nExiting...\n\n"
exit 2
fi

View File

@@ -1,70 +1,44 @@
#! /bin/bash
#
cdir=$(pwd)
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition Auto Installer
echo MBELib is considered a requirement on this build.
echo You must view this notice prior to continuing.
echo The Patent Notice can be found at the site below.
echo https://github.com/lwvmobile/mbelib#readme
echo Please confirm that you have viewed the patent notice by entering y below.
echo
echo y/N
read ANSWER
Y='y'
if [[ $Y == $ANSWER ]]; then
sudo apt update
sudo apt install libpulse-dev pavucontrol libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev
echo ITPP Manual Build and Install has been temporarily removed from this script due to issues with older versions of Ubuntu.
echo Please check to see that libitpp-dev has successfully been downloaded and installed from the repo.
read -p "Press enter to continue"
#wget -O itpp-latest.tar.bz2 http://sourceforge.net/projects/itpp/files/latest/download?source=files
#tar xjf itpp*
#if you can't cd into this folder, double check folder name first
#cd itpp-4.3.1
#mkdir build
#cd build
#cmake ..
#make -j `nproc`
#sudo make install
#sudo ldconfig
#cd ..
#cd ..
git clone https://github.com/lwvmobile/mbelib
cd mbelib
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
git branch -a
git checkout remotes/origin/pulseaudio
git checkout -b pulseaudio
git branch -a #double check to see if you are on pulseaudio branch
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
mkdir build
cd build
cmake ..
make -j `nproc`
##only run make install if you don't have another version already installed##
sudo make install
sudo ldconfig
printf "Digital Speech Decoder: Florida Man Edition - Auto Installer\n
MBELib is considered a requirement on this build.
You must view the Patent Notice prior to continuing.
The Patent Notice can be found at the site below.
https://github.com/lwvmobile/mbelib#readme
Please confirm that you have viewed the patent notice by entering y below:\n\n"
read -p "Have you viewed the patent notice? y/N " ANSWER
ANSWER=$(printf "$ANSWER"|tr '[:upper:]' '[:lower:]')
if [ "$ANSWER" = "y" ]; then
sudo apt update
sudo apt install libpulse-dev libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev libcodec2-dev
chkitpp=$(dpkg -l libitpp-dev 2>/dev/null | awk '/^ii/ {print 1} END {if (NR == 0) print 0}')
if [ "$chkitpp" -lt "1" ];then
printf "\nFor some reason, ITPP did NOT install!\nYou may have to manually install it.\n\n"
read -p "Press Enter to exit..." x
exit 1
fi
git clone https://github.com/lwvmobile/mbelib
cd mbelib
git checkout ambe_tones
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
cd $cdir
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
#git checkout audio_work
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
sudo ldconfig
else
echo
echo Sorry, you cannot build DSD-FME without acknowledging the Patent Notice.
fi
printf "\nSorry, you cannot build DSD-FME without acknowledging the Patent Notice.\nExiting...\n\n"
exit 2
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 725 KiB

BIN
dsd-fme3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -0,0 +1,74 @@
## Audio Plumbing
While using DSD-FME to demodulate and decode RF Audio, you will find it necessary to properly plumb (or route) audio from each input source and output sink properly. This mini tutorial aims to help you do such when using Pulse Audio.
You will first want to locate and run the virtualsink.sh script file via `sh virtualsink.sh` command. This will create two null-sink, or 'virtual sinks' for us to plumb audio from point A to point B.
Here are screenshots of a proper setup using pavucontrol, or "Pulse Audio Volume Control", having voice input from the encoder listening to your microphone, the RF Output going into the "Virtual_Sink" null-sink, and on the playback side, playing back voice to our speakers, with RF modulated audio being monitored on "Virtual-Sink" null-sink.
![Audio 1](https://github.com/lwvmobile/dsd-fme/blob/aw_dev/examples/pavucontrol_plumbing1.png)
![Audio 2](https://github.com/lwvmobile/dsd-fme/blob/aw_dev/examples/pavucontrol_plumbing2.png)
The general idea is that we want to route RF modulated audio into our Virtual_Sink and have our decoder listen to the same sink. Voice Output should always be to Audio Hardware (speakers, headphones, etc).
Note, that using the virtualsink.sh will create these sinks for us for the duration of your computers boot. If you reboot, they will not persist. Configuration files can be modified to always have these sinks available, or the `virtualsink.sh` script can be executed on login, but you must do so at your own risk and own research, it is out of the scope of this tutorial to create persistent sinks.
In case of the usage of a headless environment and pavucontrol is not viable, you may use alternatives such as pulsemixer which is similar in functionality, just as a CLI tool and not a GUI tool.
Users can now use the `-O` CLI argument to list out all pulse audio input sources and output sinks and pass an optional argument alongside `pulse`, appending the name or index number to select the device each time. This method will work in both Linux environments as well as Cygwin builds (making sure to start the pulseaudio.exe server in the back first with the specified .bat file or command, see below).
For Example:
The Output (truncated) of `dsd-fme -O`
```
=======[ Output Device #1 ]=======
Description: Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
Name: alsa_output.pci-0000_0d_00.3.analog-stereo
Index: 1
=======[ Output Device #4 ]=======
Description: Virtual_Sink1
Name: virtual_sink1
Index: 4
=======[ Output Device #5 ]=======
Description: Virtual_Sink2
Name: virtual_sink2
Index: 5
=======[ Input Device #2 ]=======
Description: Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
Name: alsa_input.pci-0000_0d_00.3.analog-stereo
Index: 2
=======[ Input Device #5 ]=======
Description: Monitor of Virtual_Sink1
Name: virtual_sink1.monitor
Index: 5
=======[ Input Device #6 ]=======
Description: Monitor of Virtual_Sink2
Name: virtual_sink2.monitor
Index: 6
```
You might use any of the following for input and output options:
```
-i pulse
-i pulse:6
-i pulse:virtual_sink2.monitor
-o pulse
-o pulse:1
-o pulse:alsa_output.pci-0000_0d_00.3.analog-stereo
```
Something to keep in mind is that often times, you only need to set these values once, as a pulse audio server (or plugin) can often times remember these settings, even across reboots, as long as the same hardware is present for future use (real or null-sink).
<!-- TODO: Add This later -->
<!-- Cygwin Note: Running the supplied `0p - start-pulse-audio-backend.bat` file will not only start up the pulse audio server for you, but also setup your null-sinks, and enumerate all devices for you to use, making it an easy selection for your start up .bat files. See any notes in the precomplied .zip file for more information. -->

380
examples/Example_Usage.md Normal file
View File

@@ -0,0 +1,380 @@
### Example Usage and Notes!
`dsd-fme` is all you need to run for pulse input, pulse output, and auto detect for DMR BS/MS, and P25. To use other decoding methods which cannot be auto detected, please use the following command line switches.
```
-ft XDMA decoder class (P25p1 and p2, YSF, and DMR Stereo)
-fs DMR Stereo, also may need to use -xr if inverted DMR
-fa Legacy Auto (not recommended)
-fi NXDN48
-fn NXDN96
-fp Provoice
-fh EDACS Standard / Network
-fH EDACS Standard / Network with ESK
-fe EDACS Extended Addresssing
-fE EDACS Extended Addressing with ESK
-fm dPMR, also may need to use -xd if inverted dPMR.
-f1 P25P1
-f2 P25P2 (may need to specify wacn/sys/nac manually if traffic channel)
-fx X2-TDMA
-fy YSF
-fz M17 Audio
```
## Conventional Frequency Scanner
This feature is used to allow DSD-FME to use RIGCTL or RTL input and cycle through frequencies to attain a frame sync.
This works almost identically to how the trunkng methods work, but instead of locking onto a control channel and tuning based on its decoding, it tunes through all loaded frequencies in a CSV file and stops when it finds a frame sync. This method is meant for loading a bunch of conventional non-trunking frequencies that signal only when voice or short data bursts are present (DMR T2, Conventional P25 P1, Conventional NXDN, etc) and decode them until the frame sync stops and then resume its scan. This method uses SDR++ RIGCTL, or RTL internal handling to go through signal. -Y is the scan switch. Note: This method will NOT perform at a level similar to a real hardware scanner, SDR tuning is not nearly as fast or reliable at locking onto signal.
To scan through a mixture of DMR and P25 Conventional, use:
`dsd-fme -i tcp -C channel_map.csv -G group.csv -Y -U 4532 -N 2> log.ans`
To scan through NXDN48 only conventional, use:
`dsd-fme -fi -i tcp -C channel_map.csv -Y -U 4532 -N 2> log.ans`
To scan through NXDN96 only conventional, use:
`dsd-fme -fn -i tcp -C channel_map.csv -Y -U 4532 -N 2> log.ans`
The Channel Map setup will be identical to any of the channel maps found for trunking systems, channel numbers do not matter and can be arbitrarily organized, and frequencies can be duplicated to be 'scanned' more frequently in larger CSV files. Scan speed by default is 1 second, and is most stable at that speed. This can be adjusted by using the `-t 2` option, for example, to specify 2 seconds of hang time per frequency. ~~If activity occurs on a frequency, an additional 2 seconds of 'hangtime' will occur on that frequency for any follow up voice activity.~~ Using `-t 0` will forego the one second wait time, and this can work in some situations, but is not advised as it may skip during the middle of transmissions, or skip over them entirely without a framesync.
Please Note: DMR Simplex may not behave well on scan, I have not been able to test it as such, but given the nature of the on-off timeslot signalling on DMR Simplex, missed frame syncs and skipping/resuming scan may occur.
## Trunking Examples
Please see trunking.sh for sample start up scripts or scroll down to the bottom for more explanation.
## Example Usage - Default Decoder, Ncurses Terminal, Pulse Input/Output, and Log Console to file
`dsd-fme -N 2> voice.log`
and in a second terminal tab, same folder, run
`tail -n 40 -f voice.log`
### Audio Plumbing
Please see [Audio Plumbing](https://github.com/lwvmobile/dsd-fme/blob/aw_dev/examples/Audio_Plumbing.md "Audio Plumbing") for general help with audio plumbing (routing from A to B).
### Input ###
--TCP Direct Audio Link with SDR++
`dsd-fme -i tcp` Currently defaults to localhost:7355 (SDR++ defaults)
`dsd-fme -i tcp:192.168.7.5:7356` (remote host and custom port)
--48000/9600 Mono Wav File Input
`dsd-fme -i filename.wav` 48k/1 Audio (SDR++, GQRX wav recordings)
`dsd-fme -i filename.wav -s 96000` 96k/1 (DSDPlus Raw Signal Wav Files)
Wav File Input Note: Due to 96000 rate audio requiring me to double the symbol rate and center, be sure to use the -s 96000 at the very end of the startup command. Also, some NXDN48/96 may have difficulties decoding properly with wav file input.
## Example Usage - RTL2832 Dongle Input
Short Setup (all default values):
`dsd-fme -i rtl`
Detailed Setup:
`dsd-fme -ft -i rtl:0:154.9875M:26:-2:8:0:6020 `
```
RTL-SDR options:
Usage: rtl:dev:freq:gain:ppm:bw:sq:vol
NOTE: all arguments after rtl are optional now for trunking, but user configuration is recommended
dev <num> RTL-SDR Device Index Number
freq <num> RTL-SDR Frequency (851800000 or 851.8M)
gain <num> RTL-SDR Device Gain (0-49)(default = 0; Hardware AGC recommended)
ppm <num> RTL-SDR PPM Error (default = 0)
bw <num> RTL-SDR Bandwidth kHz (default = 12)(8, 12, 16, 24)
sq <num> RTL-SDR Squelch Level vs RMS Value (Optional)
vol <num> RTL-SDR Sample 'Volume' Multiplier (default = 2)(1,2,3)
Example: dsd-fme -fs -i rtl -C cap_plus_channel.csv -T
Example: dsd-fme -fp -i rtl:0:851.375M:22:-2:24:0:2
```
## Example Usage - Extra Payload/PDU Logging
`dsd-fme -Z -N 2> log.ans`
and in a second terminal tab, same folder, run
`tail -n 40 -f log.ans`
### EDACS/P25/NXDN/DMR Simple/Single VFO Trunking ###
EDACS Trunking (w/ channel map import)
--EDACS/PV Trunking using RIGCTL and TCP Direct Link Audio inside of SDR++ (see switches above for STD/NET, EA, and ESK modes)
`dsd-fme -i tcp -fE -C channel_map.csv -G group.csv -T -U 4532 -N 2> log.ans`
--NXDN48 Trunking (Direct Frequency Assignment) with SDR++ (untested for frequency accuracy)
`dsd-fme -fi -i tcp -T -U 4532 -N 2> log.ans`
--NXDN48 Trunking (w/ channel map import) with SDR++ (put control channel frequency at channel 0 in channel_map.csv)
`dsd-fme -fi -i tcp -T -U 4532 -C channel_map.csv -N 2> log.ans`
--DMR Trunking (w/ channel map import) with SDR++ (put control channel frequency at channel 0 (TIII and Con+) in channel_map.csv)
`dsd-fme -fs -i tcp -T -U 4532 -C channel_map.csv -N 2> log.ans`
--P25 Trunking P1 and P2 (C4FM) with SDR++
`dsd-fme -i tcp -T -U 4532 -N 2> log.ans`
--P25 Trunking (QPSK) with P1 Control Channel (Should switch symbol rate and center on Phase 2 audio channels)
`dsd-fme -i tcp -T -U 4532 -N -mq 2> log.ans`
--P25 Trunking Phase 2 TDMA Control Channel systems with QPSK (non Phase 1 systems)
`dsd-fme -i tcp -T -U 4532 -N -f2 -m2 2> log.ans`
Trunking Note1: All samples above can also be run with the RTL input method and setting of RTL UDP remote port. In terms of performance, however, SDR++ will do a much better job on weaker/marginal signal compared to the RTL input. RTL input should only be used on strong signal.
`dsd-fme -fp -i rtl:0:851.8M:22:-2:24:0:6020 -T -C channel_map.csv -G group.csv -N 2> log.ans`
Trunking Note2: QPSK Phase 1 and Phase 2 Systems may be subceptible to LSM distortion issues, but seem to do okay, but require really good signal. Some CRC issues still occur with Phase 2 TDMA LCCH Mac Signal that can affect reliability, I believe this issue is ultimately caused by the PSK demodulation inside of FME. I also don't believe this will work on 8-level PSK, but I cannot determine that at the moment. Update: I have improved the LCCH Mac Signal decoding my increasing the QPSK decision point buffers to their maximum values.
Trunking Note3: DMR Trunking has been coded, and some testing and tweaks have been carried out. Cap+, Con+, and TIII systems seem to do well with trunking now. Placing the frequency for the control channel at channel map 0 in your channel_map.csv file is not required now if using RIGCTL or the RTL Input, both can poll the VFO for the current frequency if it believes its on a control channel, but setting a fake channel number (i.e. 999) first with the CC frequency will result in finding the CC faster on startup if desired. If you need to map out your channels for TIII, you can observe the console output and look for channel numbers. For conveniece I have included the DSDPlus style LSN-esque numbering into the console print so it will make it easier for users from DSDPlus to map frequencies into the channel_map.csv file. Make sure your channel numbers are the lpcn (12-bit logical physical channel number - decimal format) values from the log, and not the LPCN+TS (13-bit DSDPlus LSN) values. Notice: TIII Site ID value needs work to determine proper DMRLA values for system area and sub area.
```
00:43:00 Sync: +DMR [slot1] slot2 | Color Code=00 | CSBK
Talkgroup Voice Channel Grant (TV_GRANT) - Logical
LPCN: 0075; TS: 2; LPCN+TS: 0152; Target: 16518173 - Source: 16533625
```
Use channel 75 in your import file, which would correspond to dsdplus channels 151 and 152 (151 = TS1 / 152 = TS2).
For Connect Plus, enumerate your list from 1 to the last channel and add the frequency. For Capacity Plus, LSN 1 and 2 will share the same frequency, 3 and 4 will share, 5 and 6 will share, and 7-8 will share, as Capacity Plus counts each 'channel' as two seperate channels (LSN), one for each time slot. Capacity Plus Quirk: DSD-FME makes its best effort to follow the rest channel in the event that the sync is lost for longer than the hangtime, but occassionally, DSD-FME may lose the rest channel and will have to hunt through all frequencies to find it again.
Trunking Note4: NXDN Trunking v1 will require a channel map. Please see the example folder for an appropriate channel map. NOTICE: NXDN trunking has been fixed on the RTL (rtl_fm) input method and works correctly now using a soft squelch value to determine when to look for frame sync. Tests show this works very well, but squelch adjustments may be required to differentiate the noise floor from the signal.
NXDN Trunking Update: NXDN DFA (Direct Frequency Assignment) has been coded from the v2 documents, so using a channel map may not be required, as long as the DFA is configured with standard values, and not 'system definable' values. This will only work on trunking systems that use DFA (newer systems) in accordance to the v2 CAI document NXDN TS 1-A Version 2.0 September 2016. If the system uses 'system definable' values, then make sure to put the channels in a channel map csv file as as the 16-bit OFN values for proper tuning.
NXDN Type-D/IDAS Update: Type-D or IDAS decoding/trunking has been coded now and tested on a small two channel system. Set up a channel map much like Type-C trunking. If preferred, insert channel 31 at the top of your channel map for the 'home repeater' or go to channel of choice during a TX_REL or DISC message. Extensive testing of Type-D has not been conducted. Some cavaets may currently include iffy per call wav file saving and potentially shifting SRC and TGT ID values due to how SCCH messages are handled and how Busy Repeater Messages are handled. Private calls will need to be enabled by enabling 'data calls', if desired. During testing, only data calls came on private calls, so this was set to disabled by default, but can be enabled with data calls enabled. Also, note that some home repeater channels may or may not carry calls from all systems.
Channel Map and Group CSV Note: Leave the top line of the channel_map.csv and group.csv as the label, do not delete the line, if no line is there, dsd_import skips the first line so it will not import the first channel or first group in those files if there is something there that isn't a label.
Hytera XPT: Code has been added for XPT system slco/flco/csbk decoding and trunking. The setup will be similar to Capacity Plus trunking in the csv file, listing each LSN channel to a frequency (see examples/hytera_xpt_chan.csv). Currently, this set up is working with smaller XPT systems that I have been able to test with.
## NCurses Keyboard Shortcuts ##
Some Keyboard Shortcuts have been implemented for testing to see how users like them. Just hope nobody pushes a key on accident and doesn't know which one it was or what it does. The current list of keyboard shortcuts include:
```
esc or arrow keys - ncurses menu
q - quit
c - toggle compact mode
h - cycle event history short, long, or off
z - toggle console payloads
a - toggle call alert beep
4 - force privacy/scrambler key assertion over enc identifiers (dmr and nxdn)
6 - force rc4 key assertion over missing pi header/le enc identifiers (dmr)
i - toggle signal inversion on types that can't auto detect (dmr, dpmr)
m - toggle c4fm/qpsk 10/4 (everything but phase 2 signal)
M - toggle c4fm/qpsk 8/3 (phase 2 tdma control channel)
R - start capturing symbol capture bin (date/time name file)
r - stop capturing symbol capture bin
spacebar - replay last symbol capture bin (captures must be stopped first)
s - stop playing symbol capture bin or wav input file (lower s)
P - start per call decoded wav files (Capital P)
p - stop per call decoded wav files (lower p)
t - toggle trunking (needs either rtl input, or rigctl connection)
y - toggle scanner (needs either rtl input, or rigctl connection)
1 - Toggle Voice Synthesis in TDMA Slot 1 or FDMA Conventional Voice
2 - Toggle Voice Synthesis in TDMA Slot 2
w - Toggle Trunking/Playback White List (Allow A Groups Only) / Black List (Block B or DE groups only) Mode
g - Toggle Trunking Tuning to Group Calls (DMR T3, Con+, Cap+, P25, NXDN)
u - Toggle Trunking Tuning to Private Calls (DMR T3, Cap+, P25)
d - Toggle Trunking Tuning to Data Calls (DMR T3, NXDN)
e - Toggle Trunking Tuning to Encrypted Calls (P25)
8 - Connect to SDR++ TCP Audio Sink with Defaults/Retry Sink Connection on Disconnect
9 - Connect to SDR++ RIGCTL Server with Defaults/Retry RIGCTL Connection
D - Reset DMR Site Parms/Call Strings, etc.
Z - Simulate NoCarrier/No VC/CC sync (capital Z)
! - Lockout Tuning/Playback of TG in Slot 1 or Conventional -- Current Session Only if no group.csv file specified
@ - Lockout Tuning/Playback of TG in Slot 2 -- Current Session Only if no group.csv file specified
k - Hold TG in Slot 1 or Conventional, or clear current hold
l - Hold TG in Slot 2 on TDMA Systems, or clear current hold
C - Drop Call and Return to CC during trunking operation
L - Manual Cycle Forward Channel Tuned when RIGCTL or using RTL input and channel csv loaded
S - Toggle between EDACS Standard/Network and Extended Addressing mode (Capital S)
A - Toggle EDACS ESK Mask (none vs A0)
H - Toggle High Pass Filter on Digital Sythesized Voice
V - Toggle Low Pass Filter on Analog Voice or Raw Signal Monitoring
B - Toggle High Pass Filter on Analog Voice or Raw Signal Monitoring
N - Toggle Passband Filter on Analog Voice or Raw Signal Monitoring
[ - Scroll backwards through Event History
] - Scroll forwards through Event History
\ - Switch between Slot 1 and Slot 2 Event History
v - Cycle RTL Input Volume Multiplier 1X, 2X, 3X (lower v)
```
## Sending Audio to a Icecast 2 Server via FFmpeg (Windows)
Make sure to enable "Stereo Mix" from Volume Control Panel and then disable Windows Sounds.
```
ffmpeg -f dshow -i audio="Stereo Mix (Realtek High Definition Audio)" -c:a aac -b:a 64k -content_type 'audio/aac' -vn -f adts icecast://source:password@192.168.5.251:8844/DSDFME
```
## Sending Audio to a Icecast 2 Server via FFmpeg (Linux w/ Pulse Audio)
`pactl list short sources`
Choose Desired Device to Cast:
```
0 auto_null.monitor module-null-sink.c s16le 2ch 48000Hz IDLE
1 alsa_output.pci-0000_0d_00.3.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING
2 alsa_input.pci-0000_0d_00.3.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
3 virtual_sink.monitor module-null-sink.c s16le 2ch 44100Hz RUNNING
4 virtual_sink2.monitor module-null-sink.c s16le 2ch 44100Hz RUNNING
7 alsa_output.pci-0000_0b_00.1.hdmi-stereo-extra1.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING
```
Example:
```
francis@12cores:~$ pactl list short sources
0 auto_null.monitor module-null-sink.c s16le 2ch 48000Hz IDLE
francis@12coresx:~$ ffmpeg -f pulse -i 0 -c:a libmp3lame -ab 64k -f mp3 icecast://source:password@XXXXXXXXX:8000
```
Note: Do not run this command for ffmpeg/icecast piped to the main dsd-fme command, make sure these are running in seperate terminals.
## Sending Audio to UDP Target/Port
Audio can be sent to a target address on your local area network with the UDP blaster using the `-o udp:targetaddress:port` option.
Note: Any analog audio monitoring will not function properly over UDP port (rate difference issues)
Example (Short 8k/2):
`dsd-fme -fs -o udp:192.168.7.8:23470`
Receiving End (Short 8k/2):
`socat stdio udp-listen:23470 | play --buffer 640 -q -b 16 -r 8000 -c2 -t s16 -`
Example (Short 8k/1):
`dsd-fme -f1 -o udp:192.168.7.8:23469`
Receiving End (Short 8k/1):
`socat stdio udp-listen:23469 | play --buffer 320 -q -b 16 -r 8000 -c1 -t s16 -`
Example (Float 8k/2):
`dsd-fme -ft -y -o udp:192.168.7.8:23468`
Receiving End (Float 8k/2):
`socat stdio udp-listen:23468 | play --buffer 1280 -q -b 16 -r 8000 -c2 -t f32 -`
Example (Float 8k/1):
`dsd-fme -fi -y -o udp:192.168.7.8:23467`
Receiving End (Float 8k/1):
`socat stdio udp-listen:23467 | play --buffer 640 -q -b 16 -r 8000 -c1 -t f32 -`
Note: --buffer option in play is calculated by (channels * samples * sizeof(samples)),
where samples is 160 for mono, 320 for stereo, and short samples are 2 and float samples are 4.
This is vital to prevent 'lag' or cut-off audio when the UDP audio doesn't fill the default buffer size.
Note2: Be sure to start the receiving end AFTER starting DSD-FME. If DSD-FME is restarted, make sure to restart the receiving end as well, as socat/UDP closes the UDP port listening when DSD-FME closes the UDP socket.
Note3: socat version 1.8 may have a `E xioopen_ipdgram_listen(): unknown address family 0` problem, downgrading to 1.7.4 is recommended if this occurs. `sudo downgrade socat`.
## Record 48k/1 audio with rtl_fm
You can record suitable audio to feed as input to dsd-fme with `-i` using rtl_fm:
`rtl_fm -M nfm -f [FREQ] -s 48k -g 42 -l 20 > input.wav`
You can also combine that with `socat` to send the audio to a remote dsd-fme instance in real time while keeping a local copy on the host where the RTL-SDR dongle is:
`rtl_fm -M fm -f [FREQ] -s 48k -g 42 -l 20 | tee input.wav | socat -u - TCP-LISTEN:1234,forever,reuseaddr`
On the remote side where dsd-fme is, use the TCP input:
`dsd-fme -i tcp:192.168.7.8:1234 -N`
Note: As always, when using rtl_fm, play with `-l` and `-g` to find a good squelch and gain values for your environment - you will know if the squelch is the right value when `input.wav` does not increase in size in the absence of useful signal on the monitored frequency.
## Using the Experimental M17 Encoder (and Decoder)
You can use the experimental M17 Voice Stream and Packet encoder with the following examples.
Encode/Decode Local Feedback Voice Stream (Single Session):
`dsd-fme -fZ -i pulse -o pulse -M M17:3:SP5WWP:BROADCAST:48000`
Using the `-8` option (raw audio monitor) will instead send encoded raw audio to output instead of decoded audio. For example,
To send a voice stream out of stdout into SOCAT TCP to a second/remote DSD-FME session to decode:
Encode (Upper Z):
`dsd-fme -fZ -8 -i pulse -M M17:9:LWVMOBILE:DSD-FME:48000 -o - | socat stdio tcp-listen:7355,forever,reuseaddr`
Decode (Lower z):
`dsd-fme -fz -i tcp:192.168.7.8:7355`
NOTE: When using tcp input for M17 decoding, DSD-FME will keep the TCP connection alive with constant retries, so no need to restart the decoding session on connection failure.
SMS Packet Encoder (Text Only):
`dsd-fme -fP -8 -S "This is a sample message sent over M17 Packet Data using DSD-FME to encode it."`
SMS Packet Encoder (over SOCAT TCP):
`dsd-fme -fP -8 -S "This is a sample message sent over M17 Packet Data using DSD-FME to encode it and SOCAT to send it over TCP." -o - | socat stdio tcp-listen:7355,forever,reuseaddr`
Many combinations of input and output can be used as well, and using features like raw audio saving with `-6 m17str.wav` will save a wav file of your encoded audio to be replayed later with `-i m17str.wav`
Also note, features function similarly, like -Z for payload, and input options include pulse, oss, stdin, rtl, tcp, etc, using those as the mic in for voice encoding. With the right setup of input/output/input using SOCAT TCP pipes, it is conceivable to use DSD-FME to convert analog audio from NFM into M17 audio, or even change another digital format supported by DSD-FME into M17 audio, if desired (purely for research and fun purposes). Ncurses terminal will function with internal encoder/decoder and wav file creation, with toggle encode/tx with `\` key, but will not function with stdout properly.
The `-M` switch is used to specify user M17 variables, the string is in the format of M17:CAN:SRC:DST:INPUT_RATE.
CAN 1-15; SRC and DST have to be no more than 9 UPPER base40 characters.
BASE40: ' ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/.'
Input Rate Default is 48000; Use Multiples of 8000 up to 48000.
Values not entered into the M17: string are set to default values. M17:7:DSD-FME:DSD-FME:48000
Fun Example Transmuting OTA Analog Things into M17:
Start up in sequence.
Terminal #1 (RTL Input):
`dsd-fme -fZ -8 -M M17:1:ANALOG:M17:48000 -i rtl:0:162.425M -o - | socat stdio tcp-listen:7310,forever,reuseaddr`
Terminal #2:
`dsd-fme -fz -i tcp:127.0.0.1:7310`
Fun Example Transmuting OTA Digital Things into M17:
Start up all three of these in sequence.
Terminal #1 (connecting to SDR++):
`dsd-fme -fi -i tcp:127.0.0.1:7355 -o - | socat stdio tcp-listen:7300,forever,reuseaddr`
Terminal #2:
`dsd-fme -fZ -8 -M M17:2:NXDN:M17:8000 -i tcp:127.0.0.1:7300 -o - | socat stdio tcp-listen:7301,forever,reuseaddr`
Terminal #3:
`dsd-fme -fz -i tcp:127.0.0.1:7301`
Note: Transmuting only carries over voice when audio is output, and will not carry any ID values, or any other data payloads.
This mode is only meant for educational or fun purposes, please do not retransmit stuff that doesn't belong to you.
Information on this section will be updated as features are added or modified, etc. If you need help with a particular function and can't find a suitable answer, always open a new issue here, or make contact on the radio reference forum for additional examples, guidance, ideas, help, etc.

204
examples/Install_Notes.md Normal file
View File

@@ -0,0 +1,204 @@
## How to clone and build this branch
### Ubuntu 22.04/20.04/LM20/Debian Bullseye:
Using the included download-and-install.sh should make for a simple and painless clone, build, and install on newer Debian/Ubuntu/Mint/Pi systems. Simply acquire or copy the script, and run it. Update: Ubuntu 23.04 and RPi Bullseye 64-bit has been tested working with the installer script and functions appropriately.
If you need all dependencies build and installed first (only on Debian/Ubuntu/Mint/Pi), run:
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/audio_work/download-and-install.sh
sh download-and-install.sh
```
### Debian 12 (SID) / Ubuntu 24.04 LTS (Updated Ncurses Dependencies)
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/audio_work/download-and-install-ubuntu2404lts.sh
sh download-and-install-ubuntu2404lts.sh
```
### Arch Based Distros:
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/audio_work/download-and-install-Arch.sh
sh download-and-install-Arch.sh
```
### Other:
If you have dependencies already installed, please run this instead:
```
wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/audio_work/download-and-install-nodeps.sh
sh download-and-install-nodeps.sh
```
## Manual Install
First, install dependency packages. This guide will assume you are using Debian/Ubuntu based distros. Check your package manager for equivalent packages if different.
Debian/Mint/Ubuntu/Pi
```
sudo apt update
#Ubuntu 22.04 lts / Debian 11 and lower
sudo apt install libpulse-dev pavucontrol libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libcodec2-dev
#Ubuntu 24.04 lts / Debian 12
#sudo apt install libpulse-dev pavucontrol libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncurses-dev libncurses6 libcodec2-dev
```
Fedora 36/37 -- from https://github.com/lwvmobile/dsd-fme/issues/99
```
sudo dnf update
sudo dnf install libsndfile-devel fftw-devel lapack-devel rtl-sdr-devel pulseaudio-libs-devel libusb-devel cmake git ncurses ncurses-devel gcc wget pavucontrol gcc-c++ codec2-devel
```
Arch -- https://github.com/lwvmobile/dsd-fme/issues/153 and https://github.com/lwvmobile/dsd-fme/issues/153
```
sudo pacman -Syu
sudo pacman -S libpulse cmake ncurses lapack perl fftw rtl-sdr codec2 base-devel libsndfile git wget rtl-sdr
wget https://mirror.archstrike.org/x86_64/archstrike/itpp-4.3.1-3-x86_64.pkg.tar.xz
sudo pacman -U itpp-4.3.1-3-x86_64.pkg.tar.xz
```
## Headless Ubuntu Server/Pi
If running headless, swap out pavucontrol for pulsemixer, and also install pulseaudio as well. Attempting to install pavucontrol in a headless environment may attempt to install a minimal desktop environment. Note: Default behavior of pulseaudio in a headless environment may be to be muted, so check by opening pulsemixer and unmuting and routing audio appropriately.
```
sudo apt install libpulse-dev libsndfile1-dev libfftw3-dev liblapack-dev socat libusb-1.0-0-dev libncurses5 libncurses5-dev rtl-sdr librtlsdr-dev libusb-1.0-0-dev cmake git wget make build-essential libitpp-dev libncursesw5-dev pulsemixer pulseaudio libcodec2-dev
```
### Build and Install ITPP - ONLY IF NOT IN REPO!!
```
wget -O itpp-latest.tar.bz2 http://sourceforge.net/projects/itpp/files/latest/download?source=files
tar xjf itpp*
#if you can't cd into this folder, double check folder name first
cd itpp-4.3.1
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
```
MBELib is considered a requirement in this build. You must read this notice prior to continuing. [MBElib Patent Notice](https://github.com/lwvmobile/mbelib#readme "MBElib Patent Notice")
```
git clone https://github.com/lwvmobile/mbelib
git checkout ambe_tones
cd mbelib
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
cd ..
```
Finish by running these steps to clone and build DSD-FME.
```
git clone https://github.com/lwvmobile/dsd-fme
cd dsd-fme
mkdir build
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
```
### LD_PATH
Some environments may require an LD path to be set to /usr/local/lib, similar to:
```
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
```
### Windows Cygwin Builds
Cygwin builds now have an experimental semi-automatic installer, to run, follow steps below:
Open Windows PowerShell (not Command Prompt) and copy and paste all of this in all at once.
```
Invoke-WebRequest https://cygwin.com/setup-x86_64.exe -OutFile setup-x86_64.exe
.\setup-x86_64.exe --packages nano,libpulse-devel,libpulse-mainloop-glib0,libpulse-simple0,libpulse0,pulseaudio,pulseaudio-debuginfo,pulseaudio-equalizer,pulseaudio-module-x11,pulseaudio-module-zeroconf,pulseaudio-utils,sox-fmt-pulseaudio,libusb0,libusb1.0,libusb1.0-debuginfo,libusb1.0-devel,libncurses++w10,libncurses-devel,libncursesw10,ncurses,cmake,gcc-core,gcc-debuginfo,gcc-objc,git,make,socat,sox,sox-fmt-ao,zip,unzip,wget,gcc-g++,libsndfile-devel
```
Pick a Mirror. http://www.gtlib.gatech.edu mirror seems relatively fast. Nurse the Cygwin installer by clicking next and waiting for it to finish. Ignore the warning popup telling you to install libusb from sourceforge. Install the [Zadig](https://zadig.akeo.ie/ "Zadig") driver instead, if you haven't already and have an RTL Dongle. After Cygwin finishes installing, the installer sh script will download and run, be patient, it may also take a little while.
Then:
```
C:\cygwin64\bin\mintty.exe /bin/bash -l -c "wget https://raw.githubusercontent.com/lwvmobile/dsd-fme/refs/heads/audio_work/download-and-install-cygwin.sh; sh download-and-install-cygwin.sh; dsd-fme;"
```
After the sh script finishes, dsd-fme should open. If not, then double click on the Cygwin Terminal desktop shortcut, and try running `dsd-fme`. If you chose to create a portable version, you will find the folder and zip file in the `C:\cygwin64\home\username` directory if using the default cygwin64 folder location.
You can also update your versions by using the cyg_rebuild.sh script `sh cyg_rebuild.sh`.
### Virtual Sinks
You may wish to direct sound into DSD-FME via Virtual Sinks. You may set up a Virtual Sink or two on your machine for routing audio in and out of applications to other applications using the following command, and opening up pavucontrol "PulseAudio Volume Control" in the menu (or `pulsemixer` in headless mode) to change line out of application to virtual sink, and line in of DSD-FME to monitor of virtual sink. This command will not persist past a reboot, so you will need to invoke them each time you reboot, or search for how to add this to your conf files for persistency if desired. Note: This setup is completely optional if using TCP Network Sink Audio and/or RTL Input. You may need to manually install either of these programs manually, if desired, or find suitable alternatives for pipewire-pulse such as pwvucontrol, or similar.
```
pactl load-module module-null-sink sink_name=virtual_sink sink_properties=device.description=Virtual_Sink
pactl load-module module-null-sink sink_name=virtual_sink2 sink_properties=device.description=Virtual_Sink2
```
Already have this branch, and just want to pull the latest build? You can run the rebuild.sh file in the dsd-fme folder, or manually do the pull with the commands:
```
##Open your clone folder##
git pull
##cd into your build folder##
cd build
cmake ..
make -j `nproc`
sudo make install
sudo ldconfig
```
### Applying Patches -- Recommended For Advanced Users Only
More experimental or potentially functionality changing or temperamental features may be included as seperate .patch files inside of the patch folder, and are not included in the source code by default.
If users wish to try or use these patches, then they can apply patches and build/rebuild with the following procedure. Make sure you have changed to the dsd-fme directory first, either by the top
command, or by otherwise opening the terminal to the clone folder.
```
cd dsd-fme
git apply patch/patchname.patch
cd build
make
sudo make install
```
If you later wish to update to the latest version via `git pull`, you may first need to reset any patches, perform the `git pull`, and then reapply patches.
A procedure for this is similar to, but not limited to:
```
cd dsd-fme
git reset --hard
git pull
git apply patch/xyz.patch
cd build
make
sudo make install
```
NOTE: Patches can potential break over time with further changes to code, requiring merge resolution or other manual intervention to re-apply patches.

View File

@@ -0,0 +1,10 @@
LSN(dec),frequency(Hz) (do not delete this line or won't import properly)
1,858606250
2,858606250
3,859606250
4,859606250
5,860606250
6,860606250
7,861606250
8,861606250
1 LSN(dec) frequency(Hz) (do not delete this line or won't import properly)
2 1 858606250
3 2 858606250
4 3 859606250
5 4 859606250
6 5 860606250
7 6 860606250
8 7 861606250
9 8 861606250

View File

@@ -0,0 +1,19 @@
ChannelNumber(dec),frequency(Hz) (do not delete this line or won't import properly)
999,862093750,default cc (come here first), optional use non-existent channel as first entry
1,863093750
2,862093750
3,861093750
4,860093750
5,859093750
6,863593750
7,862593750
8,861593750
9,860593750
10,859593750
11,863393750
12,862393750
13,861393750
14,860393750
15,859393750
1 ChannelNumber(dec),frequency(Hz) (do not delete this line or won't import properly)
2 999,862093750,default cc (come here first), optional use non-existent channel as first entry
3 1,863093750
4 2,862093750
5 3,861093750
6 4,860093750
7 5,859093750
8 6,863593750
9 7,862593750
10 8,861593750
11 9,860593750
12 10,859593750
13 11,863393750
14 12,862393750
15 13,861393750
16 14,860393750
17 15,859393750

View File

@@ -0,0 +1,14 @@
@REM Shutdown pulseaudio and clean out any remenants in /dev/shm if left behind
cd dsd-fme
pactl.exe exit
@REM now navigate to the /dev/shm folder and automatically remove any
@REM remnants from other times pulse wasn't shut down properly
cd ..
cd dev
cd shm
del pulse*
PAUSE

View File

@@ -0,0 +1,34 @@
@REM Set the console / terminal to 90 columns, 50 lines
@REM mode con: cols=90 lines=50
@ECHO OFF
@REM change directory into the dsd-fme folder
cd dsd-fme
@REM Start the Pulse Audio backend with a 10 minute time out
@REM start pulse audio server with 600 second idle time and no CPU limit (prevent closing while idle in menu)
@REM output from pulse server routed to NUL to supress "capabilities dropped, nag messages, etc" messages
pulseaudio.exe --start --no-cpu-limit=TRUE --exit-idle-time=600 2> NUL
@REM End pulse start up
ECHO The Pulse Audio Server should now be active!
@REM Setup Some null-sinks (if desired, remove @REM below)
@REM pactl load-module module-null-sink sink_name=virtual_sink1 sink_properties=device.description=Virtual_Sink1
@REM pactl load-module module-null-sink sink_name=virtual_sink2 sink_properties=device.description=Virtual_Sink2
@REM Setup Default Sink to device 0 (output)
pactl set-default-sink 0
@REM List Avaiable Pulse Audio Sinks and Sources
@ECHO ON
dsd-fme -O
PAUSE

View File

@@ -0,0 +1,231 @@
Build Version: AW 2025-182-g24c1dd9
MBElib Version: 1.3.4
CODEC2 Support Enabled
Usage: dsd-fme [options] Decoder/Trunking Mode
or: dsd-fme [options] -r <files> Read/Play saved mbe data from file(s)
or: dsd-fme -h Show help
Display Options:
-N Use NCurses Terminal
dsd-fme -N 2> console_log.txt
-Z Log MBE/PDU Payloads to console
Device Options:
-O List All Pulse Audio Input Sources and Output Sinks (devices).
Input/Output options:
-i <device> Audio input device (default is pulse)
/dev/dsp for OSS audio (Depreciated: Will require padsp wrapper in Linux)
pulse for pulse audio signal input
pulse:6 or pulse:virtual_sink2.monitor for pulse audio signal input on virtual_sink2 (see -O)
rtl for rtl dongle (Default Values -- see below)
rtl:dev:freq:gain:ppm:bw:sq:vol for rtl dongle (see below)
tcp for tcp client SDR++/GNURadio Companion/Other (Port 7355)
tcp:192.168.7.5:7355 for custom address and port
m17udp for M17 UDP/IP socket bind input (default host 127.0.0.1; default port 17000)
m17udp:192.168.7.8:17001 for M17 UDP/IP bind input (Binding Address and Port
filename.bin for OP25/FME capture bin files
filename.wav for 48K/1 wav files (SDR++, GQRX)
filename.wav -s 96000 for 96K/1 wav files (DSDPlus)
(Use single quotes '/directory/audio file.wav' when directories/spaces are present)
-s <rate> Sample Rate of wav input files (48000 or 96000) Mono only!
-o <device> Audio output device (default is pulse)
/dev/dsp for OSS audio (Depreciated: Will require padsp wrapper in Linux)
pulse for pulse audio decoded voice or analog output
pulse:1 or pulse:alsa_output.pci-0000_0d_00.3.analog-stereo for pulse audio decoded voice or analog output on device (see -O)
null for no audio output
udp for UDP socket blaster output (default host 127.0.0.1; default port 23456)
udp:192.168.7.8:23470 for UDP socket blaster output (Target Address and Port
m17udp for M17 UDP/IP socket blaster output (default host 127.0.0.1; default port 17000)
m17udp:192.168.7.8:17001 for M17 UDP/IP blaster output (Target Address and Port
-d <dir> Create mbe data files, use this directory (TDMA version is experimental)
-r <files> Read/Play saved mbe data from file(s)
-g <float> Audio Digital Output Gain (Default: 0 = Auto; )
(Manual: 1 = 2%; 50 = 100%)
-n <float> Audio Analog Output Gain (Default: 0 = Auto; 0-100% )
-6 <file> Output raw audio .wav file (48K/1). (WARNING! Large File Sizes 1 Hour ~= 360 MB)
-7 <dir> Create/Use Custom directory for Per Call decoded .wav file saving.
(Use ./folder for Nested Directory!)
(Use /path/to/folder for hard coded directory!)
(Use Before the -P option!)
-8 Enable Source Audio Monitor
(Set Squelch in RTL, SDR++ or GQRX, etc, if monitoring mixed analog/digital)
-w <file> Output synthesized speech to a single static .wav file. (Do not use with -P Per Call Switch)
-P Enable Per Call WAV file saving. (Do not use with -w filename.wav single wav file switch)
(Per Call works with everything now and doesn't require ncurses terminal!)
-a Enable Call Alert Beep
(Warning! Might be annoying.)
-J <file> Specify Filename for Event Log Output.
-L <file> Specify Filename for LRRP Data Output.
-Q <file> Specify Filename for OK-DMRlib Structured File Output. (placed in DSP folder)
-Q <file> Specify Filename for M17 Float Stream Output. (placed in DSP folder)
-c <file> Output symbol capture to .bin file
-q Reverse Mute - Mute Unencrypted Voice and Unmute Encrypted Voice
-V <num> Enable TDMA Voice Synthesis on Slot 1 (1), Slot 2 (2), or Both (3); Default is 3;
-z Set TDMA Voice Slot Preference when using /dev/dsp audio output (prevent lag and stuttering)
-y Enable Experimental Pulse Audio Float Audio Output
-v <hex> Set Filtering Bitmap Options (Advanced Option)
1 1 1 1 (0xF): PBF/LPF/HPF/HPFD on
RTL-SDR options:
Usage: rtl:dev:freq:gain:ppm:bw:sq:vol
NOTE: all arguments after rtl are optional now for trunking, but user configuration is recommended
dev <num> RTL-SDR Device Index Number or 8 Digit Serial Number, no strings! (default 0)
freq <num> RTL-SDR Frequency (851800000 or 851.8M)
gain <num> RTL-SDR Device Gain (0-49)(default = 0; Hardware AGC recommended)
ppm <num> RTL-SDR PPM Error (default = 0)
bw <num> RTL-SDR Bandwidth kHz (default = 12)(4, 6, 8, 12, 16, 24)
sq <num> RTL-SDR Squelch Level vs RMS Value (Optional)
vol <num> RTL-SDR Sample 'Volume' Multiplier (default = 2)(1,2,3)
Example: dsd-fme -fs -i rtl -C cap_plus_channel.csv -T
Example: dsd-fme -fp -i rtl:0:851.375M:22:-2:24:0:2
Encoder options:
-fZ M17 Stream Voice Encoder
Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i pulse -6 m17signal.wav -8 -N 2> m17encoderlog.txt
Run M17 Encoding, listening to pulse audio server, with internal decode/playback and output to 48k/1 wav file
Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i tcp -o pulse -8 -N 2> m17encoderlog.txt
Run M17 Encoding, listening to default tcp input, without internal decode/playback and output to 48k/1 analog output device
-fP M17 Packet Encoder
Example: dsd-fme -fP -M M17:9:DSD-FME:LWVMOBILE -6 m17pkt.wav -8 -S 'Hello World'
-fB M17 BERT Encoder
Example: dsd-fme -fB -M M17:9:DSD-FME:LWVMOBILE -6 m17bert.wav -8
-M M17 Encoding User Configuration String: M17:CAN:SRC:DST:INPUT_RATE:VOX (see examples above).
CAN 1-15; SRC and DST have to be no more than 9 UPPER base40 characters.
BASE40: ' ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/.'
Input Rate Default is 48000; Use Multiples of 8000 up to 48000.
VOX Enabled on 1; (Default = 0)
Values not entered into the M17: string are set to default values.
Decoder options:
-fa Auto Detection
-fA Passive Analog Audio Monitor
-ft TDMA Trunking P25p1 Control and Voice, P25p2 Trunked Channels, and DMR
-fs DMR TDMA BS and MS Simplex
-f1 Decode only P25 Phase 1
-f2 Decode only P25 Phase 2 (6000 sps) **
-fd Decode only DSTAR
-fx Decode only X2-TDMA
-fy Decode only YSF
-fz Decode only M17*
-fU Decode only M17 UDP/IP Frame***
-fi Decode only NXDN48* (6.25 kHz) / IDAS*
-fn Decode only NXDN96* (12.5 kHz)
-fp Decode only ProVoice*
-fh Decode only EDACS Standard/ProVoice*
-fH Decode only EDACS Standard/ProVoice with ESK 0xA0*
-fh344 Decode only EDACS Standard/ProVoice and set AFS to 344 or similar custom 11-bit scheme*
-fH434 Decode only EDACS Standard/ProVoice and set AFS to custom 11-bit scheme with ESK 0xA0*
-fe Decode only EDACS EA/ProVoice*
-fE Decode only EDACS EA/ProVoice with ESK 0xA0*
-fm Decode only dPMR*
-l Disable DMR, dPMR, NXDN, M17 input filtering
-u <num> Unvoiced speech quality (default=3)
-xx Expect non-inverted X2-TDMA signal
-xr Expect inverted DMR signal
-xd Expect inverted ICOM dPMR signal
-xz Expect inverted M17 signal
* denotes frame types that cannot be auto-detected.
** Phase 2 Single Frequency may require user to manually set WACN/SYSID/CC parameters if MAC_SIGNAL not present.
*** configure UDP Input with -i m17:127.0.0.1:17000
Advanced Decoder options:
-X <hex> Manually Set P2 Parameters (WACN, SYSID, CC/NAC)
(-X BEE00ABC123)
-D <dec> Manually Set TIII DMR Location Area n bit len (0-10)(10 max)
(Value defaults to max n bit value for site model size)
(Setting 0 will show full Site ID, no area/subarea)
-ma Auto-select modulation optimizations
-mc Use only C4FM modulation optimizations (default)
-mg Use only GFSK modulation optimizations
-mq Use only QPSK modulation optimizations
-m2 Use P25p2 6000 sps QPSK modulation optimizations
-F Relax P25 Phase 2 MAC_SIGNAL CRC Checksum Pass/Fail
Use this feature to allow MAC_SIGNAL even if CRC errors.
-F Relax DMR RAS/CRC CSBK/DATA Pass/Fail
Enabling on some systems could lead to bad channel assignments/site data decoding if bad or marginal signal
-F Relax M17 LSF/PKT CRC Error Checking
-b <dec> Manually Enter Basic Privacy Key (Decimal Value of Key Number)
(NOTE: This used to be the 'K' option!
-H <hex> Manually Enter Hytera 10/32/64 Char Basic Privacy Hex Key (see example below)
Encapulate in Single Quotation Marks; Space every 16 chars.
-H 0B57935150
-H '736B9A9C5645288B 243AD5CB8701EF8A'
-H '20029736A5D91042 C923EB0697484433 005EFC58A1905195 E28E9C7836AA2DB8'
-H <hex> Manually Enter AES-128 or AES-256 Hex Key (see example below)
Encapulate in Single Quotation Marks; Space every 16 chars.
-H '736B9A9C5645288B 243AD5CB8701EF8A'
-H '20029736A5D91042 C923EB0697484433 005EFC58A1905195 E28E9C7836AA2DB8'
-R <dec> Manually Enter dPMR or NXDN EHR Scrambler Key Value (Decimal Value)
-1 <hex> Manually Enter RC4 or DES Key Value (DMR, P25, NXDN) (Hex Value)
-2 <hex> Manually Enter and Enforce TYT 16-bit BP Key Value (DMR) (Hex Value)
-! <hex> Manually Enter and Enforce TYT Advanced Privacy (PC4) AP Hex Key (see example below)
Encapulate in Single Quotation Marks; Space every 16 chars.
-! '736B9A9C5645288B 243AD5CB8701EF8A'
-5 <hex> Manually Enter and Enforce TYT Enhanced Privacy (AES-128) EP Hex Key (see example below)
Encapulate in Single Quotation Marks; Space every 16 chars.
-5 '736B9A9C5645288B 243AD5CB8701EF8A'
-9 <dec> Manually Enter and Enforce Kenwood 15-bit Scrambler Key Value (DMR) (Dec Value)
-A <hex> Manually Enter and Enforce Anytone 16-bit BP Key Value (DMR) (Hex Value)
-S <str> Manually Enter and Enforce Generic Static Keystream -> Length and BYTE PACKED / ALIGNED String for AMBE (up to 882 bits)
For Example, enter 16-bit Keystream 0909 as:
-S 16:0909
For Example, enter 49-bit Keystream as:
-S 49:123456789ABC80
For Example, enter 49-bit Keystream (MBP 70) as:
-S 49:ED0AED4AED4AED4A
-k <file> Import Key List from csv file (Decimal Format) -- Lower Case 'k'.
Only supports NXDN, DMR Basic Privacy (decimal value).
(dPMR and Hytera 32/64 char not supported, DMR uses TG value as key id -- EXPERIMENTAL!!).
-K <file> Import Key List from csv file (Hexidecimal Format) -- Capital 'K'.
Use for Hex Value Hytera 10-char BP keys, RC4 10-char, DES 16-char Hex Keys, and AES128/256 32/64-char keys.
-4 Force Privacy Key over Encryption Identifiers (DMR MBP/HBP and NXDN Scrambler)
-0 Force RC4 Key over Missing PI header/LE Encryption Identifiers (DMR)
-3 Disable DMR Late Entry Encryption Identifiers (VC6 Single Burst)
Note: Disable this if false positives on Voice ENC occur.
Trunking Options:
-C <file> Import Channel to Frequency Map (channum, freq) from csv file. (Capital C)
(See channel_map.csv for example)
-G <file> Import Group List Allow/Block and Label from csv file.
(See group.csv for example)
-T Enable Trunking Features (NXDN/P25/EDACS/DMR) with RIGCTL/TCP or RTL Input
-Y Enable Scanning Mode with RIGCTL/TCP or RTL Input
Experimental -- Can only scan for sync with enabled decoders, don't mix NXDN and DMR/P25!
This is not a Trunking Feature, just scans through conventional frequencies fast!
-W Use Imported Group List as a Trunking Allow/White List -- Only Tune with Mode A
-p Disable Tune to Private Calls (DMR TIII, P25, NXDN Type-C and Type-D)
-E Disable Tune to Group Calls (DMR TIII, Con+, Cap+, P25, NXDN Type-C, and Type-D)
-e Enable Tune to Data Calls (DMR TIII, Cap+, NXDN Type-C)
(NOTE: No Clear Distinction between Cap+ Private Voice Calls and Data Calls -- Both enabled with Data Calls
-I <dec> Specify TG to Hold During Trunking (DMR, P25, NXDN Type-C Trunking)
-U <port> Enable RIGCTL/TCP; Set TCP Port for RIGCTL. (4532 on SDR++)
-B <Hertz> Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF)
P25 - 12000; NXDN48 - 7000; NXDN96: 12000; DMR - 7000-12000; EDACS/PV - 12000-24000;
May vary based on system stregnth, etc.
-t <secs> Set Trunking or Scan Speed VC/sync loss hangtime in seconds. (default = 1 second)
Trunking Example TCP: dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.txt
Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8 -T -C connect_plus_chan.csv -G group.csv -N 2> log.txt

View File

@@ -0,0 +1,97 @@
This example options contains numerous options put into the start-dsd-fme.bat file in the option string
feel free to experiment and mix and match example options for your bat files option string.
Trunking Option Examples:
P25 (Phase 1 Control) Trunking with SDR++ Network Sink input, RIGCTL, /dev/dsp output,
per call wav files, ncurses terminal
-ft -i tcp:127.0.0.1:7355 -U 4532 -T -P -N
P25 (Phase 2 Control) Trunking with SDR++ Network Sink input, RIGCTL, /dev/dsp output,
per call wav files, ncurses terminal
-f2 -i tcp:127.0.0.1:7355 -U 4532 -T -P -N
DMR Trunking with RTL input, /dev/dsp output, channel map import,
per call wav files, ncurses terminal, payload dump to console
-fs -i rtl:0:450M:0:-2:12 -T -C examples\dmr_t3_chan.csv -P -N -Z
DMR Trunking with SDR++ input, RIGCTL, /dev/dsp output, RAS enabled CSBK (-F),
channel map import, per call wav files, ncurses terminal, payload dump to console
-fs -F -i tcp -U 4532 -T -C examples\capacity_plus_chan.csv -P -N -Z
NXDN48 v2.0 DFA (Direct Frequency Assignment) Trunking with SDR++ input, RIGCTL, /dev/dsp output,
scrambler key import (decimal), per call wav files, ncurses terminal, payload dump to console
-fi -i tcp -U 4532 -T -P -N -Z -k examples\nxdn_sc_key.csv
NXDN96 Trunking with SDR++ input, RIGCTL, /dev/dsp output,
channel map import, per call wav files, ncurses terminal, payload dump to console
-fn -i tcp -U 4532 -T -C examples\nxdn_chan_map.csv -P -N -Z
EDACS Standard Network Analog and Digital
-fh -i tcp -U 4532 -T -C edacs_channel_map.csv -G group.csv -N
-fh -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N
EDACS Extended Address Analog and Digital (with ESK)
-fE -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N
-fE -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N
Scanning Option Examples:
Scanning will not perform quickly like a real scanner, but can be used with any
supported decoding type and analog as well, and will require a channel_map to scan frequencies
channel numbers do not matter, but use unique ones for each frequeny
-t 0 will scan as fast as possible, but may miss frame sync, -t 1 is stable, but needs 1 second between tuning
P25/DMR/Analog Scanning with RTL input, /dev/dsp output, channel map import,
per call wav files, ncurses terminal, payload dump to console, raw audio signal monitoring
-ft -i rtl:0:450M:0:-2:12 -Y -t 1 -C examples\dmr_t3_chan.csv -P -8 -N -Z
P25/DMR/Analog Scanning with SDR++ input (use squelch), RIGCTL, /dev/dsp output, channel map import,
per call wav files, ncurses terminal, payload dump to console, raw audio signal monitoring
-ft -i tcp:127.0.0.1:7355 -U 4532 -Y -t 1 -C examples\dmr_t3_chan.csv -P -8 -N -Z
NXDN48/Analog Scanning with SDR++ input (use squelch), RIGCTL, /dev/dsp output, channel map import,
per call wav files, ncurses terminal, payload dump to console, raw audio signal monitoring
-fi -i tcp:127.0.0.1:7355 -U 4532 -Y -t 1-C examples\nxdn_chan_map.csv -P -8 -N -Z
Analog Scanning with SDR++ input (use squelch), RIGCTL, /dev/dsp output, channel map import
-fA -i tcp:127.0.0.1:7355 -U 4532 -Y -t 0 -C examples\nxdn_chan_map.csv -8
Encryption Option Examples:
DMR with default /dev/dsp input and output, use basic privacy key 70
-fs -b 70
DMR with default /dev/dsp input and output, load .csv file with decimal basic privacy keys loaded by TG value,
-fs -k examples\multi_key.csv
DMR with default /dev/dsp input and output, use Hytera basic privacy key (10, 32, and 64 hex char versions)
-fs -H 1111111111
-fs -H '2222222222222222 3333333333333333'
-fs -H '2222222222222222 3333333333333333 4444444444444444 5555555555555555'
DMR with default /dev/dsp input and output, use RC4 key 0x7777777777
-fs -1 7777777777
DMR with default /dev/dsp input and output, use RC4 key 0x7777777777,
Force RC4 Key over Missing PI header/LE Encryption Identifiers (-0)
Disable Late Entry Encryption Signalling Identifiers (-3)
-fs -0 -3 -1 7777777777
DMR with default /dev/dsp input and output, load RC4 and 10-char HBP keys from .csv file (hexidecimal format)
-fs -K dsd-fme\examples\multi_key_hex.csv
P25 with default /dev/dsp input and output, use RC4 key 0x7777777777
-ft -1 7777777777
NXDN48 with default /dev/dsp input and output, use Scrambler key 32767
-fi -R 32767
NXDN96 with default /dev/dsp input and output, use Scrambler key 15000
-fn -R 15000
dPMR with default /dev/dsp input and output, use Scrambler key 32767
-fm -R 32767
NXDN48 with default /dev/dsp input and output, load scrambler keys from .csv file (decimal format)
-fi -k dsd-fme\examples\nxdn_sc_key.csv

View File

@@ -0,0 +1 @@
These .bat files are ONLY for use on the portable cygwin builds, do not use these in any other build environments!

View File

@@ -0,0 +1,74 @@
@REM Digital Speech Decoder: Florida Man Edition
@REM DSD-FME Cygwin Windows Portable Builds
@REM
@REM The source code of this software can be downloaded here:
@REM https://github.com/lwvmobile/dsd-fme
@REM
@REM If you paid for, or were otherwise fleeced for this software, DEMAND YOUR MONEY BACK!
@REM
@REM This software is designed to be used with an SDR receiver (like SDR++ or SDR#) with TCP input,
@REM RTL Input, media file playback over virtual cables or null-sinks, or a Discriminator Tap input
@REM
@REM The complete options list can be seen by viewing complete_usage_options.txt
@REM Many examples can be found in example_options.txt
@REM
@REM Enjoy!
@REM Regarding the options string (or any string in .bat files)
@REM If your string may contain spaces, set the first '"' before options, and then an ending '"'
@REM Incorrect: set options="-fs -N -Z"
@REM Correct: set "options=-fs -N -Z"
@REM set options to pass to dsd-fme
set "options= -N -Z "
@REM Set Date Time for log (sourced from: https://stackoverflow.com/questions/1192476/format-date-and-time-in-a-windows-batch-script)
@echo off
REM "%date: =0%" replaces spaces with zeros
set d=%date: =0%
REM "set yyyy=%d:~-4%" pulls the last 4 characters
set yyyy=%d:~-4%
set mm=%d:~4,2%
set dd=%d:~7,2%
set dow=%d:~0,3%
set d=%yyyy%%mm%%dd%
set t=%TIME: =0%
REM "%t::=%" removes semi-colons
REM Instead of above, you could use "%t::=-%" to
REM replace semi-colons with hyphens (or any
REM non-special character)
set t=%t::=%
set t=%t:.=%
set datetimestr=%d%_%t%
@REM @echo Long date time str = %datetimestr%
@REM random number is used so that two log files don't share the same name
set rnd=%RANDOM%
@REM set log file relative filepath
set "clog=.\logs\console_log_%datetimestr%_%rnd%.txt"
set "elog=.\logs\event_log_%datetimestr%_%rnd%.txt"
@REM create the log file now with touch
.\dsd-fme\touch.exe %clog%
.\dsd-fme\touch.exe %elog%
@REM Launch Tail to display the console log and event log in a seperate console windows
start .\dsd-fme\tail.exe -n 40 -f %clog%
start .\dsd-fme\tail.exe -n 40 -f %elog%
@REM start dsd-fme with options and logs
.\dsd-fme\dsd-fme.exe %options% -J %elog% 2> %clog%
echo ----------------------------------------------------------------------------------
echo ----------------------------------------------------------------------------------
echo For any errors, see: %clog%
echo Forward %clog% and Options: "%options%"
echo to developer on Github or Radio Reference for troubleshooting.
echo ----------------------------------------------------------------------------------
echo ----------------------------------------------------------------------------------
@REM Set pause to diplay above message
PAUSE

8
examples/dmr_t3_chan.csv Normal file
View File

@@ -0,0 +1,8 @@
ChannelNumber(dec),frequency(Hz) (do not delete this line or won't import properly)
999,456318750,default cc (come here first), optional use non-existent channel as first entry
36,455756250
54,455981250
81,456318750
1 ChannelNumber(dec),frequency(Hz) (do not delete this line or won't import properly)
2 999,456318750,default cc (come here first), optional use non-existent channel as first entry
3 36,455756250
4 54,455981250
5 81,456318750

View File

@@ -0,0 +1,6 @@
LSN(dec),frequency(Hz) (do not delete this line or won't import properly)
1,851375000
2,851800000
3,855987500
4,858487500
5,852312500
1 LSN(dec) frequency(Hz) (do not delete this line or won't import properly)
2 1 851375000
3 2 851800000
4 3 855987500
5 4 858487500
6 5 852312500

View File

@@ -0,0 +1,7 @@
keyid(hex), keyvalue(hex)
0001,0000000000000000,0000000000000000,0000000000000000,0000002823d87923
0003,0101010101010101,0101010101010101
0004,0101010101010101,0101010101010101,0101010101010101,0101010101010101
C197,A753BC945DE5E0F1,EC1970F8565154E6,D9DF2FAC6278FA93,B531D2CC046E93A2
0067,0000000000000000,0000000000000000,0000000000000000,DEADBEEFBAADF00D
0000,0000000000000000,0000000000000000,0000000000000000,0000000000000001
1 keyid(hex), keyvalue(hex)
2 0001,0000000000000000,0000000000000000,0000000000000000,0000002823d87923
3 0003,0101010101010101,0101010101010101
4 0004,0101010101010101,0101010101010101,0101010101010101,0101010101010101
5 C197,A753BC945DE5E0F1,EC1970F8565154E6,D9DF2FAC6278FA93,B531D2CC046E93A2
6 0067,0000000000000000,0000000000000000,0000000000000000,DEADBEEFBAADF00D
7 0000,0000000000000000,0000000000000000,0000000000000000,0000000000000001

5
examples/group.csv Normal file
View File

@@ -0,0 +1,5 @@
DEC,Mode(A- Allow; B - Block; DE - Digital Enc),Name of Group,Tag (do not delete this line or won't import properly)
100,B,Example Name,Tag
1449,A,Fire Dispatch,Fire
929,A,Fire Tac,Fire
22033,DE,Law Dispatch,Law
1 DEC Mode(A- Allow; B - Block; DE - Digital Enc) Name of Group Tag (do not delete this line or won't import properly)
2 100 B Example Name Tag
3 1449 A Fire Dispatch Fire
4 929 A Fire Tac Fire
5 22033 DE Law Dispatch Law

View File

@@ -0,0 +1,10 @@
LSN(dec),frequency(Hz) (do not delete this line or won't import properly)
1,858606250
2,858606250
3,859606250
4,859606250
5,860606250
6,860606250
7,861606250
8,861606250
1 LSN(dec) frequency(Hz) (do not delete this line or won't import properly)
2 1 858606250
3 2 858606250
4 3 859606250
5 4 859606250
6 5 860606250
7 6 860606250
8 7 861606250
9 8 861606250

6
examples/multi_key.csv Normal file
View File

@@ -0,0 +1,6 @@
key id or tg id (dec), key number or value (dec) //NXDN Scrambler, BP, 10-char Hytera BP only
2,70
1,123
100,70
12,48713912656
672560,254
1 key id or tg id (dec), key number or value (dec) //NXDN Scrambler, BP, 10-char Hytera BP only
2 2,70
3 1,123
4 100,70
5 12,48713912656
6 672560,254

View File

@@ -0,0 +1,5 @@
key id(hex), key value (hex) //10-char Hytera BP, RC4
1,1234567890
2,ABCDEF1234
C,0B57935150
64,0B57935150
1 key id(hex), key value (hex) //10-char Hytera BP, RC4
2 1,1234567890
3 2,ABCDEF1234
4 C,0B57935150
5 64,0B57935150

View File

@@ -0,0 +1,8 @@
channel(dec), freq(Hz)
141,423862500
142,424337500
143,424912500
203,424100000
204,424625000
271,422650000
302,423287500
1 channel(dec) freq(Hz)
2 141 423862500
3 142 424337500
4 143 424912500
5 203 424100000
6 204 424625000
7 271 422650000
8 302 423287500

5
examples/nxdn_sc_key.csv Normal file
View File

@@ -0,0 +1,5 @@
key(dec) or tg(dec), value(dec), load any single keys as key 0
0,23466
1,12345
2,32700
63,32767
1 key(dec) or tg(dec), value(dec), load any single keys as key 0
2 0,23466
3 1,12345
4 2,32700
5 63,32767

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@@ -0,0 +1,112 @@
#!/bin/bash
# Force bash for better compatibility (I think)
#
# Digital Speech Decoder: Florida Man Edition
#
# The source code of this software can be downloaded here:
# https://github.com/lwvmobile/dsd-fme
#
# If you paid for, or were otherwise fleeced for this software, DEMAND YOUR MONEY BACK!
#
# This software is designed to be used with an SDR receiver (like SDR++ or SDR#) with TCP input,
# RTL Input, media file playback over virtual cables or null-sinks, or a Discriminator Tap input
#
# The complete options list can be seen by viewing complete_usage_options.ans
# Many examples can be found in example_options.ans
#
# Enjoy!
###
#### IMPORTANT! Set your dsd-fme options here! ####
# Example : opts=' -ft -i rtl:0:460.350M:0:-1:8 -N -Z '
####
# set options to pass to dsd-fme
opts=' -N -Z '
####
# Initialize variables
xe="0"
gt="0"
xt="0"
ko="0"
# Functions to check for available terminals
chk_xe(){
# Check if x-terminal-emulator is installed
xe=$(which x-terminal-emulator 2>/dev/null)
if [ -z $xe ];then xe="0";else xe="1";fi
}
chk_gt(){
# Check if gnome-terminal is installed
gt=$(which gnome-terminal 2>/dev/null)
if [ -z $gt ];then gt="0";else gt="1";fi
}
chk_ko(){
# Check if Konsole is installed
ko=$(which konsole 2>/dev/null)
if [ -z $ko ];then ko="0";else ko="1";fi
}
chk_xt(){
# Check if xterm is installed
xt=$(which xterm 2>/dev/null)
if [ -z $xt ];then xt="0";else xt="1";fi
}
# Check for and set terminal
chk_xe
if [ $xe = "1" ];then
term=$(which x-terminal-emulator 2>/dev/null)
printf "Using X-Terminal-Emulator!\n"
else
chk_gt
fi
if [ $gt = "1" ];then
term=$(which gnome-terminal 2>/dev/null)
printf "Using Gnome-Terminal!\n"
elif [ $xe = "0" ]&&[ $gt = "0" ];then
chk_xt
fi
if [ $xt = "1" ];then
term=$(which xterm 2>/dev/null)
printf "Using XTerm!\n"
elif [ $xe = "0" ]&&[ $gt = "0" ]&&[ $xt = "0" ];then
chk_ko
fi
if [ $ko = "1" ];then
term=$(which konsole 2>/dev/null)
printf "Using Konsole!\n"
fi
# Bail if no terminal found
if [ "$ko" -eq "0" ]&&[ "$gt" -eq "0" ]&&[ "$xt" -eq "0" ]&&[ "$xe" -eq "0" ];then printf "No known terminals available!\n";exit 1;fi
# Get current directory
wd=$(pwd)
# Set date/time
# dt=$(date +%F_%H%M-%S-%N) #with hyphens
dt=$(date +%Y%m%d_%H%M%S) #just an underscore between date and time
if [ ! -d "logs" ]; then
mkdir logs
fi
# set log file relative filepath
clog="$wd/logs/console_log_$dt.txt"
elog="$wd/logs/event_log_$dt.txt"
# create the log file now with touch
touch $clog
touch $elog
# open new terminal windows to watch live log files
if [ "$term" == "$(which konsole)" ]||[ "$term" == "$(which xterm)" ];then
$term -e "tail -n 40 -f $clog" 2>/dev/null
$term -e "tail -n 40 -f $elog" 2>/dev/null
else
$term --window -e "tail -n 40 -f $clog" 2>/dev/null
$term --window -e "tail -n 40 -f $elog" 2>/dev/null
fi
# start dsd-fme with options and log files
dsd-fme $opts -J $elog 2> $clog
echo -------------------------------------------------------------------------------
echo -------------------------------------------------------------------------------
echo For any errors, see: $clog
echo Forward $clog and
echo Options: \" $opts \"
echo to developer on Github or Radio Reference for troubleshooting.
echo -------------------------------------------------------------------------------
echo -------------------------------------------------------------------------------
# Set pause to diplay above message
read -p "Press ENTER to continue... " x

57
examples/trunking.sh Normal file
View File

@@ -0,0 +1,57 @@
#example trunking sh scripts (SDR++ with RIGCTL and RTL Input)
#make sure to put a # in front of all lines except the one you wish to use
#P25 P1 FDMA CC with C4FM
#dsd-fme -i tcp -U 4532 -T -N 2> log.ans
#dsd-fme -i rtl:0:850M:0:-2:12 -T -N 2> log.ans
#P25 P1 FDMA CC with QPSK (Simulcast)
#dsd-fme -i tcp:192.168.7.8:7355 -U 4532 -T -mq -N 2> log.ans
#dsd-fme -i rtl:0:855.625M:0:-2:12 -T -mq -N 2> log.ans
#P25 P2 TDMA CC with C4FM
#dsd-fme -i tcp:192.168.7.8:7355 -U 4532 -T -f2 -N 2> log.ans
#dsd-fme -i rtl:0:855.625M:0:-2:12 -T -f2 -m2 -N 2> log.ans
#DMR TIII, Con+, Cap+, XPT
dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans
#dsd-fme -fs -i rtl:0:450M:44:-2:8 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans
#EDACS Standard Network Analog and Digital
#dsd-fme -fh -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#dsd-fme -fh -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#EDACS Standard Network Analog and Digital (with ESK)
#dsd-fme -fH -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#dsd-fme -fH -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#EDACS Extended Address Analog and Digital
#dsd-fme -fe -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#dsd-fme -fe -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#EDACS Extended Address Analog and Digital (with ESK)
#dsd-fme -fE -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#dsd-fme -fE -i rtl:0:850M:44:-2:24 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
#NXDN48 Type-C or Type-D Trunking with Channel Map
#dsd-fme -fi -i tcp -T -U 4532 -C nxdn_channel_map.csv -N 2> log.ans
#dsd-fme -fi -i rtl:0:855.625M:0:-2:12:100 -T -C nxdn_channel_map.csv -N 2> log.ans
#NXDN48 Type-C Trunking with DFA
#dsd-fme -fi -i tcp -T -U 4532 -N 2> log.ans
#dsd-fme -fi -i rtl:0:855.625M:0:-2:12:100 -T -N 2> log.ans
#NXDN96 Trunking with Channel Map
#dsd-fme -fn -i tcp -T -U 4532 -C nxdn_channel_map.csv -N 2> log.ans
#dsd-fme -fn -i rtl -T -C nxdn_channel_map.csv -N 2> log.ans
#Notes: parameters after -i tcp can be omitted if using localhost as the default hostname to connect
#and 7355 as the default port number. -U is the port number for RIGCTL and will mirror the tcp hostname
#running under the assumption that the user will be connnecting the VFO to the same instance of SDR++
#You can also specify an ip address to connect to a remote SDR++ instance, make sure that the settings
#inside of SDR++ match, i.e., change in SDR++ from 'localhost' to an IP to bind to (machine's IP address)
#Note2: RTL input should only be used on strong signal, the SDR++ VFO will perform much better on marginal signal
#paramters after -i rtl can also be omitted now if using the default configurations
#Having a -G group.csv is purely optional, but useful if you want to block groups, or give groups names

64
flake.lock generated Normal file
View File

@@ -0,0 +1,64 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1709336216,
"narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711163522,
"narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1709237383,
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

18
flake.nix Normal file
View File

@@ -0,0 +1,18 @@
{
description = "Digital Speech Decoder - Florida Man Edition ";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, pkgs, ... }: {
packages.default = config.packages.dsd-fme;
packages.dsd-fme = pkgs.callPackage ./package.nix { };
};
};
}

71
include/bp.h Normal file
View File

@@ -0,0 +1,71 @@
#ifndef BP_H
#define BP_H
static const uint16_t BPK[256] = {
//000
0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903,
//008
0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306,
//016
0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B,
//024
0x6C1D, 0x731D, 0x8F1D, 0x901D, 0x491E, 0x561E, 0xAA1E, 0xB51E,
//032
0x4B28, 0x5428, 0xA828, 0xB728, 0x6E2B, 0x712B, 0x8D2B, 0x922B,
//040
0x012D, 0x1E2D, 0xE22D, 0xFD2D, 0x242E, 0x3B2E, 0xC72E, 0xD82E,
//048
0x6D30, 0x7230, 0x8E30, 0x9130, 0x4833, 0x5733, 0xAB33, 0xB433,
//056
0x2735, 0x3835, 0xC435, 0xDB35, 0x0236, 0x1D36, 0xE136, 0xFE36,
//064
0x2B49, 0x3449, 0xC849, 0xD749, 0x0E4A, 0x114A, 0xED4A, 0xF24A,
//072
0x614C, 0x7E4C, 0x824C, 0x9D4C, 0x444F, 0x5B4F, 0xA74F, 0xB84F,
//080
0x0D51, 0x1251, 0xEE51, 0xF151, 0x2852, 0x3752, 0xCB52, 0xD452,
//088
0x4754, 0x5854, 0xA454, 0xBB54, 0x6257, 0x7D57, 0x8157, 0x9E57,
//096
0x6061, 0x7F61, 0x8361, 0x9C61, 0x4562, 0x5A62, 0xA662, 0xB962,
//104
0x2A64, 0x3564, 0xC964, 0xD664, 0x0F67, 0x1067, 0xEC67, 0xF367,
//112
0x4679, 0x5979, 0xA579, 0xBA79, 0x637A, 0x7C7A, 0x807A, 0x9F7A,
//120
0x0C7C, 0x137C, 0xEF7C, 0xF07C, 0x297F, 0x367F, 0xCA7F, 0xD57F,
//128
0x4D89, 0x5289, 0xAE89, 0xB189, 0x688A, 0x778A, 0x8B8A, 0x948A,
//136
0x078C, 0x188C, 0xE48C, 0xFB8C, 0x228F, 0x3D8F, 0xC18F, 0xDE8F,
//144
0x6B91, 0x7491, 0x8891, 0x9791, 0x4E92, 0x5192, 0xAD92, 0xB292,
//152
0x2194, 0x3E94, 0xC294, 0xDD94, 0x0497, 0x1B97, 0xE797, 0xF897,
//160
0x06A1, 0x19A1, 0xE5A1, 0xFAA1, 0x23A2, 0x3CA2, 0xC0A2, 0xDFA2,
//168
0x4CA4, 0x53A4, 0xAFA4, 0xB0A4, 0x69A7, 0x76A7, 0x8AA7, 0x95A7,
//176
0x20B9, 0x3FB9, 0xC3B9, 0xDCB9, 0x05BA, 0x1ABA, 0xE6BA, 0xF9BA,
//184
0x6ABC, 0x75BC, 0x89BC, 0x96BC, 0x4FBF, 0x50BF, 0xACBF, 0xB3BF,
//192
0x66C0, 0x79C0, 0x85C0, 0x9AC0, 0x43C3, 0x5CC3, 0xA0C3, 0xBFC3,
//200
0x2CC5, 0x33C5, 0xCFC5, 0xD0C5, 0x09C6, 0x16C6, 0xEAC6, 0xF5C6,
//208
0x84D0, 0x85DF, 0x8AD3, 0x8BDC, 0xB6D5, 0xB7DA, 0xB8D6, 0xB9D9,
//216
0xD0DA, 0xD1D5, 0xDED9, 0xDFD6, 0xE2DF, 0xE3D0, 0xECDC, 0xEDD3,
//224
0x2DE8, 0x32E8, 0xCEE8, 0xD1E8, 0x08EB, 0x17EB, 0xEBEB, 0xF4EB,
//232
0x67ED, 0x78ED, 0x84ED, 0x9BED, 0x42EE, 0x5DEE, 0xA1EE, 0xBEEE,
//240
0x0BF0, 0x14F0, 0xE8F0, 0xF7F0, 0x2EF3, 0x31F3, 0xCDF3, 0xD2F3,
//248
0x41F5, 0x5EF5, 0xA2F5, 0xBDF5, 0x64F6, 0x7BF6, 0x87F6, 0x98F6
};
#endif

View File

@@ -17,7 +17,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// This code was originally written by JOnathan Naylor, G4KLX, as part
// of the "pcrepeatercontroller" project
// More info:
@@ -52,39 +52,39 @@ int traceBack (int * out, int * m_pathMemory0, int * m_pathMemory1, int * m_path
state = S2; // lower path
} else {
state = S0; // upper path
}; // end else - if
} // end else - if
out[loop]=0;
break;
case S1: // if state S1
if (m_pathMemory1[loop]) {
state = S2; // lower path
} else {
state = S0; // upper path
}; // end else - if
} // end else - if
out[loop]=1;
break;
case S2: // if state S2
if (m_pathMemory2[loop]) {
state = S3; // lower path
} else {
state = S1; // upper path
}; // end else - if
} // end else - if
out[loop]=0;
break;
case S3: // if state S3
if (m_pathMemory3[loop]) {
state = S3; // lower path
} else {
state = S1; // upper path
}; // end else - if
} // end else - if
out[loop]=1;
break;
}; // end switch
}; // end for
} // end switch
} // end for
return(length);
}; // end function
@@ -161,7 +161,7 @@ void viterbiDecode (int n, int *data, int *m_pathMemory0, int *m_pathMemory1, in
}; // end function ViterbiDecode
// function FECdecoder
// function FECdecoder
// returns outlen
int FECdecoder (int * in, int * out) {
int outLen;

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
*/
/*
* dstar interleave experiments
* dstar interleave experiments
*/
#ifndef _MAIN

View File

@@ -1,6 +1,6 @@
/* fcs.h */
// Viterbi decoder using Traceback method.
// Viterbi decoder using Traceback method.
// Original Source was written by Sho Tamaoki and Tom Wada
// See http://www.lsi.ie.u-ryukyu.ac.jp/~sho/midterm/
@@ -75,7 +75,7 @@ for (loop=0; loop < size; loop++) {
m_crc = (m_crc >> 8) ^ ccittTab[tmp];
}; // end for
} // end for
// calculate and save crc-value in fields 54 and 55 of dvframe
m_crc = ~m_crc;
@@ -86,4 +86,4 @@ m_crc = (m_crc << 8) | (tmp >> 8 & 0xFF);
// done
return(m_crc);
}; // end function
}; // end function

File diff suppressed because it is too large Load Diff

View File

@@ -1,62 +0,0 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* NXDN AMBE interleave schedule
*/
#ifndef _MAIN
extern const int nW[36];
extern const int nX[36];
extern const int nY[36];
extern const int nZ[36];
#else
const int nW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int nX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int nY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int nZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
#endif

View File

@@ -1,257 +1,82 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MAIN
extern const int nW[36];
extern const int nX[36];
extern const int nY[36];
extern const int nZ[36];
extern const char nxdnpr[145];
extern const char nxdnpr2[145]; //why is this 145 but referenced later as 182 or 384
//borrow from LEH
extern const unsigned char nsW[72];
extern const int DSDNXDN_SACCH_m_Interleave[60];
extern const int DSDNXDN_SACCH_m_PunctureList[12];
extern const int DSDNXDN_FACCH1_m_Interleave[144];
extern const int DSDNXDN_FACCH1_m_PunctureList[48];
extern const int DSDNXDN_UDCH_m_Interleave[348];
extern const int DSDNXDN_UDCH_m_PunctureList[58];
// Portions Below from Osmocom OP25
// NXDN Encoder (C) Copyright 2019 Max H. Parke KA1RBI
// thx gr-ysf fr_vch_decoder_bb_impl.cc * Copyright 2015 Mathias Weyland *
// OP25 is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
//enum
//{
#define NXDN_VCALL 0b000001 /* VCALL = VCALL_REQ = VCALL_RESP */
#define NXDN_VCALL_IV 0b000011
#define NXDN_DCALL_HDR 0b001001 /* Header Format - NXDN_DCALL_HDR = NXDN_DCALL_REQ = NXDN_DCALL_RESP */
#define NXDN_DCALL_USR 0b001011 /* User Data Format */
#define NXDN_DCALL_ACK 0b001100
#define NXDN_REL_EX 0b000111
#define NXDN_HEAD_DLY 0b001111
#define NXDN_SDCALL_REQ_HDR 0b111000 /* Header Format */
#define NXDN_SDCALL_REQ_USR 0b111001 /* User Data Format */
#define NXDN_SDCALL_RESP 0b111011
#define NXDN_SDCALL_IV 0b111010
#define NXDN_STAT_INQ_REQ 0b110000
#define NXDN_STAT_INQ_RESP 0b110001
#define NXDN_STAT_REQ 0b110010
#define NXDN_STAT_RESP 0b110011
#define NXDN_REM_CON_REQ 0b110100
#define NXDN_REM_CON_RESP 0b110101
#define NXDN_REM_CON_E_REQ 0b110110
#define NXDN_REM_CON_E_RESP 0b110111
//NXDN_VCALL_REQ = 0b000001, /* VCALL = VCALL_REQ = VCALL_RESP */
//NXDN_VCALL_RESP = 0b000001, /* VCALL = VCALL_REQ = VCALL_RESP */
#define NXDN_VCALL_REC_REQ = 0b000010 /* NXDN_VCALL_REC_REQ = NXDN_VCALL_REC_RESP */
//NXDN_VCALL_REC_RESP = 0b000010,
#define NXDN_VCALL_CONN_REQ = 0b000011 /* NXDN_VCALL_CONN_REQ = NXDN_VCALL_CONN_RESP */
//NXDN_VCALL_CONN_RESP = 0b000011, /* NXDN_VCALL_CONN_REQ = NXDN_VCALL_CONN_RESP */
#define NXDN_VCALL_ASSGN_DUP = 0b000101
//NXDN_DCALL_REQ = 0b001001, /* NXDN_DCALL_HDR = NXDN_DCALL_REQ = NXDN_DCALL_RESP */
//NXDN_DCALL_RESP = 0b001001, /* NXDN_DCALL_HDR = NXDN_DCALL_REQ = NXDN_DCALL_RESP */
#define NXDN_DCALL_REC_REQ = 0b001010 /* NXDN_DCALL_REC_REQ = NXDN_DCALL_REC_RESP */
//NXDN_DCALL_REC_RESP = 0b001010, /* NXDN_DCALL_REC_REQ = NXDN_DCALL_REC_RESP */
#define NXDN_DCALL_ASSGN = 0b001110
#define NXDN_DCALL_ASSGN_DUP = 0b001101
#define NXDN_IDLE 0b010000
#define NXDN_DISC_REQ = 0b010001 /* NXDN_DISC_REQ = NXDN_DISC */
#define NXDN_DISC = 0b010001 /* NXDN_DISC_REQ = NXDN_DISC */
// OP25 is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with OP25; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Boston, MA
// 02110-1301, USA.
#else
/*
* pseudorandom bit sequence
*/
const char nxdnpr[145] = { 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1 };
//const unsigned char nxdnpr2[384] =
const unsigned char nxdnpr2[182] = //generated from default in manual with the x^9+x^4+1 poly?
{
0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0,
1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0,
0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1,
1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1,
0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1,
1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1,
1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1,
1, 1, 0, 0, 0, 1//, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1,
// 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0,
// 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0,
// 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
// 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1,
// 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0,
// 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1,
// 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1,
// 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
// 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0,
// 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0,
// 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
// 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1
};
/*
* NXDN AMBE interleave schedule
*/
const int nW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
static const uint8_t PERM_12_5[] = {
0,12,24,36,48,
1,13,25,37,49,
2,14,26,38,50,
3,15,27,39,51,
4,16,28,40,52,
5,17,29,41,53,
6,18,30,42,54,
7,19,31,43,55,
8,20,32,44,56,
9,21,33,45,57,
10,22,34,46,58,
11,23,35,47,59
};
const int nX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
static const uint8_t PERM_16_9[] = {
0, 16, 32, 48, 64, 80, 96, 112, 128,
1, 17, 33, 49, 65, 81, 97, 113, 129,
2, 18, 34, 50, 66, 82, 98, 114, 130,
3, 19, 35, 51, 67, 83, 99, 115, 131,
4, 20, 36, 52, 68, 84, 100, 116, 132,
5, 21, 37, 53, 69, 85, 101, 117, 133,
6, 22, 38, 54, 70, 86, 102, 118, 134,
7, 23, 39, 55, 71, 87, 103, 119, 135,
8, 24, 40, 56, 72, 88, 104, 120, 136,
9, 25, 41, 57, 73, 89, 105, 121, 137,
10, 26, 42, 58, 74, 90, 106, 122, 138,
11, 27, 43, 59, 75, 91, 107, 123, 139,
12, 28, 44, 60, 76, 92, 108, 124, 140,
13, 29, 45, 61, 77, 93, 109, 125, 141,
14, 30, 46, 62, 78, 94, 110, 126, 142,
15, 31, 47, 63, 79, 95, 111, 127, 143
};
const int nY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
static const uint16_t PERM_12_25[] = {
0,12,24,36,48,60,72,84,96,108,120,132,144,156,168,180,192,204,216,228,240,252,264,276,288,
1,13,25,37,49,61,73,85,97,109,121,133,145,157,169,181,193,205,217,229,241,253,265,277,289,
2,14,26,38,50,62,74,86,98,110,122,134,146,158,170,182,194,206,218,230,242,254,266,278,290,
3,15,27,39,51,63,75,87,99,111,123,135,147,159,171,183,195,207,219,231,243,255,267,279,291,
4,16,28,40,52,64,76,88,100,112,124,136,148,160,172,184,196,208,220,232,244,256,268,280,292,
5,17,29,41,53,65,77,89,101,113,125,137,149,161,173,185,197,209,221,233,245,257,269,281,293,
6,18,30,42,54,66,78,90,102,114,126,138,150,162,174,186,198,210,222,234,246,258,270,282,294,
7,19,31,43,55,67,79,91,103,115,127,139,151,163,175,187,199,211,223,235,247,259,271,283,295,
8,20,32,44,56,68,80,92,104,116,128,140,152,164,176,188,200,212,224,236,248,260,272,284,296,
9,21,33,45,57,69,81,93,105,117,129,141,153,165,177,189,201,213,225,237,249,261,273,285,297,
10,22,34,46,58,70,82,94,106,118,130,142,154,166,178,190,202,214,226,238,250,262,274,286,298,
11,23,35,47,59,71,83,95,107,119,131,143,155,167,179,191,203,215,227,239,251,263,275,287,299
};
const int nZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
static const uint16_t PERM_12_29[] = {
0,12,24,36,48,60,72,84,96,108,120,132,144,156,168,180,192,204,216,228,240,252,264,276,288,300,312,324,336,
1,13,25,37,49,61,73,85,97,109,121,133,145,157,169,181,193,205,217,229,241,253,265,277,289,301,313,325,337,
2,14,26,38,50,62,74,86,98,110,122,134,146,158,170,182,194,206,218,230,242,254,266,278,290,302,314,326,338,
3,15,27,39,51,63,75,87,99,111,123,135,147,159,171,183,195,207,219,231,243,255,267,279,291,303,315,327,339,
4,16,28,40,52,64,76,88,100,112,124,136,148,160,172,184,196,208,220,232,244,256,268,280,292,304,316,328,340,
5,17,29,41,53,65,77,89,101,113,125,137,149,161,173,185,197,209,221,233,245,257,269,281,293,305,317,329,341,
6,18,30,42,54,66,78,90,102,114,126,138,150,162,174,186,198,210,222,234,246,258,270,282,294,306,318,330,342,
7,19,31,43,55,67,79,91,103,115,127,139,151,163,175,187,199,211,223,235,247,259,271,283,295,307,319,331,343,
8,20,32,44,56,68,80,92,104,116,128,140,152,164,176,188,200,212,224,236,248,260,272,284,296,308,320,332,344,
9,21,33,45,57,69,81,93,105,117,129,141,153,165,177,189,201,213,225,237,249,261,273,285,297,309,321,333,345,
10,22,34,46,58,70,82,94,106,118,130,142,154,166,178,190,202,214,226,238,250,262,274,286,298,310,322,334,346,
11,23,35,47,59,71,83,95,107,119,131,143,155,167,179,191,203,215,227,239,251,263,275,287,299,311,323,335,347
};
/*
* NXDN SACCH interleave
*/
const unsigned char nsW[72] = {
0, 12, 24, 36, 48, 60,
1, 13, 25, 37, 49, 61,
2, 14, 26, 38, 50, 62,
3, 15, 27, 39, 51, 63,
4, 16, 28, 40, 52, 64,
5, 17, 29, 41, 53, 65,
6, 18, 30, 42, 54, 66,
7, 19, 31, 43, 55, 67,
8, 20, 32, 44, 56, 68,
9, 21, 33, 45, 57, 69,
10,22, 34, 46, 58, 70,
11,23, 35, 47, 59, 71
};
const int DSDNXDN_SACCH_m_Interleave[60] =
{
0, 12, 24, 36, 48,
1, 13, 25, 37, 49,
2, 14, 26, 38, 50,
3, 15, 27, 39, 51,
4, 16, 28, 40, 52,
5, 17, 29, 41, 53,
6, 18, 30, 42, 54,
7, 19, 31, 43, 55,
8, 20, 32, 44, 56,
9, 21, 33, 45, 57,
10, 22, 34, 46, 58,
11, 23, 35, 47, 59,
};
const int DSDNXDN_SACCH_m_PunctureList[12] = { 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71 };
const unsigned int DSDNXDN_FACCH1_m_Interleave[144] =
{
0, 16, 32, 48, 64, 80, 96, 112, 128,
1, 17, 33, 49, 65, 81, 97, 113, 129,
2, 18, 34, 50, 66, 82, 98, 114, 130,
3, 19, 35, 51, 67, 83, 99, 115, 131,
4, 20, 36, 52, 68, 84, 100, 116, 132,
5, 21, 37, 53, 69, 85, 101, 117, 133,
6, 22, 38, 54, 70, 86, 102, 118, 134,
7, 23, 39, 55, 71, 87, 103, 119, 135,
8, 24, 40, 56, 72, 88, 104, 120, 136,
9, 25, 41, 57, 73, 89, 105, 121, 137,
10, 26, 42, 58, 74, 90, 106, 122, 138,
11, 27, 43, 59, 75, 91, 107, 123, 139,
12, 28, 44, 60, 76, 92, 108, 124, 140,
13, 29, 45, 61, 77, 93, 109, 125, 141,
14, 30, 46, 62, 78, 94, 110, 126, 142,
15, 31, 47, 63, 79, 95, 111, 127, 143,
};
const unsigned int DSDNXDN_FACCH1_m_PunctureList[48] =
{
1U, 5U, 9U, 13U, 17U, 21U, 25U, 29U, 33U, 37U,
41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, 73U, 77U,
81U, 85U, 89U, 93U, 97U, 101U, 105U, 109U, 113U, 117U,
121U, 125U, 129U, 133U, 137U, 141U, 145U, 149U, 153U, 157U,
161U, 165U, 169U, 173U, 177U, 181U, 185U, 189U
};
const int DSDNXDN_UDCH_m_Interleave[348] = {
0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336,
1, 13, 25, 37, 49, 61, 73, 85, 97, 109, 121, 133, 145, 157, 169, 181, 193, 205, 217, 229, 241, 253, 265, 277, 289, 301, 313, 325, 337,
2, 14, 26, 38, 50, 62, 74, 86, 98, 110, 122, 134, 146, 158, 170, 182, 194, 206, 218, 230, 242, 254, 266, 278, 290, 302, 314, 326, 338,
3, 15, 27, 39, 51, 63, 75, 87, 99, 111, 123, 135, 147, 159, 171, 183, 195, 207, 219, 231, 243, 255, 267, 279, 291, 303, 315, 327, 339,
4, 16, 28, 40, 52, 64, 76, 88, 100, 112, 124, 136, 148, 160, 172, 184, 196, 208, 220, 232, 244, 256, 268, 280, 292, 304, 316, 328, 340,
5, 17, 29, 41, 53, 65, 77, 89, 101, 113, 125, 137, 149, 161, 173, 185, 197, 209, 221, 233, 245, 257, 269, 281, 293, 305, 317, 329, 341,
6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138, 150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270, 282, 294, 306, 318, 330, 342,
7, 19, 31, 43, 55, 67, 79, 91, 103, 115, 127, 139, 151, 163, 175, 187, 199, 211, 223, 235, 247, 259, 271, 283, 295, 307, 319, 331, 343,
8, 20, 32, 44, 56, 68, 80, 92, 104, 116, 128, 140, 152, 164, 176, 188, 200, 212, 224, 236, 248, 260, 272, 284, 296, 308, 320, 332, 344,
9, 21, 33, 45, 57, 69, 81, 93, 105, 117, 129, 141, 153, 165, 177, 189, 201, 213, 225, 237, 249, 261, 273, 285, 297, 309, 321, 333, 345,
10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 130, 142, 154, 166, 178, 190, 202, 214, 226, 238, 250, 262, 274, 286, 298, 310, 322, 334, 346,
11, 23, 35, 47, 59, 71, 83, 95, 107, 119, 131, 143, 155, 167, 179, 191, 203, 215, 227, 239, 251, 263, 275, 287, 299, 311, 323, 335, 347,
};
const int DSDNXDN_UDCH_m_PunctureList[58] = {
3, 11,
17, 25,
31, 39,
45, 53,
59, 67,
73, 81,
87, 95,
101, 109,
115, 123,
129, 137,
143, 151,
157, 165,
171, 179,
185, 193,
199, 207,
213, 221,
227, 235,
241, 249,
255, 263,
269, 277,
283, 291,
297, 305,
311, 319,
325, 333,
339, 347,
353, 361,
367, 375,
381, 389,
395, 403,
};
//#endif /* _MAIN */
#endif

95
include/pc4.h Normal file
View File

@@ -0,0 +1,95 @@
#include <stdint.h>
#include <stddef.h>
#ifndef TYT_AP
#define TYT_AP
#define nbround 254
#define n1 264
#define UNUSEDPC4(x) ((void)x)
/* Structure holding all PC4 state variables */
typedef struct {
short bits[49], temp[49];
uint8_t ptconvert;
uint8_t convert[7];
uint8_t perm[16][256];
uint8_t new1[256];
uint8_t array[49];
uint8_t array2[49];
uint8_t decal[nbround];
uint8_t rngxor[nbround][3];
uint8_t rngxor2[nbround][3];
uint8_t rounds;
uint8_t tab[256];
uint8_t inv[256];
uint8_t permut[3][3];
uint64_t bb;
uint64_t x;
uint8_t tot[3];
uint8_t l[2][3], r[2][3];
uint8_t y, totb;
uint32_t result;
uint8_t xyz, count;
uint8_t keys[16];
unsigned char array_arc4[256];
int i_arc4, j_arc4;
int x1, x2, i;
unsigned char h2[n1];
unsigned char h1[n1*3];
} PC4Context;
/* Global context accessible from all .c files */
extern PC4Context ctx;
/* Public API */
void create_keys(PC4Context *ctx, unsigned char key1[], size_t size1);
void pc4encrypt(PC4Context *ctx);
void pc4decrypt(PC4Context *ctx);
void binhex(PC4Context *ctx, short *z, int length);
void hexbin(PC4Context *ctx, short *q, uint8_t w, uint8_t hex);
static void u64_to_bytes_be(uint64_t val, unsigned char *out);
/* Encrypt a 49-bit frame (original flow) */
static void encrypt_frame_49(short frame_bits_in[49]) {
for (int i = 0; i < 49; i++) ctx.bits[i] = frame_bits_in[i];
for (int i = 0; i < 49; i++) ctx.temp[i] = ctx.bits[ctx.array[i]];
for (int i = 0; i < 49; i++) ctx.bits[i] = ctx.temp[i];
ctx.ptconvert = 0;
binhex(&ctx, ctx.bits, 48);
pc4encrypt(&ctx);
for (int q = 0; q < 6; q++) {
uint8_t w = (uint8_t)(q * 8);
hexbin(&ctx, ctx.bits, w, ctx.convert[q]);
}
ctx.bits[48] = (short)(ctx.bits[48] ^ ctx.totb);
for (int i = 0; i < 49; i++) ctx.temp[ctx.array2[i]] = ctx.bits[i];
for (int i = 0; i < 49; i++) ctx.bits[i] = ctx.temp[i];
}
/* Decrypt a 49-bit frame (original flow) */
static void decrypt_frame_49(short frame_bits_in[49]) {
for (int i = 0; i < 49; i++) ctx.bits[i] = frame_bits_in[i];
for (int i = 0; i < 49; i++) ctx.temp[i] = ctx.bits[ctx.array2[i]];
for (int i = 0; i < 49; i++) ctx.bits[i] = ctx.temp[i];
ctx.ptconvert = 0;
binhex(&ctx, ctx.bits, 48);
pc4decrypt(&ctx);
for (int q = 0; q < 6; q++) {
uint8_t w = (uint8_t)(q * 8);
hexbin(&ctx, ctx.bits, w, ctx.convert[q]);
}
ctx.bits[48] = (short)(ctx.bits[48] ^ ctx.totb);
for (int i = 0; i < 49; i++) ctx.temp[ctx.array[i]] = ctx.bits[i];
for (int i = 0; i < 49; i++) ctx.bits[i] = ctx.temp[i];
}
/* Convert 64-bit integer to bytes (big-endian) */
static void u64_to_bytes_be(uint64_t val, unsigned char *out) {
for (int i = 0; i < 8; i++) {
out[i] = (unsigned char)((val >> (56 - 8 * i)) & 0xFF);
}
}
#endif

48
include/synctype.h Normal file
View File

@@ -0,0 +1,48 @@
#ifndef SYNCTYPE_H
#define SYNCTYPE_H
static const char * SyncTypes[44] = {
"P25p1",
"P25p1",
"X2TDMA DATA",
"X2TDMA DATA",
"X2TDMA VOICE",
"X2TDMA VOICE",
"DSTAR", //voice
"DSTAR", //voice
"M17",
"M17",
"DMR", //10
"DMR",
"DMR",
"DMR",
"EDACS/PV",
"EDACS/PV",
"M17", //M17 Voice Stream
"M17", //M17 Voice Stream
"DSTAR", //header
"DSTAR", //header
"dPMR", //20
"dPMR",
"dPMR",
"dPMR",
"dPMR",
"dPMR",
"dPMR",
"dPMR",
"NXDN",
"NXDN",
"YSF", //30
"YSF", //31
"DMR",
"DMR",
"DMR",
"P25p2",
"P25p2",
"EDACS/PV", //37
"EDACS/PV", //38
"ANALOG", //39 Generic Sync Types
"DIGITAL" //40 Generic Sync Types
};
#endif

View File

@@ -1,10 +1,8 @@
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
#!/bin/bash
#
mkdir build
cd build
cmake ..
make -j `nproc`
make -j $(nproc)
sudo make install
sudo ldconfig
sudo ldconfig

46
package.nix Normal file
View File

@@ -0,0 +1,46 @@
{ lib
, stdenv
, cmake
, mbelib
, libsndfile
, ncurses
, pulseaudio
, rtl-sdr
, itpp
, codec2
, portaudioSupport ? true
, portaudio ? null
}:
assert portaudioSupport -> portaudio != null;
stdenv.mkDerivation {
name = "dsd-fme";
src = ./.;
nativeBuildInputs = [ cmake ];
buildInputs = [
mbelib
libsndfile
itpp
rtl-sdr
ncurses.dev
pulseaudio.dev
codec2
] ++ lib.optionals portaudioSupport [ portaudio ];
doCheck = true;
meta = with lib; {
description = "Digital Speech Decoder - Florida Man Edition";
longDescription = ''
DSD is able to decode several digital voice formats from discriminator
tap audio and synthesize the decoded speech. Speech synthesis requires
mbelib, which is a separate package.
'';
homepage = "https://github.com/szechyjs/dsd";
license = licenses.mit;
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,330 @@
diff --git a/include/dsd.h b/include/dsd.h
index 4a75702..3cf085e 100644
--- a/include/dsd.h
+++ b/include/dsd.h
@@ -317,6 +317,7 @@ typedef struct
long int rtl_rms;
int monitor_input_audio;
int analog_only;
+ int ghosts_only;
int pulse_raw_rate_in;
int pulse_raw_rate_out;
int pulse_digi_rate_in;
@@ -1342,6 +1343,8 @@ void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency);
long int GetCurrentFreq(int sockfd);
bool SetFreq(int sockfd, long int freq);
bool SetModulation(int sockfd, int bandwidth);
+bool SetModulationWFM(int sockfd, int bandwidth);
+void death (dsd_opts * opts, dsd_state * state);
//commands below unique to GQRX only, not usable on SDR++
bool GetSignalLevel(int sockfd, double *dBFS);
bool GetSquelchLevel(int sockfd, double *dBFS);
diff --git a/src/3.c b/src/3.c
index e104993..b9033bd 100644
--- a/src/3.c
+++ b/src/3.c
@@ -591,4 +591,176 @@ long int raw_rms(int16_t *samples, int len, int step) //use samplespersymbol as
rms = (long int)sqrt((p-err) / len);
if (rms < 0) rms = 150;
return rms;
-}
\ No newline at end of file
+}
+
+
+//Ghosts
+void death (dsd_opts * opts, dsd_state * state)
+{
+ int i, x, result = 0;
+ short ghosts[960];
+ short spooks[960];
+ short demons[960];
+ short sample = 0;
+
+ memset (ghosts, 0, 960*sizeof(short));
+ memset (spooks, 0, 960*sizeof(short));
+ memset (demons, 0, 960*sizeof(short));
+
+ while (!exitflag) //while the software is running
+ {
+ //death on speaks at 48k/1 short output
+ if (opts->audio_in_type == 0)
+ {
+ for (i = 0; i < 960; i++)
+ {
+ pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
+ ghosts[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
+ spooks[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
+ demons[i] = sample;
+ }
+ }
+
+ if (opts->audio_in_type == 8)
+ {
+ for (i = 0; i < 960; i++)
+ {
+ result = sf_read_short(opts->tcp_file_in, &sample, 1);
+ if (result == 0)
+ {
+ sf_close(opts->tcp_file_in);
+ fprintf (stderr, "Connection to the Underworld Severed.\n");
+ fprintf (stderr, "Closing Death Speech Decoder.\n");
+ cleanupAndExit(opts, state);
+ }
+ ghosts[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ result = sf_read_short(opts->tcp_file_in, &sample, 1);
+ if (result == 0)
+ {
+ sf_close(opts->tcp_file_in);
+ fprintf (stderr, "Connection to the Underworld Severed.\n");
+ fprintf (stderr, "Closing Death Speech Decoder.\n");
+ cleanupAndExit(opts, state);
+ }
+ spooks[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ result = sf_read_short(opts->tcp_file_in, &sample, 1);
+ if (result == 0)
+ {
+ sf_close(opts->tcp_file_in);
+ fprintf (stderr, "Connection to the Underworld Severed.\n");
+ fprintf (stderr, "Closing Death Speech Decoder.\n");
+ cleanupAndExit(opts, state);
+ }
+ demons[i] = sample;
+ }
+ }
+
+ //RTL Input
+ #ifdef USE_RTLSDR
+ if (opts->audio_in_type == 3)
+ {
+ for (i = 0; i < 960; i++)
+ {
+ get_rtlsdr_sample(&sample, opts, state);
+ ghosts[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ get_rtlsdr_sample(&sample, opts, state);
+ spooks[i] = sample;
+ }
+
+ for (i = 0; i < 960; i++)
+ {
+ get_rtlsdr_sample(&sample, opts, state);
+ demons[i] = sample;
+ }
+ }
+ #endif
+
+ //The Dead Don't Like OSS input yet
+
+ //Listen to the Howls of the Deceased
+ if (opts->audio_out_type == 0 && opts->slot1_on == 1)
+ {
+ pa_simple_write(opts->pulse_raw_dev_out, ghosts, 960*2, NULL);
+ pa_simple_write(opts->pulse_raw_dev_out, spooks, 960*2, NULL);
+ pa_simple_write(opts->pulse_raw_dev_out, demons, 960*2, NULL);
+ }
+
+ if (opts->audio_out_type == 8) //UDP Audio
+ {
+ udp_socket_blasterA (opts, state, 960*2, ghosts);
+ udp_socket_blasterA (opts, state, 960*2, spooks);
+ udp_socket_blasterA (opts, state, 960*2, demons);
+ }
+
+ //added a condition check so that if OSS output and 8K, switches to 48K when opening OSS
+ if (opts->audio_out_type == 5 && opts->floating_point == 0 && opts->slot1_on == 1)
+ {
+ write (opts->audio_out_fd, ghosts, 960*2);
+ write (opts->audio_out_fd, spooks, 960*2);
+ write (opts->audio_out_fd, demons, 960*2);
+ }
+
+ //STDOUT -- I don't see the harm of adding this here, will be fine for analog only or digital only (non-mixed analog and digital)
+ if (opts->audio_out_type == 1 && opts->floating_point == 0 && opts->slot1_on == 1)
+ {
+ write (opts->audio_out_fd, ghosts, 960*2);
+ write (opts->audio_out_fd, spooks, 960*2);
+ write (opts->audio_out_fd, demons, 960*2);
+ }
+
+ //Undulate the Crystal Ball
+ if (x >= opts->trunk_hangtime)
+ {
+ long int spook_channel = state->trunk_lcn_freq[0];
+
+ //rigctl
+ if (opts->use_rigctl == 1)
+ {
+ if (opts->setmod_bw != 0 ) SetModulationWFM(opts->rigctl_sockfd, opts->setmod_bw);
+ SetFreq(opts->rigctl_sockfd, spook_channel);
+ }
+
+ //rtl
+ if (opts->audio_in_type == 3)
+ {
+ #ifdef USE_RTLSDR
+ rtl_dev_tune(opts, spook_channel);
+ #endif
+ }
+
+ //
+ state->trunk_lcn_freq[0] += 200000;
+
+ if (state->trunk_lcn_freq[0] > 106100000)
+ state->trunk_lcn_freq[0] = 87900000;
+
+ x = 0;
+
+ }
+
+ x++;
+
+ } //end while loop
+} //end ghosts
\ No newline at end of file
diff --git a/src/dsd_main.c b/src/dsd_main.c
index ca878e9..f14995d 100644
--- a/src/dsd_main.c
+++ b/src/dsd_main.c
@@ -696,6 +696,7 @@ initOpts (dsd_opts * opts)
opts->monitor_input_audio = 0; //enable with -8
opts->analog_only = 0; //only turned on with -fA
+ opts->ghosts_only = 0; //ghostbox mode with -fG
opts->inverted_p2 = 0;
opts->p2counter = 0;
@@ -1358,6 +1359,7 @@ usage ()
printf ("Decoder options:\n");
printf (" -fa Auto Detection\n");
printf (" -fA Passive Analog Audio Monitor\n");
+ printf (" -fG Ghosts, Demons, Specters, Ghouls, and Skeletons (Ghost Box)\n");
printf (" -ft TDMA Trunking P25p1 Control and Voice, P25p2 Trunked Channels, and DMR\n");
printf (" -fs DMR TDMA BS and MS Simplex\n");
printf (" -f1 Decode only P25 Phase 1\n");
@@ -2172,6 +2174,35 @@ main (int argc, char **argv)
sprintf (opts.output_name, "Analog Monitor");
fprintf (stderr,"Only Monitoring Passive Analog Signal\n");
}
+ else if (optarg[0] == 'G') //listen to spooky scary skeletons
+ {
+ opts.frame_dstar = 0;
+ opts.frame_x2tdma = 0;
+ opts.frame_p25p1 = 0;
+ opts.frame_p25p2 = 0;
+ opts.frame_nxdn48 = 0;
+ opts.frame_nxdn96 = 0;
+ opts.frame_dmr = 0;
+ opts.frame_dpmr = 0;
+ opts.frame_provoice = 0;
+ opts.frame_ysf = 0;
+ opts.frame_m17 = 0;
+ opts.pulse_digi_rate_out = 8000;
+ opts.pulse_digi_out_channels = 1;
+ opts.dmr_stereo = 0;
+ state.dmr_stereo = 0;
+ opts.dmr_mono = 0;
+ state.rf_mod = 0;
+ opts.monitor_input_audio = 1;
+ opts.ghosts_only = 1;
+ state.trunk_lcn_freq[0] = 87900000; //everybody knows ghosts live on the Broadcast FM band
+ opts.setmod_bw = 150000; //Ghosts annunciate clearly with about 150,000 PB
+ opts.trunk_hangtime = 0;
+ opts.rtlsdr_center_freq = 850000000;
+ opts.rtl_bandwidth = 48;
+ sprintf (opts.output_name, "Ghost Box");
+ fprintf (stderr,"Sounds of the Dead.\n");
+ }
else if (optarg[0] == 'd')
{
opts.frame_dstar = 1;
@@ -3462,6 +3493,22 @@ main (int argc, char **argv)
processM17IPF(&opts, &state);
}
+ else if (opts.ghosts_only == 1)
+ {
+ #ifdef USE_RTLSDR
+ if(opts.audio_in_type == 3)
+ open_rtlsdr_stream(&opts);
+ #endif
+
+ if (opts.audio_in_type == 0)
+ openPulseInput(&opts);
+
+ if (opts.audio_out_type == 0)
+ openPulseOutput(&opts);
+
+ death(&opts, &state);
+ }
+
else
{
diff --git a/src/dsd_rigctl.c b/src/dsd_rigctl.c
index 820ac7e..f12bacc 100644
--- a/src/dsd_rigctl.c
+++ b/src/dsd_rigctl.c
@@ -163,6 +163,28 @@ bool SetModulation(int sockfd, int bandwidth)
return true;
}
+bool SetModulationWFM(int sockfd, int bandwidth)
+{
+ char buf[BUFSIZE];
+ //the bandwidth is now a user/system based configurable variable
+ sprintf (buf, "M WFM %d\n", bandwidth); //SDR++ has changed the token from FM to NFM, even if Ryzerth fixes it later, users may still have an older version
+ Send(sockfd, buf);
+ Recv(sockfd, buf);
+
+ //if it fails the first time, send the other token instead
+ if (strcmp(buf, "RPRT 1\n") == 0 ) //sdr++ has a linebreak here, is that in all versions of the protocol?
+ {
+ sprintf (buf, "M WFM %d\n", bandwidth); //anything not SDR++
+ Send(sockfd, buf);
+ Recv(sockfd, buf);
+ }
+
+ if (strcmp(buf, "RPRT 1\n") == 0 )
+ return false;
+
+ return true;
+}
+
bool GetSignalLevel(int sockfd, double *dBFS)
{
char buf[BUFSIZE];
diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp
index ad04667..dd6566c 100644
--- a/src/rtl_sdr_fm.cpp
+++ b/src/rtl_sdr_fm.cpp
@@ -1034,7 +1034,7 @@ void open_rtlsdr_stream(dsd_opts *opts)
//init with low pass if decoding P25 or EDACS/Provoice
if (opts->frame_p25p1 == 1 || opts->frame_p25p2 == 1 || opts->frame_provoice == 1)
demod_init_ro2(&demod);
- else if (opts->analog_only == 1 || opts->m17encoder == 1)
+ else if (opts->analog_only == 1 || opts->m17encoder == 1 || opts->ghosts_only == 1)
demod_init_analog(&demod);
else demod_init(&demod);
output_init(&output);

View File

@@ -0,0 +1,257 @@
diff --git a/include/dsd.h b/include/dsd.h
index 4a75702..355837f 100644
--- a/include/dsd.h
+++ b/include/dsd.h
@@ -357,6 +357,8 @@ typedef struct
int frame_m17;
int inverted_m17;
+ int frame_typeii;
+
FILE *symbolfile;
int call_alert;
@@ -989,6 +991,10 @@ typedef struct
#define INV_DPMR_FRAME_SYNC_3 "311313111133"
#define INV_DPMR_FRAME_SYNC_4 "111333331133131131111313"
+//Motorola Type II Sync Pattern 0xAC binary 1010 1100
+#define TYPE_II_SYNC "13131133" //baesd on what getDibit returns
+#define TYPE_II_SINV "31313311" //baesd on what getDibit returns
+
/*
* function prototypes
*/
@@ -1357,6 +1363,9 @@ void edacs(dsd_opts * opts, dsd_state * state);
unsigned long long int edacs_bch (unsigned long long int message);
void eot_cc(dsd_opts * opts, dsd_state * state); //end of TX return to CC
+//Type II
+void type_ii(dsd_opts * opts, dsd_state * state);
+
//Generic Tuning Functions
void return_to_cc (dsd_opts * opts, dsd_state * state);
diff --git a/src/dsd_dibit.c b/src/dsd_dibit.c
index 5424f7a..9b403cf 100644
--- a/src/dsd_dibit.c
+++ b/src/dsd_dibit.c
@@ -222,13 +222,14 @@ invert_dibit(int dibit)
int digitize (dsd_opts* opts, dsd_state* state, int symbol)
{
// determine dibit state
- if ((state->synctype == 6) || (state->synctype == 14)|| (state->synctype == 18) || (state->synctype == 37))
+ if ((state->synctype == 6) || (state->synctype == 14)|| (state->synctype == 18) || (state->synctype == 37) || (state->synctype == 40))
{
// 6 +D-STAR
// 14 +ProVoice
// 18 +D-STAR_HD
// 37 +EDACS
+ // 41 +TypeII
if (symbol > state->center)
{
@@ -243,12 +244,13 @@ int digitize (dsd_opts* opts, dsd_state* state, int symbol)
return (1); // +3
}
}
- else if ((state->synctype == 7) || (state->synctype == 15)|| (state->synctype == 19) || (state->synctype == 38))
+ else if ((state->synctype == 7) || (state->synctype == 15)|| (state->synctype == 19) || (state->synctype == 38) || (state->synctype == 41))
{
// 7 -D-STAR
// 15 -ProVoice
// 19 -D-STAR_HD
// 38 -EDACS
+ // 41 -TypeII
if (symbol > state->center)
{
diff --git a/src/dsd_frame.c b/src/dsd_frame.c
index 577169c..58fa07c 100644
--- a/src/dsd_frame.c
+++ b/src/dsd_frame.c
@@ -269,6 +269,12 @@ processFrame (dsd_opts * opts, dsd_state * state)
processYSF(opts, state);
return;
}
+ //TypeII
+ else if (state->synctype == 40 || state->synctype == 41)
+ {
+ type_ii(opts, state);
+ return;
+ }
//M17
else if ((state->synctype == 16) || (state->synctype == 9) || (state->synctype == 17) || (state->synctype == 8) ||
(state->synctype == 76) || (state->synctype == 77) || (state->synctype == 86) || (state->synctype == 87) ||
diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c
index e10f3cc..7f5fbf5 100644
--- a/src/dsd_frame_sync.c
+++ b/src/dsd_frame_sync.c
@@ -117,6 +117,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
* 36 = -P25 P2
* 37 = +EDACS
* 38 = -EDACS
+ * 40 = +Type2
+ * 41 = -Type2
*/
@@ -205,7 +207,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{
t_max = 12; //based on Frame_Sync_2 pattern
}
- else if (opts->frame_m17 == 1)
+ else if (opts->frame_m17 == 1 || opts->frame_typeii == 1)
{
t_max = 8;
}
@@ -581,6 +583,40 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
//end YSF sync
+ //Motorola Type II
+ strncpy(synctest8, (synctest_p - 7), 8);
+ if (opts->frame_typeii == 1)
+ {
+ if (strcmp(synctest8, TYPE_II_SYNC) == 0)
+ {
+ if (state->lastsynctype == 40)
+ {
+ printFrameSync (opts, state, "+Type II", synctest_pos + 1, modulation);
+ state->carrier = 1;
+ state->offset = synctest_pos;
+ state->max = ((state->max) + lmax) / 2;
+ state->min = ((state->min) + lmin) / 2;
+ state->lastsynctype = 40;
+ return (40);
+ }
+ else state->lastsynctype = 40;
+ }
+ else if (strcmp(synctest8, TYPE_II_SINV) == 0)
+ {
+ if (state->lastsynctype == 41)
+ {
+ printFrameSync (opts, state, "-Type II", synctest_pos + 1, modulation);
+ state->carrier = 1;
+ state->offset = synctest_pos;
+ state->max = ((state->max) + lmax) / 2;
+ state->min = ((state->min) + lmin) / 2;
+ state->lastsynctype = 41;
+ return (41);
+ }
+ else state->lastsynctype = 41;
+ }
+ }
+
//M17 Sync -- Just STR and LSF for now
strncpy(synctest16, (synctest_p - 15), 16);
strncpy(synctest8, (synctest_p - 7), 8);
diff --git a/src/dsd_main.c b/src/dsd_main.c
index ca878e9..c5a3e95 100644
--- a/src/dsd_main.c
+++ b/src/dsd_main.c
@@ -622,6 +622,7 @@ initOpts (dsd_opts * opts)
opts->frame_provoice = 0;
opts->frame_ysf = 1;
opts->frame_m17 = 0;
+ opts->frame_typeii = 0;
opts->mod_c4fm = 1;
opts->mod_qpsk = 0;
opts->mod_gfsk = 0;
@@ -1377,6 +1378,7 @@ usage ()
printf (" -fe Decode only EDACS EA/ProVoice*\n");
printf (" -fE Decode only EDACS EA/ProVoice with ESK 0xA0*\n");
printf (" -fm Decode only dPMR*\n");
+ printf (" -fT Decode only Type II (Smartnet/Smartzone)*\n");
printf (" -l Disable DMR, dPMR, NXDN, M17 input filtering\n");
printf (" -u <num> Unvoiced speech quality (default=3)\n");
printf (" -xx Expect non-inverted X2-TDMA signal\n");
@@ -2431,6 +2433,39 @@ main (int argc, char **argv)
opts.rtl_bandwidth = 24;
// opts.rtl_gain_value = 36;
}
+ else if (optarg[0] == 'T') //Motorola Type II
+ {
+ opts.frame_dstar = 0;
+ opts.frame_x2tdma = 0;
+ opts.frame_p25p1 = 0;
+ opts.frame_p25p2 = 0;
+ opts.frame_nxdn48 = 0;
+ opts.frame_nxdn96 = 0;
+ opts.frame_dmr = 0;
+ opts.frame_dpmr = 0;
+ opts.frame_provoice = 0;
+ opts.frame_ysf = 0;
+ opts.frame_m17 = 0;
+ opts.frame_typeii = 1;
+ ////to maintain 10/4 sample per symbol rate, we need to run at 36000
+ //to hit TypeII's 3600 bps rating. BW values in rtl_fm are also modified
+ //similarly, but testing will need to be done, this MAY NOT be viable in DSD-FME.
+ opts.pulse_digi_rate_in = 36000;
+ opts.wav_sample_rate = 36000;
+ opts.mod_c4fm = 1;
+ opts.mod_qpsk = 0;
+ opts.mod_gfsk = 0; //might still be better as gfsk
+ state.rf_mod = 2;
+ opts.pulse_digi_rate_out = 8000;
+ opts.pulse_digi_out_channels = 1;
+ opts.dmr_stereo = 0;
+ opts.dmr_mono = 0;
+ state.dmr_stereo = 0;
+ // opts.setmod_bw = 12500;
+ sprintf (opts.output_name, "Type II");
+ // fprintf (stderr,"Setting symbol rate to 4800 / second\n");
+ fprintf (stderr,"Decoding Motorola Type II frames.\n");
+ }
else if (optarg[0] == '1')
{
opts.frame_dstar = 0;
diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp
index ad04667..954c6dc 100644
--- a/src/rtl_sdr_fm.cpp
+++ b/src/rtl_sdr_fm.cpp
@@ -1025,6 +1025,7 @@ void rtlsdr_sighandler()
void open_rtlsdr_stream(dsd_opts *opts)
{
int r;
+ if (opts->frame_typeii == 1) bandwidth_divisor = 36000;
rtl_bandwidth = opts->rtl_bandwidth * 1000; //reverted back to straight value
bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth);
volume_multiplier = 1; //moved to external handling to be more dynamic
diff --git a/src/typeII.c b/src/typeII.c
new file mode 100644
index 0000000..eb0cd56
--- /dev/null
+++ b/src/typeII.c
@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------------
+ * typeII.c
+ * Motorola Type II Decoder (WIP)
+ *
+ *
+ *
+ *
+ * LWVMOBILE
+ * 2024-03 DSD-FME Florida Man Edition
+ *-----------------------------------------------------------------------------*/
+
+#include "dsd.h"
+
+//Type II
+void type_ii(dsd_opts * opts, dsd_state * state)
+{
+ int i;
+ uint8_t t2[80]; memset(t2, 0, sizeof(t2));
+
+ for (i = 0; i < 76; i++)
+ t2[i] = getDibit(opts, state);
+
+ //debug dump collected bits
+ fprintf (stderr, "Frame:");
+ for (i = 0; i < 10; i++)
+ fprintf (stderr, " %02X", (uint8_t)ConvertBitIntoBytes(&t2[i*8], 8));
+
+ fprintf (stderr, "\n");
+}
\ No newline at end of file

View File

@@ -1,21 +1,15 @@
#! /bin/bash
#
clear
echo DSD-FME Digital Speech Decoder - Florida Man Edition
echo Automatic Git Pull and Rebuild
echo
printf "DSD-FME Digital Speech Decoder - Florida Man Edition
Automatic Git Pull and Rebuild\n\n"
sleep 1
##Open your clone folder##
git pull https://github.com/lwvmobile/dsd-fme pulseaudio
git pull
sleep 2
sudo cp tone8.wav /usr/share/
sudo cp tone24.wav /usr/share/
sudo chmod 777 /usr/share/tone8.wav
sudo chmod 777 /usr/share/tone24.wav
##cd into your build folder##
cd build
##cmake usually isn't necesary, but could be if I update the cmakelist.txt
cmake ..
make -j `nproc`
make -j $(nproc)
sudo make install
sudo ldconfig
sudo ldconfig

View File

@@ -134,6 +134,13 @@ const uint8_t DeInterleaveReverseChannelBptc[32] =
24, 9, 26, 11, 28, 13, 30, 15
};
const uint8_t DeInterleaveReverseChannelBptcPlacement[32] =
{
0, 16, 1, 17, 2, 18, 3, 19,
4, 20, 5, 21, 6, 22, 7, 23,
8, 24, 9, 25, 10, 26, 11, 27,
12, 28, 13, 29, 14, 30, 15, 31
};
/* Functions ----------------------------------------------------------------*/
@@ -192,18 +199,10 @@ uint32_t BPTC_196x96_Extract_Data(uint8_t InputDeInteleavedData[196], uint8_t DM
}
}
/* R(0) to R(2) may be used to transport some
* Restricted Access System (RAS) information,
* So save these three bytes before reset all of them
* See patent US 2013/0288643 A1 */
R[0] = DataMatrix[0][2]; /* Save R(0) */
R[1] = DataMatrix[0][1]; /* Save R(1) */
R[2] = DataMatrix[0][0]; /* Save R(2) */
/* Set to 0 R(0) to R(2) - See DMR standard chapter B1.1 BPTC (196,96) */
DataMatrix[0][0] = 0; /* R(2) */
DataMatrix[0][1] = 0; /* R(1) */
DataMatrix[0][2] = 0; /* R(0) */
// DataMatrix[0][0] = 0; /* R(2) */
// DataMatrix[0][1] = 0; /* R(1) */
// DataMatrix[0][2] = 0; /* R(0) */
/* Init the Hamming (15,11,3) library
* Not needed because it has already been done
@@ -356,6 +355,14 @@ uint32_t BPTC_196x96_Extract_Data(uint8_t InputDeInteleavedData[196], uint8_t DM
}
}
/* R(0) to R(2) may be used to transport some
* Restricted Access System (RAS) information,
* So save these three bits after hamming correction
* See patent US 2013/0288643 A1 */
R[0] = DataMatrix[0][2]; /* Save R(0) */
R[1] = DataMatrix[0][1]; /* Save R(1) */
R[2] = DataMatrix[0][0]; /* Save R(2) */
/* Return the number of irrecoverable Hamming errors */
return HammingIrrecoverableErrorNb;
} /* End BPTC_196x96_Extract_Data() */
@@ -498,33 +505,38 @@ uint32_t BPTC_128x77_Extract_Data(uint8_t InputDataMatrix[8][16], uint8_t DMRDat
* DMRDataExtracted[11..15] = Hamming data
* DMRDataExtracted[16..31] = 16 bits of odd parity (to be checked)
*
* @param ParityCheckTypeOdd : 0 = Parity to check is even (used in Non-Reverse Channel Single Burst BPTC)
* 1 = Parity to check is odd (used in Reverse Channel Single Burst BPTC)
*
* @return 0 = All is OK
* Other = Error - Irrecoverable Hamming parity check error number
*/
uint32_t BPTC_16x2_Extract_Data(uint8_t InputInterleavedData[32], uint8_t DMRDataExtracted[32])
uint32_t BPTC_16x2_Extract_Data(uint8_t InputInterleavedData[32], uint8_t DMRDataExtracted[32], uint32_t ParityCheckTypeOdd)
{
uint32_t i;
uint8_t DataMatrix[32];
uint8_t LineUncorrected[16];
uint8_t LineCorrected[11];
uint32_t HammingIrrecoverableErrorNb = 0;
uint32_t ParityCheckErrorNb = 0;
uint32_t ParityCheckOddErrorNb = 0;
uint32_t ParityCheckEvenErrorNb = 0;
//TODO: make this so we can load either rc interleave, or single burst interleave
for(i = 0; i < 32; i++)
{
DataMatrix[DeInterleaveReverseChannelBptc[i]] = InputInterleavedData[i] & 1;
DataMatrix[DeInterleaveReverseChannelBptcPlacement[DeInterleaveReverseChannelBptc[i]]] = InputInterleavedData[i] & 1;
}
/* Copy the entire input buffer to the output buffer */
for(i = 0; i < 32; i++)
{
DMRDataExtracted[i] = DataMatrix[i];
DMRDataExtracted[i] = DataMatrix[i] & 1;
}
/* Prepare the line to be corrected */
for(i = 0; i < 16; i++)
{
LineUncorrected[i] = DataMatrix[i];
LineUncorrected[i] = DataMatrix[i] & 1;
}
/* Apply Hamming (16,11,4) code correction */
@@ -536,7 +548,7 @@ uint32_t BPTC_16x2_Extract_Data(uint8_t InputInterleavedData[32], uint8_t DMRDat
/* Copy the corrected content to the output buffer */
for(i = 0; i < 11; i++)
{
DMRDataExtracted[i] = LineCorrected[i];
DMRDataExtracted[i] = LineCorrected[i] & 1;
}
/* Check Parity bits */
@@ -544,14 +556,24 @@ uint32_t BPTC_16x2_Extract_Data(uint8_t InputInterleavedData[32], uint8_t DMRDat
{
/* Odd parity ==> If data = 1 then parity = 0
* If data = 0 then parity = 1 */
if(DMRDataExtracted[i] == DMRDataExtracted[i + 16]) ParityCheckErrorNb++;
if((DMRDataExtracted[i] & 1) == (DMRDataExtracted[i + 16] & 1)) ParityCheckOddErrorNb++;
if((DMRDataExtracted[i] & 1) != (DMRDataExtracted[i + 16] & 1)) ParityCheckEvenErrorNb++;
}
//fprintf(stderr, "Hamming ERR=%u ; Parity ERR=%u", HammingIrrecoverableErrorNb, ParityCheckErrorNb);
//fprintf(stderr, "Hamming ERR=%u ; Parity odd ERR=%u, Parity even ERR=%u, ", HammingIrrecoverableErrorNb, ParityCheckOddErrorNb, ParityCheckEvenErrorNb);
//fprintf(stderr, "Content =\n");
//for(i = 0; i < 32; i++)
//{
// fprintf(stderr, "%u", DMRDataExtracted[i] & 1);
// if((i == 15) || (i == 31)) fprintf(stderr, "\n");
// else fprintf(stderr, "-");
//}
/* Return the number of irrecoverable Hamming errors +
* the number of parity check error */
return (HammingIrrecoverableErrorNb + ParityCheckErrorNb);
if(ParityCheckTypeOdd) return (HammingIrrecoverableErrorNb + ParityCheckOddErrorNb);
else return (HammingIrrecoverableErrorNb + ParityCheckEvenErrorNb);
} /* End BPTC_16x2_Extract_Data() */

922
src/crypt-aes.c Normal file
View File

@@ -0,0 +1,922 @@
/*-------------------------------------------------------------------------------
* aes.c Tinier AES
* Easy To Use (and configurable) AES Output and Utility Bit/Byte Functions
*
* Modified Tiny AES code for more variable nk/nr/nb values, all in one file
* https://github.com/kokke/tiny-AES-c
*-----------------------------------------------------------------------------*/
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include "dsd.h"
#define AES_BLOCKLEN 16
unsigned Nb = 4;
unsigned Nk = 8;
unsigned Nr = 14;
struct AES_ctx
{
uint8_t RoundKey[240];
uint8_t Iv[16];
};
//internal function prototypes
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
typedef uint8_t state_t[4][4];
static const uint8_t sbox[256] = {
//0 1 2 3 4 5 6 7 8 9 A B C D E F
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };
static const uint8_t rsbox[256] = {
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d };
static const uint8_t Rcon[11] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
#define getSBoxValue(num) (sbox[(num)])
static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key)
{
unsigned i, j, k;
uint8_t tempa[4]; // Used for the column/row operations
// The first round key is the key itself.
for (i = 0; i < Nk; ++i)
{
RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
RoundKey[(i * 4) + 2] = Key[(i * 4) + 2];
RoundKey[(i * 4) + 3] = Key[(i * 4) + 3];
}
// All other round keys are found from the previous round keys.
for (i = Nk; i < Nb * (Nr + 1); ++i)
{
{
k = (i - 1) * 4;
tempa[0]=RoundKey[k + 0];
tempa[1]=RoundKey[k + 1];
tempa[2]=RoundKey[k + 2];
tempa[3]=RoundKey[k + 3];
}
if (i % Nk == 0)
{
// This function shifts the 4 bytes in a word to the left once.
// [a0,a1,a2,a3] becomes [a1,a2,a3,a0]
// Function RotWord()
{
const uint8_t u8tmp = tempa[0];
tempa[0] = tempa[1];
tempa[1] = tempa[2];
tempa[2] = tempa[3];
tempa[3] = u8tmp;
}
// SubWord() is a function that takes a four-byte input word and
// applies the S-box to each of the four bytes to produce an output word.
// Function Subword()
{
tempa[0] = getSBoxValue(tempa[0]);
tempa[1] = getSBoxValue(tempa[1]);
tempa[2] = getSBoxValue(tempa[2]);
tempa[3] = getSBoxValue(tempa[3]);
}
tempa[0] = tempa[0] ^ Rcon[i/Nk];
}
if (Nk == 8) //only run if using AES256 (Nk == 8)
{
if (i % Nk == 4)
{
// Function Subword()
{
tempa[0] = getSBoxValue(tempa[0]);
tempa[1] = getSBoxValue(tempa[1]);
tempa[2] = getSBoxValue(tempa[2]);
tempa[3] = getSBoxValue(tempa[3]);
}
}
}
j = i * 4; k=(i - Nk) * 4;
RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0];
RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1];
RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2];
RoundKey[j + 3] = RoundKey[k + 3] ^ tempa[3];
}
}
//input bit array, return output as up to a 64-bit value
uint64_t convert_bits_into_output_ta(uint8_t * input, int len)
{
int i;
uint64_t output = 0;
for(i = 0; i < len; i++)
{
output <<= 1;
output |= (uint64_t)(input[i] & 1);
}
return output;
}
//take x amount of bits and pack into len amount of bytes (symmetrical)
void pack_bit_array_into_byte_array_ta (uint8_t * input, uint8_t * output, int len)
{
int i;
for (i = 0; i < len; i++)
output[i] = (uint8_t)convert_bits_into_output_ta(&input[i*8], 8);
}
//take len amount of bytes and unpack back into a bit array
void unpack_byte_array_into_bit_array_ta (uint8_t * input, uint8_t * output, int len)
{
int i = 0, k = 0;
for (i = 0; i < len; i++)
{
output[k++] = (input[i] >> 7) & 1;
output[k++] = (input[i] >> 6) & 1;
output[k++] = (input[i] >> 5) & 1;
output[k++] = (input[i] >> 4) & 1;
output[k++] = (input[i] >> 3) & 1;
output[k++] = (input[i] >> 2) & 1;
output[k++] = (input[i] >> 1) & 1;
output[k++] = (input[i] >> 0) & 1;
}
}
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key)
{
KeyExpansion(ctx->RoundKey, key);
}
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv)
{
KeyExpansion(ctx->RoundKey, key);
memcpy (ctx->Iv, iv, AES_BLOCKLEN);
}
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv)
{
memcpy (ctx->Iv, iv, AES_BLOCKLEN);
}
static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey)
{
uint8_t i,j;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
(*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j];
}
}
}
static void SubBytes(state_t* state)
{
uint8_t i, j;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
(*state)[j][i] = getSBoxValue((*state)[j][i]);
}
}
}
static void ShiftRows(state_t* state)
{
uint8_t temp;
// Rotate first row 1 columns to left
temp = (*state)[0][1];
(*state)[0][1] = (*state)[1][1];
(*state)[1][1] = (*state)[2][1];
(*state)[2][1] = (*state)[3][1];
(*state)[3][1] = temp;
// Rotate second row 2 columns to left
temp = (*state)[0][2];
(*state)[0][2] = (*state)[2][2];
(*state)[2][2] = temp;
temp = (*state)[1][2];
(*state)[1][2] = (*state)[3][2];
(*state)[3][2] = temp;
// Rotate third row 3 columns to left
temp = (*state)[0][3];
(*state)[0][3] = (*state)[3][3];
(*state)[3][3] = (*state)[2][3];
(*state)[2][3] = (*state)[1][3];
(*state)[1][3] = temp;
}
static uint8_t xtime(uint8_t x)
{
return ((x<<1) ^ (((x>>7) & 1) * 0x1b));
}
static void MixColumns(state_t* state)
{
uint8_t i;
uint8_t Tmp, Tm, t;
for (i = 0; i < 4; ++i)
{
t = (*state)[i][0];
Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ;
Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ;
Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ;
Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ;
Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ;
}
}
#define Multiply(x, y) \
( ((y & 1) * x) ^ \
((y>>1 & 1) * xtime(x)) ^ \
((y>>2 & 1) * xtime(xtime(x))) ^ \
((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ \
((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))) \
#define getSBoxInvert(num) (rsbox[(num)])
static void InvMixColumns(state_t* state)
{
int i;
uint8_t a, b, c, d;
for (i = 0; i < 4; ++i)
{
a = (*state)[i][0];
b = (*state)[i][1];
c = (*state)[i][2];
d = (*state)[i][3];
(*state)[i][0] = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09);
(*state)[i][1] = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d);
(*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b);
(*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e);
}
}
static void InvSubBytes(state_t* state)
{
uint8_t i, j;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
(*state)[j][i] = getSBoxInvert((*state)[j][i]);
}
}
}
static void InvShiftRows(state_t* state)
{
uint8_t temp;
// Rotate first row 1 columns to right
temp = (*state)[3][1];
(*state)[3][1] = (*state)[2][1];
(*state)[2][1] = (*state)[1][1];
(*state)[1][1] = (*state)[0][1];
(*state)[0][1] = temp;
// Rotate second row 2 columns to right
temp = (*state)[0][2];
(*state)[0][2] = (*state)[2][2];
(*state)[2][2] = temp;
temp = (*state)[1][2];
(*state)[1][2] = (*state)[3][2];
(*state)[3][2] = temp;
// Rotate third row 3 columns to right
temp = (*state)[0][3];
(*state)[0][3] = (*state)[1][3];
(*state)[1][3] = (*state)[2][3];
(*state)[2][3] = (*state)[3][3];
(*state)[3][3] = temp;
}
// Cipher is the main function that encrypts the PlainText,
// or produces a keystream, depending on application.
static void Cipher(state_t* state, const uint8_t* RoundKey)
{
uint8_t round = 0;
// Add the First round key to the state before starting the rounds.
AddRoundKey(0, state, RoundKey);
// There will be Nr rounds.
// The first Nr-1 rounds are identical.
// These Nr rounds are executed in the loop below.
// Last one without MixColumns()
for (round = 1; ; ++round)
{
SubBytes(state);
ShiftRows(state);
if (round == Nr) {
break;
}
MixColumns(state);
AddRoundKey(round, state, RoundKey);
}
// Add round key to last round
AddRoundKey(Nr, state, RoundKey);
}
static void InvCipher(state_t* state, const uint8_t* RoundKey)
{
uint8_t round = 0;
// Add the First round key to the state before starting the rounds.
AddRoundKey(Nr, state, RoundKey);
// There will be Nr rounds.
// The first Nr-1 rounds are identical.
// These Nr rounds are executed in the loop below.
// Last one without InvMixColumn()
for (round = (Nr - 1); ; --round)
{
InvShiftRows(state);
InvSubBytes(state);
AddRoundKey(round, state, RoundKey);
if (round == 0) {
break;
}
InvMixColumns(state);
}
}
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf)
{
// The next function call encrypts the PlainText with the Key using AES algorithm.
Cipher((state_t*)buf, ctx->RoundKey);
}
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf)
{
// The next function call decrypts the PlainText with the Key using AES algorithm.
InvCipher((state_t*)buf, ctx->RoundKey);
}
static void XorWithIv(uint8_t* buf, const uint8_t* Iv)
{
uint8_t i;
for (i = 0; i < AES_BLOCKLEN; ++i)
{
buf[i] ^= Iv[i];
}
}
void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, size_t length)
{
size_t i;
uint8_t *Iv = ctx->Iv;
for (i = 0; i < length; i += AES_BLOCKLEN)
{
XorWithIv(buf, Iv);
Cipher((state_t*)buf, ctx->RoundKey);
Iv = buf;
buf += AES_BLOCKLEN;
}
/* store Iv in ctx for next call */
memcpy(ctx->Iv, Iv, AES_BLOCKLEN);
}
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
{
size_t i;
uint8_t storeNextIv[AES_BLOCKLEN];
for (i = 0; i < length; i += AES_BLOCKLEN)
{
memcpy(storeNextIv, buf, AES_BLOCKLEN);
InvCipher((state_t*)buf, ctx->RoundKey);
XorWithIv(buf, ctx->Iv);
memcpy(ctx->Iv, storeNextIv, AES_BLOCKLEN);
buf += AES_BLOCKLEN;
}
}
/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
{
uint8_t buffer[AES_BLOCKLEN];
size_t i;
int bi;
for (i = 0, bi = AES_BLOCKLEN; i < length; ++i, ++bi)
{
if (bi == AES_BLOCKLEN) /* we need to regen xor compliment in buffer */
{
memcpy(buffer, ctx->Iv, AES_BLOCKLEN);
Cipher((state_t*)buffer,ctx->RoundKey);
/* Increment Iv and handle overflow */
for (bi = (AES_BLOCKLEN - 1); bi >= 0; --bi)
{
/* inc will overflow */
if (ctx->Iv[bi] == 255)
{
ctx->Iv[bi] = 0;
continue;
}
ctx->Iv[bi] += 1;
break;
}
bi = 0;
}
buf[i] = (buf[i] ^ buffer[bi]);
}
}
//byte-wise output of AES OFB Keystream
//input iv is a 16-byte uint8_t array of initialization vector
//input key is up to 32-byte uint8_t array of key value
//input type is the type/key len of AES required (0-128, 1-192, 2-256)
//input nblocks is the number of rounds of 16-byte keystream output blocks requried
//output is a uint8_t bytewise array, each round filled with 16-bytes from aes keystream output
void aes_ofb_keystream_output (uint8_t * iv, uint8_t * key, uint8_t * output, int type, int nblocks)
{
int i;
uint8_t input_register[16]; //OFB Input Register
memset (input_register, 0, sizeof(input_register));
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//load first round of input_register with received IV (OFB First Input Register)
memcpy (input_register, iv, 16*sizeof(uint8_t) );
//initialize the key variable for the Cipher function
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
//execute the cipher function, and copy ciphered input_register to output for required number of rounds
for (i = 0; i < nblocks; i++)
{
Cipher((state_t*)input_register, ctx.RoundKey); //input_register is returned as output, and is put back in as object feedback
memcpy (output+(i*16), input_register, 16*sizeof(uint8_t) ); //copy ciphered input_register to output
}
}
//byte-wise AES CFB (Cipher Feedback) Payload operating in 128-bit block mode
//input in is a uint8_t bytewise array,is the input to be ciphered (encrypted or decrypted)
//input iv is a 16-byte uint8_t array of initialization vector
//input key is up to 32-byte uint8_t array of key value
//input type is the type/key len of AES required (0-128, 1-192, 2-256)
//input nblocks is the number of rounds of 16-byte payload blocks requried (last block will need padding if not flush)
//output out is a uint8_t bytewise array, each round filled with 16-bytes of cfb ciphered output (encrypted or decrypted)
//de is a bit-flag signalling to run Cipher (encrypt) on 1, or InvCipher (decrypt) on 0
void aes_cfb_bytewise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * in, uint8_t * out, int type, int nblocks, int de)
{
int i, j;
uint8_t input_register[16]; //Input Register
memset (input_register, 0, sizeof(input_register));
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//load first round of input_register with received IV (CFB First Input Register)
memcpy (input_register, iv, 16*sizeof(uint8_t) );
//initialize the key variable for the Cipher function
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
//execute the cipher function, and copy ciphered input_register to output for required number of rounds
for (i = 0; i < nblocks; i++)
{
//the cipher is always run in the foward, or encryption mode
Cipher((state_t*)input_register, ctx.RoundKey);
//xor the current input 'in' to the current state of the input_register for cipher feedback
for (j = 0; j < 16; j++)
input_register[j] ^= in[j+(i*16)];
//copy ciphered/xor'd input_register to output 'out'
memcpy (out+(i*16), input_register, 16*sizeof(uint8_t) );
//if running in decryption mode, we feed in the next round of input
if (!de)
memcpy(input_register, in+(i*16), 16*sizeof(uint8_t));
}
}
//byte-wise AES CBC (Cipher Block Chaining) //Yeah, I know this already exists, but wanted a custom convenience wrapper version
//input in is a uint8_t bytewise array,is the input to be ciphered (encrypted or decrypted)
//input iv is a 16-byte uint8_t array of initialization vector
//input key is up to 32-byte uint8_t array of key value
//input type is the type/key len of AES required (0-128, 1-192, 2-256)
//input nblocks is the number of rounds of 16-byte payload blocks requried (last block will need padding if not flush)
//output out is a uint8_t bytewise array, each round filled with 16-bytes of cfb ciphered output (encrypted or decrypted)
//de is a bit-flag signalling to run Cipher (encrypt) on 1, or InvCipher (decrypt) on 0
void aes_cbc_bytewise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * in, uint8_t * out, int type, int nblocks, int de)
{
int i, j;
uint8_t input_register[16]; //Input Register
memset (input_register, 0, sizeof(input_register));
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//load first round of input_register accordingly
if (de)
memcpy (input_register, iv, 16*sizeof(uint8_t) );
else memcpy (input_register, in, 16*sizeof(uint8_t) );
//initialize the key variable for the Cipher function
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
//
for (i = 0; i < nblocks; i++)
{
//run encryption or decryption depending on de value
if (de) //encrypt
{
//xor the current input 'in' pt to the current state of the input_register for cbc feedback
for (j = 0; j < 16; j++)
input_register[j] ^= in[j+(i*16)];
Cipher((state_t*)input_register, ctx.RoundKey);
//copy ciphered input_register to output 'out'
memcpy (out+(i*16), input_register, 16*sizeof(uint8_t) );
}
else //decrypt
{
InvCipher((state_t*)input_register, ctx.RoundKey);
//copy ciphered input_register to output 'out'
memcpy (out+(i*16), input_register, 16*sizeof(uint8_t) );
//xor the current output by IV, or by last received CT
if (i == 0)
{
for (j = 0; j < 16; j++)
out[j] ^= iv[j];
}
else
{
for (j = 0; j < 16; j++)
out[j+(i*16)] ^= in[j+((i-1)*16)];
}
//copy in next segment for input_register (if not last)
if (i < nblocks)
memcpy(input_register, in+((i+1)*16), 16*sizeof(uint8_t) );
}
}
}
//byte-wise AES CBC_MAC (Cipher Block Chaining Message Authentication) //This is slightly different than above, no IV is present,
//but if iv is desireable, it will need to be pre-XOR'd with the first plaintext input block by the calling function
//input in is a uint8_t bytewise array, is the input to be ciphered.
//input key is up to 32-byte uint8_t array of key value
//input type is the type/key len of AES required (0-128, 1-192, 2-256)
//input nblocks is the number of rounds of 16-byte payload blocks requried (last block will need padding if not flush)
//output out is a uint8_t bytewise array, with only the final round output as the MAC octets
//NOTE: When doing a cbc_mac, you should only run it in the forward (encryption) mode to get the mac bytes
void aes_cbc_mac_generator (uint8_t * key, uint8_t * in, uint8_t * out, int type, int nblocks)
{
int i, j;
uint8_t input_register[16]; //Input Register
memset (input_register, 0, sizeof(input_register));
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//initialize the key variable for the Cipher function
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
//
for (i = 0; i < nblocks; i++)
{
//xor the current input 'in' pt to the current state of the input_register for cbc feedback
//if this is the first iteration, this will load the first round plain text instead
for (j = 0; j < 16; j++)
input_register[j] ^= in[j+((i+0)*16)];
Cipher((state_t*)input_register, ctx.RoundKey);
//debug, load out all intermediate output register values
// memcpy (out+(i*16), input_register, 16*sizeof(uint8_t) );
}
//copy final ciphered input_register to output 'out', user will determine how many bytes of output they want for MAC
memcpy (out, input_register, 16*sizeof(uint8_t) );
}
//byte-wise output of AES ECB Ciphering/Deciphering
//input is uint8_t byte-wise (16-bytes) data to be ciphered or deciphered
//input key is up to 32-byte uint8_t array of key value
//input type is the type/len of AES required (0-128, 1-192, 2-256)
//output is a uint8_t bytewise array of ciphered or deciphered input
//de is a bit-flag signalling to run Cipher (encrypt) on 1, or InvCipher (decrypt) on 0
void aes_ecb_bytewise_payload_crypt (uint8_t * input, uint8_t * key, uint8_t * output, int type, int de)
{
uint8_t input_register[16]; //ECB Input Register
memset (input_register, 0, sizeof(input_register));
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//load input_register with received input (ECB Payload)
memcpy (input_register, input, 16*sizeof(uint8_t) );
//initialize the key variable for the Cipher function
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
//run encryption or decryption depending on de value
if (de) //encrypt
Cipher((state_t*)input_register, ctx.RoundKey);
else //decrypt
InvCipher((state_t*)input_register, ctx.RoundKey);
//copy ciphered/deciphered input_register to output
memcpy (output, input_register, 16*sizeof(uint8_t) );
}
//symmetrical ctr mode payload encryption and decryption
void aes_ctr_bitwise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * payload, int type)
{
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//init and set the iv and key variables
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
memset (ctx.Iv, 0, 16*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
memcpy (ctx.Iv, iv, AES_BLOCKLEN);
//pack input bit-wise payload to byte array
uint8_t payload_bytes[16];
memset (payload_bytes, 0, sizeof(payload_bytes));
pack_bit_array_into_byte_array_ta (payload, payload_bytes, 16);
//pass to internal CTR handler for payload
AES_CTR_xcrypt_buffer(&ctx, payload_bytes, 16);
//unpack output bytes back to bits
unpack_byte_array_into_bit_array_ta(payload_bytes, payload, 16);
}
//symmetrical ctr mode payload encryption and decryption
void aes_ctr_bytewise_payload_crypt (uint8_t * iv, uint8_t * key, uint8_t * payload, int type)
{
//Set values specific to type (128/192/256)
if (type == 0) //128
{
Nb = 4;
Nk = 4;
Nr = 10;
}
else if (type == 1) //192
{
Nb = 4;
Nk = 6;
Nr = 12;
}
else //if (type == 2) //256
{
Nb = 4;
Nk = 8;
Nr = 14;
}
struct AES_ctx ctx;
//init and set the iv and key variables
memset (ctx.RoundKey, 0, 240*sizeof(uint8_t));
memset (ctx.Iv, 0, 16*sizeof(uint8_t));
KeyExpansion(ctx.RoundKey, key);
memcpy (ctx.Iv, iv, AES_BLOCKLEN);
//pass to internal CTR handler for payload
AES_CTR_xcrypt_buffer(&ctx, payload, 16);
}

832
src/crypt-des.c Normal file
View File

@@ -0,0 +1,832 @@
/*-------------------------------------------------------------------------------
* des.c Crypthings
* DES Alg
*-----------------------------------------------------------------------------*/
#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include "dsd.h"
//NOTE: The SLUT boxes are S boxes with additional calculations so we don't have
//to manually sort out row and column values and can cut down on operations
uint8_t SLUT1[64] = {
0xE0,0x00,0x40,0xF0,0xD0,0x70,0x10,0x40,
0x20,0xE0,0xF0,0x20,0xB0,0xD0,0x80,0x10,
0x30,0xA0,0xA0,0x60,0x60,0xC0,0xC0,0xB0,
0x50,0x90,0x90,0x50,0x00,0x30,0x70,0x80,
0x40,0xF0,0x10,0xC0,0xE0,0x80,0x80,0x20,
0xD0,0x40,0x60,0x90,0x20,0x10,0xB0,0x70,
0xF0,0x50,0xC0,0xB0,0x90,0x30,0x70,0xE0,
0x30,0xA0,0xA0,0x00,0x50,0x60,0x00,0xD0
};
uint8_t SLUT2[64] = {
0x0F,0x03,0x01,0x0D,0x08,0x04,0x0E,0x07,
0x06,0x0F,0x0B,0x02,0x03,0x08,0x04,0x0E,
0x09,0x0C,0x07,0x00,0x02,0x01,0x0D,0x0A,
0x0C,0x06,0x00,0x09,0x05,0x0B,0x0A,0x05,
0x00,0x0D,0x0E,0x08,0x07,0x0A,0x0B,0x01,
0x0A,0x03,0x04,0x0F,0x0D,0x04,0x01,0x02,
0x05,0x0B,0x08,0x06,0x0C,0x07,0x06,0x0C,
0x09,0x00,0x03,0x05,0x02,0x0E,0x0F,0x09
};
uint8_t SLUT3[64] = {
0xA0,0xD0,0x00,0x70,0x90,0x00,0xE0,0x90,
0x60,0x30,0x30,0x40,0xF0,0x60,0x50,0xA0,
0x10,0x20,0xD0,0x80,0xC0,0x50,0x70,0xE0,
0xB0,0xC0,0x40,0xB0,0x20,0xF0,0x80,0x10,
0xD0,0x10,0x60,0xA0,0x40,0xD0,0x90,0x00,
0x80,0x60,0xF0,0x90,0x30,0x80,0x00,0x70,
0xB0,0x40,0x10,0xF0,0x20,0xE0,0xC0,0x30,
0x50,0xB0,0xA0,0x50,0xE0,0x20,0x70,0xC0
};
uint8_t SLUT4[64] = {
0x07,0x0D,0x0D,0x08,0x0E,0x0B,0x03,0x05,
0x00,0x06,0x06,0x0F,0x09,0x00,0x0A,0x03,
0x01,0x04,0x02,0x07,0x08,0x02,0x05,0x0C,
0x0B,0x01,0x0C,0x0A,0x04,0x0E,0x0F,0x09,
0x0A,0x03,0x06,0x0F,0x09,0x00,0x00,0x06,
0x0C,0x0A,0x0B,0x01,0x07,0x0D,0x0D,0x08,
0x0F,0x09,0x01,0x04,0x03,0x05,0x0E,0x0B,
0x05,0x0C,0x02,0x07,0x08,0x02,0x04,0x0E
};
uint8_t SLUT5[64] = {
0x20,0xE0,0xC0,0xB0,0x40,0x20,0x10,0xC0,
0x70,0x40,0xA0,0x70,0xB0,0xD0,0x60,0x10,
0x80,0x50,0x50,0x00,0x30,0xF0,0xF0,0xA0,
0xD0,0x30,0x00,0x90,0xE0,0x80,0x90,0x60,
0x40,0xB0,0x20,0x80,0x10,0xC0,0xB0,0x70,
0xA0,0x10,0xD0,0xE0,0x70,0x20,0x80,0xD0,
0xF0,0x60,0x90,0xF0,0xC0,0x00,0x50,0x90,
0x60,0xA0,0x30,0x40,0x00,0x50,0xE0,0x30
};
uint8_t SLUT6[64] = {
0x0C,0x0A,0x01,0x0F,0x0A,0x04,0x0F,0x02,
0x09,0x07,0x02,0x0C,0x06,0x09,0x08,0x05,
0x00,0x06,0x0D,0x01,0x03,0x0D,0x04,0x0E,
0x0E,0x00,0x07,0x0B,0x05,0x03,0x0B,0x08,
0x09,0x04,0x0E,0x03,0x0F,0x02,0x05,0x0C,
0x02,0x09,0x08,0x05,0x0C,0x0F,0x03,0x0A,
0x07,0x0B,0x00,0x0E,0x04,0x01,0x0A,0x07,
0x01,0x06,0x0D,0x00,0x0B,0x08,0x06,0x0D
};
uint8_t SLUT7[64] = {
0x40,0xD0,0xB0,0x00,0x20,0xB0,0xE0,0x70,
0xF0,0x40,0x00,0x90,0x80,0x10,0xD0,0xA0,
0x30,0xE0,0xC0,0x30,0x90,0x50,0x70,0xC0,
0x50,0x20,0xA0,0xF0,0x60,0x80,0x10,0x60,
0x10,0x60,0x40,0xB0,0xB0,0xD0,0xD0,0x80,
0xC0,0x10,0x30,0x40,0x70,0xA0,0xE0,0x70,
0xA0,0x90,0xF0,0x50,0x60,0x00,0x80,0xF0,
0x00,0xE0,0x50,0x20,0x90,0x30,0x20,0xC0
};
uint8_t SLUT8[64] = {
0x0D,0x01,0x02,0x0F,0x08,0x0D,0x04,0x08,
0x06,0x0A,0x0F,0x03,0x0B,0x07,0x01,0x04,
0x0A,0x0C,0x09,0x05,0x03,0x06,0x0E,0x0B,
0x05,0x00,0x00,0x0E,0x0C,0x09,0x07,0x02,
0x07,0x02,0x0B,0x01,0x04,0x0E,0x01,0x07,
0x09,0x04,0x0C,0x0A,0x0E,0x08,0x02,0x0D,
0x00,0x0F,0x06,0x0C,0x0A,0x09,0x0D,0x00,
0x0F,0x03,0x03,0x05,0x05,0x06,0x08,0x0B
};
//initial permutation IP (on input)
uint8_t initial_register_permutation[64] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7};
//D-Box Expansion (sometimes noted as E BIT-SELECTION TABLE)
uint8_t message_expansion[48] = {
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1};
// (sometimes noted as simply 'P')
uint8_t right_half_permutation[32] = {
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25};
//inverse initial PI, a.k.a. final permutation (on output)
uint8_t final_register_permutation[64] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25};
//initial key permutation
uint8_t pc1_key_permutation[56] = {
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4};
//sub c and d key permutation
uint8_t pc2_key_permutation[48] = {
//c bits
14,17,11,24,1,5,
3,28,15,6,21,10,
23,19,12,4,26,8,
16,7,27,20,13,2,
//d bits (with -28 offset to simply/only have one permute function)
13,24,3,9,19,27,
2,12,23,17,5,20,
16,21,11,28,6,25,
18,14,22,8,1,4
};
uint8_t key_shift_sizes[17] = {
1,
1, 1, 2, 2,
2, 2, 2, 2,
1, 2, 2, 2,
2, 2, 2, 1};
uint8_t key_shift_bytes[17] = {
0x80,
0x80, 0x80, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0,
0x80, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0x80};
uint8_t key_shift_x[4] = {8,8,8,4};
uint8_t key_shift_y[4] = {1,2,3,0};
//input is byte-wise array, output is byte-wise array
void permute(uint8_t * input, uint8_t * output, uint8_t * table, uint8_t start, uint8_t end)
{
for (uint8_t i = start; i < end; i++)
{
uint8_t tdiv = (table[i] - 1) / 8;
uint8_t tmod = (table[i] - 1) % 8;
uint8_t idiv = i/8;
uint8_t imod = i%8;
//need a way to simplify or get rid of all these shifts
uint8_t bit = (((input[tdiv] & (0x80 >> tmod)) << tmod) >> imod);
output[idiv] |= bit;
}
}
void rotate_sub_keys(uint8_t * Kc, uint8_t * Kd, uint8_t shift_size, uint8_t shift_byte)
{
uint8_t sb1[4]; memset(sb1, 0, sizeof(sb1));
uint8_t sb2[4]; memset(sb2, 0, sizeof(sb2));
for (uint8_t i = 0; i < 4; i++)
{
sb1[i] = shift_byte & Kc[i];
sb2[i] = shift_byte & Kd[i];
}
for (uint8_t i = 0; i < 4; i++)
{
uint8_t x = key_shift_x[i];
uint8_t y = key_shift_y[i];
Kc[i] <<= shift_size;
Kd[i] <<= shift_size;
Kc[i] |= (sb1[y] >> (x - shift_size));
Kd[i] |= (sb2[y] >> (x - shift_size));
}
}
void des_cipher (uint8_t * main_key, uint8_t * input_register, uint8_t * output_register, uint8_t de)
{
//starting and ending permutations
uint8_t initial_permutation[8]; memset(initial_permutation, 0, sizeof(initial_permutation));
uint8_t pre_end_permutation[8]; memset(pre_end_permutation, 0, sizeof(pre_end_permutation));
//intermediate left, right, and expansion/selection arrays
uint8_t left[4]; memset(left, 0, sizeof(left));
uint8_t right[4]; memset(right, 0, sizeof(right));
uint8_t rperm[4]; memset(rperm, 0, sizeof(rperm));
uint8_t exp[6]; memset(exp, 0, sizeof(exp));
uint8_t sel[4]; memset(sel, 0, sizeof(sel));
//key sets
uint8_t Ks[16][7]; memset(Ks, 0, sizeof(Ks));
uint8_t Kc[4]; memset(Kc, 0, sizeof(Kc));
uint8_t Kd[4]; memset(Kd, 0, sizeof(Kd));
//initial Ks permutation and shuffle to Kc and Kd
permute (main_key, Ks[0], pc1_key_permutation, 0, 56);
for (uint8_t i = 0; i < 3; i++)
{
Kc[i] = Ks[0][i];
}
Kc[3] = Ks[0][3] & 0xF0;
for (uint8_t i = 0; i < 3; i++)
{
Kd[i] = (Ks[0][i+3] & 0x0F) << 4;
Kd[i] |= (Ks[0][i+4] & 0xF0) >> 4;
}
Kd[3] = (Ks[0][6] & 0x0F) << 4;
//reset Ks
memset(Ks, 0, sizeof(Ks));
//create the 16 Ks rounds
for (uint8_t i = 0; i < 16; i++)
{
uint8_t shift_size = key_shift_sizes[i+1];
uint8_t shift_byte = key_shift_bytes[i+1];
rotate_sub_keys(Kc, Kd, shift_size, shift_byte);
permute (Kc, Ks[i], pc2_key_permutation, 0, 24);
permute (Kd, Ks[i], pc2_key_permutation, 24, 48);
}
//permute the input_register with the ip (initial_register_permutation) table
permute (input_register, initial_permutation, initial_register_permutation, 0, 64);
//copy the initial permutation to left and right half arrays
memcpy (left, initial_permutation+0, sizeof(left));
memcpy (right, initial_permutation+4, sizeof(right));
//16 fiestel rounds
for (uint8_t f = 0; f < 16; f++)
{
//reset rperm and exp arrays
memset(rperm, 0, sizeof(rperm));
memset(exp, 0, sizeof(exp));
//expand right half from 32-bit to 48-bit
permute (right, exp, message_expansion, 0, 48);
//apply current iteration keyset to the expanded array (encryption cycles Ks forward, decryption goes in reverse)
if (de == 1)
{
for (uint8_t i = 0; i < 6; i++)
exp[i] ^= Ks[f][i];
}
else
{
for (uint8_t i = 0; i < 6; i++)
exp[i] ^= Ks[15-f][i];
}
//extract 6 bits for each sbox swap from the expanded array
uint8_t e1 = exp[0] >> 2;
uint8_t e2 = ((exp[0] & 0x3) << 4) | (exp[1] >> 4);
uint8_t e3 = ((exp[1] & 0xF) << 2) | (exp[2] >> 6);
uint8_t e4 = exp[2] & 0x3F;
uint8_t e5 = exp[3] >> 2;
uint8_t e6 = ((exp[3] & 0x3) << 4) | (exp[4] >> 4);
uint8_t e7 = ((exp[4] & 0xF) << 2) | (exp[5] >> 6);
uint8_t e8 = exp[5] & 0x3F;
//select 32-bits of each 48-bit expansion via modified S Box Look Up Tables
//swap the 6 bits for 4 bits via SLUT tables and OR them together into a selection array
sel[0] = SLUT1[e1] | SLUT2[e2];
sel[1] = SLUT3[e3] | SLUT4[e4];
sel[2] = SLUT5[e5] | SLUT6[e6];
sel[3] = SLUT7[e7] | SLUT8[e8];
//permute the selected 32-bits into a new right half
permute (sel, rperm, right_half_permutation, 0, 32);
//xor new right half against left half
for (uint8_t i = 0; i < 4; i++)
rperm[i] ^= left[i];
//swap old right half to left, set new right half to rperm
memcpy (left, right, sizeof(left));
memcpy (right, rperm, sizeof(right));
} //end fiestel rounds f
//combine right and left into the pre_end_permutation array
memcpy (pre_end_permutation+0, right, sizeof(right));
memcpy (pre_end_permutation+4, left, sizeof(left));
//carry out the final permuation to get the completed output_register for this cipher iteration
permute (pre_end_permutation, output_register, final_register_permutation, 0, 64);
}
void des56_ofb_keystream_output (uint8_t * main_key, uint8_t * iv, uint8_t * ks_bytes, uint8_t de, int16_t nblocks)
{
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the IV to the input_register (make copy so we don't manipulate the calling functions copy)
memcpy(input_register, iv, sizeof(input_register));
//execute the des_cipher in output feedback mode
for (int16_t i = 0; i < nblocks; i++)
{
//de should be 1 here for encryption mode
des_cipher(main_key, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input register
memcpy(ks_bytes+(i*8), output_register, sizeof(output_register)); //copy output_register to ks_bytes + iteration offset of times 8
memset(output_register, 0, sizeof(output_register)); //reset output register
}
}
//the des_cipher function is already ECB mode, this convenience wrapper is just available as a reminder to illustrate that point
void des56_ecb_payload_crypt (uint8_t * main_key, uint8_t * input_register, uint8_t * output_register, uint8_t de)
{
//de 1 for encryption mode, 0 for decryption mode
des_cipher(main_key, input_register, output_register, de);
}
//TDEA, or triple data encryption algorithm, or triple DES, in electronic codebook mode
void tdea_ecb_payload_crypt (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * input, uint8_t * output, uint8_t de)
{
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the input to the input_register (make copy so we don't manipulate the calling functions copy)
memcpy(input_register, input, sizeof(input_register));
//For TDEA, the cipher alternates between encryption and decryption to the payload
//so, for example, K1 is run as de=1, K2 is run as de=0, and K3 is run as de=1,
//K1 and K3 will always use the same mode and K2 will be the opposite
//NOTE: If running ECB mode in decryption, make sure to send the keys in reverse order
//so that its K3, K2, and K1 for decryption, and K1, K2, K3 for encryption
//K1
des_cipher(K1, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
de = (de ^ 1) & 1; //flip the de bit
des_cipher(K2, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
de = (de ^ 1) & 1; //flip the de bit back
des_cipher(K3, input_register, output_register, de);
//copy payload out
memcpy(output, output_register, sizeof(output_register)); //copy output_register to output
}
//TDEA, or triple data encryption algorithm, or triple DES, in cipher block chain mode (64-bit)
//same as usual inputs (byte wise), also, if needing DES56, just feed the same key into K1, K2, and K3
//if running in decryption mode, this will reverse the key bundle order from (K1, K2, K3) to (K3, K2, K1) on this end
void tdea_cbc_payload_crypt (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * iv, uint8_t * in, uint8_t * out, int16_t nblocks, uint8_t de)
{
int16_t i, j;
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//load first round of input_register accordingly
if (de)
memcpy (input_register, iv, sizeof(input_register)); //load the IV as first input_register if encrypting
else memcpy (input_register, in, sizeof(input_register)); //load first cipher text as input_register is decrypting
//run payload for number of payload nblocks required
for (i = 0; i < nblocks; i++)
{
if (de)
{
//xor the current input 'in' pt to the current state of the input_register for cbc feedback
for (j = 0; j < 8; j++)
input_register[j] ^= in[j+(i*8)];
//K1
des_cipher(K1, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
de = (de ^ 1) & 1; //flip the de bit
des_cipher(K2, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
de = (de ^ 1) & 1; //flip the de bit back
des_cipher(K3, input_register, output_register, de);
memcpy (input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
//copy ciphered output_register to output 'out'
memcpy (out+(i*8), output_register, sizeof(output_register));
memset(output_register, 0, sizeof(output_register)); //reset output register
}
else
{
//K3
des_cipher(K3, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
de = (de ^ 1) & 1; //flip the de bit
des_cipher(K2, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K1
de = (de ^ 1) & 1; //flip the de bit back
des_cipher(K1, input_register, output_register, de);
memcpy (input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
//copy ciphered input_register to output 'out'
memcpy (out+(i*8), output_register, sizeof(output_register));
//xor the current output by IV, or by last received CT, depending on round
if (i == 0)
{
for (j = 0; j < 8; j++)
out[j] ^= iv[j];
}
else
{
for (j = 0; j < 8; j++)
out[j+(i*8)] ^= in[j+((i-1)*8)];
}
//copy in next segment for input_register (if not last)
if (i < nblocks)
memcpy(input_register, in+((i+1)*8), sizeof(input_register));
memset(output_register, 0, sizeof(output_register)); //reset output register
}
}
}
//TDEA, or triple data encryption algorithm, or triple DES, in cipher block chain mode (64-bit)
//same as usual inputs (byte wise), also, if needing DES56, just feed the same key into K1, K2, and K3
//only the last output_register is returned for the variable len MAC bytes, always run in encryption mode
//but if iv is desireable, it will need to be pre-XOR'd with the first plaintext input block by the calling function
void tdea_cbc_mac_generator (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * in, uint8_t * out, int16_t nblocks)
{
int16_t i, j;
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//run payload for number of payload nblocks required
for (i = 0; i < nblocks; i++)
{
//the cipher is always run in the foward, or encryption mode (1,0,1)
//xor the current input 'in' pt to the current state of the input_register for cbc feedback
for (j = 0; j < 8; j++)
input_register[j] ^= in[j+(i*8)];
//K1
des_cipher(K1, input_register, output_register, 1);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
des_cipher(K2, input_register, output_register, 0);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
des_cipher(K3, input_register, output_register, 1);
memcpy (input_register, output_register, sizeof(output_register));
//copy ciphered output_register to output 'out'
//Since we only want the last output_register,
//this will overwrite the out until completion
memcpy (out, output_register, sizeof(output_register));
memset(output_register, 0, sizeof(output_register)); //reset output register
}
}
//TDEA, or triple data encryption algorithm, or triple DES, in cihper feedback mode (64-bit)
//same as usual inputs (byte wise), also, if needing DES56, just feed the same key into K1, K2, and K3
void tdea_cfb_payload_crypt (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * iv, uint8_t * in, uint8_t * out, int16_t nblocks, uint8_t de)
{
int16_t i, j;
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the IV to the input_register (make copy so we don't manipulate the calling functions copy)
memcpy(input_register, iv, sizeof(input_register));
//execute the des_cipher in output feedback mode 3 times using each key and transferring output to input each time
for (i = 0; i < nblocks; i++)
{
//the cipher is always run in the foward, or encryption mode (1,0,1)
//K1
des_cipher(K1, input_register, output_register, 1);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
des_cipher(K2, input_register, output_register, 0);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
des_cipher(K3, input_register, output_register, 1);
//xor the current input 'in' to the current state of the input_register for cipher feedback
for (j = 0; j < 8; j++)
output_register[j] ^= in[j+(i*8)];
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
//copy keystream out and reset
memcpy(out+(i*8), output_register, sizeof(output_register)); //copy output_register to ks_bytes + iteration offset of times 8
memset(output_register, 0, sizeof(output_register)); //reset output register
//if running in decryption mode, we feed in the next round of input
if (!de)
memcpy(input_register, in+(i*8), sizeof(input_register));
}
}
//TDEA, or triple data encryption algorithm, or triple DES, in IV counter mode (tested, working)
void tdea_ctr_payload_crypt (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * iv, uint8_t * input, uint8_t * output, int16_t nblocks)
{
int16_t i, j;
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the IV to the input_register (ctr mode will manipulate the IV, since it needs to keep a rolling counter
memcpy(input_register, iv, sizeof(input_register));
//execute the des_cipher in counter mode 3 times using each key and transferring output to input each time
//then the IV is iterated and fed back into the input_register to start the next nblocks loop
for (i = 0; i < nblocks; i++)
{
//CTR mode cipher should always run in the forward (encryption) mode
//K1
des_cipher(K1, input_register, output_register, 1);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
des_cipher(K2, input_register, output_register, 0);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
des_cipher(K3, input_register, output_register, 1);
//set output at current pointer to the xor of input current pointer and the output_register
for (j = 0; j < 8; j++)
output[j+(i*8)] = input[j+(i*8)] ^ output_register[j];
memset(output_register, 0, sizeof(output_register)); //reset output register
//increment the IV, and handle roll over (uint8_t will rollover to 0 after 0xFF)
for (j = 7; j >= 0; j--)
{
iv[j]++;
if (iv[j] == 0)
continue;
else break;
}
//debug IV iteration
// fprintf (stderr, "\n IV: ");
// for (j = 0; j < 8; j++)
// fprintf (stderr, "%02X", iv[j]);
//feed the new IV into the input register
memcpy (input_register, iv, sizeof(input_register));
}
}
//TDEA, or triple data encryption algorithm, or triple DES, in output feedback mode
void tdea_tofb_keystream_output (uint8_t * K1, uint8_t * K2, uint8_t * K3, uint8_t * iv, uint8_t * ks_bytes, uint8_t de, int16_t nblocks)
{
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the IV to the input_register (make copy so we don't manipulate the calling functions copy)
memcpy(input_register, iv, sizeof(input_register));
//execute the des_cipher in output feedback mode 3 times using each key and transferring output to input each time
for (int16_t i = 0; i < nblocks; i++)
{
//K1
des_cipher(K1, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K2
de = (de ^ 1) & 1; //flip the de bit
des_cipher(K2, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
memset(output_register, 0, sizeof(output_register)); //reset output register
//K3
de = (de ^ 1) & 1; //flip the de bit back
des_cipher(K3, input_register, output_register, de);
memcpy(input_register, output_register, sizeof(output_register)); //recycle output_register back into input_register
//copy keystream out and reset
memcpy(ks_bytes+(i*8), output_register, sizeof(output_register)); //copy output_register to ks_bytes + iteration offset of times 8
memset(output_register, 0, sizeof(output_register)); //reset output register
}
}
//a linear feedback shift register with maximal taps on 64-bit values that can be run to any specified len,
//its input is a byte array of up to 8 bytes, and its output is same array packed with new LFSR value in it.
uint64_t lfsr_64_to_len_ca(uint8_t * iv, int16_t len)
{
uint64_t lfsr = 0, bit = 0;
lfsr = ((uint64_t)iv[0] << 56ULL) + ((uint64_t)iv[1] << 48ULL) + ((uint64_t)iv[2] << 40ULL) + ((uint64_t)iv[3] << 32ULL) +
((uint64_t)iv[4] << 24ULL) + ((uint64_t)iv[5] << 16ULL) + ((uint64_t)iv[6] << 8ULL) + ((uint64_t)iv[7] << 0ULL);
memset (iv, 0, 8*sizeof(uint8_t));
for(int16_t cnt = 0; cnt < len; cnt++)
{
//63,61,45,37,27,14
// Polynomial is C(x) = x^64 + x^62 + x^46 + x^38 + x^27 + x^15 + 1
bit = ((lfsr >> 63) ^ (lfsr >> 61) ^ (lfsr >> 45) ^ (lfsr >> 37) ^ (lfsr >> 26) ^ (lfsr >> 14)) & 0x1;
lfsr = (lfsr << 1) | bit;
}
for (int16_t i = 0; i < 8; i++)
iv[i] = (lfsr >> (56-(i*8))) & 0xFF;
// fprintf (stderr, "\n IV(%02d): ", len);
// for (int16_t i = 0; i < 8; i++)
// fprintf (stderr, "%02X", iv[i]);
return bit;
}
void des56_ca_keystream_output (uint8_t * main_key, uint8_t * iv, uint8_t * ks_bytes, uint8_t de, int16_t ff, int16_t nbits)
{
//cipher input and output
uint8_t input_register[8]; memset(input_register, 0, sizeof(input_register));
uint8_t output_register[8]; memset(output_register, 0, sizeof(output_register));
//copy the IV to the input_register (make copy so we don't manipulate the calling functions copy)
memcpy(input_register, iv, sizeof(input_register));
//fast forward the current input_register state
lfsr_64_to_len_ca(input_register, ff);
//execute the des_cipher in (CA) mode with 1-bit output
for (int16_t i = 0; i < nbits; i++)
{
//de should be 1 here for encryption mode
des_cipher(main_key, input_register, output_register, de);
//keystream accumulation, shift current byte and append
//single bit from current output register's most significant bit
ks_bytes[i/8] <<= 1;
ks_bytes[i/8] |= ((output_register[0] >> 7) & 1);
//advance the input_register with the lfsr 1 time
lfsr_64_to_len_ca(input_register, 1);
//reset output register
memset(output_register, 0, sizeof(output_register));
}
// fprintf (stderr, "\n IR: ");
// for (int16_t i = 0; i < 8; i++)
// fprintf (stderr, "%02X", input_register[i]);
}
//transitional function mainly to load key and iv into an array
void des_multi_keystream_output (unsigned long long int mi, unsigned long long int key_ulli, uint8_t * output, int type, int len)
{
int i = 0;
uint8_t iv[8]; memset (iv, 0, sizeof(iv));
uint8_t key[8]; memset(key, 0, sizeof(key));
//convert unsinged long long int values into array values
for (i = 7; i >= 0; i--)
iv[7-i] = (mi >> (8*i)) & 0xFF;
for (i = 7; i >= 0; i--)
key[7-i] = (key_ulli >> (8*i)) & 0xFF;
//debug
// fprintf (stderr, "\n IV: ");
// for (i = 0; i < 8; i++)
// fprintf (stderr, "%02X", iv[i]);
// fprintf (stderr, "\n Key: ");
// for (i = 0; i < 8; i++)
// fprintf (stderr, "%02X", key[i]);
//types: 1 = DES56 OFB; 2 = DES56 CA (XL)
if (type == 2)
{
if (len == 0)
des56_ca_keystream_output(key, iv, output, 1, 110+696, 1704);
else des56_ca_keystream_output(key, iv, output, 1, 110+000, 1704);
}
else des56_ofb_keystream_output(key, iv, output, 1, len);
}
//transitional function mainly to load iv into an array
void tdea_multi_keystream_output (unsigned long long int mi, uint8_t * key, uint8_t * output, int type, int len)
{
int i = 0;
uint8_t iv[8]; memset (iv, 0, sizeof(iv));
//convert unsinged long long int values into array values
for (i = 7; i >= 0; i--)
iv[7-i] = (mi >> (8*i)) & 0xFF;
//debug
// fprintf (stderr, "\n IV: ");
// for (i = 0; i < 8; i++)
// fprintf (stderr, "%02X", iv[i]);
//type 1 = TDEA TOFB //TODO: Add more types like 2DES?
if (type == 1)
tdea_tofb_keystream_output(key, key+8, key+16, iv, output, 1, len);
else tdea_tofb_keystream_output(key, key+8, key+16, iv, output, 1, len);
}

126
src/crypt-etc.c Normal file
View File

@@ -0,0 +1,126 @@
#include "dsd.h"
void ken_dmr_scrambler_keystream_creation(dsd_state * state, char * input)
{
/*
SLOT 1 Protected LC FLCO=0x00 FID=0x20 <--this link appears to indicate scrambler usage from Kenwood on DMR
DMR PDU Payload [80][20][40][00][00][01][00][00][01] SB: 00000000000 - 000;
SLOT 1 TGT=1 SRC=1 FLCO=0x00 FID=0x00 SVC=0x00 Group Call <--different call, no scrambler from same Kenwood Radio
DMR PDU Payload [00][00][00][00][00][01][00][00][01]
For This, we could possible transition this to not be enforced
since we may have a positive indicator in link control,
but needs further samples and validation
*/
int lfsr = 0, bit = 0;
sscanf (input, "%d", &lfsr);
fprintf (stderr,"DMR Kenwood 15-bit Scrambler Key %05d with Forced Application\n", lfsr);
for (int i = 0; i < 882; i++)
{
state->static_ks_bits[0][i] = lfsr & 0x1;
state->static_ks_bits[1][i] = lfsr & 0x1;
bit = ( (lfsr >> 1) ^ (lfsr >> 0) ) & 1;
lfsr = ( (lfsr >> 1 ) | (bit << 14) );
}
state->ken_sc = 1;
}
void anytone_bp_keystream_creation(dsd_state * state, char * input)
{
uint16_t key = 0;
uint16_t kperm = 0;
sscanf (input, "%hX", &key);
key &= 0xFFFF; //truncate to 16-bits
//calculate key permutation using simple operations
uint8_t nib1, nib2, nib3, nib4;
//nib 1 and 3 are simple inversions
nib1 = ~(key >> 12) & 0xF;
nib3 = ~(key >> 4) & 0xF;
//nib 2 and 4 are +8 and mod 16 (& 0xF)
nib2 = (((key >> 8) & 0xF) + 8) % 16;
nib4 = (((key >> 0) & 0xF) + 8) % 16;
//debug
// fprintf (stderr, "{%01X, %01X, %01X, %01X}", nib1, nib2, nib3, nib4);
kperm = nib1;
kperm <<= 4;
kperm |= nib2;
kperm <<= 4;
kperm |= nib3;
kperm <<= 4;
kperm |= nib4;
//load bits into static keystream
for (int i = 0; i < 16; i++)
{
state->static_ks_bits[0][i] = (kperm >> (15-i)) & 1;
state->static_ks_bits[1][i] = (kperm >> (15-i)) & 1;
}
fprintf (stderr,"DMR Anytone Basic 16-bit Key 0x%04X with Forced Application\n", key);
state->any_bp = 1;
}
void straight_mod_xor_keystream_creation(dsd_state * state, char * input)
{
uint16_t len = 0;
char * curr;
curr = strtok(input, ":"); //should be len (mod) of key (decimal)
if (curr != NULL)
sscanf (curr, "%hd", &len);
else goto END_KS;
//len sanity check, can't be greater than 882
if (len > 882)
len = 882;
curr = strtok(NULL, ":"); //should be key in hex
if (curr != NULL)
{
//continue
}
else goto END_KS;
uint8_t ks_bytes[112];
memset (ks_bytes, 0, sizeof(ks_bytes));
parse_raw_user_string(curr, ks_bytes);
uint8_t ks_bits[896];
memset(ks_bits, 0, sizeof(ks_bits));
uint16_t unpack_len = len / 8;
if (len % 8)
unpack_len++;
unpack_byte_array_into_bit_array(ks_bytes, ks_bits, unpack_len);
for (uint16_t i = 0; i < len; i++)
{
state->static_ks_bits[0][i] = ks_bits[i];
state->static_ks_bits[1][i] = ks_bits[i];
}
fprintf (stderr,"AMBE Straight XOR %d-bit Keystream: ", len);
for (uint16_t i = 0; i < unpack_len; i++)
fprintf (stderr, "%02X", ks_bytes[i]);
fprintf (stderr, " with Forced Application \n");
state->straight_ks = 1;
state->straight_mod = (int)len;
END_KS:
if (curr == NULL)
fprintf (stderr, "Straight KS String Malformed! No KS Created!\n");
}

392
src/crypt-pc4.c Normal file
View File

@@ -0,0 +1,392 @@
#include "pc4.h"
/* Global PC4 context instance */
PC4Context ctx;
/* ---------------------------------
Internal utility functions
----------------------------------- */
/* Rotate right */
static uint32_t ror(uint32_t x, int shift, int bits) {
uint32_t m0 = (1u << (bits - shift)) - 1u;
uint32_t m1 = (1u << shift) - 1u;
return ((x >> shift) & m0) | ((x & m1) << (bits - shift));
}
/* Rotate left */
static uint32_t rol(uint32_t x, int shift, int bits) {
uint32_t m0 = (1u << (bits - shift)) - 1u;
uint32_t m1 = (1u << shift) - 1u;
return ((x & m0) << shift) | ((x >> (bits - shift)) & m1);
}
/* SplitMix64 random number generator */
static uint64_t next_rng(PC4Context *ctx) {
uint64_t z = (ctx->x += 0x9e3779b97f4a7c15ULL);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ULL;
z = (z ^ (z >> 27)) * 0x94d049bb133111ebULL;
return z ^ (z >> 31);
}
/* ARC4 initialization */
static void arc4_init(PC4Context *ctx, unsigned char key[]) {
int tmp;
for (ctx->i_arc4 = 0; ctx->i_arc4 < 256; ctx->i_arc4++)
ctx->array_arc4[ctx->i_arc4] = (unsigned char)ctx->i_arc4;
ctx->j_arc4 = 0;
for (ctx->i_arc4 = 0; ctx->i_arc4 < 256; ctx->i_arc4++) {
ctx->j_arc4 = (ctx->j_arc4 + ctx->array_arc4[ctx->i_arc4] + key[ctx->i_arc4 % 256]) % 256;
tmp = ctx->array_arc4[ctx->i_arc4];
ctx->array_arc4[ctx->i_arc4] = ctx->array_arc4[ctx->j_arc4];
ctx->array_arc4[ctx->j_arc4] = tmp;
}
ctx->i_arc4 = 0;
ctx->j_arc4 = 0;
}
/* ARC4 output combined with SplitMix64 stream */
static unsigned char arc4_output(PC4Context *ctx) {
uint8_t rndbyte, decal;
int tmp, t;
ctx->i_arc4 = (ctx->i_arc4 + 1) % 256;
ctx->j_arc4 = (ctx->j_arc4 + ctx->array_arc4[ctx->i_arc4]) % 256;
tmp = ctx->array_arc4[ctx->i_arc4];
ctx->array_arc4[ctx->i_arc4] = ctx->array_arc4[ctx->j_arc4];
ctx->array_arc4[ctx->j_arc4] = tmp;
t = (ctx->array_arc4[ctx->i_arc4] + ctx->array_arc4[ctx->j_arc4]) % 256;
if (ctx->xyz == 0) ctx->bb = next_rng(ctx);
decal = (uint8_t)(56 - (8 * ctx->xyz));
rndbyte = (uint8_t)((ctx->bb >> decal) & 0xffu);
ctx->xyz++;
if (ctx->xyz == 8) ctx->xyz = 0;
if (ctx->count == 0) {
rndbyte = (uint8_t)(rndbyte ^ ctx->array_arc4[t]);
ctx->count = 1;
} else {
rndbyte = (uint8_t)(rndbyte + ctx->array_arc4[t]);
ctx->count = 0;
}
return rndbyte;
}
/* Initialize MD2-II state */
static void md2_init(PC4Context *ctx) {
ctx->x1 = 0;
ctx->x2 = 0;
for (ctx->i = 0; ctx->i < n1; ctx->i++) ctx->h2[ctx->i] = 0;
for (ctx->i = 0; ctx->i < n1; ctx->i++) ctx->h1[ctx->i] = 0;
}
/* MD2-II hashing */
static void md2_hashing(PC4Context *ctx, unsigned char t1[], size_t b6) {
static const unsigned char s4[256] = {
13,199,11,67,237,193,164,77,115,184,141,222,73,38,147,36,150,87,21,104,12,61,156,101,111,145,
119,22,207,35,198,37,171,167,80,30,219,28,213,121,86,29,214,242,6,4,89,162,110,175,19,157,3,
88,234,94,144,118,159,239,100,17,182,173,238,68,16,79,132,54,163,52,9,58,57,55,229,192,170,226,
56,231,187,158,70,224,233,245,26,47,32,44,247,8,251,20,197,185,109,153,204,218,93,178,212,137,84,
174,24,120,130,149,72,180,181,208,255,189,152,18,143,176,60,249,27,227,128,139,243,253,59,123,172,
108,211,96,138,10,215,42,225,40,81,65,90,25,98,126,154,64,124,116,122,5,1,168,83,190,131,191,244,
240,235,177,155,228,125,66,43,201,248,220,129,188,230,62,75,71,78,34,31,216,254,136,91,114,106,46,
217,196,92,151,209,133,51,236,33,252,127,179,69,7,183,105,146,97,39,15,205,112,200,166,223,45,48,
246,186,41,148,140,107,76,85,95,194,142,50,49,134,23,135,169,221,210,203,63,165,82,161,202,53,14,
206,232,103,102,195,117,250,99,0,74,160,241,2,113};
int b1, b2, b3, b4, b5;
b4 = 0;
while (b6) {
for (; b6 && ctx->x2 < n1; b6--, ctx->x2++) {
b5 = t1[b4++];
ctx->h1[ctx->x2 + n1] = (unsigned char)b5;
ctx->h1[ctx->x2 + (n1 * 2)] = (unsigned char)(b5 ^ ctx->h1[ctx->x2]);
ctx->x1 = ctx->h2[ctx->x2] ^= s4[b5 ^ ctx->x1];
}
if (ctx->x2 == n1) {
b2 = 0;
ctx->x2 = 0;
for (b3 = 0; b3 < (n1 + 2); b3++) {
for (b1 = 0; b1 < (n1 * 3); b1++)
b2 = ctx->h1[b1] ^= s4[b2];
b2 = (b2 + b3) % 256;
}
}
}
}
/* Finalize MD2-II */
static void md2_end(PC4Context *ctx, unsigned char h4[n1]) {
unsigned char h3[n1];
int i, n4 = n1 - ctx->x2;
for (i = 0; i < n4; i++) h3[i] = (unsigned char)n4;
md2_hashing(ctx, h3, (size_t)n4);
md2_hashing(ctx, ctx->h2, sizeof(ctx->h2));
for (i = 0; i < n1; i++) h4[i] = ctx->h1[i];
}
/* Generate a random index */
static int mixy(PC4Context *ctx, int nn2) {
return arc4_output(ctx) % nn2;
}
/* Fisher-Yates shuffle */
static void mixer(PC4Context *ctx, uint8_t *mixu, int nn) {
int ii, jj, tmmp;
for (ii = nn - 1; ii > 0; ii--) {
jj = mixy(ctx, ii + 1);
tmmp = mixu[jj];
mixu[jj] = mixu[ii];
mixu[ii] = (uint8_t)tmmp;
}
}
/* Key schedule and S-box generation */
void create_keys(PC4Context *ctx, unsigned char key1[], size_t size1) {
int i, w, k;
unsigned char h4[n1];
md2_init(ctx);
md2_hashing(ctx, key1, size1);
md2_end(ctx, h4);
for (i = 0; i < 16; i++) ctx->keys[i] = h4[i];
arc4_init(ctx, h4);
ctx->x = 0;
for (i = 0; i < 8; i++) ctx->x = (ctx->x << 8) + (uint64_t)(h4[256 + i] & 0xffu);
ctx->xyz = 0;
ctx->count = 0;
for (i = 0; i < 20000; i++) (void)arc4_output(ctx);
uint8_t numbers[256];
for (w = 0; w < 16; w++) {
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 256; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 256);
for (i = 0; i < 256; i++) ctx->perm[w][i] = numbers[i];
}
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 256; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 256);
for (i = 0; i < 256; i++) ctx->new1[i] = numbers[i];
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 49; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 49);
for (i = 0; i < 49; i++) ctx->array[i] = numbers[i];
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < nbround; i++) ctx->decal[i] = (uint8_t)((arc4_output(ctx) % 23) + 1);
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (w = 0; w < 3; w++)
for (i = 0; i < nbround; i++)
ctx->rngxor[i][w] = arc4_output(ctx);
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 49; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 49);
for (i = 0; i < 49; i++) ctx->array2[i] = numbers[i];
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 256; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 256);
for (i = 0; i < 256; i++) {
ctx->tab[i] = numbers[i];
ctx->inv[ctx->tab[i]] = (unsigned char)i;
}
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (w = 0; w < 3; w++) {
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (i = 0; i < 3; i++) numbers[i] = (uint8_t)i;
mixer(ctx, numbers, 3);
for (i = 0; i < 3; i++) ctx->permut[w][i] = numbers[i];
}
k = arc4_output(ctx) + 256;
for (i = 0; i < k; i++) (void)arc4_output(ctx);
for (w = 0; w < 3; w++)
for (i = 0; i < nbround; i++)
ctx->rngxor2[i][w] = arc4_output(ctx);
}
/* Compute round transformation */
static void compute(PC4Context *ctx, uint8_t *tab1, uint8_t round) {
ctx->tot[0] = (uint8_t)((ctx->perm[round][tab1[ctx->permut[0][0]]] +
ctx->perm[round][tab1[ctx->permut[0][1]]]) ^
ctx->perm[round][tab1[ctx->permut[0][2]]]);
ctx->tot[0] = (uint8_t)(ctx->tot[0] + ctx->new1[ctx->tot[0]]);
ctx->tot[1] = (uint8_t)((ctx->perm[round][tab1[ctx->permut[1][0]]] +
ctx->perm[round][tab1[ctx->permut[1][1]]]) ^
ctx->perm[round][tab1[ctx->permut[1][2]]]);
ctx->tot[1] = (uint8_t)(ctx->tot[1] + ctx->new1[ctx->tot[1]]);
ctx->tot[2] = (uint8_t)((ctx->perm[round][tab1[ctx->permut[2][0]]] +
ctx->perm[round][tab1[ctx->permut[2][1]]]) ^
ctx->perm[round][tab1[ctx->permut[2][2]]]);
ctx->tot[2] = (uint8_t)(ctx->tot[2] + ctx->new1[ctx->tot[2]]);
}
/* Convert bits to bytes */
void binhex(PC4Context *ctx, short *z, int length) {
short *b = (short *)z;
uint8_t i, j;
for (i = 0; i < length; i = j) {
uint8_t a = 0;
for (j = i; j < i + 8; ++j) {
a |= (uint8_t)(b[((short)(7 - (j % 8)) + j) - (j % 8)] << (j - i));
}
ctx->convert[ctx->ptconvert] = a;
ctx->ptconvert++;
}
}
/* Convert byte to bits */
void hexbin(PC4Context *ctx, short *q, uint8_t w, uint8_t hex) { // warning: unused parameter ‘ctx’ [-Wunused-parameter]
short *bits = (short *)q;
for (uint8_t i = 0; i < 8; ++i) {
bits[(short)(7 + w) - i] = (short)((hex >> i) & 1u);
}
UNUSEDPC4(ctx); //fix above warning
}
/* Encrypt one block */
void pc4encrypt(PC4Context *ctx) {
int i;
ctx->totb = 0;
for (i = 0; i < 3; i++) {
ctx->l[0][i] = ctx->convert[i];
ctx->r[0][i] = ctx->convert[i + 3];
}
for (i = 1; i <= ctx->rounds; i++) {
ctx->totb ^= ctx->r[(i - 1) % 2][0];
ctx->totb ^= ctx->r[(i - 1) % 2][1];
ctx->totb ^= ctx->r[(i - 1) % 2][2];
ctx->r[(i - 1) % 2][0] += (uint8_t)(~ctx->rngxor2[ctx->rounds - i][0]);
ctx->r[(i - 1) % 2][1] ^= (uint8_t)(~ctx->rngxor2[ctx->rounds - i][1]);
ctx->r[(i - 1) % 2][2] += (uint8_t)(~ctx->rngxor2[ctx->rounds - i][2]);
ctx->result = 0;
ctx->result += ((uint32_t)ctx->r[(i - 1) % 2][0] << 16);
ctx->result += ((uint32_t)ctx->r[(i - 1) % 2][1] << 8);
ctx->result += ctx->r[(i - 1) % 2][2];
ctx->result = rol(ctx->result, ctx->decal[i - 1], 24);
ctx->r[(i - 1) % 2][0] = (uint8_t)(ctx->result >> 16);
ctx->r[(i - 1) % 2][1] = (uint8_t)((ctx->result >> 8) & 0xffu);
ctx->r[(i - 1) % 2][2] = (uint8_t)(ctx->result & 0xffu);
ctx->r[(i - 1) % 2][0] = ctx->tab[ctx->r[(i - 1) % 2][0]];
ctx->r[(i - 1) % 2][0] ^= ctx->rngxor[i - 1][0];
ctx->r[(i - 1) % 2][1] = ctx->inv[ctx->r[(i - 1) % 2][1]];
ctx->r[(i - 1) % 2][1] -= ctx->rngxor[i - 1][1];
ctx->r[(i - 1) % 2][2] = ctx->tab[ctx->r[(i - 1) % 2][2]];
ctx->r[(i - 1) % 2][2] ^= ctx->rngxor[i - 1][2];
compute(ctx, ctx->r[(i - 1) % 2], (uint8_t)((i - 1) % 16));
ctx->l[i % 2][0] = ctx->r[(i - 1) % 2][0];
ctx->r[i % 2][0] = ctx->l[(i - 1) % 2][0] - ctx->tot[0];
ctx->l[i % 2][1] = ctx->r[(i - 1) % 2][1];
ctx->r[i % 2][1] = ctx->l[(i - 1) % 2][1] ^ ctx->tot[1];
ctx->l[i % 2][2] = ctx->r[(i - 1) % 2][2];
ctx->r[i % 2][2] = ctx->l[(i - 1) % 2][2] - ctx->tot[2];
}
for (i = 0; i < 3; i++) {
ctx->convert[i + 3] = ctx->l[(ctx->rounds - 1) % 2][i];
ctx->convert[i] = ctx->r[(ctx->rounds - 1) % 2][i];
}
ctx->totb %= 2;
}
/* Decrypt one block */
void pc4decrypt(PC4Context *ctx) {
int i;
ctx->totb = 0;
for (i = 0; i < 3; i++) {
ctx->l[0][i] = ctx->convert[i];
ctx->r[0][i] = ctx->convert[i + 3];
}
ctx->y = (uint8_t)((ctx->rounds - 1) % 16);
if (ctx->y == 0) ctx->y = 16;
for (i = 1; i <= ctx->rounds; i++) {
ctx->y--;
compute(ctx, ctx->r[(i - 1) % 2], ctx->y);
if (ctx->y == 0) ctx->y = 16;
ctx->result = 0;
ctx->l[(i - 1) % 2][0] ^= ctx->rngxor[ctx->rounds - i][0];
ctx->l[(i - 1) % 2][0] = ctx->inv[ctx->l[(i - 1) % 2][0]];
ctx->l[(i - 1) % 2][1] += ctx->rngxor[ctx->rounds - i][1];
ctx->l[(i - 1) % 2][1] = ctx->tab[ctx->l[(i - 1) % 2][1]];
ctx->l[(i - 1) % 2][2] ^= ctx->rngxor[ctx->rounds - i][2];
ctx->l[(i - 1) % 2][2] = ctx->inv[ctx->l[(i - 1) % 2][2]];
ctx->result += ((uint32_t)ctx->l[(i - 1) % 2][0] << 16);
ctx->result += ((uint32_t)ctx->l[(i - 1) % 2][1] << 8);
ctx->result += ctx->l[(i - 1) % 2][2];
ctx->result = ror(ctx->result, ctx->decal[ctx->rounds - i], 24);
ctx->l[(i - 1) % 2][0] = (uint8_t)(ctx->result >> 16);
ctx->l[(i - 1) % 2][1] = (uint8_t)((ctx->result >> 8) & 0xffu);
ctx->l[(i - 1) % 2][2] = (uint8_t)(ctx->result & 0xffu);
ctx->l[(i - 1) % 2][0] -= (uint8_t)(~ctx->rngxor2[i - 1][0]);
ctx->l[(i - 1) % 2][1] ^= (uint8_t)(~ctx->rngxor2[i - 1][1]);
ctx->l[(i - 1) % 2][2] -= (uint8_t)(~ctx->rngxor2[i - 1][2]);
ctx->totb ^= ctx->l[(i - 1) % 2][0];
ctx->totb ^= ctx->l[(i - 1) % 2][1];
ctx->totb ^= ctx->l[(i - 1) % 2][2];
ctx->l[i % 2][0] = ctx->r[(i - 1) % 2][0];
ctx->r[i % 2][0] = ctx->l[(i - 1) % 2][0] + ctx->tot[0];
ctx->l[i % 2][1] = ctx->r[(i - 1) % 2][1];
ctx->r[i % 2][1] = ctx->l[(i - 1) % 2][1] ^ ctx->tot[1];
ctx->l[i % 2][2] = ctx->r[(i - 1) % 2][2];
ctx->r[i % 2][2] = ctx->l[(i - 1) % 2][2] + ctx->tot[2];
}
for (i = 0; i < 3; i++) {
ctx->convert[i + 3] = ctx->l[(ctx->rounds - 1) % 2][i];
ctx->convert[i] = ctx->r[(ctx->rounds - 1) % 2][i];
}
ctx->totb %= 2;
}

146
src/crypt-rc4.c Normal file
View File

@@ -0,0 +1,146 @@
/*-------------------------------------------------------------------------------
* rc4.c Crypthings
* RC4 Alg
*-----------------------------------------------------------------------------*/
#include "dsd.h"
//this version is for voice, going to transition to a block output version
void rc4_voice_decrypt(int drop, uint8_t keylength, uint8_t messagelength, uint8_t key[], uint8_t cipher[], uint8_t plain[])
{
int i, j, count;
uint8_t t, b;
//init Sbox
uint8_t S[256];
for(int i = 0; i < 256; i++) S[i] = i;
//Key Scheduling
j = 0;
for(i = 0; i < 256; i++)
{
j = (j + S[i] + key[i % keylength]) % 256;
t = S[i];
S[i] = S[j];
S[j] = t;
}
//Drop Bytes and Cipher Byte XOR
i = j = 0;
for(count = 0; count < (messagelength + drop); count++)
{
i = (i + 1) % 256;
j = (j + S[i]) % 256;
t = S[i];
S[i] = S[j];
S[j] = t;
b = S[(S[i] + S[j]) % 256];
//return mbe payload byte here
if (count >= drop)
plain[count - drop] = b^cipher[count - drop];
}
}
//this is for PDU usage
void rc4_block_output (int drop, int keylen, int meslen, uint8_t * key, uint8_t * output_blocks)
{
int i, j, x, count;
unsigned int keylength = (unsigned int)keylen;
unsigned int messagelength = (unsigned int)meslen;
unsigned int S[256];
for(i=0; i<256; i++)
S[i] = i;
j = 0;
for(i = 0; i<256; i++)
{
j = (j + S[i] + key[i % keylength]) % 256;
unsigned int temp = S[i];
S[i] = S[j];
S[j] = temp;
}
//Generate Keystream
i = 0;
j = 0;
x = 0;
unsigned int byte;
// fprintf (stderr, " Keystream Octets = ");
for(count = 0; count < (messagelength + drop); count++)
{
i = (i + 1) % 256;
j = (j + S[i]) % 256;
unsigned int temp = S[i];
S[i] = S[j];
S[j] = temp;
byte = S[(S[i] + S[j]) % 256];
//Collect Output blocks
if (count >= drop)
output_blocks[x++] = byte;
}
}
//This is now verified to work after changing the drop byte value from 256 to 0.
//also, had to change the application to not skip the additional 7 bits like DMRA or P25 does.
void hytera_enhanced_rc4_setup(dsd_opts * opts, dsd_state * state, unsigned long long int key_value, unsigned long long int mi_value)
{
UNUSED(opts);
uint8_t key[5]; memset (key, 0, sizeof(key));
uint8_t kiv[5]; memset (kiv, 0, sizeof(kiv));
uint8_t mi[5]; memset (mi, 0, sizeof(mi));
uint8_t ks[135]; memset (ks, 0, sizeof(ks));
//load key_value into key array
key[0] = ((key_value & 0xFF00000000) >> 32UL);
key[1] = ((key_value & 0xFF000000) >> 24);
key[2] = ((key_value & 0xFF0000) >> 16);
key[3] = ((key_value & 0xFF00) >> 8);
key[4] = ((key_value & 0xFF) >> 0);
//load mi_value into mi array
mi[0] = ((mi_value & 0xFF00000000) >> 32UL);
mi[1] = ((mi_value & 0xFF000000) >> 24);
mi[2] = ((mi_value & 0xFF0000) >> 16);
mi[3] = ((mi_value & 0xFF00) >> 8);
mi[4] = ((mi_value & 0xFF) >> 0);
//pointer to the ks_octet storage
uint8_t * ks_octets;
if (state->currentslot == 0)
ks_octets = state->ks_octetL;
else ks_octets = state->ks_octetR;
//NOTE: Drop Byte value is 0
rc4_block_output(0, 5, 135, key, ks);
for (int i = 0; i < 5; i++)
kiv[i] = key[i] ^ mi[i];
for (int i = 0; i < 135; i++)
ks_octets[i] = kiv[i%5] ^ ks[i];
//debug
// fprintf (stderr, " KS: ");
// for (int i = 0; i < 135; i++)
// {
// if ((i != 0) && ((i%7) == 0))
// fprintf (stderr, " ");
// fprintf (stderr, "%02X", ks[i]); //ks_octets
// }
//NULL pointer to ks_octets
ks_octets = NULL;
//end line break
// fprintf (stderr, "\n");
}

241
src/crypt-tyt.c Normal file
View File

@@ -0,0 +1,241 @@
#include "dsd.h"
#include "dmr_const.h"
#include "pc4.h"
//interleaved code words for AMBE+2 (as it arrives over the air)
void ambe2_codeword_print_i (dsd_opts * opts, char ambe_fr[4][24])
{
uint8_t interleaved[72];
memset (interleaved, 0, sizeof(interleaved));
//reinterleave the frame
const int *w, *x, *y, *z;
w = rW; x = rX; y = rY; z = rZ;
for (int8_t i = 0; i < 36; i++)
{
interleaved[(i*2)+0] = (uint8_t)ambe_fr[*w][*x];
interleaved[(i*2)+1] = (uint8_t)ambe_fr[*y][*z];
w++;
x++;
y++;
z++;
}
uint8_t bytes[9]; memset(bytes, 0, sizeof(bytes));
//pack
pack_bit_array_into_byte_array(interleaved, bytes, 9);
if (opts->payload == 1)
{
fprintf (stderr, " AMBE HEX(72) INT: ");
for (int8_t i = 0; i < 9; i++)
fprintf (stderr, "%02X", bytes[i]);
fprintf (stderr, "\n");
}
}
//de-interleaved code words for AMBE+2
void ambe2_codeword_print_b (dsd_opts * opts, char ambe_fr[4][24])
{
uint8_t fr_reverse[4][24]; memset(fr_reverse, 0, sizeof(fr_reverse));
for (int i = 0; i < 24; i++)
fr_reverse[0][i] = ambe_fr[0][23-i];
for (int i = 0; i < 23; i++)
fr_reverse[1][i] = ambe_fr[1][22-i];
for (int i = 0; i < 11; i++)
fr_reverse[2][i] = ambe_fr[2][10-i];
for (int i = 0; i < 14; i++)
fr_reverse[3][i] = ambe_fr[3][13-i];
uint32_t v0 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[0], 24); //24
uint32_t v1 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[1], 23); //23
uint32_t v2 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[2], 11); //11
uint32_t v3 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[3], 14); //14
uint32_t c0 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[0], 12);
uint32_t c1 = (uint32_t)convert_bits_into_output((uint8_t *)fr_reverse[1], 12);
//72 bit version
unsigned long long int hex1 = ((unsigned long long int)v0 << 40ULL) + ((unsigned long long int)v1 << 17ULL) + ((unsigned long long int)v2 << 6ULL) + (v3 >> 8);
unsigned long long int hex2 = v3 & 0xFF;
//49 bit version prior to golay correction and c1 demodulation pN
unsigned long long int hex49 = ((unsigned long long int)c0 << 37ULL) + ((unsigned long long int)c1 << 25ULL) + ((unsigned long long int)v2 << 14ULL) + v3;
UNUSED(opts);
if (opts->payload == 1)
{
fprintf (stderr, " AMBE HEX(72): %016llX%02llX \n", hex1, hex2);
fprintf (stderr, " AMBE HEX(49): %014llX\n", hex49 << 7);
}
}
//de-interleaved code words for AMBE+2
void ambe2_codeword_print_f (dsd_opts * opts, char ambe_fr[4][24])
{
uint32_t v0 = (uint32_t)convert_bits_into_output((uint8_t *)ambe_fr[0], 24); //24
uint32_t v1 = (uint32_t)convert_bits_into_output((uint8_t *)ambe_fr[1], 23); //23
uint32_t v2 = (uint32_t)convert_bits_into_output((uint8_t *)ambe_fr[2], 11); //11
uint32_t v3 = (uint32_t)convert_bits_into_output((uint8_t *)ambe_fr[3], 14); //14
// if (opts->payload == 1)
// fprintf (stderr, " AMBE V0: %06X; V1: %06X; V2: %03X; V3: %04X; \n", v0, v1, v2, v3);
unsigned long long int hex1 = ((unsigned long long int)v0 << 40ULL) + ((unsigned long long int)v1 << 17ULL) + ((unsigned long long int)v2 << 6ULL) + (v3 >> 8);
unsigned long long int hex2 = v3 & 0xFF;
if (opts->payload == 1)
fprintf (stderr, " AMBE HEX(72): %016llX%02llX \n", hex1, hex2);
}
//NOTE: This mode DOES NOT work over a repeater, simplex only
//repeaters may or will attempt to correct the frame errors
void tyt16_ambe2_codeword_keystream(dsd_state * state, char ambe_fr[4][24], int fnum)
{
char interleaved[72];
memset (interleaved, 0, sizeof(interleaved));
//interleave the frame
const int *w, *x, *y, *z;
w = rW; x = rX; y = rY; z = rZ;
for (int8_t i = 0; i < 36; i++)
{
interleaved[(i*2)+0] = ambe_fr[*w][*x];
interleaved[(i*2)+1] = ambe_fr[*y][*z];
w++;
x++;
y++;
z++;
}
uint8_t ks_bytes[10]; memset(ks_bytes, 0, sizeof(ks_bytes));
uint8_t ks[80]; memset(ks, 0, sizeof(ks));
ks_bytes[0] = (state->H >> 8) & 0xFF;
ks_bytes[1] = (state->H >> 0) & 0xFF;
//copy same bytes into rest of byte array
for (int16_t i = 2; i < 10; i++)
ks_bytes[i] = ks_bytes[i%2];
//convert byte array into a bit array
unpack_byte_array_into_bit_array(ks_bytes, ks, 10);
//set ks idx position (-1)
int idx = 0;
if (fnum == 0)
idx = 79;
else idx = 71;
//apply keystream to interleave
for (int8_t i = 0; i < 72; i++)
interleaved[i] ^= ks[idx--];
//deinterleave back into ambe_fr frame
w = rW; x = rX; y = rY; z = rZ;
int k = 0;
for (int8_t i = 0; i < 36; i++)
{
ambe_fr[*w][*x] = interleaved[k++];
ambe_fr[*y][*z] = interleaved[k++];
w++;
x++;
y++;
z++;
}
}
void tyt_ap_pc4_keystream_creation(dsd_state * state, char * input)
{
unsigned char key1[16] = {0};
unsigned char key2[16] = {0};
char buf[1024];
strncpy(buf, input, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
char *pEnd;
uint64_t K1 = strtoull(buf, &pEnd, 16);
uint64_t K2 = strtoull(pEnd, &pEnd, 16);
u64_to_bytes_be(K1, &key1[0]);
u64_to_bytes_be(K2, &key1[8]);
for (int i=0;i<16;i++) key2[i] = key1[15-i];
/* Create key schedule */
create_keys(&ctx, key2, sizeof(key2));
ctx.rounds = nbround;
fprintf (stderr,"DMR TYT AP (PC4) 128-bit Key %016llX%016llX with Forced Application\n", (unsigned long long int)K1, (unsigned long long int)K2);
state->tyt_ap = 1;
}
void tyt_ep_aes_keystream_creation(dsd_state * state, char * input)
{
char buf[1024];
strncpy(buf, input, 1023);
buf[1023] = '\0';
char *pEnd;
unsigned long long int K1 = strtoull (buf, &pEnd, 16);
unsigned long long int K2 = strtoull (pEnd, &pEnd, 16);
//
uint8_t static_key[32];
memset(static_key, 0, sizeof(static_key));
//static key value
static_key[0]=0x6e; static_key[1]=0x02; static_key[2]=0x8d; static_key[3]=0x8a;
static_key[4]=0xca; static_key[5]=0xeb; static_key[6]=0x9b; static_key[7]=0xbe;
static_key[8]=0x42; static_key[9]=0x72; static_key[10]=0xfb; static_key[11]=0x82;
static_key[12]=0x64; static_key[13]=0x56; static_key[14]=0x31; static_key[15]=0xfa;
//the key value provided by user
uint8_t user_key[16];
memset(user_key, 0, sizeof(user_key));
//Load user key into array to manipulate
for (int i = 0; i < 8; i++)
{
user_key[i+0] = (K1 >> (56-(i*8))) & 0xFF;
user_key[i+8] = (K2 >> (56-(i*8))) & 0xFF;
}
uint8_t input_register[16];
memset(input_register, 0, sizeof(input_register));
//manipulate user provided key by loading bytes in reverse order into the input_register
for (int i = 0; i < 16; i++)
input_register[15-i] = user_key[i];
uint8_t ks_bytes[16];
memset(ks_bytes, 0, sizeof(ks_bytes));
//create keystream
aes_ofb_keystream_output(input_register, static_key, ks_bytes, 0, 1);
uint8_t ks_bits[128];
memset(ks_bits, 0, sizeof(ks_bits));
unpack_byte_array_into_bit_array(ks_bytes, ks_bits, 16);
//load static keystream into ctx.bits since that isn't ever zeroed out
for (int i = 0; i < 49; i++)
ctx.bits[i] = ks_bits[i];
fprintf (stderr,"DMR TYT EP (AES-128) Key %016llX%016llX with Forced Application\n", K1, K2);
state->tyt_ep = 1;
}

214
src/dmr_34.c Normal file
View File

@@ -0,0 +1,214 @@
/*-------------------------------------------------------------------------------
* dmr_34.c
* DMR (and P25) 3/4 Rate Simple Trellis Decoder
*
* LWVMOBILE
* 2023-12 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
uint8_t interleave[98] = {
0, 1, 8, 9, 16, 17, 24, 25, 32, 33, 40, 41, 48, 49, 56, 57, 64, 65, 72, 73, 80, 81, 88, 89, 96, 97,
2, 3, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 50, 51, 58, 59, 66, 67, 74, 75, 82, 83, 90, 91,
4, 5, 12, 13, 20, 21, 28, 29, 36, 37, 44, 45, 52, 53, 60, 61, 68, 69, 76, 77, 84, 85, 92, 93,
6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 46, 47, 54, 55, 62, 63, 70, 71, 78, 79, 86, 87, 94, 95};
//this is a convertion table for converting the dibit pairs into constellation points
uint8_t constellation_map[16] = {
11, 12, 0, 7, 14, 9, 5, 2, 10, 13, 1, 6, 15, 8, 4, 3
};
//digitized dibit to OTA symbol conversion for reference
//0 = +1; 1 = +3;
//2 = -1; 3 = -3;
//finite state machine values
uint8_t fsm[64] = {
0, 8, 4, 12, 2, 10, 6, 14,
4, 12, 2, 10, 6, 14, 0, 8,
1, 9, 5, 13, 3, 11, 7, 15,
5, 13, 3, 11, 7, 15, 1, 9,
3, 11, 7, 15, 1, 9, 5, 13,
7, 15, 1, 9, 5, 13, 3, 11,
2, 10, 6, 14, 0, 8, 4, 12,
6, 14, 0, 8, 4, 12, 2, 10};
//attempt to find the surviving path, or the 'best' path available (most positions gained)
uint8_t fix_34(uint8_t * p, uint8_t state, int position)
{
int i, j, k, counter, best_p, best_v, survivors;
uint8_t temp_s, tri, t;
//status of surviving paths -- debug
int s[8];
memset (s, 0, 8*sizeof(int));
//assign all potentially correct points to temporary storage
uint8_t temp_p[8];
temp_p[0] = (p[position] ^ 1) & 0xF;
temp_p[1] = (p[position] ^ 3) & 0xF;
temp_p[2] = (p[position] ^ 5) & 0xF;
temp_p[3] = (p[position] ^ 7) & 0xF;
temp_p[4] = (p[position] ^ 9) & 0xF;
temp_p[5] = (p[position] ^ 11) & 0xF;
temp_p[6] = (p[position] ^ 13) & 0xF;
temp_p[7] = (p[position] ^ 15) & 0xF;
best_p = 0; //best position
best_v = 0; //best path value
for (k = 0; k < 8; k++)
{
temp_s = state;
counter = 0;
tri = 0;
for (i = position; i < 49; i++)
{
//assign temp t either as our temp_p, or next point of i
if (i == position) t = temp_p[k];
else t = p[i];
if (tri != 0xFF) //while the path survives
{
tri = 0xFF;
for (j = 0; j < 8; j++)
{
if ( fsm[(temp_s*8)+j] == t )
{
//return our tribit value and state for the next point
tri = temp_s = (uint8_t)j;
counter++;
break;
}
}
if (counter > best_p)
{
best_p = counter;
best_v = k; //if we make it further on current path, assign as best path
}
// surviving path -- made it to 49
if (i == 48) s[k] = 1;
}
}
}
//NOTE: If there are no surviving paths, then that means there is another bit/point err
//Ideally, at the end of a single or multiple fixes, there should only be one survivor, but in practice,
//I've seen up to 4 surviving paths and somehow, get a good CRC and a good LRRP or LOCN decode
//multiple survivors seems common when the starting err position is very close to 49
//tally number of surviving paths
survivors = 0;
for (k = 0; k < 8; k++)
{
if (s[k] == 1) survivors++;
}
//debug
// fprintf (stderr, "START: %d; BEST_P: %d; BEST_V: %d; Survivors: %d; Point: %d; ", position, best_p, best_v, survivors, temp_p[best_v]);
return temp_p[best_v]; //return the point value of the best path's starting point value
}
uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
{
int i, j;
uint32_t irr_err = 0; //irrecoverable errors
uint8_t deinterleaved_dibits[98];
memset (deinterleaved_dibits, 0, sizeof(deinterleaved_dibits));
//deinterleave our input dibits
for (i = 0; i < 98; i++)
deinterleaved_dibits[interleave[i]] = input[i];
//pack the input into nibbles (dibit pairs)
uint8_t nibs[49];
memset (nibs, 0, sizeof(nibs));
for (i = 0; i < 49; i++)
nibs[i] = (deinterleaved_dibits[i*2+0] << 2) | (deinterleaved_dibits[i*2+1] << 0);
//convert our dibit pairs into constellation point values
uint8_t point[49];
memset (point, 0xFF, sizeof(point));
for (i = 0; i < 49; i++)
point[i] = constellation_map[nibs[i]];
//debug view points
// fprintf (stderr, "\n P =");
// for (i = 0; i < 49; i++)
// fprintf (stderr, " %02d", point[i]);
//convert constellation points into tribit values using the FSM
uint8_t state = 0;
uint32_t tribits[49];
memset (tribits, 0xF, sizeof(tribits));
for (i = 0; i < 49; i++)
{
for (j = 0; j < 8; j++)
{
if ( fsm[(state*8)+j] == point[i] )
{
//return our tribit value and state for the next point
tribits[i] = state = (uint8_t)j;
break;
}
}
//if tribit value is greater than 7, then we have a decoding error
if (tribits[i] > 7)
{
irr_err++; //tally number of errors
//debug point, position of error, and state value
// fprintf (stderr, "\n P: %d, %d:%d; ", point[i], i, state);
//attempt to fix point by looking for the best path from here
point[i] = fix_34(point, state, i);
//Make a hard decision and flip point to fit in current state
// point[i] ^= 7; //lucky number 7 (0111) //fallback
//decrement one and resume decoding
i--;
}
}
//debug view tribits/states
// fprintf (stderr, "\n T =");
// for (i = 0; i < 49; i++)
// fprintf (stderr, " %02d", tribits[i]);
//convert tribits into a return payload
uint32_t temp = 0;
//break into chunks of 24 bit values and shuffle into 8-bit (byte) treturn values
for (i = 0; i < 6; i++)
{
temp = (tribits[(i*8)+0] << 21) + (tribits[(i*8)+1] << 18) + (tribits[(i*8)+2] << 15) + (tribits[(i*8)+3] << 12) +
(tribits[(i*8)+4] << 9) + (tribits[(i*8)+5] << 6) + (tribits[(i*8)+6] << 3) + (tribits[(i*8)+7] << 0);
treturn[(i*3)+0] = (temp >> 16) & 0xFF;
treturn[(i*3)+1] = (temp >> 8) & 0xFF;
treturn[(i*3)+2] = (temp >> 0) & 0xFF;
}
//trellis point/state err tally
// if (irr_err != 0)
// fprintf (stderr, " P_ERR = %d", irr_err);
return (0);
}

1515
src/dmr_block.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2572
src/dmr_csbk.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -18,35 +18,33 @@
#include "dsd.h"
void
processDMRdata (dsd_opts * opts, dsd_state * state)
dmr_data_sync (dsd_opts * opts, dsd_state * state)
{
int i, dibit;
int *dibit_p;
char sync[25];
char syncdata[48];
char cachdata[25] = {0};
char cc[5] = {0};
char ccAscii[5] = {0};
char bursttype[5];
unsigned int burst;
uint8_t cachdata[25];
UNUSED(syncdata);
uint8_t burst;
char info[196];
unsigned char SlotType[20];
unsigned char SlotType[20];
unsigned int SlotTypeOk;
int cachInterleave[24] = {0, 7, 8, 9, 1, 10, 11, 12, 2, 13, 14, 15, 3, 16, 4, 17, 18, 19, 5, 20, 21, 22, 6, 23};
uint8_t cach_err = 0;
UNUSED(cach_err);
#ifdef DMR_DUMP
char syncbits[49];
char cachbits[25];
int k;
#endif
ccAscii[4] = 0;
bursttype[4] = 0;
int cachInterleave[24] =
{0, 7, 8, 9, 1, 10,
11, 12, 2, 13, 14,
15, 3, 16, 4, 17, 18,
19, 5, 20, 21, 22, 6, 23
};
dibit_p = state->dmr_payload_p - 90;
// CACH
//collect cach and de-interleave
for (i = 0; i < 12; i++)
{
dibit = *dibit_p;
@@ -59,73 +57,38 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
{
dibit = (int)state->dmr_stereo_payload[i];
}
else state->dmr_stereo_payload[i] = dibit;
cachdata[cachInterleave[(i*2)]] = (1 & (dibit >> 1)); // bit 1
cachdata[cachInterleave[(i*2)+1]] = (1 & dibit); // bit 0
}
//decode and correct cach and compare
int cach_okay = 69;
if ( Hamming_7_4_decode (cachdata) ) //is now de-interleaved appropriately
//seperate tact bits from cach
uint8_t tact_bits[7];
for (i = 0; i < 7; i++)
{
cach_okay = 1;
}
if (cach_okay == 1)
{
//fprintf (stderr, "CACH Okay ");
}
if (cach_okay != 1)
{
//fprintf (stderr, "CACH FEC Error %d", cach_okay);
if (opts->aggressive_framesync == 1) //may not worry about it on data
{
goto END;
}
tact_bits[i] = cachdata[i];
}
state->currentslot = cachdata[1];
//run hamming on tact bits
int cach_okay = -1;
if ( Hamming_7_4_decode (tact_bits) ) cach_okay = 1;
else
{
cach_okay = -1;
SlotTypeOk = 0;
goto END;
}
//minor bugfix for MSData when MSData has accumulated data blocks
//(i.e. data header and 1/2 rate data), force all data into slot 0
state->currentslot = tact_bits[1];
//in the future, maybe we will remove the hard set on this
if (state->dmr_ms_mode == 1)
{
state->currentslot = 0;
}
if (state->currentslot == 0 && state->dmr_ms_mode == 0)
{
state->slot1light[0] = '[';
state->slot1light[6] = ']';
state->slot2light[0] = ' ';
state->slot2light[6] = ' ';
}
//else
if (state->currentslot == 1 && state->dmr_ms_mode == 0)
{
state->slot2light[0] = '[';
state->slot2light[6] = ']';
state->slot1light[0] = ' ';
state->slot1light[6] = ' ';
}
//end correct cach and set slot
#ifdef DMR_DUMP
k = 0;
for (i = 0; i < 12; i++)
{
dibit = cachdata[i];
cachbits[k] = (1 & (dibit >> 1)) + 48; // bit 1
k++;
cachbits[k] = (1 & dibit) + 48; // bit 0
k++;
}
cachbits[24] = 0;
fprintf(stderr, "%s ", cachbits);
#endif
//trellis bits
unsigned char trellisdibits[98];
// Current slot - First half - Data Payload - 1st part
for (i = 0; i < 49; i++)
{
@@ -139,7 +102,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
{
dibit = (int)state->dmr_stereo_payload[i+12];
}
trellisdibits[i] = dibit;
else state->dmr_stereo_payload[i+12] = dibit;
info[2*i] = (1 & (dibit >> 1)); // bit 1
info[(2*i)+1] = (1 & dibit); // bit 0
}
@@ -153,10 +116,10 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
}
if (state->dmr_stereo == 1)
{
dibit = (int)state->dmr_stereo_payload[61]; //61, not i+61
dibit = (int)state->dmr_stereo_payload[61];
}
cc[0] = (1 & (dibit >> 1)); // bit 1
cc[1] = (1 & dibit); // bit 0
else state->dmr_stereo_payload[61] = dibit;
SlotType[0] = (1 & (dibit >> 1)); // bit 1
SlotType[1] = (1 & dibit); // bit 0
@@ -170,17 +133,11 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
{
dibit = (int)state->dmr_stereo_payload[62];
}
cc[2] = (1 & (dibit >> 1)); // bit 1
cc[3] = (1 & dibit); // bit 0
else state->dmr_stereo_payload[62] = dibit;
SlotType[2] = (1 & (dibit >> 1)); // bit 1
SlotType[3] = (1 & dibit); // bit 0
ccAscii[0] = cc[0] + '0';
ccAscii[1] = cc[1] + '0';
ccAscii[2] = cc[2] + '0';
ccAscii[3] = cc[3] + '0';
ccAscii[4] = cc[4] + '\0';
dibit = *dibit_p;
dibit_p++;
if (opts->inverted_dmr == 1)
@@ -189,8 +146,9 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
}
if (state->dmr_stereo == 1) //state
{
dibit = (int)state->dmr_stereo_payload[63]; //(int)
dibit = (int)state->dmr_stereo_payload[63];
}
else state->dmr_stereo_payload[63] = dibit;
SlotType[4] = (1 & (dibit >> 1)); // bit 1
SlotType[5] = (1 & dibit); // bit 0
@@ -203,8 +161,9 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
}
if (state->dmr_stereo == 1) //state
{
dibit = (int)state->dmr_stereo_payload[64]; //(int)
dibit = (int)state->dmr_stereo_payload[64];
}
else state->dmr_stereo_payload[64] = dibit;
SlotType[6] = (1 & (dibit >> 1)); // bit 1
SlotType[7] = (1 & dibit); // bit 0
@@ -220,10 +179,11 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
{
dibit = (int)state->dmr_stereo_payload[65];
}
else state->dmr_stereo_payload[65] = dibit;
SlotType[8] = (1 & (dibit >> 1)); // bit 1
SlotType[9] = (1 & dibit); // bit 0
// signalling data or sync
// signaling data or sync
for (i = 0; i < 24; i++)
{
dibit = *dibit_p;
@@ -234,37 +194,26 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
}
if (state->dmr_stereo == 1)
{
dibit = (int)state->dmr_stereo_payload[i+66];
dibit = (int)state->dmr_stereo_payload[i+66];
}
else state->dmr_stereo_payload[i+66] = dibit;
syncdata[2*i] = (1 & (dibit >> 1)); // bit 1
syncdata[(2*i)+1] = (1 & dibit); // bit 0
sync[i] = (dibit | 1) + 48;
}
sync[24] = 0;
sync[24] = 0;
#ifdef DMR_DUMP
k = 0;
for (i = 0; i < 24; i++)
{
syncbits[k] = syncdata[(k*2)] + 48; // bit 1
k++;
syncbits[k] = syncdata[(k*2)+1] + 48; // bit 0
k++;
}
syncbits[48] = 0;
fprintf(stderr, "%s ", syncbits);
#endif
if((strcmp (sync, DMR_BS_DATA_SYNC) == 0) )//|| (strcmp (sync, DMR_MS_DATA_SYNC) == 0))
if((strcmp (sync, DMR_BS_DATA_SYNC) == 0) )
{
if (state->currentslot == 0)
{
sprintf(state->slot1light, "[slot1]");
sprintf(state->slot2light, " slot2 ");
}
else
{
sprintf(state->slot1light, " slot1 ");
sprintf(state->slot2light, "[slot2]");
}
}
@@ -273,15 +222,17 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
{
state->currentslot = 0;
sprintf(state->slot1light, "[sLoT1]");
sprintf(state->slot2light, "[DMODE]");
}
else if(strcmp (sync, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0)
{
state->currentslot = 1;
sprintf(state->slot1light, "[DMODE]");
sprintf(state->slot2light, "[sLoT2]");
}
if (opts->errorbars == 1 && state->dmr_ms_mode == 0)
if (state->dmr_ms_mode == 0)
{
fprintf(stderr, "%s %s ", state->slot1light, state->slot2light);
}
@@ -289,17 +240,14 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
// Slot type - Second part - Parity bit
for (i = 0; i < 5; i++)
{
if (state->dmr_stereo == 0) //only get dibits if not using dmr_stereo method
if (state->dmr_stereo == 0)
{
dibit = getDibit(opts, state);
}
if (opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
state->dmr_stereo_payload[i+90] = dibit;
}
if (state->dmr_stereo == 1)
{
dibit = (int)state->dmr_stereo_payload[i+90]; //double checked these i+ values make sure we are on the right ones
dibit = (int)state->dmr_stereo_payload[i+90];
}
SlotType[(i*2) + 10] = (1 & (dibit >> 1)); // bit 1
SlotType[(i*2) + 11] = (1 & dibit); // bit 0
@@ -308,264 +256,90 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
/* Check and correct the SlotType (apply Golay(20,8) FEC check) */
// golay (20,8) hamming-weight of 6 reliably corrects at most 2 bit-errors
if( Golay_20_8_decode(SlotType) )
{
SlotTypeOk = 1;
//fprintf (stderr, "Slot Okay ");
}
if( Golay_20_8_decode(SlotType) ) SlotTypeOk = 1;
else
{
if (opts->aggressive_framesync == 1)
{
SlotTypeOk = 0;
goto END;
}
SlotTypeOk = 0;
goto END;
}
/* Slot Type parity checked => Fill the color code */
state->color_code = (SlotType[0] << 3) + (SlotType[1] << 2) +(SlotType[2] << 1) + (SlotType[3] << 0);
state->color_code_ok = SlotTypeOk;
/* Reconstitute the burst type */
//consider assigning this only when slottypeok or similar check passes, eliminate bad burst types from decoding randomly
burst = (unsigned int)((SlotType[4] << 3) + (SlotType[5] << 2) + (SlotType[6] << 1) + SlotType[7]);
if (state->currentslot == 0)
{
state->dmrburstL = burst;
}
if (state->currentslot == 1)
{
state->dmrburstR = burst;
}
//not sure why I still have two variables for this, need to look and see what state->color_code still ties into
if (SlotTypeOk == 1) state->dmr_color_code = state->color_code;
/* Reconstitute the burst type */
bursttype[0] = SlotType[4] + '0';
bursttype[1] = SlotType[5] + '0';
bursttype[2] = SlotType[6] + '0';
bursttype[3] = SlotType[7] + '0';
bursttype[4] = '\0';
burst = (uint8_t)((SlotType[4] << 3) + (SlotType[5] << 2) + (SlotType[6] << 1) + SlotType[7]);
if (state->currentslot == 0) state->dmrburstL = burst;
if (state->currentslot == 1) state->dmrburstR = burst;
if (strcmp (bursttype, "0000") == 0)
{
sprintf(state->fsubtype, " PI Header ");
}
else if (strcmp (bursttype, "0001") == 0)
{
sprintf(state->fsubtype, " VOICE LC ");
}
else if (strcmp (bursttype, "0010") == 0)
{
sprintf(state->fsubtype, " TLC ");
}
else if (strcmp (bursttype, "0011") == 0)
{
sprintf(state->fsubtype, " CSBK ");
}
else if (strcmp (bursttype, "0100") == 0)
{
sprintf(state->fsubtype, " MBC Header ");
}
else if (strcmp (bursttype, "0101") == 0)
{
sprintf(state->fsubtype, " MBC ");
}
else if (strcmp (bursttype, "0110") == 0)
{
sprintf(state->fsubtype, " DATA Header ");
}
else if (strcmp (bursttype, "0111") == 0)
{
sprintf(state->fsubtype, " RATE 1/2 DATA");
}
else if (strcmp (bursttype, "1000") == 0)
{
sprintf(state->fsubtype, " RATE 3/4 DATA");
}
else if (strcmp (bursttype, "1001") == 0)
{
sprintf(state->fsubtype, " Slot idle ");
}
else if (strcmp (bursttype, "1010") == 0)
{
sprintf(state->fsubtype, " Rate 1 DATA ");
}
else
{
sprintf(state->fsubtype, " ");
}
// Current slot - First half - Data Payload - 1st part
//trellis
// Current slot - Second Half - Data Payload - 2nd part
for (i = 0; i < 49; i++)
{
if (state->dmr_stereo == 0) //only get dibits if not using dmr_stereo method
if (state->dmr_stereo == 0)
{
dibit = getDibit(opts, state);
state->dmr_stereo_payload[i+95] = dibit;
}
if (opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
if (state->dmr_stereo == 1)
{
dibit = (int)state->dmr_stereo_payload[i+95]; //double checked these i+ values make sure we are on the right ones
dibit = (int)state->dmr_stereo_payload[i+95];
}
trellisdibits[i+49] = dibit;
info[(2*i) + 98] = (1 & (dibit >> 1)); // bit 1
info[(2*i) + 99] = (1 & dibit); // bit 0
}
//
dmr_data_burst_handler(opts, state, (uint8_t *)info, burst);
//don't run cach on simplex or mono
if (state->dmr_ms_mode == 0 && opts->dmr_mono == 0)
{
cach_err = dmr_cach (opts, state, cachdata);
}
//ending line break
fprintf(stderr, "\n");
END:
if (SlotTypeOk == 0 || cach_okay != 1)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, "| CACH/Burst FEC ERR");
fprintf (stderr, "%s", KNRM);
fprintf (stderr, "\n");
dmr_reset_blocks (opts, state); //failsafe to reset all data header and blocks when bad tact or slottype
}
// Skip cach (24 bit = 12 dibit) and next slot 1st half (98 + 10 bit = 49 + 5 dibit)
if (state->dmr_stereo == 0)
{
skipDibit (opts, state, 12 + 49 + 5);
}
if (opts->errorbars == 1)
{
/* Print the color code */
//if (burst == 0b1001 && state->color_code_ok) //only print on idle for data types, otherwise prints on voice frames.
if (SlotTypeOk == 1)
{
fprintf (stderr, "%s", KCYN);
fprintf(stderr, "| Color Code=%02d ", (int)state->color_code);
fprintf (stderr, "%s", KNRM);
//state->dmr_color_code = state->color_code;
}
else fprintf(stderr, "| ");
#define CON_TUNEAWAY //disable if any unlock issues noted on the logic
//if(state->color_code_ok) fprintf(stderr, "(OK) |");
if(state->color_code_ok) fprintf(stderr, "| (CRC OK ) |"); //add line break
else
#ifdef CON_TUNEAWAY
//simplified, if IDLE condition, drop cc and vc sync time so when RF channel tears down, we go back much quicker
//NOTE: This was adopted, because going back to the CC early and then to be sent back to the channel grant,
//only for it to tear down and being sent back to the CC again isn't very efficient for trunk tracking
//NOTE: This will still leave the tuner in the 'locked' state when tuning a voice channel grant on the CC,
//and will remain locked until a new voice channel grant is received, but its just asthetic, trying to fix it
//is too much of a hassle and causes other issues like CC hunting, etc.
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && state->is_con_plus == 1)
{
int clear = 0;
//IF both slots currently signalling IDLE
if (state->dmrburstL == 9 && state->dmrburstR == 9) clear = 1;
if (clear == 1)
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, "| (CRC ERR) |");
fprintf (stderr, "%s", KNRM);
}
//fprintf (stderr, "\n"); //print line break
if (strcmp (state->fsubtype, " ") == 0)
{
//fprintf(stderr, " Unknown burst type: %s", bursttype);
fprintf(stderr, " Unknown");
}
else
{
fprintf(stderr, "%s", state->fsubtype);
state->last_cc_sync_time = 0;
state->last_vc_sync_time = 0;
}
}
switch(burst)
{
/* Burst = PI header */
case 0b0000:
{
ProcessDmrPIHeader(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = Voice LC header */
case 0b0001:
{
/* Extract data from Voice LC Header */
ProcessDmrVoiceLcHeader(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = TLC */
case 0b0010:
{
//Not sure if I really care about this in the context of what it shows
ProcessDmrTerminaisonLC(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = CSBK */
case 0b0011:
{
//going to disable until I can find more useful info to present
ProcessCSBK(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = MBC Header */
case 0b0100:
{
ProcessMBChData(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = MBC Continuation*/
case 0b0101:
{
ProcessMBCData(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = DATA Header */
case 0b0110:
{
ProcessDataData(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = RATE 1/2 DATA */
case 0b0111:
{
Process12Data(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = RATE 3/4 DATA */
case 0b1000:
{
//need to keep working on improving the trellis decode, but is partially viable now
Process34Data(opts, state, trellisdibits, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = Slot idle */
case 0b1001:
{
if(state->color_code_ok && state->dmr_stereo == 0) state->dmr_color_code = state->color_code; //try setting this on idle if crc ok
break;
}
/* Burst = Rate 1 DATA */
case 0b1010:
{
Process1Data(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Burst = Unified Single Block DATA */
case 0b1101:
{
ProcessUnifiedData(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
/* Default */
default:
{
/* Nothing to do */
ProcessReservedData(opts, state, (uint8_t *)info, (uint8_t *)syncdata, (uint8_t *)SlotType);
break;
}
} /* End switch(burst) */
if (opts->errorbars == 1)
{
fprintf(stderr, "\n");
}
END:
if (SlotTypeOk == 0 || cach_okay != 1)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, "| ** CACH or Burst Type FEC ERR ** ");
fprintf (stderr, "%s", KNRM);
fprintf (stderr, "\n");
}
} /* End processDMRdata() */
#endif
}

654
src/dmr_dburst.c Normal file
View File

@@ -0,0 +1,654 @@
/*-------------------------------------------------------------------------------
* dmr_dburst.c
* DMR Data Burst Handling and related BPTC/FEC/CRC Functions
*
* Portions of BPTC/FEC/CRC code from LouisErigHerve
* Source: https://github.com/LouisErigHerve/dsd/blob/master/src/dmr_sync.c
*
* LWVMOBILE
* 2023-12 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
//TODO: Test USBD LIP Decoder with Real World Samples (if/when available)
//TODO: Test UDT NMEA and LIP Decoders with Real World Samples (if/when available)
#include "dsd.h"
void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t databurst)
{
uint32_t i, j, k;
uint32_t CRCExtracted = 0;
uint32_t CRCComputed = 0;
uint32_t CRCCorrect = 0;
uint32_t IrrecoverableErrors = 0;
uint8_t slot = state->currentslot;
//confirmed data
uint8_t dbsn = 0; //data block serial number for confirmed data blocks
uint8_t blockcounter = 0; //local block count
uint8_t confdatabits[250]; //array to reshuffle conf data block bits into sequence for crc9 check
memset (confdatabits, 0, sizeof(confdatabits));
UNUSED(dbsn);
//BPTC 196x96 Specific
uint8_t BPTCDeInteleavedData[196];
uint8_t BPTCDmrDataBit[96];
uint8_t BPTCDmrDataByte[12];
//Embedded Signalling Specific
uint8_t BptcDataMatrix[8][16];
uint8_t LC_DataBit[77];
uint8_t LC_DataBytes[10];
int Burst = -1;
memset (BPTCDeInteleavedData, 0, sizeof(BPTCDeInteleavedData));
memset (BPTCDmrDataBit, 0, sizeof(BPTCDmrDataBit));
memset (BPTCDmrDataByte, 0, sizeof(BPTCDmrDataByte));
memset (BptcDataMatrix, 0, sizeof(BptcDataMatrix));
memset (LC_DataBit, 0, sizeof(LC_DataBit));
memset (LC_DataBytes, 0, sizeof(LC_DataBytes));
//PDU Bytes and Bits
uint8_t DMR_PDU[25];
uint8_t DMR_PDU_bits[196];
memset (DMR_PDU, 0, sizeof (DMR_PDU));
memset (DMR_PDU_bits, 0, sizeof (DMR_PDU_bits));
uint8_t R[3];
uint8_t BPTCReservedBits = 0;
uint8_t is_ras = 0;
uint8_t crc_original_validity = 0;
uint32_t crcmask = 0;
uint8_t crclen = 0;
uint8_t is_bptc = 0;
uint8_t is_trellis = 0;
uint8_t is_emb = 0;
uint8_t is_lc = 0;
uint8_t is_full = 0;
uint8_t is_udt = 0;
uint8_t pdu_len = 0;
uint8_t pdu_start = 0; //starting value of pdu (0 normal, 2 for confirmed)
uint8_t usbd_st = 0; //usbd service type
switch(databurst){
case 0x00: //PI
is_bptc = 1;
crclen = 16;
crcmask = 0x6969; //insert pi and 69 jokes here
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " PI ");
break;
case 0x01: //VLC
is_bptc = 1;
is_lc = 1;
crclen = 24;
crcmask = 0x969696;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " VLC ");
break;
case 0x02: //TLC
is_bptc = 1;
is_lc = 1;
crcmask = 0x999999;
crclen = 24;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " TLC ");
break;
case 0x03: //CSBK
is_bptc = 1;
crclen = 16;
crcmask = 0xA5A5;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " CSBK");
break;
case 0x04: //MBC Header
is_bptc = 1;
crclen = 16;
crcmask = 0xAAAA;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " MBCH");
break;
case 0x05: //MBC Continuation
is_bptc = 1;
//let block assembler carry out crc on the completed message
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " MBCC");
break;
case 0x06: //Data Header
is_bptc = 1;
crclen = 16;
crcmask = 0xCCCC;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " DATA");
break;
case 0x07: //1/2 Rate Data
is_bptc = 1;
crclen = 9; //confirmed data only
crcmask = 0x0F0;
pdu_len = 12; //12 bytes unconfirmed
sprintf(state->fsubtype, " R12U ");
if (state->data_conf_data[slot] == 1)
{
pdu_len = 10;
pdu_start = 2; //start at plus two when assembling
sprintf(state->fsubtype, " R12C ");
}
if (state->data_header_format[slot] == 0) //UDT 1/2 Encoded Blocks
{
is_udt = 1;
if (state->data_conf_data[slot] == 1)
sprintf(state->fsubtype, " UDTC "); //confirmed data
else sprintf(state->fsubtype, " UDTU "); //unconfirmed data
}
break;
case 0x08: //3/4 Rate Data
is_trellis = 1;
crclen = 9; //confirmed data only
crcmask = 0x1FF;
pdu_len = 18; //18 bytes unconfirmed
sprintf(state->fsubtype, " R34U ");
if (state->data_conf_data[slot] == 1)
{
pdu_len = 16;
pdu_start = 2; //start at plus two when assembling
sprintf(state->fsubtype, " R34C ");
}
break;
case 0x09: //Idle
//pseudo-random data fill, no need to do anything with this
sprintf(state->fsubtype, " IDLE ");
break;
case 0x0A: //1 Rate Data
crclen = 9; //confirmed data only
crcmask = 0x10F;
is_full = 1;
pdu_len = 24; //192 bits 24 bytes + 4 pad bits
sprintf(state->fsubtype, " R_1U ");
if (state->data_conf_data[slot] == 1)
{
pdu_len = 22; //start at plus two when assembling
pdu_start = 2; //start at plus two when assembling
sprintf(state->fsubtype, " R_1C ");
}
break;
case 0x0B: //Unified Single Block Data USBD
is_bptc = 1;
crclen = 16;
crcmask = 0x3333;
pdu_len = 12; //12 bytes
sprintf(state->fsubtype, " USBD ");
break;
//special types (not real data 'sync' bursts)
case 0xEB: //Embedded Signalling
crclen = 5;
is_emb = 1;
pdu_len = 9;
break;
default:
//Slot Type FEC should catch this so we never see it,
//but if it doesn't, then we can still dump the entire 'packet'
//treat like rate 1 unconfirmed data
is_full = 1;
pdu_len = 25; //196 bits - 24.5 bytes
sprintf(state->fsubtype, " _UNK ");
break;
}
//flag off prop head when not looking at data blocks
if (databurst != 0x6 && databurst != 0x7 && databurst != 0x8 && databurst != 0xA && databurst != 0xB) state->data_p_head[slot] = 0;
if (databurst != 0xEB)
{
if (state->dmr_ms_mode == 0)
{
if (state->dmr_color_code != 16)
fprintf(stderr, "| Color Code=%02d ", state->dmr_color_code);
else fprintf(stderr, "| Color Code=XX ");
}
fprintf(stderr, "|%s", state->fsubtype);
//'DSP' output to file
if (opts->use_dsp_output == 1)
{
FILE * pFile; //file pointer
pFile = fopen (opts->dsp_out_file, "a");
fprintf (pFile, "\n%d 98 ", slot+1); //'98' is CACH designation value
for (i = 0; i < 6; i++) //3 byte CACH
{
int cach_byte = (state->dmr_stereo_payload[i*2] << 2) | state->dmr_stereo_payload[i*2 + 1];
fprintf (pFile, "%X", cach_byte); //nibble, not a byte, next time I look at this and wonder why its not %02X
}
fprintf (pFile, "\n%d %02X ", slot+1, databurst); //use hex value of current data burst type
for (i = 6; i < 72; i++) //33 bytes, no CACH
{
int dsp_byte = (state->dmr_stereo_payload[i*2] << 2) | state->dmr_stereo_payload[i*2 + 1];
fprintf (pFile, "%X", dsp_byte);
}
fclose (pFile);
}
}
//Most Data Sync Burst types will use the bptc 196x96
if (is_bptc)
{
CRCExtracted = 0;
CRCComputed = 0;
IrrecoverableErrors = 0;
/* Deinterleave DMR data */
BPTCDeInterleaveDMRData(info, BPTCDeInteleavedData);
/* Extract the BPTC 196,96 DMR data */
IrrecoverableErrors = BPTC_196x96_Extract_Data(BPTCDeInteleavedData, BPTCDmrDataBit, R);
/* Fill the reserved bit (R(0)-R(2) of the BPTC(196,96) block) */
BPTCReservedBits = (R[0] & 0x01) | ((R[1] << 1) & 0x02) | ((R[2] << 2) & 0x04);
//debug print
//fprintf (stderr, " RAS? %X - %d %d %d", BPTCReservedBits, R[0], R[1], R[2]);
/* Convert the 96 bits BPTC data into 12 bytes */
k = 0;
for(i = 0; i < 12; i++)
{
BPTCDmrDataByte[i] = 0;
for(j = 0; j < 8; j++)
{
BPTCDmrDataByte[i] = BPTCDmrDataByte[i] << 1;
BPTCDmrDataByte[i] = BPTCDmrDataByte[i] | (BPTCDmrDataBit[k] & 0x01);
k++;
}
}
/* Fill the CRC extracted (before Reed-Solomon (12,9) FEC correction) */
CRCExtracted = 0;
for(i = 0; i < crclen; i++)
{
CRCExtracted = CRCExtracted << 1;
CRCExtracted = CRCExtracted | (uint32_t)(BPTCDmrDataBit[i + 96 - crclen] & 1);
}
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
CRCExtracted = CRCExtracted ^ crcmask;
/* Check/correct the BPTC data and compute the Reed-Solomon (12,9) CRC */
if (is_lc) CRCCorrect = ComputeAndCorrectFullLinkControlCrc(BPTCDmrDataByte, &CRCComputed, crcmask);
//set CRC to correct on unconfirmed 1/2 data blocks (for reporting due to no CRC available on these)
else if (state->data_conf_data[slot] == 0 && databurst == 0x7)
{
CRCComputed = 0;
CRCExtracted = 0;
CRCCorrect = 1;
}
//run CRC9 on intermediate and last 1/2 confirmed data blocks
else if (state->data_conf_data[slot] == 1 && databurst == 0x7)
{
blockcounter = state->data_block_counter[slot]; //current block number according to the counter
dbsn = (uint32_t)ConvertBitIntoBytes(&BPTCDmrDataBit[0], 7) + 1; //recover data block serial number
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&BPTCDmrDataBit[7], 9); //extract CRC from data
CRCExtracted = CRCExtracted ^ crcmask;
//reorganize the BPTCDmrDataBit array into confdatabits, just for CRC9 check
//need to find a sample to confirm this
for(i = 0; i < 80; i++) confdatabits[i] = BPTCDmrDataBit[i + 16];
for(i = 0; i < 7; i++) confdatabits[i + 80] = BPTCDmrDataBit[i];
CRCComputed = ComputeCrc9Bit(confdatabits, 87);
if (CRCExtracted == CRCComputed)
{
CRCCorrect = 1;
state->data_block_crc_valid[slot][blockcounter] = 1;
}
else state->data_block_crc_valid[slot][blockcounter] = 0;
}
//run CCITT on other data forms
else
{
CRCComputed = ComputeCrcCCITT(BPTCDmrDataBit);
if (CRCComputed == CRCExtracted) CRCCorrect = 1;
else CRCCorrect = 0;
}
//set the 'RAS Flag', if no irrecoverable errors but bad crc, only when enabled by user (to prevent a lot of bad data CSBKs)
if (opts->aggressive_framesync == 0 && CRCCorrect == 0 && IrrecoverableErrors == 0 && BPTCReservedBits == 4) is_ras = 1;
//make sure the system type isn't Hytera, but could just be bad decodes on bad sample
if (BPTCDmrDataByte[1] == 0x68) is_ras = 0;
//if this is a RAS system, set the CRC to okay if irrecoverable errors are okay
//if we don't do this, then we can't view some data (CSBKs on RAS enabled systems)
if (is_ras == 1)
{
crc_original_validity = CRCCorrect;
CRCCorrect = 1;
}
if (databurst == 0x04 || databurst == 0x06) //MBC Header, Data Header
{
if (CRCCorrect)
{
state->data_block_crc_valid[slot][0] = 1;
}
else state->data_block_crc_valid[slot][0] = 0;
}
/* Convert corrected x bytes into x*8 bits */
for(i = 0, j = 0; i < pdu_len; i++, j+=8)
{
BPTCDmrDataBit[j + 0] = (BPTCDmrDataByte[i+pdu_start] >> 7) & 0x01;
BPTCDmrDataBit[j + 1] = (BPTCDmrDataByte[i+pdu_start] >> 6) & 0x01;
BPTCDmrDataBit[j + 2] = (BPTCDmrDataByte[i+pdu_start] >> 5) & 0x01;
BPTCDmrDataBit[j + 3] = (BPTCDmrDataByte[i+pdu_start] >> 4) & 0x01;
BPTCDmrDataBit[j + 4] = (BPTCDmrDataByte[i+pdu_start] >> 3) & 0x01;
BPTCDmrDataBit[j + 5] = (BPTCDmrDataByte[i+pdu_start] >> 2) & 0x01;
BPTCDmrDataBit[j + 6] = (BPTCDmrDataByte[i+pdu_start] >> 1) & 0x01;
BPTCDmrDataBit[j + 7] = (BPTCDmrDataByte[i+pdu_start] >> 0) & 0x01;
}
//convert to DMR_PDU and DMR_PDU_bits
for (i = 0; i < pdu_len; i++)
{
DMR_PDU[i] = BPTCDmrDataByte[i+pdu_start];
}
for (i = 0; i < pdu_len * 8; i++)
{
DMR_PDU_bits[i] = BPTCDmrDataBit[i];
}
}
//Embedded Signalling will use BPTC 128x77
if (is_emb)
{
CRCExtracted = 0;
CRCComputed = 0;
IrrecoverableErrors = 0;
/* First step : Reconstitute the BPTC 16x8 matrix */
Burst = 1; /* Burst B to E contains embedded signaling data */
k = 0;
for(i = 0; i < 16; i++)
{
for(j = 0; j < 8; j++)
{
/* Only the LSBit of the byte is stored */
BptcDataMatrix[j][i] = state->dmr_embedded_signalling[slot][Burst][k+8];
k++;
/* Go on to the next burst once 32 bit
* of the SNYC have been stored */
if(k >= 32)
{
k = 0;
Burst++;
}
} /* End for(j = 0; j < 8; j++) */
} /* End for(i = 0; i < 16; i++) */
/* Extract the 72 LC bit (+ 5 CRC bit) of the matrix */
IrrecoverableErrors = BPTC_128x77_Extract_Data(BptcDataMatrix, LC_DataBit);
/* Reconstitute the 5 bit CRC */
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&LC_DataBit[72], 5);
/* Compute the 5 bit CRC */
CRCComputed = ComputeCrc5Bit(LC_DataBit);
if(CRCExtracted == CRCComputed) CRCCorrect = 1;
else CRCCorrect = 0;
for (i = 0; i < 72; i++)
{
DMR_PDU_bits[i] = LC_DataBit[i];
}
for (i = 0; i < 9; i++)
{
DMR_PDU[i] = (uint8_t)ConvertBitIntoBytes(&LC_DataBit[i*8], 8);
}
}
//the sexy one
if (is_trellis)
{
CRCExtracted = 0;
CRCComputed = 0;
IrrecoverableErrors = 1;
uint8_t tdibits[98];
memset (tdibits, 0, sizeof(tdibits));
//reconstitute info bits into dibits for the trellis decoder
for (i = 0; i < 98; i++)
tdibits[i] = (info[i*2] << 1) | info[i*2+1];
uint8_t TrellisReturn[18];
memset (TrellisReturn, 0, sizeof(TrellisReturn));
IrrecoverableErrors = dmr_34(tdibits, TrellisReturn);
//NOTE: IrrecoverableErrors in this context are a tally of errors from trellis
//they may have been successfully corrected, the CRC will reveal as much
for (i = 0; i < pdu_len; i++)
DMR_PDU[i] = TrellisReturn[i+pdu_start];
for(i = 0, j = 0; i < 18; i++, j+=8)
{
DMR_PDU_bits[j + 0] = (TrellisReturn[i] >> 7) & 0x01;
DMR_PDU_bits[j + 1] = (TrellisReturn[i] >> 6) & 0x01;
DMR_PDU_bits[j + 2] = (TrellisReturn[i] >> 5) & 0x01;
DMR_PDU_bits[j + 3] = (TrellisReturn[i] >> 4) & 0x01;
DMR_PDU_bits[j + 4] = (TrellisReturn[i] >> 3) & 0x01;
DMR_PDU_bits[j + 5] = (TrellisReturn[i] >> 2) & 0x01;
DMR_PDU_bits[j + 6] = (TrellisReturn[i] >> 1) & 0x01;
DMR_PDU_bits[j + 7] = (TrellisReturn[i] >> 0) & 0x01;
}
//set CRC to correct on unconfirmed 3/4 data blocks (for reporting due to no CRC available on these)
if (state->data_conf_data[slot] == 0) CRCCorrect = 1;
//run CRC9 on intermediate and last 3/4 data blocks
else if (state->data_conf_data[slot] == 1)
{
blockcounter = state->data_block_counter[slot]; //current block number according to the counter
dbsn = (uint32_t)ConvertBitIntoBytes(&DMR_PDU_bits[0], 7) + 1; //recover data block serial number
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&DMR_PDU_bits[7], 9); //extract CRC from data
CRCExtracted = CRCExtracted ^ crcmask;
//reorganize the DMR_PDU_bits array into confdatabits, just for CRC9 check
for(i = 0; i < 128; i++) confdatabits[i] = DMR_PDU_bits[i + 16];
for(i = 0; i < 7; i++) confdatabits[i + 128] = DMR_PDU_bits[i];
CRCComputed = ComputeCrc9Bit(confdatabits, 135);
if (CRCExtracted == CRCComputed)
{
CRCCorrect = 1;
state->data_block_crc_valid[slot][blockcounter] = 1;
}
else
state->data_block_crc_valid[slot][blockcounter] = 0;
}
//reorganize the DMR_PDU_bits into PDU friendly format (minus the dbsn and crc9)
memset (DMR_PDU_bits, 0, sizeof(DMR_PDU_bits));
for(i = 0, j = 0; i < pdu_len; i++, j+=8)
{
DMR_PDU_bits[j + 0] = (TrellisReturn[i+pdu_start] >> 7) & 0x01;
DMR_PDU_bits[j + 1] = (TrellisReturn[i+pdu_start] >> 6) & 0x01;
DMR_PDU_bits[j + 2] = (TrellisReturn[i+pdu_start] >> 5) & 0x01;
DMR_PDU_bits[j + 3] = (TrellisReturn[i+pdu_start] >> 4) & 0x01;
DMR_PDU_bits[j + 4] = (TrellisReturn[i+pdu_start] >> 3) & 0x01;
DMR_PDU_bits[j + 5] = (TrellisReturn[i+pdu_start] >> 2) & 0x01;
DMR_PDU_bits[j + 6] = (TrellisReturn[i+pdu_start] >> 1) & 0x01;
DMR_PDU_bits[j + 7] = (TrellisReturn[i+pdu_start] >> 0) & 0x01;
}
}
if (is_full) //Rate 1 Data
{
//assembly (w/ confirmed data) on a working Tier III Tait System
CRCExtracted = 0;
CRCComputed = 0;
IrrecoverableErrors = 0; //implicit, since there is no encoding
//pack rate 1 data for a total of up to 24 bytes, (22 if Confirmed Data)
//skipping the 4 padding bits located at 96,97,98,99 using the ptr values
//as offsets for confirmed data, len, and continue points for packing
int bit_ptr = pdu_start * 8;
int byte_ptr = 0;
pack_bit_array_into_byte_array (info+bit_ptr, DMR_PDU+byte_ptr, 12-pdu_start);
bit_ptr = 100; byte_ptr = 12-pdu_start;
pack_bit_array_into_byte_array (info+bit_ptr, DMR_PDU+byte_ptr, 12);
//set CRC to correct on unconfirmed 1 rate data blocks (for reporting due to no CRC available on these)
if (state->data_conf_data[slot] == 0) CRCCorrect = 1;
//run CRC9 on intermediate and last 1 rate data blocks
else if (state->data_conf_data[slot] == 1)
{
blockcounter = state->data_block_counter[slot]; //current block number according to the counter
dbsn = (uint32_t)ConvertBitIntoBytes(&info[0], 7) + 1; //recover data block serial number
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&info[7], 9); //extract CRC from data
CRCExtracted = CRCExtracted ^ crcmask;
//reorganize the info bit array into confdatabits, just for CRC9 check
int k = 0;
for (i = 16; i < 96; i++) confdatabits[k++] = info[i]; //first half
for (i = 100; i < 196; i++) confdatabits[k++] = info[i]; //second half
for (i = 0; i < 7; i++) confdatabits[k++] = info[i]; //DBSN
CRCComputed = ComputeCrc9Bit(confdatabits, k);
if (CRCExtracted == CRCComputed)
{
CRCCorrect = 1;
state->data_block_crc_valid[slot][blockcounter] = 1;
}
else state->data_block_crc_valid[slot][blockcounter] = 0;
//debug confirmed data values (working now)
// fprintf (stderr, " K: %d; DSBN: %d; CRC: %03X / %03X;", k, dbsn, CRCComputed, CRCExtracted);
}
//copy info to dmr_pdu_bits
memcpy(DMR_PDU_bits, info, sizeof(DMR_PDU_bits));
}
//time for some pi
if (databurst == 0x00) dmr_pi (opts, state, DMR_PDU, CRCCorrect, IrrecoverableErrors);
//full link control
if (databurst == 0x01) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 1); //VLC
if (databurst == 0x02) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 2); //TLC
if (databurst == 0xEB) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, &IrrecoverableErrors, 3); //EMB
//dmr data header and multi block types (header, 1/2, 3/4, 1, UDT) - type 1
if (databurst == 0x06) dmr_dheader (opts, state, DMR_PDU, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors);
if (databurst == 0x08) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //3/4 Rate Data
if (databurst == 0x0A) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //Full Rate Data
if (databurst == 0x07 && is_udt == 0) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //1/2 Rate Data
if (databurst == 0x07 && is_udt == 1) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 3); //UDT with 1/2 Rate Encoding
//control signalling types (CSBK, MBC)
if (databurst == 0x03) dmr_cspdu (opts, state, DMR_PDU_bits, DMR_PDU, CRCCorrect, IrrecoverableErrors);
//both MBC header and MBC continuation will go to the block_assembler - type 2, and then to dmr_cspdu
if (databurst == 0x04)
{
state->data_block_counter[slot] = 0; //zero block counter before running header
state->data_header_valid[slot] = 1; //set valid header since we received one
dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 2);
}
if (databurst == 0x05) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 2);
//Unified Single Data Block (USBD) -- Not to be confused with Unified Data Transport (UDT)
if (databurst == 0x0B)
{
//TODO: provide more robust handling at a later date -- ETSI TS 102 361-4 V1.11.1 (2021-01) 6.6.11.3
usbd_st = (uint8_t)ConvertBitIntoBytes(&DMR_PDU_bits[0], 4);
fprintf (stderr, "%s\n", KYEL);
fprintf (stderr, " USBD - ");
if (usbd_st == 0) lip_protocol_decoder (opts, state, DMR_PDU_bits);
else if (usbd_st > 8) fprintf (stderr, "Manufacturer Specific Service %d ", usbd_st);
else fprintf (stderr, "Reserved %d ", usbd_st);
}
//set the original CRCCorrect back to its original value if the RAS flag was tripped
if (is_ras == 1) CRCCorrect = crc_original_validity;
//start printing relevant fec/crc/ras messages, don't print on idle or MBC continuation blocks (handled in dmr_block.c)
// if (IrrecoverableErrors == 0 && CRCCorrect == 1 && databurst != 0x09 && databurst != 0x05) fprintf(stderr, "(CRC OK)");
// if (IrrecoverableErrors == 0 && CRCCorrect == 0 && databurst != 0x09 && databurst != 0x05)
// {
// fprintf (stderr, "%s", KYEL);
// fprintf(stderr, " (FEC OK)");
// fprintf (stderr, "%s", KNRM);
// }
if (IrrecoverableErrors != 0 && databurst != 0x08 && databurst != 0x09) //&& databurst != 0x05
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, " (FEC ERR)");
fprintf (stderr, "%s", KNRM);
}
//print whether or not the 'RAS Field' bits are set to indicate RAS enabled (to be verified)
if (is_ras == 1)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, " -RAS ");
//the value of this field seems to always, or usually, be 4, or just R[2] bit is set
if (opts->payload == 1) fprintf (stderr, "%X ", BPTCReservedBits);
fprintf (stderr, "%s", KNRM);
}
if (IrrecoverableErrors == 0 && CRCCorrect == 0 && is_ras == 0 && databurst != 0x09 && databurst != 0x05)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, " (CRC ERR) ");
fprintf (stderr, "%s", KNRM);
}
//print the unified PDU format here, if not slot idle
if (opts->payload == 1 && databurst != 0x09)
{
fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " DMR PDU Payload ");
for (i = 0; i < pdu_len; i++)
{
fprintf (stderr, "[%02X]", DMR_PDU[i]);
}
//debug print
// if (dbsn) fprintf (stderr, " SN %X", dbsn);
// fprintf (stderr, " CRC - EXT %X CMP %X", CRCExtracted, CRCComputed);
fprintf (stderr, "%s", KNRM);
}
}

1327
src/dmr_flco.c Normal file

File diff suppressed because it is too large Load Diff

582
src/dmr_le.c Normal file
View File

@@ -0,0 +1,582 @@
/*-------------------------------------------------------------------------------
* dmr_le.c
* DMR Late Entry MI Fragment Assembly, Procesing, and related Alg functions
*
* LWVMOBILE
* 2022-12 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
//gather ambe_fr mi fragments for processing
void dmr_late_entry_mi_fragment (dsd_opts * opts, dsd_state * state, uint8_t vc, uint8_t ambe_fr[4][24], uint8_t ambe_fr2[4][24], uint8_t ambe_fr3[4][24])
{
uint8_t slot = state->currentslot;
//enforce RC4 due to missing PI header, but with valid SVC Opts
//ideally, this would be handled by VC-F single burst, but its not fully reliable compared to this
//due to multiple signalling occurring inside of it, depending on system type
if (state->M == 0x21)
{
if (slot == 0 && state->dmr_so & 0x40)
{
state->payload_algid = 0x21;
state->payload_keyid = 0xFF;
}
if (slot == 1 && state->dmr_soR & 0x40)
{
state->payload_algidR = 0x21;
state->payload_keyidR = 0xFF;
}
}
//collect our fragments and place them into storage
state->late_entry_mi_fragment[slot][vc][0] = (uint64_t)ConvertBitIntoBytes(&ambe_fr[3][0], 4);
state->late_entry_mi_fragment[slot][vc][1] = (uint64_t)ConvertBitIntoBytes(&ambe_fr2[3][0], 4);
state->late_entry_mi_fragment[slot][vc][2] = (uint64_t)ConvertBitIntoBytes(&ambe_fr3[3][0], 4);
if (vc == 6) dmr_late_entry_mi (opts, state);
}
void dmr_late_entry_mi (dsd_opts * opts, dsd_state * state)
{
UNUSED(opts);
uint8_t slot = state->currentslot;
int i, j;
int g[3];
unsigned char mi_go_bits[24];
uint64_t mi_test = 0;
uint64_t go_test = 0;
uint64_t mi_corrected = 0;
uint64_t go_corrected = 0;
uint8_t mi_bits[36];
memset (mi_bits, 0, sizeof(mi_bits));
uint8_t mi_crc_cmp = 0;
uint8_t mi_crc_ext = 1;
uint8_t mi_crc_ok = 0;
mi_test = (state->late_entry_mi_fragment[slot][1][0] << 32L) | (state->late_entry_mi_fragment[slot][2][0] << 28) | (state->late_entry_mi_fragment[slot][3][0] << 24) |
(state->late_entry_mi_fragment[slot][1][1] << 20) | (state->late_entry_mi_fragment[slot][2][1] << 16) | (state->late_entry_mi_fragment[slot][3][1] << 12) |
(state->late_entry_mi_fragment[slot][1][2] << 8) | (state->late_entry_mi_fragment[slot][2][2] << 4) | (state->late_entry_mi_fragment[slot][3][2] << 0);
go_test = (state->late_entry_mi_fragment[slot][4][0] << 32L) | (state->late_entry_mi_fragment[slot][5][0] << 28) | (state->late_entry_mi_fragment[slot][6][0] << 24) |
(state->late_entry_mi_fragment[slot][4][1] << 20) | (state->late_entry_mi_fragment[slot][5][1] << 16) | (state->late_entry_mi_fragment[slot][6][1] << 12) |
(state->late_entry_mi_fragment[slot][4][2] << 8) | (state->late_entry_mi_fragment[slot][5][2] << 4) | (state->late_entry_mi_fragment[slot][6][2] << 0);
for (j = 0; j < 3; j++)
{
for (i = 0; i < 12; i++)
{
mi_go_bits[i] = (( mi_test << (i+j*12) ) & 0x800000000) >> 35;
mi_go_bits[i+12] = (( go_test << (i+j*12) ) & 0x800000000) >> 35;
}
//execute golay decode and assign pass or fail to g
if ( Golay_24_12_decode(mi_go_bits) ) g[j] = 1;
else g[j] = 0;
for (i = 0; i < 12; i++)
{
mi_corrected = mi_corrected << 1;
mi_corrected |= mi_go_bits[i];
go_corrected = go_corrected << 1;
go_corrected |= mi_go_bits[i+12];
//manipulate for crc check
mi_bits[i+(j*12)] = mi_go_bits[i];
}
}
unsigned long long int mi_final = 0;
mi_final = (mi_corrected >> 4) & 0xFFFFFFFF;
mi_crc_ext = (uint8_t)ConvertBitIntoBytes(&mi_bits[32], 4);
mi_crc_cmp = crc4(mi_bits, 32);
if (mi_crc_ext == mi_crc_cmp)
mi_crc_ok = 1;
//debug -- working now
// fprintf (stderr, " LE MI: %09llX; CRC EXT: %X; CRC CMP: %X; \n", mi_corrected, mi_crc_ext, mi_crc_cmp);
if (g[0] && g[1] && g[2])
{
if (slot == 0 && state->payload_algid != 0)
{
if (state->payload_mi != mi_final)
{
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " Slot 1 PI/LFSR and Late Entry MI Mismatch - %08llX : %08llX ", state->payload_mi, mi_final);
if (mi_crc_ok == 1) state->payload_mi = mi_final;
if (mi_crc_ok == 1) fprintf (stderr, "(CRC OK)");
else fprintf (stderr, "(CRC ERR)");
fprintf (stderr, "\n");
fprintf (stderr, "%s", KNRM);
}
//run expansions afterwards, or le verification won't match up properly
//DES1
if (state->payload_algid == 0x22)
{
LFSR64 (state);
fprintf (stderr, "\n");
}
//AES-128 or AES-256
if (state->payload_algid == 0x24 || state->payload_algid == 0x25)
{
LFSR128d (state);
fprintf (stderr, "\n");
}
}
if (slot == 1 && state->payload_algidR != 0)
{
if (state->payload_miR != mi_final)
{
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " Slot 2 PI/LFSR and Late Entry MI Mismatch - %08llX : %08llX ", state->payload_miR, mi_final);
if (mi_crc_ok == 1) state->payload_miR = mi_final;
if (mi_crc_ok == 1) fprintf (stderr, "(CRC OK)");
else fprintf (stderr, "(CRC ERR)");
fprintf (stderr, "\n");
fprintf (stderr, "%s", KNRM);
}
//run expansions afterwards, or le verification won't match up properly
//DES1
if (state->payload_algidR == 0x22)
{
LFSR64 (state);
fprintf (stderr, "\n");
}
//AES-128 or AES-256
if (state->payload_algidR == 0x24 || state->payload_algidR == 0x25)
{
LFSR128d (state);
fprintf (stderr, "\n");
}
}
}
//run LFSR even if golay fails
else if (slot == 0 && state->payload_algid != 0)
{
//DES1
if (state->payload_algid == 0x22)
{
LFSR64 (state);
fprintf (stderr, "\n");
}
//AES-128 or AES-256
if (state->payload_algid == 0x24 || state->payload_algid == 0x25)
{
LFSR128d (state);
fprintf (stderr, "\n");
}
}
else if (slot == 1 && state->payload_algidR != 0)
{
//DES1
if (state->payload_algidR == 0x22)
{
LFSR64 (state);
fprintf (stderr, "\n");
}
//AES-128 or AES-256
if (state->payload_algidR == 0x24 || state->payload_algidR == 0x25)
{
LFSR128d (state);
fprintf (stderr, "\n");
}
}
}
void dmr_alg_refresh (dsd_opts * opts, dsd_state * state)
{
UNUSED(opts);
if (state->currentslot == 0)
{
state->dropL = 256;
if (state->K1 != 0)
{
state->DMRvcL = 0;
}
if (state->payload_algid == 0x21)
{
LFSR (state);
fprintf (stderr, "\n");
}
//LFSR64/128 carried out after LE verification in order to keep it from constantly resetting the MI to the previous value
if (state->payload_algid == 0x02)
{
state->DMRvcL = 0;
//LFSR already calculated, just dump it now
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 1");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algid, state->payload_keyid);
fprintf (stderr, " MI(40): %010llX;", state->payload_mi);
fprintf (stderr, " Hytera Enhanced;");
fprintf (stderr, "%s\n", KNRM);
}
}
if (state->currentslot == 1)
{
state->dropR = 256;
if (state->K1 != 0)
{
state->DMRvcR = 0;
}
if (state->payload_algidR == 0x21)
{
LFSR (state);
fprintf (stderr, "\n");
}
//LFSR64/128 carried out after LE verification in order to keep it from constantly resetting the MI to the previous value
if (state->payload_algidR == 0x02)
{
state->DMRvcR = 0;
//LFSR already calculated, just dump it now
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 2");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algidR, state->payload_keyidR);
fprintf (stderr, " MI(40): %010llX;", state->payload_miR);
fprintf (stderr, " Hytera Enhanced;");
fprintf (stderr, "%s\n", KNRM);
}
}
}
void dmr_alg_reset (dsd_opts * opts, dsd_state * state)
{
UNUSED(opts);
state->dropL = 256;
state->dropR = 256;
state->DMRvcL = 0;
state->DMRvcR = 0;
// state->payload_miP = 0; //running these clears out before we can create a new keystream
// state->payload_miN = 0; //running these clears out before we can create a new keystream
}
//handle Single Burst (Voice Burst F) or Reverse Channel Signalling
void dmr_sbrc (dsd_opts * opts, dsd_state * state, uint8_t power)
{
int i;
uint8_t slot = state->currentslot;
uint8_t sbrc_interleaved[32];
uint8_t sbrc_return[32];
uint8_t sbrc_retcrc[32]; //crc significant bits of the return for SB
memset (sbrc_interleaved, 0, sizeof(sbrc_interleaved));
memset (sbrc_return, 0, sizeof(sbrc_return));
memset (sbrc_retcrc, 0, sizeof(sbrc_retcrc));
uint32_t irr_err = 0;
uint32_t sbrc_hex = 0;
uint16_t crc_extracted = 7777;
uint16_t crc_computed = 9999;
uint8_t crc7_okay = 0; //RC
uint8_t crc3_okay = 0; //TXI
uint8_t txi = 0; //SEE: https://patents.google.com/patent/US8271009B2
UNUSED(txi);
//NOTE: Any previous mentions to Cap+ in this area may have been in error,
//The signalling observed here was actually TXI information, not Cap+ Specifically
//check to see if this a TXI system
if (slot == 0 && state->dmr_so & 0x20) txi = 1;
if (slot == 1 && state->dmr_soR & 0x20) txi = 1;
// 9.3.2 Pre-emption and power control Indicator (PI)
// 0 - The embedded signalling carries information associated to the same logical channel or the Null embedded message
// 1 - The embedded signalling carries RC information associated to the other logical channel
for(i = 0; i < 32; i++) sbrc_interleaved[i] = state->dmr_embedded_signalling[slot][5][i + 8];
//power == 0 should be single burst
if (power == 0) irr_err = BPTC_16x2_Extract_Data(sbrc_interleaved, sbrc_return, 0);
//power == 1 should be reverse channel -- still need to check the interleave inside of BPTC
if (power == 1) irr_err = BPTC_16x2_Extract_Data(sbrc_interleaved, sbrc_return, 1);
//bad emb burst, never set a valid power indicator value (probably 9)
if (power > 1) goto SBRC_END;
//arrange the return for proper order for the crc3 check
for (i = 0; i < 8; i++) sbrc_retcrc[i] = sbrc_return[i+3];
//RC Channel CRC 7 Mask = 0x7A; CRC bits are used as privacy indicators on
//Single Voice Burst F (see below), other moto values seem to exist there as well -- See TXI patent
if (power == 1) //RC
{
crc_extracted = 0;
for (i = 0; i < 7; i++)
{
crc_extracted = crc_extracted << 1;
crc_extracted = crc_extracted | sbrc_return[i+4];
}
crc_extracted = crc_extracted ^ 0x7A;
crc_computed = crc7((uint8_t *) sbrc_return, 4); //#187 fix
if (crc_extracted == crc_computed) crc7_okay = 1;
}
else //if (txi == 1) //if TXI -- but TXI systems also carry the non-crc protected ENC identifiers
{
crc_extracted = 0;
for (i = 0; i < 3; i++)
{
crc_extracted = crc_extracted << 1;
crc_extracted = crc_extracted | sbrc_return[i]; //first 3 most significant bits
}
crc_computed = crc3((uint8_t *) sbrc_retcrc, 8); //working now seems consistent as well
if (crc_extracted == crc_computed) crc3_okay = 1;
// fprintf (stderr, " CRC EXT %02X, CRC CMP %02X", crc_extracted, crc_computed);
}
// else //crc_okay = 0; //CRC invalid / not available when is ENC Identifiers (I really hate that)
for(i = 0; i < 11; i++)
{
sbrc_hex = sbrc_hex << 1;
sbrc_hex |= sbrc_return[i] & 1;
}
if (opts->payload == 1) //hide the sb/rc behind the payload printer, won't be useful to most people
{
fprintf (stderr, "%s", KCYN);
if (power == 0) fprintf (stderr, " SB: ");
if (power == 1) fprintf (stderr, " RC: ");
for(i = 0; i < 11; i++)
fprintf (stderr, "%d", sbrc_return[i]);
fprintf (stderr, " - %03X; ", sbrc_hex);
fprintf (stderr, "%s", KNRM);
// if (crc_okay == 0) //forego this since the crc can vary or not be used at all
// {
// fprintf (stderr, "%s", KRED);
// fprintf (stderr, " (CRC ERR)");
// fprintf (stderr, "%s", KNRM);
// fprintf (stderr, " CRC EXT %02X, CRC CMP %02X", crc_extracted, crc_computed);
// }
fprintf (stderr, "\n");
}
uint8_t sbrc_opcode = sbrc_hex & 0x7; //opcode and alg the same bits, but the alg is present when CRC is bad (I know they are limited on bits, but I hate that idea)
uint8_t alg = sbrc_hex & 0x7; //SEE: https://patents.google.com/patent/EP2347540B1/en
uint8_t key = (sbrc_hex >> 3) & 0xFF;
uint8_t txi_delay = (sbrc_hex >> 3) & 0x1F; //middle five are the 'delay' value on a TXI system
//Note: AES-256 Key 1 will pass a CRC3 due to its bit arrangement vs the CRC poly 1101
// if (irr_err == 0 && sbrc_hex = 0xD) crc3_okay = 0; //SB: 00000001101
//NOTE: on above, I belive that we need to check by opcode as well, as a CRC3 can have multiple collisions
//so we need to exclude op/alg 0 and 3 from the check (does algID 0x03/0x23 even exist?)
if (opts->dmr_le == 1)
{
if (irr_err != 0)
{
uint32_t sbrcpl = 0;
for(i = 0; i < 32; i++)
{
sbrcpl = sbrcpl << 1;
sbrcpl |= sbrc_interleaved[i] & 1;
}
if (opts->payload == 0) fprintf (stderr, "\n");
fprintf (stderr, "%s SLOT %d SB/RC (FEC ERR) E:%d; I:%08X D:%03X; %s ", KRED, slot+1, irr_err, sbrcpl, sbrc_hex, KNRM);
if (opts->payload == 1) fprintf (stderr, "\n");
}
if (irr_err == 0)
{
if (sbrc_hex == 0 && crc7_okay == 0) ; //NULL Single Burst, do nothing (changed to allow the 0 value of RC below to trigger)
//else if (placeholder for future conditions)
// {
// placeholder for future conditions
// }
else if (crc7_okay == 1)
{
//decode the reverse channel information ETSI TS 102 361-4 V1.12.1 (2023-07) p 103 Table 6.32: MS Reverse Channel (RC) Command Information Elements
if (opts->payload == 0) fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
sbrc_hex = sbrc_hex >> 7; //set value to its 4-bit form
if (sbrc_hex == 0) fprintf (stderr, " RC: Increase Power By One Step;");
else if (sbrc_hex == 1) fprintf (stderr, " RC: Decrease Power By One Step;");
else if (sbrc_hex == 2) fprintf (stderr, " RC: Set Power To Highest;");
else if (sbrc_hex == 3) fprintf (stderr, " RC: Set Power To Lowest;");
else if (sbrc_hex == 4) fprintf (stderr, " RC: Cease Transmission Command;");
else if (sbrc_hex == 5) fprintf (stderr, " RC: Cease Transmission Request;");
else fprintf (stderr, " RC: Reserved %02X;", sbrc_hex);
fprintf (stderr, "%s", KNRM);
// if (opts->payload == 1)
fprintf (stderr, "\n");
}
//if the call is interruptable (TXI) and the crc3 is okay and TXI Opcode
else if (crc3_okay == 1 && (sbrc_opcode == 0 || sbrc_opcode == 3) )
{
//opcodes -- 0 (NULL), BR Delay (3)
if (opts->payload == 0) fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " TXI Op: %X -", sbrc_opcode);
if (sbrc_opcode == 0) fprintf (stderr, " Null; ");
else if (sbrc_opcode == 3)
{
if (txi_delay != 0)
fprintf (stderr, " BR Delay: %d - %d ms;", txi_delay, txi_delay * 30); //could also indicate number of superframes until next VC6 pre-emption
else fprintf (stderr, "BR Delay: Irrelevant / Send at any time;");
//alignment of inbound backwards channel and outbound burst
if (txi_delay == 2) fprintf (stderr, " SF3, Burst E;"); //E is inbound
if (txi_delay == 4) fprintf (stderr, " SF3, Burst D;"); //D is inbound
if (txi_delay == 6) fprintf (stderr, " SF3, Burst C;"); //C is inbound
if (txi_delay == 8) fprintf (stderr, " SF3, Burst B;"); //B is inbound
}
else fprintf (stderr, " Unk; ");
fprintf (stderr, "%s", KNRM);
if (opts->payload == 1) fprintf (stderr, "\n"); //only during payload
}
else if (sbrc_opcode != 0 && sbrc_opcode != 3) //all that should be left in this field is the potential ENC identifiers
{
if (slot == 0) //may not need the state->errs anymore //&& state->errs < 3
{
if (state->dmr_so & 0x40 && key != 0 && alg != 0)
{
//if we aren't forcing a particular alg or privacy key set
if (state->M == 0)
{
fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " Slot 1");
fprintf (stderr, " DMR LE SB ALG ID: %02X; KEY ID: %02X;", alg + 0x20, key);
if (alg == 1) fprintf (stderr, " RC4;");
if (alg == 2) fprintf (stderr, " DES;");
if (alg == 4) fprintf (stderr, " AES128;");
if (alg == 5) fprintf (stderr, " AES256;");
fprintf (stderr, "%s ", KNRM);
if (opts->payload == 1) fprintf (stderr, "\n");
if (state->payload_keyid != key)
state->payload_keyid = key;
if (state->payload_algid != alg)
state->payload_algid = alg + 0x20; //assuming DMRA approved alg values (moto patent)
}
}
}
if (slot == 1) //may not need the state->errs anymore //&& state->errsR < 3
{
if (state->dmr_soR & 0x40 && key != 0 && alg != 0)
{
//if we aren't forcing a particular alg or privacy key set
if (state->M == 0)
{
fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
fprintf (stderr, " Slot 2");
fprintf (stderr, " DMR LE SB ALG ID: %02X; KEY ID: %02X;", alg + 0x20, key);
fprintf (stderr, "%s ", KNRM);
if (opts->payload == 1) fprintf (stderr, "\n");
if (state->payload_keyidR != key)
state->payload_keyidR = key;
if (state->payload_algidR != alg)
state->payload_algidR = alg + 0x20; //assuming DMRA approved alg values (moto patent)
}
}
}
}
}
}
SBRC_END:
//'DSP' output to file -- SB and RC
if (opts->use_dsp_output == 1)
{
FILE * pFile; //file pointer
pFile = fopen (opts->dsp_out_file, "a");
fprintf (pFile, "\n%d 99 ", slot+1); //'99' is SB and RC designation value
for (i = 0; i < 12; i++) //48 bits (includes CC, PPI, LCSS, and QR)
// for (i = 2; i < 10; i++) //32 bits (only SB/RC Data and its PC/H)
{
uint8_t sbrc_nib = (state->dmr_embedded_signalling[slot][5][(i*4)+0] << 3) | (state->dmr_embedded_signalling[slot][5][(i*4)+1] << 2) | (state->dmr_embedded_signalling[slot][5][(i*4)+2] << 1) | (state->dmr_embedded_signalling[slot][5][(i*4)+3] << 0);
fprintf (pFile, "%X", sbrc_nib);
}
fclose (pFile);
}
}
uint8_t crc3(uint8_t bits[], unsigned int len)
{
uint8_t crc=0;
unsigned int K = 3;
//x^3+x+1
uint8_t poly[4] = {1,1,0,1};
uint8_t buf[256];
if (len+K > sizeof(buf)) {
return 0;
}
memset (buf, 0, sizeof(buf));
for (unsigned int i=0; i<len; i++){
buf[i] = bits[i];
}
for (unsigned int i=0; i<len; i++)
if (buf[i])
for (unsigned int j=0; j<K+1; j++)
buf[i+j] ^= poly[j];
for (unsigned int i=0; i<K; i++){
crc = (crc << 1) + buf[len + i];
}
return crc;
}
uint8_t crc4(uint8_t bits[], unsigned int len)
{
uint8_t crc=0;
unsigned int K = 4;
//x^4+x+1
uint8_t poly[5] = {1,0,0,1,1};
uint8_t buf[256];
if (len+K > sizeof(buf)) {
return 0;
}
memset (buf, 0, sizeof(buf));
for (unsigned int i=0; i<len; i++){
buf[i] = bits[i];
}
for (unsigned int i=0; i<len; i++)
if (buf[i])
for (unsigned int j=0; j<K+1; j++)
buf[i+j] ^= poly[j];
for (unsigned int i=0; i<K; i++){
crc = (crc << 1) + buf[len + i];
}
return crc ^ 0xF; //invert
}

File diff suppressed because it is too large Load Diff

1008
src/dmr_pdu.c Normal file

File diff suppressed because it is too large Load Diff

473
src/dmr_pi.c Normal file
View File

@@ -0,0 +1,473 @@
/*-------------------------------------------------------------------------------
* dmr_pi.c
* DMR Privacy Indicator and LFSR Function
*
* LFSR code courtesy of https://github.com/mattames/LFSR/
*
* LWVMOBILE
* 2022-12 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors)
{
UNUSED2(opts, CRCCorrect);
uint8_t MFID = PI_BYTE[1];
if(IrrecoverableErrors == 0)
{
//update cc amd vc sync time for trunking purposes (particularly Con+)
if (opts->p25_is_tuned == 1)
{
state->last_vc_sync_time = time(NULL);
state->last_cc_sync_time = time(NULL);
}
if (MFID == 0x68) //Hytera Enhanced
{
if (state->currentslot == 0)
{
state->dmr_so |= 0x40; //OR the enc bit onto the SO
state->payload_algid = PI_BYTE[0];
state->payload_keyid = PI_BYTE[2];
state->payload_mi = ((unsigned long long int)PI_BYTE[3] << 32ULL) | ((unsigned long long int)PI_BYTE[4] << 24) |
((unsigned long long int)PI_BYTE[5] << 16) | ((unsigned long long int)PI_BYTE[6] << 8) | ((unsigned long long int)PI_BYTE[7] << 0);
}
else
{
state->dmr_soR |= 0x40; //OR the enc bit onto the SO
state->payload_algidR = PI_BYTE[0];
state->payload_keyidR = PI_BYTE[2];
state->payload_miR = ((unsigned long long int)PI_BYTE[3] << 32ULL) | ((unsigned long long int)PI_BYTE[4] << 24) |
((unsigned long long int)PI_BYTE[5] << 16) | ((unsigned long long int)PI_BYTE[6] << 8) | ((unsigned long long int)PI_BYTE[7] << 0);
}
fprintf (stderr, "%s ", KYEL);
fprintf (stderr, "\n Slot %d", state->currentslot+1);
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(40): %02X%02X%02X%02X%02X;",
PI_BYTE[0], PI_BYTE[2], PI_BYTE[3], PI_BYTE[4], PI_BYTE[5], PI_BYTE[6], PI_BYTE[7]);
//PI_BYTE[9] is a checksum of the other bytes combined
uint8_t checksum = 0;
for (int i = 0; i < 9; i++)
{
checksum += PI_BYTE[i];
checksum &= 0xFF;
}
checksum = ~checksum & 0xFF;
checksum++;
//debug
// fprintf (stderr, " CHK: %02X / %02X;", checksum, PI_BYTE[9]);
if (checksum == PI_BYTE[9])
{
fprintf (stderr, " Hytera Enhanced; ");
if (state->currentslot == 0 && state->R != 0)
fprintf (stderr, "Key: %010llX; ", state->R);
if (state->currentslot == 1 && state->RR != 0)
fprintf (stderr, "Key: %010llX; ", state->RR);
//disable late entry for DMRA (hopefully, there aren't any systems running both DMRA and Hytera Enhanced mixed together)
opts->dmr_le = 2;
// fprintf (stderr, " (Checksum Okay);");
}
else
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, " (Checksum Err);");
}
fprintf (stderr, "%s", KNRM);
}
else if (MFID == 0x10) //DMRA
{
if (state->currentslot == 0)
{
state->payload_algid = PI_BYTE[0];
state->payload_keyid = PI_BYTE[2];
state->payload_mi = ((unsigned long long int)PI_BYTE[3] << 24ULL) | ((unsigned long long int)PI_BYTE[4] << 16ULL) | ((unsigned long long int)PI_BYTE[5] << 8ULL) | ((unsigned long long int)PI_BYTE[6] << 0ULL);
if (state->payload_algid < 0x26)
{
fprintf (stderr, "%s ", KYEL);
fprintf (stderr, "\n Slot 1");
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(32): %08llX;", state->payload_algid, state->payload_keyid, state->payload_mi);
//check for any values that aren't 0x2X but just 0x0X
//going to be very generic here to avoid any particular vendors using 0x2X and not 0x0X
if (state->payload_algid & 0x20)
fprintf (stderr, " DMRA");
else fprintf (stderr, " DMRA Compatible");
if ((state->payload_algid & 0x07) == 0x01)
{
fprintf (stderr, " RC4;");
state->payload_algid = 0x21;
}
else if ((state->payload_algid & 0x07) == 0x02)
{
fprintf (stderr, " DES;");
state->payload_algid = 0x22;
}
else if ((state->payload_algid & 0x07) == 0x04)
{
fprintf (stderr, " AES-128;");
state->payload_algid = 0x24;
}
else if ((state->payload_algid & 0x07) == 0x05)
{
fprintf (stderr, " AES-256;");
state->payload_algid = 0x25;
}
fprintf (stderr, "%s ", KNRM);
//expand the 32-bit MI to a 64-bit DES IV
if (state->payload_algid == 0x22)
{
fprintf (stderr, "\n");
LFSR64 (state);
}
//expand the 32-bit MI to a 128-bit AES IV
if (state->payload_algid == 0x24 || state->payload_algid == 0x25)
{
fprintf (stderr, "\n");
LFSR128d (state);
}
}
if (state->payload_algid >= 0x26)
{
state->payload_algid = 0;
state->payload_keyid = 0;
state->payload_mi = 0;
}
}
if (state->currentslot == 1)
{
state->payload_algidR = PI_BYTE[0];
state->payload_keyidR = PI_BYTE[2];
state->payload_miR = ((unsigned long long int)PI_BYTE[3] << 24ULL) | ((unsigned long long int)PI_BYTE[4] << 16ULL) | ((unsigned long long int)PI_BYTE[5] << 8ULL) | ((unsigned long long int)PI_BYTE[6] << 0ULL);
if (state->payload_algidR < 0x26)
{
fprintf (stderr, "%s ", KYEL);
fprintf (stderr, "\n Slot 2");
fprintf (stderr, " DMR PI H- ALG ID: %02X; KEY ID: %02X; MI(32): %08llX;", state->payload_algidR, state->payload_keyidR, state->payload_miR);
//check for any values that aren't 0x2X but just 0x0X
//going to be very generic here to avoid any particular vendors using 0x2X and not 0x0X
if (state->payload_algidR & 0x20)
fprintf (stderr, " DMRA");
else fprintf (stderr, " DMRA Compatible");
if ((state->payload_algidR & 0x07) == 0x01)
{
fprintf (stderr, " RC4;");
state->payload_algidR = 0x21;
}
else if ((state->payload_algidR & 0x07) == 0x02)
{
fprintf (stderr, " DES;");
state->payload_algidR = 0x22;
}
else if ((state->payload_algidR & 0x07) == 0x04)
{
fprintf (stderr, " AES-128;");
state->payload_algidR = 0x24;
}
else if ((state->payload_algidR & 0x07) == 0x05)
{
fprintf (stderr, " AES-256;");
state->payload_algidR = 0x25;
}
fprintf (stderr, "%s ", KNRM);
//expand the 32-bit MI to a 64-bit DES IV
if (state->payload_algidR == 0x22)
{
fprintf (stderr, "\n");
LFSR64 (state);
}
//expand the 32-bit MI to a 128-bit AES IV
if (state->payload_algidR == 0x24 || state->payload_algidR == 0x25)
{
fprintf (stderr, "\n");
LFSR128d (state);
}
}
if (state->payload_algidR >= 0x26)
{
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->payload_miR = 0;
}
}
} //end DMRA
}
}
void LFSR(dsd_state * state)
{
unsigned long long int lfsr = 0;
if (state->currentslot == 0)
{
lfsr = state->payload_mi;
}
else lfsr = state->payload_miR;
uint8_t cnt = 0;
for(cnt=0;cnt<32;cnt++)
{
// Polynomial is C(x) = x^32 + x^4 + x^2 + 1
unsigned long long int bit = ((lfsr >> 31) ^ (lfsr >> 3) ^ (lfsr >> 1)) & 0x1;
lfsr = (lfsr << 1) | bit;
}
lfsr &= 0xFFFFFFFF;
if (state->currentslot == 0)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 1");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algid, state->payload_keyid);
fprintf (stderr, " MI(32): %08llX;", lfsr);
fprintf (stderr, " RC4;");
fprintf (stderr, "%s", KNRM);
state->payload_mi = lfsr;
}
if (state->currentslot == 1)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 2");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algidR, state->payload_keyidR);
fprintf(stderr, " MI(32): %08llX;", lfsr);
fprintf (stderr, " RC4;");
fprintf (stderr, "%s", KNRM);
state->payload_miR = lfsr;
}
}
//Expand a 32-bit MI into a 64-bit IV for DES
void LFSR64(dsd_state * state)
{
{
unsigned long long int lfsr = 0;
if (state->currentslot == 0)
{
lfsr = (uint64_t) state->payload_mi;
}
else lfsr = (uint64_t) state->payload_miR;
uint8_t cnt = 0;
for(cnt=0;cnt<32;cnt++)
{
unsigned long long int bit = ( (lfsr >> 31) ^ (lfsr >> 21) ^ (lfsr >> 1) ^ (lfsr >> 0) ) & 0x1;
lfsr = (lfsr << 1) | bit;
}
if (state->currentslot == 0)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 1");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algid, state->payload_keyid);
fprintf (stderr, " MI(64): %016llX;", lfsr);
fprintf (stderr, " DES;");
fprintf (stderr, "%s", KNRM);
state->payload_mi = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
state->payload_miP = lfsr;
state->DMRvcL = 0;
}
if (state->currentslot == 1)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 2");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X;", state->payload_algidR, state->payload_keyidR);
fprintf (stderr, " MI(64): %016llX;", lfsr);
fprintf (stderr, " DES;");
fprintf (stderr, "%s", KNRM);
state->payload_miR = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
state->payload_miN = lfsr;
state->DMRvcR = 0;
}
}
}
//Expand a 32-bit MI into a 128-bit IV for AES
void LFSR128d(dsd_state * state)
{
unsigned long long int lfsr = 0;
if (state->currentslot == 0)
lfsr = state->payload_mi;
else lfsr = state->payload_miR;
unsigned long long int next_mi;
//start packing aes_iv
if (state->currentslot == 0)
{
state->aes_iv[0] = (lfsr >> 24) & 0xFF;
state->aes_iv[1] = (lfsr >> 16) & 0xFF;
state->aes_iv[2] = (lfsr >> 8 ) & 0xFF;
state->aes_iv[3] = (lfsr >> 0 ) & 0xFF;
}
else if (state->currentslot == 1)
{
state->aes_ivR[0] = (lfsr >> 24) & 0xFF;
state->aes_ivR[1] = (lfsr >> 16) & 0xFF;
state->aes_ivR[2] = (lfsr >> 8 ) & 0xFF;
state->aes_ivR[3] = (lfsr >> 0 ) & 0xFF;
}
int cnt = 0; int x = 32;
unsigned long long int bit;
for(cnt=0;cnt<96;cnt++)
{
//32,22,2,1
bit = ( (lfsr >> 31) ^ (lfsr >> 21) ^ (lfsr >> 1) ^ (lfsr >> 0) ) & 0x1;
lfsr = (lfsr << 1) | bit;
//continue packing aes_iv
if (state->currentslot == 0)
state->aes_iv[x/8] = (state->aes_iv[x/8] << 1) + bit;
else if (state->currentslot == 1)
state->aes_ivR[x/8] = (state->aes_ivR[x/8] << 1) + bit;
x++;
}
//assign the next 32-bit short MI from 4,5,6,7 so it'll match up with OTA late entry
if (state->currentslot == 0)
next_mi = ((unsigned long long int)state->aes_iv[4] << 24) | ((unsigned long long int)state->aes_iv[5] << 16) |
((unsigned long long int)state->aes_iv[6] << 8) | ((unsigned long long int)state->aes_iv[7] << 0);
if (state->currentslot == 1)
next_mi = ((unsigned long long int)state->aes_ivR[4] << 24) | ((unsigned long long int)state->aes_ivR[5] << 16) |
((unsigned long long int)state->aes_ivR[6] << 8) | ((unsigned long long int)state->aes_ivR[7] << 0);
if (state->currentslot == 0)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 1");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X; MI(128): ", state->payload_algid, state->payload_keyid);
for (x = 0; x < 16; x++)
fprintf (stderr, "%02X", state->aes_iv[x]);
fprintf (stderr, "%s", KNRM);
fprintf (stderr, ";");
if (state->payload_algid == 0x24)
fprintf (stderr, " AES-128;");
else fprintf (stderr, " AES-256;");
state->payload_mi = next_mi;
state->DMRvcL = 0;
}
if (state->currentslot == 1)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Slot 2");
fprintf (stderr, " DMR PI C- ALG ID: %02X; KEY ID: %02X; MI(128): ", state->payload_algidR, state->payload_keyidR);
for (x = 0; x < 16; x++)
fprintf (stderr, "%02X", state->aes_ivR[x]);
fprintf (stderr, "%s", KNRM);
fprintf (stderr, ";");
if (state->payload_algidR == 0x24)
fprintf (stderr, " AES-128;");
else fprintf (stderr, " AES-256;");
state->payload_miR = next_mi;
state->DMRvcR = 0;
}
}
unsigned long long int hytera_lfsr(uint8_t * mi, uint8_t * taps, uint8_t len)
{
for (uint8_t i = 0; i < len; i++)
{
uint8_t bit = (mi[i] >> 7) & 1;
mi[i] <<= 1;
if (bit) mi[i] ^= taps[i%5];
mi[i] |= bit;
}
unsigned long long int mi_value = 0;
for (uint8_t i = 0; i < 5; i++)
{
mi_value <<= 8;
mi_value |= mi[i];
}
//debug
// fprintf (stderr, " Next MI: %010llX \n", mi_value);
return mi_value;
}
void hytera_enhanced_alg_refresh(dsd_state * state)
{
uint8_t mi[5]; memset (mi, 0, sizeof(mi));
unsigned long long int mi_value = 0;
if (state->currentslot == 0)
mi_value = state->payload_mi;
else mi_value = state->payload_miR;
//load mi_value into mi array
mi[0] = ((mi_value & 0xFF00000000) >> 32UL);
mi[1] = ((mi_value & 0xFF000000) >> 24);
mi[2] = ((mi_value & 0xFF0000) >> 16);
mi[3] = ((mi_value & 0xFF00) >> 8);
mi[4] = ((mi_value & 0xFF) >> 0);
//calculate the next MI value
uint8_t taps[5]; memset(taps, 0, sizeof(taps));
//the tap values
taps[0] = 0x12;
taps[1] = 0x24;
taps[2] = 0x48;
taps[3] = 0x22;
taps[4] = 0x14;
mi_value = hytera_lfsr(mi, taps, 5);
if (state->currentslot == 0)
state->payload_mi = mi_value;
else state->payload_miR = mi_value;
}

View File

@@ -1,395 +0,0 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsd.h"
#include "dmr_const.h"
#include "p25p1_check_hdu.h"
void ProcessDMR (dsd_opts * opts, dsd_state * state)
{
uint32_t i, j;
uint32_t Frame;
TimeSlotVoiceSuperFrame_t * TSVoiceSupFrameL = NULL;
TimeSlotVoiceSuperFrame_t * TSVoiceSupFrameR = NULL;
TimeSlotVoiceSuperFrame_t * TSVoiceSupFrameRC = NULL; //Reverse Test for MS Backwards
int *errs;
int *errs2;
unsigned long long int k;
int x;
k = 0;
TSVoiceSupFrameL = &state->TS1SuperFrame;
TSVoiceSupFrameR = &state->TS2SuperFrame;
int Pr[256] = {
0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903,
0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306,
0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B,
0x6C1D, 0x731D, 0x8F1D, 0x901D, 0x491E, 0x561E, 0xAA1E, 0xB51E, //31
0x4B28, 0x5428, 0xA828, 0xB728, 0x6E2B, 0x712B, 0x8D2B, 0x922B,
0x012D, 0x1E2D, 0xE22D, 0xFD2D, 0x242E, 0x3B2E, 0xC72E, 0xD82E,
0x6D30, 0x7230, 0x8E30, 0x9130, 0x4833, 0x5733, 0xAB33, 0xB433,
0x2735, 0x3835, 0xC435, 0xDB35, 0x0236, 0x1D36, 0xE136, 0xFE36, //63
0x2B49, 0x3449, 0xC849, 0xD749, 0x0E4A, 0x114A, 0xED4A, 0xF24A,
0x614C, 0xAE4C, 0x824C, 0x9D4C, 0x444F, 0x5B4F, 0xA74F, 0xB84F,
0x0D51, 0x1251, 0xEE51, 0xF151, 0x2852, 0x3752, 0xCB52, 0xD452,
0x4754, 0x5854, 0xA454, 0xBB54, 0x6257, 0x7D57, 0x8157, 0x9E57, //95
0x6061, 0x7F61, 0x8361, 0x9C61, 0x4562, 0x5A62, 0xA662, 0xB962,
0x2A64, 0x3564, 0xC964, 0xD664, 0x0F67, 0x1067, 0xEC67, 0xF367,
0x4679, 0x5979, 0xA579, 0xBA79, 0x637A, 0x7C7A, 0x807A, 0x9F7A,
0x0C7C, 0x137C, 0xEF7C, 0xF07C, 0x297F, 0x367F, 0xCA7F, 0xD57F, //127
0x4D89, 0x5289, 0xAE89, 0xB189, 0x688A, 0x778A, 0x8B8A, 0x948A,
0x078C, 0x188C, 0xE48C, 0xFB8C, 0x228F, 0x3D8F, 0xC18F, 0xDE8F,
0x6B91, 0x7491, 0x8891, 0x9791, 0x4E92, 0x5192, 0xAD92, 0xB292,
0x2194, 0x3E94, 0xC294, 0xDD94, 0x0497, 0x1B97, 0xE797, 0xF897, //159
0x06A1, 0x19A1, 0xE5A1, 0xFAA1, 0x23A2, 0x3CA2, 0xC0A2, 0xDFA2,
0x4CA4, 0x53A4, 0xAFA4, 0xB0A4, 0x69A7, 0x76A7, 0x8AA7, 0x95A7,
0x20B9, 0x3FB9, 0xC3B9, 0xDCB9, 0x05BA, 0x1ABA, 0xE6BA, 0xF9BA,
0x6ABC, 0x75BC, 0x89BC, 0x96BC, 0x4FBF, 0x50BF, 0xACBF, 0xB3BF, //191
0x66C0, 0x79C0, 0x85C0, 0x9AC0, 0x43C3, 0x5CC3, 0xA0C3, 0xBFC3,
0x2CC5, 0x33C5, 0xCFC5, 0xD0C5, 0x09C6, 0x16C6, 0xEAC6, 0xF5C6,
0x84D0, 0x85DF, 0x8AD3, 0x8BDC, 0xB6D5, 0xB7DA, 0xB8D6, 0xB9D9,
0xD0DA, 0xD1D5, 0xDED9, 0xDFD6, 0xE2DF, 0xE3D0, 0xECDC, 0xEDD3, //223
0x2DE8, 0x32E8, 0xCEE8, 0xD1E8, 0x08EB, 0x17EB, 0xEBEB, 0xF4EB,
0x67ED, 0x78ED, 0x84ED, 0x9BED, 0x42EE, 0x5DEE, 0xA1EE, 0xBEEE,
0x0BF0, 0x14F0, 0xE8F0, 0xF7F0, 0x2EF3, 0x31F3, 0xCDF3, 0xD2F3,
0x41F5, 0x5EF5, 0xA2F5, 0xBDF5, 0x64F6, 0x7BF6, 0x87F6, 0x98F6 //255
};
if ( (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) ||
(state->currentslot == 0 && state->K > 0 && state->M == 1) )
{
fprintf (stderr, "%s", KYEL);
fprintf(stderr, " PrK %lld", state->K);
fprintf (stderr, "%s", KNRM);
k = Pr[state->K];
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
for(Frame = 0; Frame < 6; Frame++)
{
for(i = 0; i < 3; i++)
{
for(j = 0; j < 48; j++)
{
x = ( ((k << j) & 0x800000000000) >> 47 );
TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= x;
}
}
}
}
if ( (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ||
(state->currentslot == 1 && state->K > 0 && state->M == 1) )
{
fprintf (stderr, "%s", KYEL);
fprintf(stderr, " PrK %lld", state->K);
fprintf (stderr, "%s", KNRM);
k = Pr[state->K];
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
for(Frame = 0; Frame < 6; Frame++)
{
for(i = 0; i < 3; i++)
{
for(j = 0; j < 48; j++)
{
x = ( ((k << j) & 0x800000000000) >> 47 );
TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= x;
}
}
}
}
if ( (state->currentslot == 0 && state->K1 > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) ||
(state->currentslot == 0 && state->K1 > 0 && state->M == 1) )
{
int pos = 0;
unsigned long long int k1 = state->K1;
unsigned long long int k2 = state->K2;
unsigned long long int k3 = state->K3;
unsigned long long int k4 = state->K4;
fprintf (stderr, "\n");
fprintf (stderr, "%s", KYEL);
fprintf(stderr, " SPT %010llX", k1);
int T_Key[256] = {0};
int pN[882] = {0};
int len = 0;
if (k2 == 0)
{
len = 39;
k1 = k1 << 24;
}
if (k2 != 0)
{
len = 127;
fprintf(stderr, " %016llX", k2);
}
if (k4 != 0)
{
len = 255;
fprintf(stderr, " %016llX", k3);
fprintf(stderr, " %016llX", k4);
}
fprintf (stderr, "%s", KNRM);
for (i = 0; i < 64; i++)
{
T_Key[i] = ( ((k1 << i) & 0x8000000000000000) >> 63 );
T_Key[i+64] = ( ((k2 << i) & 0x8000000000000000) >> 63 );
T_Key[i+128] = ( ((k3 << i) & 0x8000000000000000) >> 63 );
T_Key[i+192] = ( ((k4 << i) & 0x8000000000000000) >> 63 );
}
for (i = 0; i < 882; i++)
{
pN[i] = T_Key[pos];
pos++;
if (pos > len)
{
pos = 0;
}
}
pos = 0;
for(Frame = 0; Frame < 6; Frame++)
{
for(i = 0; i < 3; i++)
{
for(j = 0; j < 49; j++)
{
TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= pN[pos];
pos++;
}
}
}
}
if ( (state->currentslot == 1 && state->K1 > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) ||
(state->currentslot == 1 && state->K1 > 0 && state->M == 1) )
{
int pos = 0;
unsigned long long int k1 = state->K1;
unsigned long long int k2 = state->K2;
unsigned long long int k3 = state->K3;
unsigned long long int k4 = state->K4;
fprintf (stderr, "\n");
fprintf (stderr, "%s", KYEL);
fprintf(stderr, " SPT %010llX", k1);
int T_Key[256] = {0};
int pN[882] = {0};
int len = 0;
if (k2 == 0)
{
len = 39;
k1 = k1 << 24;
}
if (k2 != 0)
{
len = 127;
fprintf(stderr, " %016llX", k2);
}
if (k4 != 0)
{
len = 255;
fprintf(stderr, " %016llX", k3);
fprintf(stderr, " %016llX", k4);
}
fprintf (stderr, "%s", KNRM);
for (i = 0; i < 64; i++)
{
T_Key[i] = ( ((k1 << i) & 0x8000000000000000) >> 63 );
T_Key[i+64] = ( ((k2 << i) & 0x8000000000000000) >> 63 );
T_Key[i+128] = ( ((k3 << i) & 0x8000000000000000) >> 63 );
T_Key[i+192] = ( ((k4 << i) & 0x8000000000000000) >> 63 );
}
for (i = 0; i < 882; i++)
{
pN[i] = T_Key[pos];
pos++;
if (pos > len)
{
pos = 0;
}
}
pos = 0;
for(Frame = 0; Frame < 6; Frame++)
{
for(i = 0; i < 3; i++)
{
for(j = 0; j < 49; j++)
{
TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= pN[pos];
pos++;
}
}
}
}
if (state->currentslot == 0)
{
for(Frame = 0; Frame < 6; Frame++) //6
{
/* 1 DMR frame contains 3 AMBE voice samples */
for(i = 0; i < 3; i++)
{
errs = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
errs2 = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str,
TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->payload == 1)
{
PrintAMBEData(opts, state, TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
//quick enc toggle to determine whether or not to play enc traffic
int enc_bit = 0;
enc_bit = (state->dmr_so >> 6) & 0x1;
if (enc_bit == 1)
{
state->dmr_encL = 1;
}
else state->dmr_encL = 0;
if (state->K != 0 || state->K1 != 0)
{
state->dmr_encL = 0;
}
//quick test to determine whether or not to run the next few steps below
if (state->dmr_encL == 0 || opts->dmr_mute_encL == 0)
{
if (opts->mbe_out_f != NULL)
{
saveAmbe2450Data (opts, state, TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
state->debug_audio_errors += *errs2;
processAudio(opts, state);
if (opts->wav_out_f != NULL)
{
writeSynthesizedVoice (opts, state);
}
if (opts->audio_out == 1) //opts->audio_out == 1
{
playSynthesizedVoice (opts, state);
}
} //second bracket for the test enc condition
} /* End for(i = 0; i < 3; i++) */
} /* End for(Frame = 0; Frame < 6; Frame++) */
} //End if Current Slot == 0
if (state->currentslot == 1)
{
for(Frame = 0; Frame < 6; Frame++)
{
/* 1 DMR frame contains 3 AMBE voice samples */
for(i = 0; i < 3; i++)
{
errs = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
errs2 = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str,
TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->payload == 1)
{
PrintAMBEData(opts, state, TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
//quick enc toggle to determine whether or not to play enc traffic
int enc_bit = 0;
enc_bit = (state->dmr_soR >> 6) & 0x1;
if (enc_bit == 1)
{
state->dmr_encR = 1;
}
else state->dmr_encR = 0;
if (state->K != 0 || state->K1 != 0)
{
state->dmr_encR = 0;
}
//quick test to determine whether or not to run the next few steps below
if (state->dmr_encR == 0 || opts->dmr_mute_encR == 0)
{
if (opts->mbe_out_f != NULL)
{
saveAmbe2450Data (opts, state, TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
state->debug_audio_errors += *errs2;
if (opts->audio_out == 1)
{
processAudio(opts, state);
}
if (opts->wav_out_f != NULL)
{
writeSynthesizedVoice (opts, state);
}
if (opts->audio_out == 1)
{
playSynthesizedVoice (opts, state);
}
}
} /* End for(i = 0; i < 3; i++) */
} /* End for(Frame = 0; Frame < 6; Frame++) */
} //End if Current Slot == 1
} /* End ProcessDMR */
/* End of file */

File diff suppressed because it is too large Load Diff

440
src/dmr_utils.c Normal file
View File

@@ -0,0 +1,440 @@
//DMR CRC/Utility Functions
//Original File - dmr_sync.c
//ConvertBitIntoBytes, ComputeCrcCCITT, ComputeCrc5Bit, ComputeAndCorrectFullLinkControlCrc, CRC32, CRC9
//Original Source - https://github.com/LouisErigHerve/dsd
//Additional Functions
//Hamming17123, crc7, crc8, crc8ok functions
//Original Souce - https://github.com/boatbod/op25
#include "dsd.h"
//modified to accept variable payload size and len
uint16_t ComputeCrcCCITT16d(const uint8_t * buf, uint32_t len)
{
uint32_t i;
uint16_t CRC = 0x0000; /* Initialization value = 0x0000 */
/* Polynomial x^16 + x^12 + x^5 + 1
* Normal = 0x1021
* Reciprocal = 0x0811
* Reversed = 0x8408
* Reversed reciprocal = 0x8810 */
uint16_t Polynome = 0x1021;
for(i = 0; i < len; i++)
{
if(((CRC >> 15) & 1) ^ (buf[i] & 1))
{
CRC = (CRC << 1) ^ Polynome;
}
else
{
CRC <<= 1;
}
}
/* Invert the CRC */
CRC ^= 0xFFFF;
/* Return the CRC */
return CRC;
} /* End ComputeCrcCCITTd() */
// A Hamming (17,12,3) Check for completed SLC message
bool Hamming17123(uint8_t* d)
{
// Calculate the checksum this column should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9];
bool c1 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10];
bool c2 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[8] ^ d[9] ^ d[11];
bool c3 = d[0] ^ d[1] ^ d[4] ^ d[5] ^ d[7] ^ d[10];
bool c4 = d[0] ^ d[1] ^ d[2] ^ d[5] ^ d[6] ^ d[8] ^ d[11];
// Compare these with the actual bits
unsigned char n = 0x00U;
n |= (c0 != d[12]) ? 0x01U : 0x00U;
n |= (c1 != d[13]) ? 0x02U : 0x00U;
n |= (c2 != d[14]) ? 0x04U : 0x00U;
n |= (c3 != d[15]) ? 0x08U : 0x00U;
n |= (c4 != d[16]) ? 0x10U : 0x00U;
switch (n) {
// Parity bit errors
case 0x01U: d[12] = !d[12]; return true;
case 0x02U: d[13] = !d[13]; return true;
case 0x04U: d[14] = !d[14]; return true;
case 0x08U: d[15] = !d[15]; return true;
case 0x10U: d[16] = !d[16]; return true;
// Data bit errors
case 0x1BU: d[0] = !d[0]; return true;
case 0x1FU: d[1] = !d[1]; return true;
case 0x17U: d[2] = !d[2]; return true;
case 0x07U: d[3] = !d[3]; return true;
case 0x0EU: d[4] = !d[4]; return true;
case 0x1CU: d[5] = !d[5]; return true;
case 0x11U: d[6] = !d[6]; return true;
case 0x0BU: d[7] = !d[7]; return true;
case 0x16U: d[8] = !d[8]; return true;
case 0x05U: d[9] = !d[9]; return true;
case 0x0AU: d[10] = !d[10]; return true;
case 0x14U: d[11] = !d[11]; return true;
// No bit errors
case 0x00U: return true;
// Unrecoverable errors
default: return false;
}
}
uint8_t crc8(uint8_t bits[], unsigned int len)
{
uint8_t crc=0;
unsigned int K = 8;
uint8_t poly[9] = {1,0,0,0,0,0,1,1,1}; // crc8 poly
uint8_t buf[256];
if (len+K > sizeof(buf)) {
//fprintf (stderr, "crc8: buffer length %u exceeds maximum %lu\n", len+K, sizeof(buf));
return 0;
}
memset (buf, 0, sizeof(buf));
for (unsigned int i=0; i<len; i++){
buf[i] = bits[i];
}
for (unsigned int i=0; i<len; i++)
if (buf[i])
for (unsigned int j=0; j<K+1; j++)
buf[i+j] ^= poly[j];
for (unsigned int i=0; i<K; i++){
crc = (crc << 1) + buf[len + i];
}
return crc;
}
bool crc8_ok(uint8_t bits[], unsigned int len)
{
uint16_t crc = 0;
for (unsigned int i=0; i < 8; i++) {
crc = (crc << 1) + bits[len+i];
}
return (crc == crc8(bits,len));
}
uint8_t crc7(uint8_t bits[], unsigned int len)
{
uint8_t crc=0;
unsigned int K = 7;
//G7(x) = x7 + x5 + x2 + x + 1 check poly below for correct (dmr rc crc7)
uint8_t poly[8] = {1,0,1,0,0,1,1,1}; // crc7 poly
uint8_t buf[256];
if (len+K > sizeof(buf)) {
// fprintf (stderr, "crc8: buffer length %u exceeds maximum %lu\n", len+K, sizeof(buf));
return 0;
}
memset (buf, 0, sizeof(buf));
for (unsigned int i=0; i<len; i++){
buf[i] = bits[i];
}
for (unsigned int i=0; i<len; i++)
if (buf[i])
for (unsigned int j=0; j<K+1; j++)
buf[i+j] ^= poly[j];
for (unsigned int i=0; i<K; i++){
crc = (crc << 1) + buf[len + i];
}
return crc;
}
/*
* @brief : This function compute the CRC-CCITT of the DMR data
* by using the polynomial x^16 + x^12 + x^5 + 1
*
* @param Input : A buffer pointer of the DMR data (80 bytes)
*
* @return The 16 bit CRC
*/
uint16_t ComputeCrcCCITT(uint8_t * DMRData)
{
uint32_t i;
uint16_t CRC = 0x0000; /* Initialization value = 0x0000 */
/* Polynomial x^16 + x^12 + x^5 + 1
* Normal = 0x1021
* Reciprocal = 0x0811
* Reversed = 0x8408
* Reversed reciprocal = 0x8810 */
uint16_t Polynome = 0x1021;
for(i = 0; i < 80; i++)
{
if(((CRC >> 15) & 1) ^ (DMRData[i] & 1))
{
CRC = (CRC << 1) ^ Polynome;
}
else
{
CRC <<= 1;
}
}
/* Invert the CRC */
CRC ^= 0xFFFF;
/* Return the CRC */
return CRC;
} /* End ComputeCrcCCITT() */
/*
* @brief : This function compute the CRC-24 bit of the full
* link control by using the Reed-Solomon(12,9) FEC
*
* @param FullLinkControlDataBytes : A buffer pointer of the DMR data bytes (12 bytes)
*
* @param CRCComputed : A 32 bit pointer where the computed CRC 24-bit will be stored
*
* @param CRCMask : The 24 bit CRC mask to apply
*
* @return 0 = CRC error
* 1 = CRC is correct
*/
uint32_t ComputeAndCorrectFullLinkControlCrc(uint8_t * FullLinkControlDataBytes, uint32_t * CRCComputed, uint32_t CRCMask)
{
uint32_t i;
rs_12_9_codeword_t VoiceLCHeaderStr;
rs_12_9_poly_t syndrome;
uint8_t errors_found = 0;
rs_12_9_correct_errors_result_t result = RS_12_9_CORRECT_ERRORS_RESULT_NO_ERRORS_FOUND;
uint32_t CrcIsCorrect = 0;
for(i = 0; i < 12; i++)
{
VoiceLCHeaderStr.data[i] = FullLinkControlDataBytes[i];
/* Apply CRC mask on each 3 last bytes
* of the full link control */
if(i == 9)
{
VoiceLCHeaderStr.data[i] ^= (uint8_t)(CRCMask >> 16);
}
else if(i == 10)
{
VoiceLCHeaderStr.data[i] ^= (uint8_t)(CRCMask >> 8);
}
else if(i == 11)
{
VoiceLCHeaderStr.data[i] ^= (uint8_t)(CRCMask);
}
else
{
/* Nothing to do */
}
}
/* Check and correct the full link LC control with Reed Solomon (12,9) FEC */
rs_12_9_calc_syndrome(&VoiceLCHeaderStr, &syndrome);
if(rs_12_9_check_syndrome(&syndrome) != 0) result = rs_12_9_correct_errors(&VoiceLCHeaderStr, &syndrome, &errors_found);
/* Reconstitue the CRC */
*CRCComputed = (uint32_t)((VoiceLCHeaderStr.data[9] << 16) & 0xFF0000);
*CRCComputed |= (uint32_t)((VoiceLCHeaderStr.data[10] << 8) & 0x00FF00);
*CRCComputed |= (uint32_t)((VoiceLCHeaderStr.data[11] << 0) & 0x0000FF);
if((result == RS_12_9_CORRECT_ERRORS_RESULT_NO_ERRORS_FOUND) ||
(result == RS_12_9_CORRECT_ERRORS_RESULT_ERRORS_CORRECTED))
{
//fprintf(stderr, "CRC OK : 0x%06X\n", *CRCComputed);
CrcIsCorrect = 1;
/* Reconstitue full link control data after FEC correction */
for(i = 0; i < 12; i++)
{
FullLinkControlDataBytes[i] = VoiceLCHeaderStr.data[i];
/* Apply CRC mask on each 3 last bytes
* of the full link control */
if(i == 9)
{
FullLinkControlDataBytes[i] ^= (uint8_t)(CRCMask >> 16);
}
else if(i == 10)
{
FullLinkControlDataBytes[i] ^= (uint8_t)(CRCMask >> 8);
}
else if(i == 11)
{
FullLinkControlDataBytes[i] ^= (uint8_t)(CRCMask);
}
else
{
/* Nothing to do */
}
}
}
else
{
//fprintf(stderr, "CRC ERROR : 0x%06X\n", *CRCComputed);
CrcIsCorrect = 0;
}
/* Return the CRC status */
return CrcIsCorrect;
} /* End ComputeAndCorrectFullLinkControlCrc() */
/*
* @brief : This function compute the 5 bit CRC of the DMR voice burst data
* See ETSI TS 102 361-1 chapter B.3.11
*
* @param Input : A buffer pointer of the DMR data (72 bytes)
*
* @return The 5 bit CRC
*/
uint8_t ComputeCrc5Bit(uint8_t * DMRData)
{
uint32_t i, j, k;
uint8_t Buffer[9];
uint32_t Sum;
uint8_t CRC = 0;
/* Convert the 72 bit into 9 bytes */
k = 0;
for(i = 0; i < 9; i++)
{
Buffer[i] = 0;
for(j = 0; j < 8; j++)
{
Buffer[i] = Buffer[i] << 1;
Buffer[i] = Buffer[i] | DMRData[k++];
}
}
/* Add all 9 bytes */
Sum = 0;
for(i = 0; i < 9; i++)
{
Sum += (uint32_t)Buffer[i];
}
/* Sum MOD 31 = CRC */
CRC = (uint8_t)(Sum % 31);
/* Return the CRC */
return CRC;
} /* End ComputeCrc5Bit() */
uint64_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength)
{
uint64_t Output = 0;
uint32_t i;
for(i = 0; i < BitLength; i++)
{
Output <<= 1;
Output |= (uint64_t)(BufferIn[i] & 1);
}
return Output;
} /* End ConvertBitIntoBytes() */
/*
* @brief : This function compute the CRC-9 of the DMR data
* by using the polynomial x^9 + x^6 + x^4 + x^3 + 1
*
* @param Input : A buffer pointer of the DMR data (80 bytes)
* Rate 1/2 coded confirmed (10 data octets): 80 bit sequence (80 bytes)
* Rate 3/4 coded confirmed (16 data octets): 128 bit sequence (120 bytes)
* Rate 1 coded confirmed (22 data octets): 176 bit sequence (176 bytes)
*
* @param NbData : The number of bit to compute
* Rate 1/2 coded confirmed (10 data octets): 80 bit sequence (80 bytes)
* Rate 3/4 coded confirmed (16 data octets): 128 bit sequence (120 bytes)
* Rate 1 coded confirmed (22 data octets): 176 bit sequence (176 bytes)
*
* @return The 9 bit CRC
*/
uint16_t ComputeCrc9Bit(uint8_t * DMRData, uint32_t NbData)
{
uint32_t i;
uint16_t CRC = 0x0000; /* Initialization value = 0x0000 */
/* Polynomial x^9 + x^6 + x^4 + x^3 + 1
* Normal = 0x059
* Reciprocal = 0x134
* Reversed reciprocal = 0x12C */
uint16_t Polynome = 0x059;
for(i = 0; i < NbData; i++)
{
if(((CRC >> 8) & 1) ^ (DMRData[i] & 1))
{
CRC = (CRC << 1) ^ Polynome;
}
else
{
CRC <<= 1;
}
}
/* Conserve only the 9 LSBs */
CRC &= 0x01FF;
/* Invert the CRC */
CRC ^= 0x01FF;
/* Return the CRC */
return CRC;
} /* End ComputeCrc9Bit() */
/*
* @brief : This function compute the CRC-32 of the DMR data
* by using the polynomial x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
*
* @param Input : A buffer pointer of the DMR data (80 bytes)
* Rate 1/2 coded confirmed (10 data octets): 80 bit sequence (80 bytes)
* Rate 3/4 coded confirmed (16 data octets): 128 bit sequence (120 bytes)
* Rate 1 coded confirmed (22 data octets): 176 bit sequence (176 bytes)
*
* @param NbData : The number of bit to compute
* Rate 1/2 coded confirmed (10 data octets): 80 bit sequence (80 bytes)
* Rate 3/4 coded confirmed (16 data octets): 128 bit sequence (120 bytes)
* Rate 1 coded confirmed (22 data octets): 176 bit sequence (176 bytes)
*
* @return The 32 bit CRC
*/
uint32_t ComputeCrc32Bit(uint8_t * DMRData, uint32_t NbData)
{
uint32_t i;
uint32_t CRC = 0x00000000; /* Initialization value = 0x00000000 */
/* Polynomial x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
* Normal = 0x04C11DB7
* Reversed = 0xEDB88320
* Reciprocal = 0xDB710641
* Reversed reciprocal = 0x82608EDB */
uint32_t Polynome = 0x04C11DB7;
for(i = 0; i < NbData; i++)
{
if(((CRC >> 31) & 1) ^ (DMRData[i] & 1))
{
CRC = (CRC << 1) ^ Polynome;
}
else
{
CRC <<= 1;
}
}
//for whatever reason, we get the CRC returned in a reversed byte order (MSO LSO b***s***)
uint32_t a, b, c, d;
a = b = c = d = 0;
a = (CRC & 0xFF) << 24;
b = (CRC & 0xFF00) >> 8;
b = b << 16;
c = (CRC & 0xFF0000) >> 16;
c = c << 8;
d = (CRC & 0xFF000000) >> 24;
CRC = a + b + c + d;
/* Return the CRC */
return CRC;
} /* End ComputeCrc32Bit() */

View File

@@ -1,660 +0,0 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsd.h"
#include "dmr_const.h"
void processDMRvoice (dsd_opts * opts, dsd_state * state)
{
// extracts AMBE frames from DMR frame
int i, j, k, l, dibit;
int *dibit_p;
char ambe_fr[4][24] = {0};
char ambe_fr2[4][24] = {0};
char ambe_fr3[4][24] = {0};
const int *w, *x, *y, *z;
char sync[25];
char syncdata[48];
char cachdata[13] = {0};
int mutecurrentslot;
int msMode;
char cc[4];
unsigned char EmbeddedSignalling[16];
unsigned int EmbeddedSignallingOk;
#ifdef DMR_DUMP
int k;
char syncbits[49];
char cachbits[25];12
#endif
/* Init the superframe buffers */
memset(&state->TS1SuperFrame, 0, sizeof(TimeSlotVoiceSuperFrame_t));
memset(&state->TS2SuperFrame, 0, sizeof(TimeSlotVoiceSuperFrame_t));
/* Init the color code status */
state->color_code_ok = 0;
mutecurrentslot = 0;
msMode = 0;
dibit_p = state->dibit_buf_p - 144;
for(j = 0; j < 6; j++)
{
// 2nd half of previous slot
for(i = 0; i < 54; i++)
{
if(j > 0)
{
dibit = getDibit(opts, state);
}
else
{
dibit = *dibit_p;
dibit_p++;
if(opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
}
}
// CACH
for(i = 0; i < 12; i++)
{
if(j > 0)
{
dibit = getDibit(opts, state);
}
else
{
dibit = *dibit_p;
dibit_p++;
if(opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
}
cachdata[i] = dibit;
if(i == 2)
{
/* Change the current slot only if we are in relayed mode (not in direct mode) */
if(state->directmode == 0) state->currentslot = (1 & (dibit >> 1)); // bit 1
if(state->currentslot == 0)
{
state->slot1light[0] = '[';
state->slot1light[6] = ']';
state->slot2light[0] = ' ';
state->slot2light[6] = ' ';
}
else
{
state->slot2light[0] = '[';
state->slot2light[6] = ']';
state->slot1light[0] = ' ';
state->slot1light[6] = ' ';
}
}
}
cachdata[12] = 0;
//set state-dmrburstL and R here to a value for ncurses
if (state->currentslot == 0)
{
state->dmrburstL = 16; //use 16 for Voice?
}
if (state->currentslot == 1)
{
state->dmrburstR = 16; //Use 16 for Voice?
}
#ifdef DMR_DUMP
k = 0;
for(i = 0; i < 12; i++)
{
dibit = cachdata[i];
cachbits[k] = (1 & (dibit >> 1)) + 48; // bit 1
k++;
cachbits[k] = (1 & dibit) + 48; // bit 0
k++;
}
cachbits[24] = 0;
fprintf(stderr, "%s ", cachbits);
#endif
// current slot frame 1
w = rW;
x = rX;
y = rY;
z = rZ;
k = 0;
for(i = 0; i < 36; i++)
{
if(j > 0)
{
dibit = getDibit(opts, state);
}
else
{
dibit = *dibit_p;
dibit_p++;
if(opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
}
ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr[*y][*z] = (1 & dibit); // bit 0
/* Save the current frame in the appropriate superframe buffer */
if(state->currentslot == 0)
{
/* Time slot 1 superframe buffer filling => RAW voice bit */
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[0][k++] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[0][k++] = (1 & dibit); // bit 0
/* Time slot 1 superframe buffer filling => Deinterleaved voice bit */
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[0][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[0][*y][*z] = (1 & dibit); // bit 0
}
else
{
/* Time slot 2 superframe buffer filling => RAW voice bit */
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[0][k++] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[0][k++] = (1 & dibit); // bit 0
/* Time slot 2 superframe buffer filling => Deinterleaved voice bit */
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[0][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[0][*y][*z] = (1 & dibit); // bit 0
}
w++;
x++;
y++;
z++;
}
// current slot frame 2 first half
w = rW;
x = rX;
y = rY;
z = rZ;
k = 0;
for(i = 0; i < 18; i++)
{
if(j > 0)
{
dibit = getDibit(opts, state);
}
else
{
dibit = *dibit_p;
dibit_p++;
if(opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
}
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
/* Save the current frame in the appropriate superframe buffer */
if(state->currentslot == 0)
{
/* Time slot 1 superframe buffer filling => RAW voice bit */
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & dibit); // bit 0
/* Time slot 1 superframe buffer filling => Deinterleaved voice bit */
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*y][*z] = (1 & dibit); // bit 0
}
else
{
/* Time slot 2 superframe buffer filling => RAW voice bit */
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & dibit); // bit 0
/* Time slot 2 superframe buffer filling => Deinterleaved voice bit */
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*y][*z] = (1 & dibit); // bit 0
}
w++;
x++;
y++;
z++;
}
l = 0;
// signaling data or sync
for(i = 0; i < 24; i++)
{
if(j > 0)
{
dibit = getDibit(opts, state);
}
else
{
dibit = *dibit_p;
dibit_p++;
if(opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
}
syncdata[(2*i)] = (1 & (dibit >> 1)); // bit 1
syncdata[(2*i)+1] = (1 & dibit); // bit 0
sync[i] = (dibit | 1) + 48;
/* Save the current frame in the appropriate superframe buffer */
if(state->currentslot == 0)
{
/* Time slot 1 superframe buffer filling => SYNC data */
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].Sync[l++] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].Sync[l++] = (1 & dibit); // bit 0
}
else
{
/* Time slot 2 superframe buffer filling => SYNC data */
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].Sync[l++] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].Sync[l++] = (1 & dibit); // bit 0
}
}
sync[24] = 0;
/* Copy the Embedded signaling (1st part) */
for(i = 0; i < 8; i++)
{
EmbeddedSignalling[i] = syncdata[i];
}
/* Copy the Embedded signaling (2nd part) */
for(i = 0; i < 8; i++)
{
EmbeddedSignalling[i + 8] = syncdata[i + 40];
}
/* Check and correct the SlotType (apply Golay(20,8) FEC check) */
if(QR_16_7_6_decode(EmbeddedSignalling)) EmbeddedSignallingOk = 1;
else EmbeddedSignallingOk = 0;
/* Get the color code */
cc[0] = EmbeddedSignalling[0];
cc[1] = EmbeddedSignalling[1];
cc[2] = EmbeddedSignalling[2];
cc[3] = EmbeddedSignalling[3];
/* The color code is normally the same for all
* 6 received voice frame, so in case of error
* do not store it except if the last SYNC frame
* has been received. */
if(EmbeddedSignallingOk || ((state->color_code_ok == 0) && (j == 5)))
{
/* Save the color code */
state->color_code = (unsigned int)((cc[0] << 3) + (cc[1] << 2) + (cc[2] << 1) + cc[3]);
state->color_code_ok = EmbeddedSignallingOk;
}
/* Save the Power Control (PI) indicator */
state->PI = (unsigned int)EmbeddedSignalling[4];
state->PI_ok = EmbeddedSignallingOk;
/* Save the Link Control Start Stop (LCSS) indicator */
state->LCSS = (unsigned int)((EmbeddedSignalling[5] << 1) + EmbeddedSignalling[6]);
state->LCSS_ok = EmbeddedSignallingOk;
if((strcmp (sync, DMR_BS_DATA_SYNC) == 0) || (strcmp (sync, DMR_MS_DATA_SYNC) == 0))
{
mutecurrentslot = 1;
state->directmode = 0;
if(state->currentslot == 0)
{
sprintf(state->slot1light, "[slot1]");
}
else
{
sprintf(state->slot2light, "[slot2]");
}
}
else if(strcmp (sync, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0)
{
mutecurrentslot = 1;
state->currentslot = 0;
state->directmode = 1; /* Direct mode */
sprintf(state->slot1light, "[sLoT1]");
}
else if(strcmp (sync, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0)
{
mutecurrentslot = 1;
state->currentslot = 1;
state->directmode = 1; /* Direct mode */
sprintf(state->slot1light, "[sLoT2]");
}
else if((strcmp (sync, DMR_BS_VOICE_SYNC) == 0) ) //|| (strcmp (sync, DMR_MS_VOICE_SYNC) == 0))
{
mutecurrentslot = 0;
state->directmode = 0;
if(state->currentslot == 0)
{
sprintf(state->slot1light, "[SLOT1]");
}
else
{
sprintf(state->slot2light, "[SLOT2]");
}
}
else if(strcmp (sync, DMR_DIRECT_MODE_TS1_VOICE_SYNC) == 0)
{
mutecurrentslot = 0;
state->currentslot = 0;
state->directmode = 1; /* Direct mode */
sprintf(state->slot1light, "[sLoT1]");
}
else if(strcmp (sync, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0)
{
mutecurrentslot = 0;
state->currentslot = 1;
state->directmode = 1; /* Direct mode */
sprintf(state->slot2light, "[sLoT2]");
}
#ifdef DMR_DUMP
k = 0;
for(i = 0; i < 24; i++)
{
dibit = syncdata[i];
syncbits[k] = (1 & (dibit >> 1)) + 48; // bit 1
k++;
syncbits[k] = (1 & dibit) + 48; // bit 0
k++;
}
syncbits[48] = 0;
fprintf(stderr, "%s ", syncbits);
#endif
// current slot frame 2 second half
for(i = 0; i < 18; i++)
{
dibit = getDibit(opts, state);
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
/* Save the current frame in the appropriate superframe buffer */
if(state->currentslot == 0)
{
/* Time slot 1 superframe buffer filling => RAW voice bit */
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & dibit); // bit 0
/* Time slot 1 superframe buffer filling => Deinterleaved voice bit */
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*y][*z] = (1 & dibit); // bit 0
}
else
{
/* Time slot 2 superframe buffer filling */
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[1][k++] = (1 & dibit); // bit 0
/* Time slot 2 superframe buffer filling => Deinterleaved voice bit */
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[1][*y][*z] = (1 & dibit); // bit 0
}
w++;
x++;
y++;
z++;
}
if(mutecurrentslot == 0)
{
if(state->firstframe == 1)
{ // we don't know if anything received before the first sync after no carrier is valid
state->firstframe = 0;
}
else
{
//processMbeFrame (opts, state, NULL, ambe_fr, NULL);
//processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
}
}
// current slot frame 3
w = rW;
x = rX;
y = rY;
z = rZ;
k = 0;
for(i = 0; i < 36; i++)
{
dibit = getDibit(opts, state);
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr3[*y][*z] = (1 & dibit); // bit 0
/* Save the current frame in the appropriate superframe buffer */
if(state->currentslot == 0)
{
/* Time slot 1 superframe buffer filling => RAW voice bit */
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[2][k++] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[2][k++] = (1 & dibit); // bit 0
/* Time slot 1 superframe buffer filling => Deinterleaved voice bit */
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[2][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[2][*y][*z] = (1 & dibit); // bit 0
}
else
{
/* Time slot 2 superframe buffer filling => RAW voice bit */
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[2][k++] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotRawVoiceFrame[j].VoiceFrame[2][k++] = (1 & dibit); // bit 0
/* Time slot 2 superframe buffer filling => Deinterleaved voice bit */
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[2][*w][*x] = (1 & (dibit >> 1)); // bit 1
state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[2][*y][*z] = (1 & dibit); // bit 0
}
w++;
x++;
y++;
z++;
}
if(mutecurrentslot == 0)
{
//processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
}
// CACH
for(i = 0; i < 12; i++)
{
dibit = getDibit(opts, state);
cachdata[i] = dibit;
}
cachdata[12] = 0;
#ifdef DMR_DUMP
k = 0;
for(i = 0; i < 12; i++)
{
dibit = cachdata[i];
cachbits[k] = (1 & (dibit >> 1)) + 48; // bit 1
k++;
cachbits[k] = (1 & dibit) + 48; // bit 0
k++;
}
cachbits[24] = 0;
fprintf(stderr, "%s ", cachbits);
#endif
// next slot
skipDibit (opts, state, 54);
// signaling data or sync
for(i = 0; i < 24; i++)
{
dibit = getDibit(opts, state);
syncdata[i] = dibit;
sync[i] = (dibit | 1) + 48;
}
sync[24] = 0;
syncdata[24] = 0;
if((strcmp (sync, DMR_BS_DATA_SYNC) == 0) || (msMode == 1))
{
state->directmode = 0;
if(state->currentslot == 0)
{
sprintf(state->slot2light, " slot2 ");
}
else
{
sprintf(state->slot1light, " slot1 ");
}
}
else if(strcmp (sync, DMR_BS_VOICE_SYNC) == 0)
{
state->directmode = 0;
if(state->currentslot == 0)
{
sprintf(state->slot2light, " SLOT2 ");
}
else
{
sprintf(state->slot1light, " SLOT1 ");
}
}
else if((strcmp (sync, DMR_DIRECT_MODE_TS1_VOICE_SYNC) == 0) || (strcmp (sync, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0))
{
state->currentslot = 0;
state->directmode = 1; /* Direct mode */
sprintf(state->slot1light, " sLoT1 ");
}
else if((strcmp (sync, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0) || (strcmp (sync, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0))
{
state->currentslot = 1;
state->directmode = 1; /* Direct mode */
sprintf(state->slot1light, " sLoT2 ");
}
#ifdef DMR_DUMP
k = 0;
for(i = 0; i < 24; i++)
{
dibit = syncdata[i];
syncbits[k] = (1 & (dibit >> 1)) + 48; // bit 1
k++;
syncbits[k] = (1 & dibit) + 48; // bit 0
k++;
}
syncbits[48] = 0;
fprintf(stderr, "%s ", syncbits);
#endif
if(j == 5) //j == 5
{
// 2nd half next slot
skipDibit (opts, state, 54);
// CACH
skipDibit (opts, state, 12);
// first half current slot
skipDibit (opts, state, 54);
}
/* Extract the 49 bits AMBE of the voice frame */
if(state->currentslot == 0)
{
/* 3 x 49 bit of AMBE sample per voice frame => Slot 1buffer here */
for(i = 0; i < 3; i++)
{
state->TS1SuperFrame.TimeSlotAmbeVoiceFrame[j].errs1[i] = mbe_eccAmbe3600x2450C0(state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i]);
state->TS1SuperFrame.TimeSlotAmbeVoiceFrame[j].errs2[i] = state->TS1SuperFrame.TimeSlotAmbeVoiceFrame[j].errs1[i];
mbe_demodulateAmbe3600x2450Data(state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i]);
state->TS1SuperFrame.TimeSlotAmbeVoiceFrame[j].errs2[i] += mbe_eccAmbe3600x2450Data(state->TS1SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i],
&(state->TS1SuperFrame.TimeSlotAmbeVoiceFrame[j].AmbeBit[i][0]));
}
}
else
{
/* 3 x 49 bit of AMBE sample per voice frame => Slot 2 buffer here */
for(i = 0; i < 3; i++)
{
state->TS2SuperFrame.TimeSlotAmbeVoiceFrame[j].errs1[i] = mbe_eccAmbe3600x2450C0(state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i]);
state->TS2SuperFrame.TimeSlotAmbeVoiceFrame[j].errs2[i] = state->TS2SuperFrame.TimeSlotAmbeVoiceFrame[j].errs1[i];
mbe_demodulateAmbe3600x2450Data(state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i]);
state->TS2SuperFrame.TimeSlotAmbeVoiceFrame[j].errs2[i] += mbe_eccAmbe3600x2450Data(state->TS2SuperFrame.TimeSlotDeinterleavedVoiceFrame[j].DeInterleavedVoiceSample[i],
&(state->TS2SuperFrame.TimeSlotAmbeVoiceFrame[j].AmbeBit[i][0]));
}
}
} /* End for(j = 0; j < 6; j++) */
if(opts->errorbars == 1)
{
fprintf(stderr, "%s %s ", state->slot1light, state->slot2light);
/* Print the color code */
fprintf (stderr, "%s", KCYN);
fprintf(stderr, "| Color Code=%02d ", (int)state->color_code);
fprintf (stderr, "%s", KNRM);
//if(state->color_code_ok) fprintf(stderr, "(OK) |");
if(state->color_code_ok)
{
fprintf(stderr, "| (CRC OK ) |"); //add line break
state->dmr_color_code = state->color_code; //set here when voice? otherwise is set off of idle.
}
else
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, "| (CRC ERR) |"); //add line break
fprintf (stderr, "%s", KNRM);
}
fprintf(stderr, " VOICE ");
}
/* Perform the SYNC DMR data embedded decoding */
ProcessVoiceBurstSync(opts, state);
/* Perform the DMR voice decoding */
ProcessDMR(opts, state);
//LFSR if required, change condition?
if ( (state->currentslot == 0 && state->payload_algid == 0x21 ) || //&& opts->payload == 1
(state->currentslot == 1 && state->payload_algidR == 0x21 ) ) //&& opts->payload == 1
{
LFSR(state);
}
if(opts->errorbars == 1)
{
fprintf(stderr, "\n");
}
} /* End processDMRvoice() */

View File

@@ -24,11 +24,18 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
uint8_t CCH[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
uint8_t CCHDescrambled[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
uint8_t CCHDeInterleaved[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
uint8_t CCHDataHammingCorrected[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48] = {0};
uint8_t CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE] = {0};
uint8_t CCHDataCRCComputed[NB_OF_DPMR_VOICE_FRAME_TO_DECODE] = {0};
uint8_t CCHDataHammingCorrected[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48];
uint8_t CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
memset (CCHDataHammingCorrected, 1, sizeof(CCHDataHammingCorrected));
memset (CCHDataCRC, 1, sizeof(CCHDataCRC));
uint8_t CCHDataCRCComputed[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
memset (CCHDataCRCComputed, 0, sizeof(CCHDataCRCComputed));
uint8_t CC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE / 2][24] = {0};
char ambe_fr[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][4][24] = {0};
char ambe_fr[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][4][24];
memset (ambe_fr, 0, sizeof (ambe_fr));
const int *w, *x, *y, *z;
uint32_t ScramblerLFSR = 0;
bool correctable = true;
@@ -46,20 +53,10 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
uint32_t CCH_EmergencyPriority[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
uint32_t CCH_Reserved[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
uint32_t CCH_SlowData[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
uint32_t *errs;
uint32_t *errs2;
uint8_t AmbeBitDescrambled[49] = {0};
uint32_t ScramblerKey = 0;
uint32_t PartOfSuperFrame = 0;
uint32_t VoiceFrameFlag = 1; /* We consider the current frame as a voice frame */
uint32_t AttachedDataFlag = 0;
uint8_t CalledID[8] = {0};
uint8_t CallingID[8] = {0};
if (opts->errorbars == 1)
{
//fprintf(stderr, "VOICE e:");
}
UNUSED(PartOfSuperFrame);
/* First CCH (Control CHannel) - 72 bit */
k = 0;
@@ -76,7 +73,6 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
CCH[0][(i * 2)] = (1 & (dibit >> 1)); // bit 1
CCH[0][(i * 2) + 1] = (1 & dibit); // bit 0
}
/* 4 TCH (Traffic CHannel) = 4 x 72 bit voice playload */
@@ -148,9 +144,6 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
/* 4 TCH (Traffic CHannel) = 4 x 72 bit voice playload */
//Sync issues occur when FS2 occurs immediatly after the 4th rep, so cutting of 4 early to gain constant resync
//probably can't resync fast enough when the next sync starts immediately after the 4th rep of 36 dibits
//consider writing a method that will loop this entire process based on the frame numbering found inside the CCH info, is that possible?
k = 0;
for (j = 0; j < 4; j++)
{
@@ -177,18 +170,10 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
x++;
y++;
z++;
if (j == 3 && i == 28) //find sweet spot to cut off early
{
i = 40; //break early so FS2 sync can resync
}
}
}
/* Initialize the Hamming (12,8) error code detection
* Not needed because it has already been done
* in the "InitAllFecFunction()" function */
//Hamming_12_8_init();
/* Decoding all CCH (Control CHannel) */
for(i = 0; i < NB_OF_DPMR_VOICE_FRAME_TO_DECODE; i++)
{
@@ -209,22 +194,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
if(HammingCorrectable[i][j] == false) correctable = false;
}
if(correctable)
{
//fprintf(stderr, "CCH data corrected successfully\n");
HammingOk[i] = 1;
}
else
{
//fprintf(stderr, "ERROR !!! CCH data contains uncorrectable bit\n");
HammingOk[i] = 0;
}
if(correctable) HammingOk[i] = 1;
else HammingOk[i] = 0;
/* Reconstitute the 7 bit CRC */
CCHDataCRC[i] = 0;
@@ -239,24 +210,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
/* Compute the 7 bit CRC */
CCHDataCRCComputed[i] = CRC7BitdPMR(CCHDataHammingCorrected[i], 41);
if(CCHDataCRC[i] == CCHDataCRCComputed[i])
{
//fprintf(stderr, "Good CCH CRCs ! CRC received = 0x%02X, CRC computed = 0x%02X\n",
// CCHDataCRC[i], CCHDataCRCComputed[i]);
CrcOk[i] = 1;
}
else
{
//fprintf(stderr, "ERROR !!! CCH CRCs are different ! CRC received = 0x%02X, CRC computed = 0x%02X\n",
// CCHDataCRC[i], CCHDataCRCComputed[i]);
CrcOk[i] = 0;
}
if(CCHDataCRC[i] == CCHDataCRCComputed[i]) CrcOk[i] = 1;
else CrcOk[i] = 0;
/* Fill the frame number */
CCH_FrameNumber[i] = ConvertBitIntoBytes(&CCHDataHammingCorrected[i][0], 2);
@@ -302,45 +257,18 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
CallingID[7] = '\0';
/* Print Hamming debug info */
//fprintf(stderr, " | ");
for(i = 0; i < NB_OF_DPMR_VOICE_FRAME_TO_DECODE; i++)
{
//fprintf(stderr, "Hamming[%u]=", i);
for(j = 0; j < 6; j++)
{
//if(HammingCorrectable[i][j]) fprintf(stderr, "1");
//else fprintf(stderr, "0");
}
//fprintf(stderr, " HammingOk[%u]=%u", i, HammingOk[i]);
//fprintf(stderr, " CrcOk[%u]=%u", i, CrcOk[i]);
//fprintf(stderr, " Bit[%u]=", i);
//for(j = 0; j < 7; j++)
//{
// if(CCHDataHammingCorrected[i][j + 41]) fprintf(stderr, "1");
// else fprintf(stderr, "0");
//}
//fprintf(stderr, " CRCrec=0x%02X CRCcomp=0x%02X", CCHDataCRC[i], CCHDataCRCComputed[i]);
//if(i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE - 1)) fprintf(stderr, " - ");
}
#if (NB_OF_DPMR_VOICE_FRAME_TO_DECODE == 2)
/* To determine the part of the payload frame, we need to check the
* Hamming code result, the CRC and the frame number */
// if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 0)) ||
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 1)))
if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 0)) ||
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 1)))
{
/* First part of the super frame */
PartOfSuperFrame = 1;
//fprintf(stderr, "\nFirst part of the Super Frame");
/* The next part will normally be the second part */
opts->dPMR_next_part_of_superframe = 2;
@@ -368,20 +296,19 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
/* BUGFIX : Copy in all case the TG ID */
strcpy((char *)state->dPMRVoiceFS2Frame.CalledID, (char *)CalledID);
}
/* To determine the part of the payload frame, we need to check the
* Hamming code result, the CRC and the frame number */
// else if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 2)) ||
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 3)))
else if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 2)) ||
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 3)))
{
/* Second part of the super frame */
PartOfSuperFrame = 2;
//fprintf(stderr, "\nSecond part of the Super Frame");
/* The next part will normally be the first part */
opts->dPMR_next_part_of_superframe = 1;
@@ -394,7 +321,9 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
CallingID[7] = '\0';
/* Determine if the calling SRC ID is correct */
//if(HammingOk[0] && CrcOk[0] && HammingOk[1] && CrcOk[1])
if((CrcOk[0] || (HammingCorrectable[0][0] && HammingCorrectable[0][1])) &&
(CrcOk[1] || (HammingCorrectable[1][0] && HammingCorrectable[1][1])))
{
@@ -422,133 +351,152 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
/* Set the next part of the superframe to receive */
if(opts->dPMR_next_part_of_superframe == 1)
{
//fprintf(stderr, "Supposed first part of the Super Frame\n");
/* Set the next part as the second part */
opts->dPMR_next_part_of_superframe = 2;
}
else if(opts->dPMR_next_part_of_superframe == 2)
{
//fprintf(stderr, "Supposed second part of the Super Frame\n");
/* Set the next part as the first part */
opts->dPMR_next_part_of_superframe = 1;
}
else
{
//fprintf(stderr, "Unknown part of the Super Frame\n");
/* Unknown current part, set to 0 */
opts->dPMR_next_part_of_superframe = 0;
}
}
if(state->dPMRVoiceFS2Frame.ColorCode[0] != (unsigned int)(-1))
{
//only print the CC and src/tg info if CRC is good
/* Display the color code */
//fprintf(stderr, " | Color Code=%02d ", (int)state->dPMRVoiceFS2Frame.ColorCode[0]);
}
else
{
/* Unknown color code, display "??" */
//fprintf(stderr, " | Color Code=?? ");
}
/* Display the destination ID (talk group - TG) */
//fprintf(stderr, "| TG=%s", CalledID);
fprintf (stderr, "\n");
if(state->dPMRVoiceFS2Frame.CalledIDOk)
{
fprintf (stderr, "%s", KGRN);
fprintf(stderr, "\n| TG=%s", CalledID);
fprintf(stderr, " TG=%s", CalledID);
fprintf (stderr, "%s", KNRM);
//strcpy (state->dpmr_target_id, CalledID); //HERE HERE
state->dpmr_target_id = CalledID;
//fprintf(stderr, " (CRC OK) ");
//check other as well before assigning
if(state->dPMRVoiceFS2Frame.CalledIDOk) sprintf (state->dpmr_target_id, "%s", CalledID);
}
else
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, " TG=(CRC ERR)");
fprintf (stderr, "%s", KNRM);
}
/* Display the source ID */
if(state->dPMRVoiceFS2Frame.CallingIDOk)
{
fprintf (stderr, "%s", KGRN);
fprintf(stderr, " Src=%s", CallingID);
fprintf (stderr, "%s", KNRM);
//check other as well before assigning
if(state->dPMRVoiceFS2Frame.CalledIDOk) sprintf (state->dpmr_caller_id, "%s", CallingID);
//stashed channel code in here, more likely to be correct, but no guarantee
if(state->dPMRVoiceFS2Frame.ColorCode[0] != (unsigned int)(-1))
{
fprintf (stderr, "%s", KGRN);
fprintf(stderr, " | Color Code=%02d ", (int)state->dPMRVoiceFS2Frame.ColorCode[0]);
fprintf(stderr, " Channel Code=%02d", (int)state->dPMRVoiceFS2Frame.ColorCode[0]);
fprintf (stderr, "%s", KNRM);
state->dpmr_color_code = (int)state->dPMRVoiceFS2Frame.ColorCode[0];
//check other as well before assigning
if(state->dPMRVoiceFS2Frame.CalledIDOk) state->dpmr_color_code = (int)state->dPMRVoiceFS2Frame.ColorCode[0];
}
}
else
{
//fprintf(stderr, " (CRC ERR) ");
}
/* Display the source ID */
//fprintf(stderr, "| Src=%s", CallingID);
if(state->dPMRVoiceFS2Frame.CallingIDOk)
{
fprintf (stderr, "%s", KGRN);
fprintf(stderr, "| Src=%s", CallingID);
fprintf (stderr, "%s", KNRM);
//strcpy (state->dpmr_caller_id, CallingID);
state->dpmr_caller_id = CallingID;
//fprintf(stderr, " (CRC OK) \n");
}
else
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, " (CRC ERR) \n");
fprintf(stderr, " Src=(CRC ERR) Channel Code =(CRC ERR)");
fprintf (stderr, "%s", KNRM);
}
#endif /* (NB_OF_DPMR_VOICE_FRAME_TO_DECODE == 2) */
if (state->dPMRVoiceFS2Frame.Version[0] == 3)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, " Scrambler");
fprintf (stderr, "%s", KNRM);
if (state->R != 0)
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Key %05lld ", state->R );
fprintf (stderr, "%s", KNRM);
}
}
//Play only voice frames by first looking to see if there is a TCH voice in CommunicationMode,
//then sending it to be processed by processMbeFrame, its much cleaner this way
short start = 0;
short end = 4;
//not really even sure why I made this loop
//I probably should actually read the manual again
for (short o = 0; o < 2; o++)
{
//reset scrambler key seed on frame 0
if (state->dPMRVoiceFS2Frame.FrameNumbering[o] == 0) state->payload_miN = 0;
//depending on first or second TCH, set start and end variables appropriately
if (o == 1)
{
start = 4;
end = 8;
//add extra line break on second repitition only when dumping payload to console
if (opts->payload == 1)
{
fprintf(stderr, "\n");
}
}
//fprintf (stderr, "\nCommunication Mode: %d\n", state->dPMRVoiceFS2Frame.CommunicationMode[o]);
//fprintf (stderr, "Encryption Mode: %d\n", state->dPMRVoiceFS2Frame.Version[o]);
//fprintf (stderr, "Superframe Number: %d", state->dPMRVoiceFS2Frame.FrameNumbering[o]); //should be 1-4, but may be same number on TCH 1 or TCH 2
//this is used so we can simply pass the voice here to the
//nxdn scrambler by telling mbe these are nxdn frames and to
//apply the same descramble method to them if necessary
int realsynctype = state->synctype;
// fprintf (stderr, "\nCommunication Mode: %d\n", state->dPMRVoiceFS2Frame.CommunicationMode[o]);
// fprintf (stderr, "Encryption Mode: %d\n", state->dPMRVoiceFS2Frame.Version[o]); //shows as 3 (manufacturer specific, 5.16) on the dPMR scrambler values received
// fprintf (stderr, "Superframe Number: %d", state->dPMRVoiceFS2Frame.FrameNumbering[o]);
if((state->dPMRVoiceFS2Frame.CommunicationMode[o] == 0) ||
(state->dPMRVoiceFS2Frame.CommunicationMode[o] == 1) ||
(state->dPMRVoiceFS2Frame.CommunicationMode[o] == 5))
{
//There are 4 AMBE voice samples per TCH
//check to see if we are using scrambler
if (state->dPMRVoiceFS2Frame.Version[o] == 3) //!= 0
{
state->synctype = 28; //fake it as nxdn
state->nxdn_cipher_type = 0x01; //turn on nxdn scrambler cipher
state->dmr_encL = 1; //flag on enc bit here so we can mute if no key provided
}
//flag back off if key is provided
if (state->R != 0) state->dmr_encL = 0;
//print Current Frame Number if payload verbosity enabled
if (opts->payload == 1)
fprintf (stderr, "\n FN %d/4", state->dPMRVoiceFS2Frame.FrameNumbering[o]+1);
//There are 4 AMBE voice frames per TCH
for(i = start; i < end; i++)
{
processMbeFrame (opts, state, NULL, ambe_fr[i], NULL);
} //End for(i = start; i < end); i++)
} //if comms and not encrypted
}//End for TCH for o loop
if (opts->floating_point == 0)
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
}
//set the correct sync type again and flag off the cipher
state->synctype = realsynctype;
state->nxdn_cipher_type = 0;
if (opts->errorbars == 1)
{
fprintf(stderr, "\n");
}
}
fprintf(stderr, "\n");
//keep code below, could be handy cheat sheet for other info
#ifdef dPMR_PRINT_DEBUG_INFO
//Display the CCH content

829
src/dsd_alias.c Normal file
View File

@@ -0,0 +1,829 @@
/*-------------------------------------------------------------------------------
* dsd_alias.c
* Talker Alias Handling for Various Protocols and Vendors
*
* LWVMOBILE
* 2025-02 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
//Motorola P25 OTA Alias Decoding ripped/demystified from Ilya Smirnov's SDRTrunk Voodoo Code
uint8_t moto_alias_lut[256] = {
0xD2, 0xF6, 0xD4, 0x2B, 0x63, 0x49, 0x94, 0x5E, 0xA7, 0x5C, 0x70, 0x69, 0xF7, 0x08, 0xB1, 0x7D,
0x38, 0xCF, 0xCC, 0xD8, 0x51, 0x8F, 0xD5, 0x93, 0x6A, 0xF3, 0xEF, 0x7E, 0xFB, 0x64, 0xF4, 0x35,
0x27, 0x07, 0x31, 0x14, 0x87, 0x98, 0x76, 0x34, 0xCA, 0x92, 0x33, 0x1B, 0x4F, 0x8C, 0x09, 0x40,
0x32, 0x36, 0x77, 0x12, 0xD3, 0xC3, 0x01, 0xAB, 0x72, 0x81, 0x95, 0xC9, 0xC0, 0xE9, 0x65, 0x52,
0x24, 0x30, 0x1C, 0xDB, 0x88, 0xE8, 0x97, 0x9D, 0x58, 0x26, 0x04, 0x39, 0xAC, 0x2A, 0x9E, 0xAA,
0x25, 0xD7, 0xCE, 0xEB, 0x96, 0xF5, 0x0E, 0x8D, 0xDC, 0xA9, 0x2F, 0xDD, 0x1F, 0xEA, 0x91, 0xB7,
0xD6, 0x89, 0x8B, 0xD1, 0xB0, 0x99, 0x13, 0x7A, 0xE7, 0x9A, 0xB5, 0x86, 0xFF, 0x46, 0x85, 0xB2,
0x73, 0xDA, 0xBF, 0xD0, 0x71, 0xCB, 0x4D, 0x80, 0x15, 0x67, 0x16, 0x1A, 0x20, 0x8E, 0x45, 0x3E,
0xF2, 0x2E, 0x66, 0x90, 0x74, 0x8A, 0x6F, 0x78, 0xBB, 0x53, 0x03, 0x11, 0x68, 0xCD, 0x44, 0x17,
0x28, 0x5F, 0x1E, 0x84, 0x75, 0x79, 0x6E, 0x9B, 0x2C, 0xBE, 0x62, 0x2D, 0xF1, 0x7C, 0xB8, 0x83,
0xD9, 0x4E, 0x6D, 0x02, 0x61, 0x3D, 0xA8, 0x06, 0xB9, 0xF8, 0x9C, 0x37, 0x3A, 0x23, 0xC1, 0x50,
0xED, 0x9F, 0xAF, 0x3B, 0xBD, 0x82, 0xBA, 0xA0, 0xDF, 0xC2, 0x47, 0x22, 0xF0, 0xEE, 0xA1, 0xFE,
0xA2, 0x10, 0x5B, 0x48, 0x57, 0xA3, 0x05, 0x60, 0x7B, 0x0D, 0xF9, 0x6C, 0xB3, 0x56, 0x4C, 0xBC,
0x29, 0xA4, 0x0F, 0xEC, 0xB6, 0xA5, 0xA6, 0x3C, 0x7F, 0x6B, 0xB4, 0x21, 0xAD, 0xAE, 0xC4, 0xC8,
0xC5, 0x5D, 0xDE, 0xE0, 0x1D, 0x19, 0x4B, 0xC6, 0x0C, 0x3F, 0x5A, 0xC7, 0xE1, 0x59, 0x55, 0x54,
0x4A, 0x43, 0x42, 0xE2, 0xE3, 0xFA, 0x00, 0xE4, 0xE5, 0x18, 0x41, 0x0B, 0x0A, 0xE6, 0xFC, 0xFD
};
void apx_embedded_alias_test_phase1 (dsd_opts * opts, dsd_state * state)
{
uint64_t temp_a = 0x15902D2806010005; uint64_t temp_b = 0xDE; //72 bits, so break into segments
uint8_t lcw[72]; memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x1790010BEE0740F0; temp_b = 0x4E;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x17900200DD2D2168; temp_b = 0x1A;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x17900301B52FFBFB; temp_b = 0xFE;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x1790040E53FE86BE; temp_b = 0xF7;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x17900508FD5AB910; temp_b = 0xB2;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x1790060376F9D800; temp_b = 0x00;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
//Harris Phase 1 GPS
state->lastsrc = 1000;
temp_a = 0x2AA41D4C24262328; temp_b = 0xAF;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
temp_a = 0x2BA44E0DB2660108; temp_b = 0x14;
memset (lcw, 0, sizeof(lcw));
for (uint64_t i = 0; i < 64; i++)
lcw[i] = (temp_a >> (63-i)) & 1;
for (uint64_t i = 0; i < 8; i++)
lcw[i+64] = (temp_b >> (7-i)) & 1;
p25_lcw(opts, state, lcw, 0);
state->lastsrc = 0;
}
void apx_embedded_alias_header_phase1 (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
UNUSED(opts);
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&lc_bits[32], 8); //len in blocks of associated talker alias
uint8_t sn = (uint8_t)ConvertBitIntoBytes(&lc_bits[56], 4);
fprintf (stderr, " SN: %X;", sn);
fprintf (stderr, " BN: 0/%d;", ta_len);
//use dmr_pdu_sf for storage, store entire header (will be used to verify complete reception of full alias)
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot])); //reset storage for header and blocks
memcpy (state->dmr_pdu_sf[slot], lc_bits, 72*sizeof(uint8_t));
}
void apx_embedded_alias_blocks_phase1 (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
UNUSED(opts);
uint8_t bn = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 8); //current block number
uint8_t sn = (uint8_t)ConvertBitIntoBytes(&lc_bits[24], 4); //is a static value on all block sequences
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][32], 8); //len in blocks pulled from stored header
uint16_t header = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0], 16); //header check, should be 0x1590
if (ta_len == 0 || header != 0x1590) //checkdown, make sure we have an up to date header for this with a good len value
{
fprintf (stderr, " Missing Header");
fprintf (stderr, " BN: %d/??;", bn);
fprintf (stderr, " SN: %X;", sn);
fprintf (stderr, " Partial: ");
for (uint8_t i = 7; i < 18; i++)
fprintf (stderr, "%0X", (uint8_t)ConvertBitIntoBytes(&lc_bits[0+(i*4)], 4));
//clear out now stale storage
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot]));
}
else //good len and header stored
{
//sanity check, bn cannot equal zero (this shouldn't happen, but bad decode could occur)
if (bn == 0) bn = 1;
fprintf (stderr, " SN: %X;", sn);
fprintf (stderr, " BN: %d/%d;", bn, ta_len);
//use dmr_pdu_sf for storage, store data relevant portion at ptr of (bn-1) * 44 + 72 offset for header
memcpy(state->dmr_pdu_sf[slot]+(((bn-1)*44)+72), lc_bits+28, 44*sizeof(uint8_t));
if (ta_len == bn) //this is the last block, proceed to decoding
{
//Calculate variable len bits determined by non-zero octets
int16_t num_bits = 56; //starting value is the static bit count on the fqsuid
// //evaluate the storage and determine how many octets/bits are present at this point (fall back to this if needed)
// for (int16_t i = 0; i < 368; i++) //(3072-128)/8
// {
// uint8_t byte = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][72+56+(i*8)], 8);
// if (byte == 0)
// break;
// else
// num_bits += 8;
// }
//evaluate the storage and determine how many octets/bits are present at this point (expanded to two octets each, CRC with a 00xx pattern failed this)
for (int16_t i = 0; i < 184; i++) //(3072-128)/16
{
uint16_t bytes = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][72+56+(i*16)], 16);
if (bytes == 0)
break;
else
num_bits += 16;
}
//pass to alias decoder
apx_embedded_alias_decode (opts, state, slot, num_bits, state->dmr_pdu_sf[slot]);
//clear out now stale storage
memset (state->dmr_pdu_sf[slot], 0, sizeof(state->dmr_pdu_sf[slot]));
}
}
}
void apx_embedded_alias_header_phase2 (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
UNUSED(opts);
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&lc_bits[40], 8);
uint8_t sn = (uint8_t)ConvertBitIntoBytes(&lc_bits[64], 4);
uint8_t bn = (uint8_t)ConvertBitIntoBytes(&lc_bits[56], 8);
fprintf (stderr, " SN: %X;", sn); //NOTE: vPDU header is also a partial block, and has a block num and SN value in it
fprintf (stderr, " BN: %d/%d;", bn, ta_len);
//bit array to rearrange input lc_bits from phase 2 input to match the phase 1 header and block handling
uint8_t bits[136]; memset(bits, 0, sizeof(bits));
memcpy (bits, lc_bits, 2*8*sizeof(uint8_t)); //header 0x9190
memcpy (bits+16, lc_bits+24, 4*8*sizeof(uint8_t)); //BN, SN, etc
memcpy (bits+56, lc_bits+56, 10*8*sizeof(uint8_t)); //adding 8 bits of extra padding here
int16_t alias_st = 136; //start of the encoded alias (the copied size of this header, basically)
//debug, dump header arranged at this end
// fprintf (stderr, " Header: ");
// for (int16_t i = 0; i < alias_st/8; i++) //double check and adjust
// fprintf (stderr, "%02X", (uint8_t)ConvertBitIntoBytes(&bits[0+(i*8)], 8));
//use dmr_pdu_sf for storage, store entire header (will be used to verify complete reception of full alias)
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot])); //reset storage for header and blocks
memcpy (state->dmr_pdu_sf[slot], bits, alias_st*sizeof(uint8_t)); //this header block has 128 bits of relevant data (through the fqsuid)
}
void apx_embedded_alias_blocks_phase2 (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
UNUSED(opts);
int16_t rel_bits = 100; //number of relevant bits in each block
int16_t rel_st = 36; //start of relevant bits in this block
int16_t alias_st = 136; //start of the encoded alias
uint8_t bn = (uint8_t)ConvertBitIntoBytes(&lc_bits[24], 8); //current block number
uint8_t sn = (uint8_t)ConvertBitIntoBytes(&lc_bits[32], 4); //is a static value on all block sequences
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][32], 8); //len in blocks pulled from stored header
uint16_t header = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0], 16); //header check, should be 0x9190
if (ta_len == 0 || header != 0x9190)
{
fprintf (stderr, " Missing Header");
fprintf (stderr, " BN: %d/??;", bn);
fprintf (stderr, " SN: %X;", sn);
fprintf (stderr, " Partial: ");
for (uint8_t i = 9; i < 32; i++) //double check and adjust
fprintf (stderr, "%0X", (uint8_t)ConvertBitIntoBytes(&lc_bits[0+(i*4)], 4));
//clear out now stale storage
memset (state->dmr_pdu_sf[slot], 0, sizeof(state->dmr_pdu_sf[slot]));
}
else //good len and header stored
{
//sanity check, bn cannot equal zero (this shouldn't happen, but bad decode could occur)
if (bn == 0) bn = 1;
fprintf (stderr, " SN: %X;", sn);
fprintf (stderr, " BN: %d/%d;", bn, ta_len);
//use dmr_pdu_sf for storage, store data relevant portion at ptr calculated below
memcpy(state->dmr_pdu_sf[slot]+(alias_st+((bn-1)*rel_bits)), lc_bits+rel_st, rel_bits*sizeof(uint8_t)); //Fix this value when samples arrive
//debug, dump accumulated data at this end
// fprintf (stderr, " Accumulated: ");
// for (int16_t i = 0; i < (alias_st+(rel_bits*bn))/8; i++) //double check and adjust
// fprintf (stderr, "%02X", (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0+(i*8)], 8));
if (ta_len == bn) //this is the last block, proceed to decoding
{
//Calculate variable len bits determined by non-zero octets
int16_t num_bits = 56; //starting value is the static bit count on the fqsuid
// //evaluate the storage and determine how many octets/bits are present at this point (fall back to this if needed)
// for (int16_t i = 0; i < 368; i++) //(3072-128)/8
// {
// uint8_t byte = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][72+56+(i*8)], 8);
// if (byte == 0)
// break;
// else
// num_bits += 8;
// }
//evaluate the storage and determine how many octets/bits are present at this point (expanded to two octets each, CRC with a 00xx pattern failed this)
for (int16_t i = 0; i < 184; i++) //(3072-128)/16
{
uint16_t bytes = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][72+56+(i*16)], 16);
if (bytes == 0)
break;
else
num_bits += 16;
}
//pass to alias decoder
apx_embedded_alias_decode (opts, state, slot, num_bits, state->dmr_pdu_sf[slot]);
//clear out now stale storage
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot]));
}
}
}
void apx_embedded_alias_decode (dsd_opts * opts, dsd_state * state, uint8_t slot, int16_t num_bits, uint8_t * input)
{
UNUSED(opts);
UNUSED(state);
UNUSED(slot);
//debug, dump completed data set
// fprintf (stderr, "\n Full: ");
// for (int16_t i = 0; i < (72+num_bits)/4; i++)
// fprintf (stderr, "%X", (uint8_t)ConvertBitIntoBytes(&input[0+(i*4)], 4));
//extract CRC
uint16_t crc_ext = (uint16_t)ConvertBitIntoBytes(&input[(72+num_bits-16)], 16);
//compute CRC
uint16_t crc_cmp = ComputeCrcCCITT16d(&input[72], num_bits-16);
//print comparison
// fprintf (stderr, " CRC EXT: %04X CMP: %04X;", crc_ext, crc_cmp);
if (crc_ext != crc_cmp)
fprintf (stderr, " Alias CRC Error;");
// else fprintf (stderr, " Alias Okay;");
//start decoding the alias
if (crc_ext == crc_cmp)
{
//extract fully qualified SUID
uint32_t wacn = (uint32_t)ConvertBitIntoBytes(&input[72], 20);
uint32_t sys = (uint32_t)ConvertBitIntoBytes(&input[92], 12);
uint32_t rid = (uint32_t)ConvertBitIntoBytes(&input[104], 24);
//print fully qualified SUID
fprintf (stderr, "\n FQ-SUID: %05X.%03X.%06X (%d);", wacn, sys, rid, rid);
//WIP: Working, needs more samples to verify various num_bits values
uint16_t ptr = 128; //starting point of encoded alias
uint8_t encoded[200]; memset(encoded, 0, sizeof(encoded));
uint8_t decoded[200]; memset(decoded, 0, sizeof(decoded));
uint16_t num_bytes = (num_bits / 8) - 9; //subtract 2 CRC and 7 FQSUID
//sanity check
if (num_bytes <= 0) num_bytes = 1;
for (int16_t i = 0; i < num_bytes; i++)
{
encoded[i] = (uint8_t)ConvertBitIntoBytes(&input[ptr], 8);
ptr += 8;
}
uint16_t accumulator = num_bytes;
//Ilya's Voodoo Code
for (uint16_t i = 0; i < num_bytes; i++)
{
// Multiplication step 1
uint16_t accum_mult = accumulator * 293 + 0x72E9;
// Lookup table step
uint8_t lut = moto_alias_lut[encoded[i]];
uint8_t mult1 = lut - (accum_mult >> 8);
// Incrementing step
uint8_t mult2 = 1;
uint8_t shortstop = accum_mult | 0x1;
uint8_t increment = shortstop << 1;
//clang warning -- warning: result of comparison of constant -1 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
// while(mult2 != -1 && shortstop != 1) //clang warning can't be -1 if uint8_t (set to 255 instead?)
while(shortstop != 1) //this one tests out okay, so may use it instead
{
shortstop += increment;
mult2 += 2;
}
// Multiplication step 2
decoded[i] = mult1 * mult2;
// Update the accumulator
accumulator += encoded[i] + 1;
}
// //debug, dump just the encoded alias portion
// fprintf (stderr, "\n Encoded: ");
// for (int16_t i = 0; i < num_bytes; i++)
// fprintf (stderr, "%02X", encoded[i]);
// //debug, dump the decoded payload as hex octets
// fprintf (stderr, "\n Decoded: ");
// for (int16_t i = 0; i < num_bytes; i++)
// fprintf (stderr, "%02X", decoded[i]);
//dump the decoded payload as long chars
// fprintf (stderr, "\n");
fprintf (stderr, " Alias: ");
for (int16_t i = 0; i < num_bytes/2; i++)
fprintf (stderr, "%lc", ((decoded[(i*2)+0])<<8) | ((decoded[(i*2)+1])<<0) );
apx_embedded_alias_dump (opts, state, slot, num_bytes, input, decoded);
}
}
void apx_embedded_alias_dump (dsd_opts * opts, dsd_state * state, uint8_t slot, uint16_t num_bytes, uint8_t * input, uint8_t * decoded)
{
char str[50]; memset(str, 0, sizeof(str));
char fqs[50]; memset(fqs, 0, sizeof(fqs));
//check num_bytes, if greter than 100, then set to 100
if (num_bytes >= 98) num_bytes = 98;
for (int16_t i = 0; i < num_bytes/2; i++)
{
if (decoded[(i*2)+1] == 0x2C) //remove a comma if it exists, change it to a 0x2E dot
str[i] = 0x2E;
else if (decoded[(i*2)+1] > 0x1F && decoded[(i*2)+1] < 0x7F) //may not need or use this restriction
str[i] = decoded[(i*2)+1];
else str[i] = 0x20; //space
}
//flag to indicate this already exists in import or group struct
uint8_t wr = 0;
//fully qualified SUID
uint32_t wacn = (uint32_t)ConvertBitIntoBytes(&input[72], 20);
uint32_t sys = (uint32_t)ConvertBitIntoBytes(&input[92], 12);
uint32_t rid = (uint32_t)ConvertBitIntoBytes(&input[104], 24);
sprintf (fqs, " FQ-SUID: %05X:%03X.%06X (%d);", wacn, sys, rid, rid);
if (rid != 0 && state->event_history_s[slot].Event_History_Items[0].source_id == rid)
{
sprintf (state->event_history_s[slot].Event_History_Items[0].alias, "%s; ", str);
strcat (state->event_history_s[slot].Event_History_Items[0].alias, fqs);
}
for (int16_t i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == rid)
{
wr = 1; //already in there, so no need to assign it
break;
}
}
if (wr == 0) //not already in there, so save it there now
{
state->group_array[state->group_tally].groupNumber = rid;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "D");
sprintf (state->group_array[state->group_tally].groupName, "%s", str);
state->group_tally++;
//if we have an opened group file, let's write what info we found into it
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,D,", rid); //may want to not use this one
fprintf (pFile, "%s", str);
fprintf (pFile, ",FQS:%05X.%03X.%06X(%d),Moto\n", wacn, sys, rid, rid);
fclose (pFile);
}
}
}
//end Motorola P25 OTA Alias Decoding
//TODO: Migrate Other OTA Alias functions here
void l3h_embedded_alias_blocks_phase1 (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
uint8_t op = (uint8_t)ConvertBitIntoBytes(&lc_bits[0], 8);
uint8_t ptr = op-0x32;
uint8_t bytes[7]; memset(bytes, 0, sizeof(bytes));
for (uint8_t i = 0; i < 7; i++)
bytes[i] = (uint8_t)ConvertBitIntoBytes(&lc_bits[16+(i*8)], 8);
//use +4 offset to match the MAC vPDU since that was already worked out long ago
memcpy(state->dmr_pdu_sf[slot]+4+(ptr*7), bytes, sizeof(bytes));
//to be tested
if (ptr == 4) //is there always 4 blocks, or is it a variable amount?
l3h_embedded_alias_decode(opts, state, slot, 4+28, state->dmr_pdu_sf[slot]);
}
void l3h_embedded_alias_decode (dsd_opts * opts, dsd_state * state, uint8_t slot, int16_t len, uint8_t * input)
{
//storage info for storing to groupName, if not available
char str[40]; memset (str, 0, sizeof(str));
char ttemp[40]; memset (ttemp, 0, sizeof(ttemp));
uint8_t wr = 0;
uint32_t tsrc = 0, ttg = 0;
if (slot == 0 && state->lastsrc != 0) tsrc = state->lastsrc;
if (slot == 1 && state->lastsrcR != 0) tsrc = state->lastsrcR;
if (slot == 0 && state->lasttg != 0) ttg = state->lasttg;
if (slot == 1 && state->lasttgR != 0) ttg = state->lasttgR;
int8_t ptr = 0;
if (tsrc != 0)
fprintf (stderr, " TG: %d; SRC: %d; Talker Alias: ", ttg, tsrc);
else fprintf (stderr, " TG: UNK; SRC: UNK; Talker Alias: ");
for (int8_t i = 4; i <= len; i++)
{
if ( (input[i] > 0x19) && (input[i] < 0x7F) )
fprintf (stderr, "%c", (char)input[i]);
else fprintf (stderr, " ");
if (input[i] == 0x2C) //remove a comma if it exists, change it to a 0x2E dot
ttemp[ptr] = 0x2E;
else if ( (input[i] > 0x19) && (input[i] < 0x7F) )
ttemp[ptr] = input[i];
else if (input[i] != 0)
ttemp[ptr] = 0x20; //space
ptr++;
}
//assign completed talker to a more useful string instead
snprintf (str, ptr+1, "%s", ttemp);
if (state->event_history_s[slot].Event_History_Items[0].source_id == tsrc && tsrc != 0)
sprintf (state->event_history_s[slot].Event_History_Items[0].alias, "%s", str);
//The Duke Energy system may relay two src values, may be a good idea to pick one and stick with it
if (tsrc != 0)
{
for (int16_t i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == tsrc)
{
wr = 1; //already in there, so no need to assign it
break;
}
}
if (wr == 0) //not already in there, so save it there now
{
state->group_array[state->group_tally].groupNumber = tsrc;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "D");
sprintf (state->group_array[state->group_tally].groupName, "%s", str);
state->group_tally++;
//if we have an opened group file, let's write what info we found into it
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,D,", tsrc);
fprintf (pFile, "%s", str);
fprintf (pFile, ",TG:%d,SYS:%03llX,RFSS:%lld,SITE:%lld,Harris\n", ttg, state->p2_sysid, state->p2_rfssid, state->p2_siteid);
fclose (pFile);
}
}
}
//debug
// fprintf (stderr, "\n WR: %d TG: %d SRC: %d Res: %d Len: %d STR: %s", wr, ttg, tsrc, res, len, str);
//reset storage
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot]));
}
void tait_iso7_embedded_alias_decode (dsd_opts * opts, dsd_state * state, uint8_t slot, int16_t len, uint8_t * input)
{
UNUSED(slot);
uint8_t alias[24]; memset(alias, 0, sizeof(alias));
for (uint8_t i = 0; i < len; i++)
{
alias[i] = (uint8_t)ConvertBitIntoBytes(&input[16+(i*7)], 7);
fprintf (stderr, "%c", alias[i]);
if (alias[i] == 0x2C) //change a comma to a dot
alias[i] = 0x2E;
else if (alias[i] < 0x20) //change any garble / control chars to a space
alias[i] = 0x20;
}
//flag to indicate this already exists in import or group struct
uint8_t wr = 0;
uint32_t rid = state->lastsrc;
uint16_t nac = state->nac;
if (state->event_history_s[slot].Event_History_Items[0].source_id == rid)
sprintf (state->event_history_s[slot].Event_History_Items[0].alias, "%s", alias);
if (rid != 0)
{
for (int16_t i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == rid)
{
wr = 1; //already in there, so no need to assign it
break;
}
}
if (wr == 0) //not already in there, so save it there now
{
state->group_array[state->group_tally].groupNumber = rid;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "D");
sprintf (state->group_array[state->group_tally].groupName, "%s", alias);
state->group_tally++;
//if we have an opened group file, let's write what info we found into it
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,D,", rid); //may want to not use this one
fprintf (pFile, "%s,", alias);
fprintf (pFile, "%03X,", nac); //if we find this on a trunking system, may want to add the site and rfss id
fprintf (pFile, "%s", ",Tait\n");
fclose (pFile);
}
}
}
}
void dmr_talker_alias_lc_header (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t * lc_bits)
{
uint8_t format = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 2);
uint8_t block_len = (uint8_t)ConvertBitIntoBytes(&lc_bits[18], 5);
uint8_t char_size = 0;
if (format == 0) char_size = 7;
else if (format == 1 || format == 2) char_size = 8;
else char_size = 16;
state->dmr_alias_format[slot] = format;
state->dmr_alias_block_len[slot] = block_len; //data len, see below
state->dmr_alias_char_size[slot] = char_size;
//load into dmr_pdu_sf as bit wise values for this since iso7 has 49 bits in this header, otherwise, load with 48?
if (char_size == 7)
memcpy(state->dmr_pdu_sf[slot], lc_bits+23, 49*sizeof(uint8_t));
else if (char_size == 8)
memcpy(state->dmr_pdu_sf[slot], lc_bits+24, 48*sizeof(uint8_t));
else if (char_size == 16)
memcpy(state->dmr_pdu_sf[slot], lc_bits+24, 48*sizeof(uint8_t));
//TEST: The Block Len (Data Lan) value is, according to my interpretation, the number of encoded
//character units in the alias, test to verify, but fall back to the ptr index if necessary
//this is referenced in 5.4.3 ETSI TS 102 361-2 V2.5.1 (2023-05) 7.2.19 Talker Alias Data Length
fprintf (stderr, " Slot %d - Talker Alias LC Header; Format %d; Char Len: %d; Char Size: %d;", slot, format, block_len, char_size);
//Decode the header's alias portion
fprintf (stderr, "\n");
dmr_talker_alias_lc_decode(opts, state, slot, 0, char_size, block_len);
}
void dmr_talker_alias_lc_blocks (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t block_num, uint8_t * lc_bits)
{
UNUSED(opts); //delete if we don't use this, but may want it if we dump alias to a file later on
uint8_t block_len = state->dmr_alias_block_len[slot];
uint8_t char_size = state->dmr_alias_char_size[slot];
uint16_t ptr = 0;
uint16_t end = block_len;
//Note: The Joann sample only carries block 5, and no header on block 4
//another radio on that ham setup also has a broken alias similar, but
//the other talkers have the 04 and the sample has a good decode otherwise
//debug broken aliasing on ham radio
// if (char_size == 0) //Enable this is you need to check alias even with missing header (set 7, 8, or 16)
// char_size = 8;
/*
22:54:51 Sync: +DMR slot1 [SLOT2] | Color Code=01 | VC6
Slot 1 - Talker Alias Block Num: 1; Valid Block; Talker Alias: Joann
DMR PDU Payload [05][00][4A][6F][61][6E][6E][00][FF]
*/
//set the pointer to the current index of the dmr_pdu_sf
if (char_size == 16)
ptr = 48 + (block_num * 56);
else if (char_size == 8)
ptr = 48 + (block_num * 56);
else if (char_size == 7)
ptr = 49 + (block_num * 56);
if (char_size == 0) //unset, no header received
fprintf (stderr, " Slot %d - Talker Alias Block Num: %d; Invalid Header;", slot, block_num+1);
else if (block_num > 3) //invalid block (data error)
fprintf (stderr, " Slot %d - Talker Alias Block Num: %d; Invalid Block;", slot, block_num+1);
else //valid header present, continue
{
if (char_size == 7)
{
memcpy(state->dmr_pdu_sf[slot]+ptr, lc_bits+16, 56*sizeof(uint8_t));
ptr += 56;
if (block_len == 0)
end = ptr / 7;
else end = block_len;
}
else if (char_size == 8)
{
memcpy(state->dmr_pdu_sf[slot]+ptr, lc_bits+16, 56*sizeof(uint8_t));
ptr += 56;
if (block_len == 0)
end = ptr / 8;
else end = block_len;
}
else if (char_size == 16)
{
memcpy(state->dmr_pdu_sf[slot]+ptr, lc_bits+16, 56*sizeof(uint8_t));
ptr += 56;
if (block_len == 0)
end = ptr / 16;
else end = block_len;
}
dmr_talker_alias_lc_decode (opts, state, slot, block_num+1, char_size, end);
}
}
//Decode partial or completed alias
void dmr_talker_alias_lc_decode (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t block_num, uint8_t char_size, uint16_t end)
{
UNUSED(opts);
uint16_t i = 0;
fprintf (stderr, " Slot %d - Talker Alias Block Num: %d; Valid Block;", slot, block_num+1);
fprintf (stderr, " Talker Alias: ");
char alias_string[500]; memset (alias_string, 0, sizeof(alias_string));
sprintf (alias_string, "%s", "");
if (char_size == 7)
{
for (i = 0; i < end; i++)
{
uint8_t character = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*7)], 7);
char ch[2]; ch[0] = character; ch[1] = 0;
if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set
{
fprintf (stderr, "%c", character);
strcat (alias_string, ch);
}
// else if (character == 0)
// {
// strcat (alias_string, " ");
// fprintf (stderr, " ");
// break;
// }
else
{
strcat (alias_string, " ");
fprintf (stderr, " ");
}
}
}
else if (char_size == 8)
{
for (i = 0; i < end; i++)
{
uint8_t character = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*8)], 8);
char ch[2]; ch[0] = character; ch[1] = 0;
// if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set
if (character >= 0x20 && character != 0x7F) //allow some extended UTF diacritical characters as well
{
fprintf (stderr, "%c", character);
strcat (alias_string, ch);
}
// else if (character == 0)
// {
// strcat (alias_string, " ");
// fprintf (stderr, " ");
// break;
// }
else
{
strcat (alias_string, " ");
fprintf (stderr, " ");
}
}
}
else if (char_size == 16)
{
setlocale(LC_ALL, ""); //needed when encoded alias contains Chinese (or probably any non-roman charset that isn't default on users terminal)
for (i = 0; i < end; i++)
{
uint16_t character = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*16)], 16);
char ch[2]; ch[0] = character & 0xFF; ch[1] = 0;
if (character >= 0x20 && character != 0x7F)
fprintf (stderr, "%lc", character);
else fprintf (stderr, " ");
if (character == 0)
strcat (alias_string, " ");
else if (character >= 0x20 && character <= 0xFE)
strcat (alias_string, ch);
else
strcat (alias_string, "*");
//debug
// fprintf (stderr, " [%04X], ", character);
}
}
//assign to string for event history and ncurses display
uint32_t source = 0;
if (slot == 0)
source = state->lastsrc;
else source = state->lastsrcR;
if (state->event_history_s[slot].Event_History_Items[0].source_id == source)
sprintf (state->event_history_s[slot].Event_History_Items[0].alias, "%s; ", alias_string);
sprintf (state->generic_talker_alias[slot], "Talker Alias: %s; ", alias_string);
}

View File

@@ -21,14 +21,16 @@ pa_sample_spec ss;
pa_sample_spec tt;
pa_sample_spec zz;
pa_sample_spec cc;
pa_sample_spec ff; //float
//pulse audio buffer attributes (input latency)
pa_buffer_attr lt;
void closePulseOutput (dsd_opts * opts)
{
pa_simple_free (opts->pulse_digi_dev_out);
if (opts->dmr_stereo == 1)
{
pa_simple_free (opts->pulse_digi_dev_outR);
}
if (opts->frame_provoice == 1 || opts->monitor_input_audio == 1) //EDACS analog calls and/or monitoring source analog audio
pa_simple_free (opts->pulse_raw_dev_out);
}
void closePulseInput (dsd_opts * opts)
@@ -39,33 +41,66 @@ void closePulseInput (dsd_opts * opts)
void openPulseOutput(dsd_opts * opts)
{
char * dev = NULL;
if (opts->pa_output_idx[0] != 0)
dev = opts->pa_output_idx;
int err = 0;
ss.format = PA_SAMPLE_S16NE;
ss.channels = opts->pulse_raw_out_channels; //doing tests with 2 channels at 22050 for 44100 audio default in pulse
ss.rate = opts->pulse_raw_rate_out; //48000
ss.channels = opts->pulse_raw_out_channels;
ss.rate = opts->pulse_raw_rate_out;
tt.format = PA_SAMPLE_S16NE;
tt.channels = opts->pulse_digi_out_channels; //doing tests with 2 channels at 22050 for 44100 audio default in pulse
tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle
tt.channels = opts->pulse_digi_out_channels;
tt.rate = opts->pulse_digi_rate_out;
if (opts->monitor_input_audio == 1)
ff.format = PA_SAMPLE_FLOAT32NE;
ff.channels = opts->pulse_digi_out_channels;
ff.rate = opts->pulse_digi_rate_out;
//reconfigured to open when using edacs or raw analog monitor so we can have a analog audio out that runs at 48k1 and not 8k1 float/short
if (opts->frame_provoice == 1 || opts->monitor_input_audio == 1)
opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME3", PA_STREAM_PLAYBACK, dev, "Analog", &ss, 0, NULL, &err);
if (err != 0)
{
opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME3", PA_STREAM_PLAYBACK, NULL, "Raw Audio Out", &ss, NULL, NULL, NULL);
fprintf (stderr, "Err: %d; %s; ", err, pa_strerror(err));
#ifdef __CYGWIN__
fprintf (stderr, "Please make sure the Pulse Audio Server Backend is running first.");
#endif
exit(0);
}
//tt
pa_channel_map* left = 0; //NULL and 0 are same in this context
pa_channel_map* right = 0; //NULL and 0 are same in this context
pa_channel_map* fl = 0; //NULL and 0 are same in this context
pa_channel_map* ss = 0; //NULL and 0 are same in this context
if (opts->dmr_stereo == 0)
if (opts->floating_point == 0 && opts->analog_only == 0)
{
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, opts->output_name, &tt, left, NULL, NULL);
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, dev, opts->output_name, &tt, ss, NULL, &err);
if (err != 0)
{
fprintf (stderr, "Err: %d; %s; ", err, pa_strerror(err));
#ifdef __CYGWIN__
fprintf (stderr, "Please make sure the Pulse Audio Server Backend is running first.");
#endif
exit(0);
}
}
if (opts->dmr_stereo == 1)
if (opts->floating_point == 1 && opts->analog_only == 0)
{
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME1", PA_STREAM_PLAYBACK, NULL, "XDMA SLOT 1", &tt, left, NULL, NULL);
opts->pulse_digi_dev_outR = pa_simple_new(NULL, "DSD-FME2", PA_STREAM_PLAYBACK, NULL, "XDMA SLOT 2", &tt, right, NULL, NULL);
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, dev, opts->output_name, &ff, fl, NULL, &err);
if (err != 0)
{
fprintf (stderr, "Err: %d; %s; ", err, pa_strerror(err));
#ifdef __CYGWIN__
fprintf (stderr, "Please make sure the Pulse Audio Server Backend is running first.");
#endif
exit(0);
}
}
}
@@ -73,12 +108,198 @@ void openPulseOutput(dsd_opts * opts)
void openPulseInput(dsd_opts * opts)
{
char * dev = NULL;
if (opts->pa_input_idx[0] != 0)
dev = opts->pa_input_idx;
int err = 0;
cc.format = PA_SAMPLE_S16NE;
cc.channels = opts->pulse_digi_in_channels;
cc.rate = opts->pulse_digi_rate_in; //48000
opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, NULL, NULL);
//adjust input latency settings (defaults are all -1 to let server set these automatically, but without pavucontrol open, this is approx 2s)
//setting fragsize to 960 for 48000 input seems to do the trick to allow a much faster latency without underrun, may need adjusting if
//modifying the input rate (will only apply IF using pulse audio input, and not any other input method)
//TODO: set fragsize vs expected input rate if required in the future
//NOTE: If users report any underrun conditions, then either change 960 back to -1, or pass NULL instead of &lt
//https://freedesktop.org/software/pulseaudio/doxygen/structpa__buffer__attr.html
//for now, only going to modify the fragsize if using the encoder, else, let the pa server set it automatically
// if (opts->m17encoder == 1)
// lt.fragsize = 960*5;
// else lt.fragsize = -1;
//test doing it universally, fall back to above if needed
lt.fragsize = 960*5;
lt.maxlength = -1;
lt.prebuf = -1;
lt.tlength = -1;
if (opts->m17encoder == 1)
opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME4", PA_STREAM_RECORD, dev, "M17 Voice Input", &cc, NULL, &lt, &err);
else opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, dev, opts->output_name, &cc, NULL, &lt, &err);
if (err != 0)
{
fprintf (stderr, "Err: %d; %s; ", err, pa_strerror(err));
#ifdef __CYGWIN__
fprintf (stderr, "Please make sure the Pulse Audio Server Backend is running first.");
#endif
exit(0);
}
//debug
// if (opts->m17encoder == 1)
// {
// unsigned long long int latency = pa_simple_get_latency (opts->pulse_digi_dev_in, NULL);
// fprintf (stderr, "Pulse Audio Input Latency: %05lld;", latency);
// }
}
void parse_pulse_input_string (dsd_opts * opts, char * input)
{
char * curr;
curr = strtok(input, ":");
if (curr != NULL)
{
strncpy (opts->pa_input_idx, curr, 99);
opts->pa_input_idx[99] = 0;
fprintf (stderr, "\n");
fprintf (stderr, "Pulse Input Device: %s; ", opts->pa_input_idx);
fprintf (stderr, "\n");
}
}
void parse_pulse_output_string (dsd_opts * opts, char * input)
{
char * curr;
curr = strtok(input, ":");
if (curr != NULL)
{
strncpy (opts->pa_output_idx, curr, 99);
opts->pa_output_idx[99] = 0;
fprintf (stderr, "\n");
fprintf (stderr, "Pulse Output Device: %s; ", opts->pa_output_idx);
fprintf (stderr, "\n");
}
}
void openOSSOutput (dsd_opts * opts)
{
int fmt;
int speed = 48000;
if (opts->audio_in_type == 5) //if((strncmp(opts->audio_in_dev, "/dev/dsp", 8) == 0)) or 'split' == 0
{
if((strncmp(opts->audio_out_dev, "/dev/dsp", 8) == 0))
{
fprintf (stderr, "OSS Output %s.\n", opts->audio_out_dev);
opts->audio_out_fd = open (opts->audio_out_dev, O_RDWR);
if (opts->audio_out_fd == -1)
{
fprintf (stderr, "Error, couldn't open #1 %s\n", opts->audio_out_dev);
opts->audio_out = 0;
exit(1);
}
fmt = 0;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_RESET) < 0)
{
fprintf (stderr, "ioctl reset error \n");
}
fmt = speed;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
fprintf (stderr, "ioctl speed error \n");
}
fmt = 0; //this seems okay to be 1 or 0, not sure what the difference really is (works in stereo on 0)
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
fprintf (stderr, "ioctl stereo error \n");
}
fmt = AFMT_S16_LE;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
fprintf (stderr, "ioctl setfmt error \n");
}
opts->audio_out_type = 5; //5 for 1 channel - 48k OSS 16-bit short output (matching with input)
opts->pulse_digi_rate_out = 48000; //this is used to force to upsample and also allow source audio monitor conditional check
opts->pulse_digi_out_channels = 1; //this is used to allow source audio monitor conditional check
opts->audio_gain = 0;
}
}
if (opts->audio_in_type != 5 || opts->split == 1) //split == 1
{
if((strncmp(opts->audio_out_dev, "/dev/dsp", 8) == 0))
{
fprintf (stderr, "OSS Output %s.\n", opts->audio_out_dev);
opts->audio_out_fd = open (opts->audio_out_dev, O_WRONLY);
if (opts->audio_out_fd == -1)
{
fprintf (stderr, "Error, couldn't open %s\n", opts->audio_out_dev);
opts->audio_out = 0;
exit(1);
}
//Setup the device. Note that it's important to set the sample format, number of channels and sample rate exactly in this order. Some devices depend on the order.
fmt = 0;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_RESET) < 0)
{
fprintf (stderr, "ioctl reset error \n");
}
fmt = AFMT_S16_LE; //Sample Format
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
fprintf (stderr, "ioctl setfmt error \n");
}
fmt = opts->pulse_digi_out_channels; //number of channels //was 2
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_CHANNELS, &fmt) < 0)
{
fprintf (stderr, "ioctl channel error \n");
}
//if using split with OSS output, and using EDACS w/ Analog, we have to use 48k
if (opts->frame_provoice == 1)
opts->pulse_digi_rate_out = 48000;
speed = opts->pulse_digi_rate_out; //since we have split input/output, we want to mirror pulse rate out
fmt = speed; //output rate
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
fprintf (stderr, "ioctl speed error \n");
}
if (opts->pulse_digi_out_channels == 2)
fmt = 1;
else fmt = 0;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
fprintf (stderr, "ioctl stereo error \n");
}
//TODO: Multiple output returns based on 8k/1, 8k/2, or maybe 48k/1? (2,3,5)??
if (opts->pulse_digi_out_channels == 2)
opts->audio_out_type = 2; //2 for 2 channel 8k OSS 16-bit short output
else if (opts->frame_m17 == 1)
opts->audio_out_type = 2;
else opts->audio_out_type = 5;
//debug
fprintf (stderr, "Using OSS Output with %dk/%d channel configuration.\n", opts->pulse_digi_rate_out, opts->pulse_digi_out_channels);
}
}
}
void
@@ -92,11 +313,7 @@ processAudio (dsd_opts * opts, dsd_state * state)
{
// detect max level
max = 0;
//attempt to reduce crackle by overriding the max value when not using pulse input
if (opts->audio_in_type != 0)
{
max = 3000;
}
state->audio_out_temp_buf_p = state->audio_out_temp_buf;
for (n = 0; n < 160; n++)
{
@@ -176,8 +393,7 @@ processAudio (dsd_opts * opts, dsd_state * state)
// copy audio data to output buffer and upsample if necessary
state->audio_out_temp_buf_p = state->audio_out_temp_buf;
//we only want to upsample when using sample rates greater than 8k for output,
//hard set to 8k for RTL mono and MBE playback, otherwise crackling may occur.
//we only want to upsample when using sample rates greater than 8k for output
if (opts->pulse_digi_rate_out > 8000)
{
for (n = 0; n < 160; n++)
@@ -201,6 +417,8 @@ processAudio (dsd_opts * opts, dsd_state * state)
*state->audio_out_float_buf_p = -32768.0F;
}
*state->audio_out_buf_p = (short) *state->audio_out_float_buf_p;
//tap the pointer here and store the short upsample buffer samples
state->s_lu[n] = (short) *state->audio_out_float_buf_p;
state->audio_out_buf_p++;
state->audio_out_float_buf_p++;
}
@@ -219,6 +437,10 @@ processAudio (dsd_opts * opts, dsd_state * state)
*state->audio_out_temp_buf_p = -32768.0F;
}
*state->audio_out_buf_p = (short) *state->audio_out_temp_buf_p;
//tap the pointer here and store the short buffer samples
state->s_l[n] = (short) *state->audio_out_temp_buf_p;
//debug
// fprintf (stderr, " %d", state->s_l[n]);
state->audio_out_buf_p++;
state->audio_out_temp_buf_p++;
state->audio_out_idx++;
@@ -238,11 +460,7 @@ processAudioR (dsd_opts * opts, dsd_state * state)
{
// detect max level
max = 0;
//attempt to reduce crackle by overriding the max value when not using pulse input
if (opts->audio_in_type != 0)
{
max = 3000;
}
state->audio_out_temp_buf_pR = state->audio_out_temp_bufR;
for (n = 0; n < 160; n++)
{
@@ -323,7 +541,6 @@ processAudioR (dsd_opts * opts, dsd_state * state)
// copy audio data to output buffer and upsample if necessary
state->audio_out_temp_buf_pR = state->audio_out_temp_bufR;
//we only want to upsample when using sample rates greater than 8k for output,
//hard set to 8k for RTL mono and MBE playback, otherwise crackling may occur.
if (opts->pulse_digi_rate_out > 8000)
{
for (n = 0; n < 160; n++)
@@ -347,6 +564,8 @@ processAudioR (dsd_opts * opts, dsd_state * state)
*state->audio_out_float_buf_pR = -32768.0F;
}
*state->audio_out_buf_pR = (short) *state->audio_out_float_buf_pR;
//tap the pointer here and store the short upsample buffer samples
state->s_ru[n] = (short) *state->audio_out_float_buf_pR;
state->audio_out_buf_pR++;
state->audio_out_float_buf_pR++;
}
@@ -365,6 +584,8 @@ processAudioR (dsd_opts * opts, dsd_state * state)
*state->audio_out_temp_buf_pR = -32768.0F;
}
*state->audio_out_buf_pR = (short) *state->audio_out_temp_buf_pR;
//tap the pointer here and store the short buffer samples
state->s_r[n] = (short) *state->audio_out_temp_buf_pR;
state->audio_out_buf_pR++;
state->audio_out_temp_buf_pR++;
state->audio_out_idxR++;
@@ -429,12 +650,47 @@ void writeSynthesizedVoiceR (dsd_opts * opts, dsd_state * state)
}
void writeRawSample (dsd_opts * opts, dsd_state * state, short sample)
//short Mono to Stereo version for new static .wav files in stereo format for TDMA
void writeSynthesizedVoiceMS (dsd_opts * opts, dsd_state * state)
{
int n;
short aout_buf[160];
short *aout_buf_p;
aout_buf_p = aout_buf;
state->audio_out_temp_buf_p = state->audio_out_temp_buf;
for (n = 0; n < 160; n++)
{
if (*state->audio_out_temp_buf_p > (float) 32767)
{
*state->audio_out_temp_buf_p = (float) 32767;
}
else if (*state->audio_out_temp_buf_p < (float) -32768)
{
*state->audio_out_temp_buf_p = (float) -32768;
}
*aout_buf_p = (short) *state->audio_out_temp_buf_p;
aout_buf_p++;
state->audio_out_temp_buf_p++;
}
short ss[320];
for (n = 0; n < 160; n++)
{
ss[(n*2)+0] = aout_buf[n];
ss[(n*2)+1] = aout_buf[n];
}
sf_write_short(opts->wav_out_f, ss, 320);
}
void writeRawSample (dsd_opts * opts, dsd_state * state, short sample)
{
UNUSED(state);
//short aout_buf[160];
//sf_write_short(opts->wav_out_raw, aout_buf, 160);
//only write if actual audio, truncate silence
@@ -449,24 +705,46 @@ void
playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
{
ssize_t result;
UNUSED(result);
//don't synthesize voice if slot is turned off
if (opts->slot1_on == 0)
{
//clear any previously buffered audio
state->audio_out_float_buf_p = state->audio_out_float_buf + 100;
state->audio_out_buf_p = state->audio_out_buf + 100;
memset (state->audio_out_float_buf, 0, 100 * sizeof (float));
memset (state->audio_out_buf, 0, 100 * sizeof (short));
state->audio_out_idx2 = 0;
state->audio_out_idx = 0;
goto end_psv;
}
if (state->audio_out_idx > opts->delay)
{
// output synthesized speech to sound card
if(opts->audio_out_type == 2)
{
//go F yourself PA
}
else
if (opts->audio_out_type == 5 || opts->audio_out_type == 1) //OSS
{
//Test just sending it straight on since I think I've figured out the STDIN and RTL for Stereo
pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works.
//OSS 48k/1
result = write (opts->audio_out_fd, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2));
state->audio_out_idx = 0;
}
else if (opts->audio_out_type == 0)
{
pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL);
state->audio_out_idx = 0;
}
else if (opts->audio_out_type == 8) //UDP Audio Out -- Forgot some things still use this for now
{
udp_socket_blaster (opts, state, (state->audio_out_idx * 2), (state->audio_out_buf_p - state->audio_out_idx));
state->audio_out_idx = 0;
}
else state->audio_out_idx = 0; //failsafe for audio_out == 0
}
end_psv:
if (state->audio_out_idx2 >= 800000)
{
state->audio_out_float_buf_p = state->audio_out_float_buf + 100;
@@ -482,19 +760,28 @@ void
playSynthesizedVoiceR (dsd_opts * opts, dsd_state * state)
{
ssize_t result;
UNUSED(result);
if (state->audio_out_idxR > opts->delay)
{
// output synthesized speech to sound card
if(opts->audio_out_type == 2)
{
//go F yourself PA
}
else
if (opts->audio_out_type == 5) //OSS
{
pa_simple_write(opts->pulse_digi_dev_outR, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2), NULL); //Yay! It works.
//OSS 48k/1
result = write (opts->audio_out_fd, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2));
state->audio_out_idxR = 0;
}
else if (opts->audio_out_type == 0)
{
pa_simple_write(opts->pulse_digi_dev_outR, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2), NULL);
state->audio_out_idxR = 0;
}
else if (opts->audio_out_type == 8) //UDP Audio Out -- Not sure how this would handle, but R never gets called anymore, so just here for symmetry
{
udp_socket_blaster (opts, state, (state->audio_out_idxR * 2), (state->audio_out_buf_pR - state->audio_out_idxR));
state->audio_out_idxR = 0;
}
else state->audio_out_idxR = 0; //failsafe for audio_out == 0
}
@@ -511,6 +798,8 @@ playSynthesizedVoiceR (dsd_opts * opts, dsd_state * state)
void
openAudioOutDevice (dsd_opts * opts, int speed)
{
UNUSED(speed);
//converted to handle any calls to use portaudio
if(strncmp(opts->audio_out_dev, "pa:", 3) == 0)
{
@@ -525,7 +814,7 @@ openAudioOutDevice (dsd_opts * opts, int speed)
}
else
{
struct stat stat_buf;
// struct stat stat_buf;
// if(stat(opts->audio_out_dev, &stat_buf) != 0 && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) //HERE
// {
// fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev);
@@ -545,74 +834,223 @@ openAudioOutDevice (dsd_opts * opts, int speed)
void
openAudioInDevice (dsd_opts * opts)
{
// get info of device/file
if(strncmp(opts->audio_in_dev, "-", 1) == 0)
{
opts->audio_in_type = 1;
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate=48000;
opts->pulse_digi_rate_out = 8000; //set out rate to 8000 for stdin input
opts->audio_in_file_info->channels=1;
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
opts->audio_in_file = sf_open_fd(fileno(stdin), SFM_READ, opts->audio_in_file_info, 0);
char * extension;
const char ch = '.';
extension = strrchr(opts->audio_in_dev, ch); //return extension if this is a .wav or .bin file
if(opts->audio_in_file == NULL) {
fprintf (stderr,"Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL));
exit(1); //had this one disabled, re-enabling it now
}
}
//converted to handle any calls to use portaudio
else if(strncmp(opts->audio_in_dev, "pa:", 2) == 0)
//if no extension set, give default of .wav -- bugfix for github issue #105
// if (extension == NULL) extension = ".wav";
// get info of device/file
if (strncmp(opts->audio_in_dev, "-", 1) == 0)
{
opts->audio_in_type = 0;
fprintf (stderr,"Error, Port Audio is not supported by FME!\n");
fprintf (stderr,"Using Pulse Audio Input Stream Instead! \n");
sprintf (opts->audio_in_dev, "pulse");
opts->audio_in_type = 1;
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
opts->audio_in_file_info->channels=1;
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
opts->audio_in_file = sf_open_fd(fileno(stdin), SFM_READ, opts->audio_in_file_info, 0);
if(opts->audio_in_file == NULL)
{
fprintf(stderr, "Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL));
exit(1);
}
}
else if (strncmp(opts->audio_in_dev, "m17udp", 6) == 0)
{
opts->audio_in_type = 9; //NULL audio device
}
else if (strncmp(opts->audio_in_dev, "tcp", 3) == 0)
{
opts->audio_in_type = 8;
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
opts->audio_in_file_info->channels=1;
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
opts->tcp_file_in = sf_open_fd(opts->tcp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
if(opts->tcp_file_in == NULL)
{
fprintf(stderr, "Error, couldn't open TCP with libsndfile: %s\n", sf_strerror(NULL));
exit(1);
}
}
// else if (strncmp(opts->audio_in_dev, "udp", 3) == 0)
// {
// opts->audio_in_type = 6;
// opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
// opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
// opts->audio_in_file_info->channels=1;
// opts->audio_in_file_info->seekable=0;
// opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
// opts->udp_file_in = sf_open_fd(opts->udp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
// if(opts->udp_file_in == NULL)
// {
// fprintf(stderr, "Error, couldn't open UDP with libsndfile: %s\n", sf_strerror(NULL));
// exit(1);
// }
// }
else if(strncmp(opts->audio_in_dev, "rtl", 3) == 0)
{
#ifdef USE_RTLSDR
opts->audio_in_type = 3;
#elif AERO_BUILD
opts->audio_in_type = 5;
sprintf (opts->audio_in_dev, "/dev/dsp");
#else
opts->audio_in_type = 0;
sprintf (opts->audio_in_dev, "pulse");
#endif
}
else if(strncmp(opts->audio_in_dev, "pulse", 5) == 0)
{
opts->audio_in_type = 0;
}
//convert from opening wav files to OP25 symbol capture files since opening wav files is busted
else if((strncmp(opts->audio_in_dev, "/dev/dsp", 8) == 0))
{
opts->audio_in_type = 5;
}
//if no extension set, treat as named pipe or extensionless wav file -- bugfix for github issue #105
else if (extension == NULL)
{
opts->audio_in_type = 2;
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate = opts->wav_sample_rate;
opts->audio_in_file_info->channels = 1;
opts->audio_in_file_info->seekable = 0;
opts->audio_in_file_info->format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE;
opts->audio_in_file = sf_open(opts->audio_in_dev, SFM_READ, opts->audio_in_file_info);
if (opts->audio_in_file == NULL)
{
fprintf(stderr, "Error, couldn't open file/pipe with libsndfile: %s\n", sf_strerror(NULL));
exit(1);
}
}
//test .rrc files with hardset wav file settings
else if (strncmp(extension, ".rrc", 4) == 0)
{
//debug
fprintf (stderr, "Opening M17 .rrc headless wav file\n");
opts->audio_in_type = 2;
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate = 48000;
opts->audio_in_file_info->channels = 1;
opts->audio_in_file_info->seekable = 0;
opts->audio_in_file_info->format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE;
opts->audio_in_file = sf_open(opts->audio_in_dev, SFM_READ, opts->audio_in_file_info);
if(opts->audio_in_file == NULL)
{
fprintf(stderr, "Error, couldn't open %s with libsndfile: %s\n", opts->audio_in_dev, sf_strerror(NULL));
exit(1);
}
}
//Open .raw files as a float input type
else if (strncmp(extension, ".raw", 4) == 0)
{
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
fprintf (stderr,"Error, couldn't open raw (float) file %s\n", opts->audio_in_dev);
exit(1);
}
if (S_ISREG(stat_buf.st_mode))
{
opts->symbolfile = fopen(opts->audio_in_dev, "r");
opts->audio_in_type = 44; //float symbol input
}
else
{
opts->audio_in_type = 0;
}
}
//Open .raw files as a float input type
else if (strncmp(extension, ".sym", 4) == 0)
{
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
fprintf (stderr,"Error, couldn't open sym (float) file %s\n", opts->audio_in_dev);
exit(1);
}
if (S_ISREG(stat_buf.st_mode))
{
opts->symbolfile = fopen(opts->audio_in_dev, "r");
opts->audio_in_type = 44; //float symbol input
}
else
{
opts->audio_in_type = 0;
}
}
else if (strncmp(extension, ".bin", 4) == 0)
{
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
fprintf (stderr,"Error, couldn't open bin file %s\n", opts->audio_in_dev);
exit(1);
}
if (S_ISREG(stat_buf.st_mode))
{
opts->symbolfile = fopen(opts->audio_in_dev, "r");
opts->audio_in_type = 4; //symbol capture bin files
}
else
{
opts->audio_in_type = 0;
}
}
//open as wav file as last resort, wav files subseptible to sample rate issues if not 48000
else
{
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev);
fprintf (stderr,"Error, couldn't open wav file %s\n", opts->audio_in_dev);
exit(1);
}
if (S_ISREG(stat_buf.st_mode))
{
// is this a regular file? then process with libsndfile.
//opts->pulse_digi_rate_out = 8000; //this for wav files input?
// opts->audio_in_type = 1;
// opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
// opts->audio_in_file_info->channels = 1;
// opts->audio_in_file = sf_open(opts->audio_in_dev, SFM_READ, opts->audio_in_file_info);
opts->audio_in_type = 2; //two now, seperating STDIN and wav files
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
opts->audio_in_file_info->channels=1;
opts->audio_in_file_info->channels = 1;
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
//
// if(opts->audio_in_file == NULL)
// {
// fprintf (stderr,"Error, couldn't open file %s\n", opts->audio_in_dev);
// exit(1);
// }
opts->audio_in_file = sf_open(opts->audio_in_dev, SFM_READ, opts->audio_in_file_info);
if(opts->audio_in_file == NULL)
{
fprintf(stderr, "Error, couldn't open wav file %s\n", opts->audio_in_dev);
exit(1);
}
opts->symbolfile = fopen(opts->audio_in_dev, "r");
opts->audio_in_type = 4; //symbol capture bin files
}
else
//open pulse audio if no bin or wav
else //seems this condition is never met
{
// this is a device, use old handling, pulse audio now
opts->audio_in_type = 0;
//opts->audio_in_type = 5; //not sure if this works or needs to openPulse here
fprintf(stderr, "Error, couldn't open input file.\n");
exit(1);
}
}
if (opts->split == 1)
{
fprintf (stderr,"Audio In Device: %s\n", opts->audio_in_dev);

2334
src/dsd_audio2.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -118,6 +118,8 @@ print_datascope(dsd_opts* opts, dsd_state* state, int* sbuf2)
static void
use_symbol (dsd_opts* opts, dsd_state* state, int symbol)
{
UNUSED(symbol);
int i;
int sbuf2[128];
int lmin, lmax, lsum;
@@ -217,16 +219,16 @@ invert_dibit(int dibit)
return -1;
}
static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
//int digitize (dsd_opts* opts, dsd_state* state, int symbol)
int digitize (dsd_opts* opts, dsd_state* state, int symbol)
{
// determine dibit state
if ((state->synctype == 6) || (state->synctype == 14)|| (state->synctype == 18))
if ((state->synctype == 6) || (state->synctype == 14)|| (state->synctype == 18) || (state->synctype == 37))
{
// 6 +D-STAR
// 14 +ProVoice
// 18 +D-STAR_HD
// 37 +EDACS
if (symbol > state->center)
{
@@ -241,11 +243,12 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
return (1); // +3
}
}
else if ((state->synctype == 7) || (state->synctype == 15)|| (state->synctype == 19))
else if ((state->synctype == 7) || (state->synctype == 15)|| (state->synctype == 19) || (state->synctype == 38))
{
// 7 -D-STAR
// 15 -ProVoice
// 19 -D-STAR_HD
// 38 -EDACS
if (symbol > state->center)
{
@@ -263,27 +266,39 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
else if ((state->synctype == 1) || (state->synctype == 3) || (state->synctype == 5) ||
(state->synctype == 9) || (state->synctype == 11) || (state->synctype == 13) ||
(state->synctype == 17) || (state->synctype == 36) )
(state->synctype == 17) || (state->synctype == 29) || (state->synctype == 31) ||
(state->synctype == 77) || (state->synctype == 87) ||(state->synctype == 36) ||
(state->synctype == 99) )
{
// 1 -P25p1
// 3 -X2-TDMA (inverted signal voice frame)
// 5 -X2-TDMA (inverted signal data frame)
// 9 -NXDN (inverted voice frame)
// 9 -M17 LSR
// 11 -DMR (inverted signal voice frame)
// 13 -DMR (inverted signal data frame)
// 17 -NXDN (inverted data frame)
// 17 -M17 STR
// 29 -NXDN (inverted FSW)
// 31 -YSF
// 36 -P25p2
// 77 -M17 BRT
// 87 -M17 PKT
// 99 -M17 Preamble
int valid;
int dibit;
valid = 0;
if (state->synctype == 1)
{
// Use the P25 heuristics if available
valid = estimate_symbol(state->rf_mod, &(state->inv_p25_heuristics), state->last_dibit, symbol, &dibit);
}
UNUSED(opts);
//testing again, either on Voice channels only (when tuned) or with trunk disabled
// if (state->synctype == 1 && (opts->p25_is_tuned == 1 || opts->p25_trunk == 0) && opts->use_heuristics == 1)
if (state->synctype == 1 && opts->use_heuristics == 1)
{
// Use the P25p1 heuristics if available
valid = estimate_symbol(state->rf_mod, &(state->inv_p25_heuristics), state->last_dibit, symbol, &dibit);
}
if (valid == 0)
{
@@ -319,7 +334,7 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
state->dibit_buf_p++;
//dmr buffer
*state->dmr_payload_p = invert_dibit(dibit);
*state->dmr_payload_p = invert_dibit(dibit);
state->dmr_payload_p++;
//dmr buffer end
@@ -330,21 +345,29 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
// 0 +P25p1
// 2 +X2-TDMA (non inverted signal data frame)
// 4 +X2-TDMA (non inverted signal voice frame)
// 8 +NXDN (non inverted voice frame)
// 8 +M17 LSF
// 10 +DMR (non inverted signal data frame)
// 12 +DMR (non inverted signal voice frame)
// 16 +NXDN (non inverted data frame)
// 16 +M17 STR
// 28 +NXND (FSW)
// 30 +YSF
// 35 +p25p2
// 76 +M17 BRT
// 86 +M17 PKT
// 98 +M17 Preamble
int valid;
int dibit;
valid = 0;
if (state->synctype == 0)
{
// Use the P25 heuristics if available
valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit);
}
//testing again, either on Voice channels only (when tuned) or with trunk disabled
// if (state->synctype == 0 && (opts->p25_is_tuned == 1 || opts->p25_trunk == 0) && opts->use_heuristics == 1)
if (state->synctype == 0 && opts->use_heuristics == 1)
{
// Use the P25p1 heuristics if available
valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit);
}
if (valid == 0)
{
@@ -426,18 +449,18 @@ get_dibit_and_analog_signal (dsd_opts* opts, dsd_state* state, int* out_analog_s
dibit = digitize (opts, state, symbol);
if (opts->audio_in_type == 4)
if (opts->audio_in_type == 4)
{
//assign dibit from last symbol/dibit read from capture bin
dibit = state->symbolc;
if (state->use_throttle == 1)
{
usleep(0);
usleep(0);
}
}
//symbol/dibit file capture/writing
if (opts->symbol_out == 1)
if (opts->symbol_out_f)
{
//fprintf (stderr, "%d", dibit);
fputc (dibit, opts->symbol_out_f);
@@ -474,6 +497,7 @@ skipDibit (dsd_opts * opts, dsd_state * state, int count)
short sample;
int i;
UNUSED(sample);
for (i = 0; i < (count); i++)
{

870
src/dsd_events.c Normal file
View File

@@ -0,0 +1,870 @@
/*-------------------------------------------------------------------------------
* dsd_events.c
* DSD-FME event history init, watchdog, push, and related functions
*
*
* LWVMOBILE
* 2025-05 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
#include "git_ver.h"
#include "synctype.h"
//init each event history struct passed into here
void init_event_history (Event_History_I * event_struct, uint8_t start, uint8_t stop)
{
for (uint8_t i = start; i < stop; i++)
{
event_struct->Event_History_Items[i].write = 0;
event_struct->Event_History_Items[i].color_pair = 4;
event_struct->Event_History_Items[i].systype = -1;
event_struct->Event_History_Items[i].subtype = -1;
event_struct->Event_History_Items[i].sys_id1 = 0;
event_struct->Event_History_Items[i].sys_id2 = 0;
event_struct->Event_History_Items[i].sys_id3 = 0;
event_struct->Event_History_Items[i].sys_id4 = 0;
event_struct->Event_History_Items[i].sys_id5 = 0;
event_struct->Event_History_Items[i].gi = 0;
event_struct->Event_History_Items[i].enc = 0;
event_struct->Event_History_Items[i].enc_alg = 0;
event_struct->Event_History_Items[i].enc_key = 0;
event_struct->Event_History_Items[i].mi = 0;
event_struct->Event_History_Items[i].svc = 0;
event_struct->Event_History_Items[i].source_id = 0;
event_struct->Event_History_Items[i].target_id = 0;
sprintf (event_struct->Event_History_Items[i].src_str, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].tgt_str, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].t_name, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].s_name, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].t_mode, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].s_mode, "%s", "BUMBLEBEETUNA");
event_struct->Event_History_Items[i].channel = 0;
event_struct->Event_History_Items[i].event_time = 0;
memset (event_struct->Event_History_Items[i].pdu, 0, sizeof(event_struct->Event_History_Items[0].pdu));
sprintf (event_struct->Event_History_Items[i].sysid_string, "%s", "");
sprintf (event_struct->Event_History_Items[i].alias, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].gps_s, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].text_message, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].event_string, "%s", "BUMBLEBEETUNA");
sprintf (event_struct->Event_History_Items[i].internal_str, "%s", "BUMBLEBEETUNA");
}
}
void push_event_history (Event_History_I * event_struct)
{
//Fixed, had it going in the wrong direction first time
for (uint8_t i = 254; i >= 1; i--)
{
event_struct->Event_History_Items[i].write = event_struct->Event_History_Items[i-1].write;
event_struct->Event_History_Items[i].color_pair = event_struct->Event_History_Items[i-1].color_pair;
event_struct->Event_History_Items[i].systype = event_struct->Event_History_Items[i-1].systype;
event_struct->Event_History_Items[i].subtype = event_struct->Event_History_Items[i-1].subtype;
event_struct->Event_History_Items[i].sys_id1 = event_struct->Event_History_Items[i-1].sys_id1;
event_struct->Event_History_Items[i].sys_id2 = event_struct->Event_History_Items[i-1].sys_id2;
event_struct->Event_History_Items[i].sys_id3 = event_struct->Event_History_Items[i-1].sys_id3;
event_struct->Event_History_Items[i].sys_id4 = event_struct->Event_History_Items[i-1].sys_id4;
event_struct->Event_History_Items[i].sys_id5 = event_struct->Event_History_Items[i-1].sys_id5;
event_struct->Event_History_Items[i].gi = event_struct->Event_History_Items[i-1].gi;
event_struct->Event_History_Items[i].enc = event_struct->Event_History_Items[i-1].enc;
event_struct->Event_History_Items[i].enc_alg = event_struct->Event_History_Items[i-1].enc_alg;
event_struct->Event_History_Items[i].enc_key = event_struct->Event_History_Items[i-1].enc_key;
event_struct->Event_History_Items[i].mi = event_struct->Event_History_Items[i-1].mi;
event_struct->Event_History_Items[i].svc = event_struct->Event_History_Items[i-1].svc;
event_struct->Event_History_Items[i].source_id = event_struct->Event_History_Items[i-1].source_id;
event_struct->Event_History_Items[i].target_id = event_struct->Event_History_Items[i-1].target_id;
sprintf (event_struct->Event_History_Items[i].src_str, "%s", event_struct->Event_History_Items[i-1].src_str);
sprintf (event_struct->Event_History_Items[i].tgt_str, "%s", event_struct->Event_History_Items[i-1].tgt_str);
sprintf (event_struct->Event_History_Items[i].t_name, "%s", event_struct->Event_History_Items[i-1].t_name);
sprintf (event_struct->Event_History_Items[i].s_name, "%s", event_struct->Event_History_Items[i-1].s_name);
sprintf (event_struct->Event_History_Items[i].t_mode, "%s", event_struct->Event_History_Items[i-1].t_mode);
sprintf (event_struct->Event_History_Items[i].s_mode, "%s", event_struct->Event_History_Items[i-1].s_mode);
event_struct->Event_History_Items[i].channel = event_struct->Event_History_Items[i-1].channel;
event_struct->Event_History_Items[i].event_time = event_struct->Event_History_Items[i+1].event_time;
memcpy (event_struct->Event_History_Items[i].pdu, event_struct->Event_History_Items[i-1].pdu, sizeof(event_struct->Event_History_Items[0].pdu));
sprintf (event_struct->Event_History_Items[i].sysid_string, "%s", event_struct->Event_History_Items[i-1].sysid_string);
sprintf (event_struct->Event_History_Items[i].alias, "%s", event_struct->Event_History_Items[i-1].alias);
sprintf (event_struct->Event_History_Items[i].gps_s, "%s", event_struct->Event_History_Items[i-1].gps_s);
sprintf (event_struct->Event_History_Items[i].text_message, "%s", event_struct->Event_History_Items[i-1].text_message);
sprintf (event_struct->Event_History_Items[i].event_string, "%s", event_struct->Event_History_Items[i-1].event_string);
sprintf (event_struct->Event_History_Items[i].internal_str, "%s", event_struct->Event_History_Items[i-1].internal_str);
}
}
void write_event_to_log_file (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t swrite, char * event_string) //pass completed event string here that is in the struct
{
//open log file
FILE * event_log_file;
event_log_file = fopen(opts->event_out_file, "a");
fprintf (event_log_file, "%s ", event_string);
if (swrite == 1)
fprintf (event_log_file, "Slot %d; ", slot+1);
fprintf (event_log_file,"\n");
char text_string[2000]; sprintf (text_string, "%s", "BUMBLEBEETUNA");
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].text_message, 13) != 0)
fprintf (event_log_file, "%s \n", state->event_history_s[slot].Event_History_Items[0].text_message);
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].alias, 13) != 0)
fprintf (event_log_file, " Talker Alias: %s \n", state->event_history_s[slot].Event_History_Items[0].alias);
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].gps_s, 13) != 0)
fprintf (event_log_file, " GPS: %s \n", state->event_history_s[slot].Event_History_Items[0].gps_s);
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].internal_str, 13) != 0)
fprintf (event_log_file, " DSD-FME: %s \n", state->event_history_s[slot].Event_History_Items[0].internal_str);
//flush and close log file
fflush (event_log_file);
fclose (event_log_file);
}
// run once per loop to check for and push and update event history
void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot)
{
//create a pointer to the current slot event history
Event_History_I * event_struct = &state->event_history_s[slot];
//is this a TDMA slot (append Slot value to end of written event history)
uint8_t swrite = 0;
//who is currently talking
uint32_t source_id = 0;
//last values pulled from the event history
uint32_t last_source_id = event_struct->Event_History_Items[0].source_id;
if (slot == 0)
source_id = state->lastsrc;
else
source_id = state->lastsrcR;
//if DMR BS or P25P2, then flag the swrite, so write can append slot value to event history log //|| state->lastsynctype == 32 || state->lastsynctype == 33 || state->lastsynctype == 34 MS
if (state->lastsynctype == 10 || state->lastsynctype == 11 || state->lastsynctype == 12 || state->lastsynctype == 13)
swrite = 1;
else if (state->lastsynctype == 35 || state->lastsynctype == 36)
swrite = 1;
if (slot == 0) //BUGFIX: generic catch on FDMA systems so that we don't write duplicate data to slot 2 event history
{
//NXDN RID (TODO: Changeover to lastsrc later on)
if (state->lastsynctype == 28 || state->lastsynctype == 29)
source_id = state->nxdn_last_rid;
if (state->lastsynctype == 30 || state->lastsynctype == 31) //YSF Fusion
{
source_id = 0;
if (strncmp(state->ysf_src, " ", 10) != 0) //if this field does not have ten spaces in it
{
for (uint8_t i = 0; i < 11; i++)
source_id += state->ysf_src[i]; //convert to sum value to make a distinct enough src value
}
}
if (state->lastsynctype == 8 || state->lastsynctype == 9 || state->lastsynctype == 16 || state->lastsynctype == 17) //M17 STR
{
source_id = (uint32_t)state->m17_src;
}
if (state->lastsynctype == 6 || state->lastsynctype == 7 || state->lastsynctype == 18 || state->lastsynctype == 19) //DSTAR
{
source_id = 0;
for (uint8_t i = 0; i < 12; i++)
source_id += state->dstar_src[i]; //convert to sum value to make a distinct enough src value
//need a strncmp here for 8 spaces in this field first so we don't blip a blank into the event history
if (strncmp(state->dstar_src, " ", 8) == 0)
source_id = 0;
}
if (state->lastsynctype == 20 || state->lastsynctype == 24 || state->lastsynctype == 21 || state->lastsynctype == 25 || state->lastsynctype == 22 || state->lastsynctype == 26 || state->lastsynctype == 23 || state->lastsynctype == 27) //dPMR
{
source_id = 0;
for (uint8_t i = 0; i < 20; i++)
source_id += state->dpmr_caller_id[i]; //convert to sum value to make a distinct enough src value
//need a strncmp here for 8 spaces in this field first so we don't blip a blank into the event history
if (strncmp(state->dpmr_caller_id, " ", 6) == 0)
source_id = 0;
}
if (state->lastsynctype == 14 || state->lastsynctype == 15 || state->lastsynctype == 37 || state->lastsynctype == 38) //EDACS Calls
{
source_id = 0;
if (opts->p25_is_tuned == 1)
source_id = state->lastsrc;
}
}
//call alert beep when new call detected
if (last_source_id == 0 && source_id != 0 && opts->call_alert == 1)
beeper (opts, state, slot, 40, 86, 3);
if (source_id != last_source_id && last_source_id != 0)
{
if (opts->event_out_file[0] != 0)
write_event_to_log_file(opts, state, slot, swrite, event_struct->Event_History_Items[0].event_string);
event_struct->Event_History_Items[0].write = 1; //written, or pushed at this point
if (opts->static_wav_file == 0)
{
if (slot == 0 && opts->wav_out_f != NULL)
{
opts->wav_out_f = close_and_rename_wav_file(opts->wav_out_f, opts->wav_out_file, opts->wav_out_dir, event_struct);
opts->wav_out_f = open_wav_file(opts->wav_out_dir, opts->wav_out_file, 8000, 0);
}
else if (slot == 1 && opts->wav_out_fR != NULL)
{
opts->wav_out_fR = close_and_rename_wav_file(opts->wav_out_fR, opts->wav_out_fileR, opts->wav_out_dir, event_struct);
opts->wav_out_fR = open_wav_file(opts->wav_out_dir, opts->wav_out_fileR, 8000, 0);
}
}
push_event_history (event_struct);
init_event_history (event_struct, 0, 1);
//clear out some strings and things
memset(state->ysf_txt, 0, sizeof(state->ysf_txt));
memset(state->dstar_gps, 0, sizeof(state->dstar_gps));
memset(state->dstar_txt, 0, sizeof(state->dstar_txt));
state->gi[slot] = -1; //return to an unset value
//end of voice call alert
if (opts->call_alert == 1)
beeper (opts, state, slot, 40, 86, 3);
}
}
//similar to above, but constantly testing and checking the most recent event only
//this will hopefully be more useful when dealing with an ongoing event with
//features that update over time with embedded signalling, etc
void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot)
{
//create a pointer to the current slot event history
Event_History_I * event_struct = &state->event_history_s[slot];
//ncurses color pairs
uint8_t color_pair = 4; //default voice color (unknown gi)
if (state->gi[slot] == 1)
color_pair = 4; //default private voice color
else if (state->gi[slot] == 0)
color_pair = 4; //default group voice color
//TODO: Flesh out more later on.
uint32_t source_id = 0;
uint32_t target_id = 0;
char src_str[200]; memset (src_str, 0, sizeof(src_str));
sprintf (src_str, "%s", "BUMBLEBEETUNA");
char tgt_str[200]; memset (tgt_str, 0, sizeof(tgt_str));
sprintf (tgt_str, "%s", "BUMBLEBEETUNA");
//group import items
char t_name[200]; memset (t_name, 0, sizeof(t_name));
sprintf (t_name, "%s", "BUMBLEBEETUNA");
char s_name[200]; memset (s_name, 0, sizeof(s_name));
sprintf (s_name, "%s", "BUMBLEBEETUNA");
char t_mode[200]; memset (t_mode, 0, sizeof(t_mode));
sprintf (t_mode, "%s", "BUMBLEBEETUNA");
char s_mode[200]; memset (s_mode, 0, sizeof(s_mode));
sprintf (s_mode, "%s", "BUMBLEBEETUNA");
uint16_t svc_opts = 0;
uint8_t subtype = 0;
uint8_t mfid = 0;
uint32_t sys_id1 = 0;
uint32_t sys_id2 = 0;
uint32_t sys_id3 = 0;
uint32_t sys_id4 = 0;
uint32_t sys_id5 = 0;
uint32_t channel = 0;
uint8_t enc = 0;
uint8_t alg_id = 0;
uint16_t key_id = 0;
unsigned long long int mi;
char sysid_string[200]; memset(sysid_string, 0, sizeof(sysid_string));
sprintf (sysid_string, "%s", "");
if (slot == 0)
{
source_id = state->lastsrc;
target_id = state->lasttg;
subtype = state->dmrburstL;
mfid = state->dmr_fid;
svc_opts = state->dmr_so;
enc = (svc_opts >> 6) & 1;
alg_id = state->payload_algid;
key_id = (uint16_t)state->payload_keyid;
mi = state->payload_mi;
}
else
{
source_id = state->lastsrcR;
target_id = state->lasttgR;
subtype = state->dmrburstR;
mfid = state->dmr_fidR;
svc_opts = state->dmr_soR;
enc = (svc_opts >> 6) & 1;
alg_id = state->payload_algidR;
key_id = (uint16_t)state->payload_keyidR;
mi = state->payload_miR;
}
//if P25 (if not P25, then these will all be zero anyways)
sys_id1 = state->p2_wacn;
sys_id2 = state->p2_sysid;
if (state->nac != 0)
sys_id3 = state->nac; //same as state->p2_cc, but zeroes out when no signal or error
else sys_id3 = state->p2_cc;
sys_id4 = state->p2_rfssid;
sys_id5 = state->p2_siteid;
if (sys_id1)
sprintf (sysid_string, "P25_%05X%03X%03X_%d_%d", sys_id1, sys_id2, sys_id3, sys_id4, sys_id5);
else sprintf (sysid_string, "P25_%03X", sys_id3);
if (state->lastsynctype == 10 || state->lastsynctype == 11 || state->lastsynctype == 12 || state->lastsynctype == 13 ||
state->lastsynctype == 32 || state->lastsynctype == 33 || state->lastsynctype == 34 )
{
sys_id1 = state->dmr_t3_syscode;
sys_id2 = state->dmr_color_code;
if (sys_id1)
sprintf (sysid_string, "DMR_%X_CC_%d", sys_id1, sys_id2);
else sprintf (sysid_string, "DMR_CC_%d", sys_id2);
}
if (slot == 0) //BUGFIX: generic catch on FDMA systems so that we don't write duplicate data to slot 2 event history
{
//NXDN RID (TODO: Changeover to lastsrc and lasttg later on)
if (state->lastsynctype == 28 || state->lastsynctype == 29)
{
source_id = state->nxdn_last_rid;
target_id = state->nxdn_last_tg;
if (state->nxdn_cipher_type != 0)
enc = 1;
alg_id = state->nxdn_cipher_type;
key_id = state->nxdn_key;
sys_id1 = state->nxdn_location_site_code;
sys_id2 = state->nxdn_location_sys_code;
sys_id3 = state->nxdn_last_ran; //might be an issue on conventional systems that have a different RAN on the tx_rel or idle data bursts
if (sys_id1)
sprintf (sysid_string, "NXDN_%d_%d_RAN_%d", sys_id2, sys_id1, sys_id3);
else sprintf (sysid_string, "NXDN_RAN_%d", sys_id3);
}
if (state->lastsynctype == 30 || state->lastsynctype == 31) //YSF Fusion
{
source_id = 0;
if (strncmp(state->ysf_src, " ", 10) != 0) //if this field does not have ten spaces in it
{
for (uint8_t i = 0; i < 11; i++)
source_id += state->ysf_src[i]; //convert to sum value to make a distinct enough src value
}
//WIP: If Text, compile it here (still having issues with an empty txt string making a line break)
uint8_t k = 0; char ysf_emp[21][21]; memset(ysf_emp, 0, sizeof(ysf_emp));
if (memcmp(ysf_emp, state->ysf_txt, sizeof(state->ysf_txt)) != 0)
{
for (uint8_t i = 4; i < 8; i++)
{
for (uint8_t j = 0; j < 20; j++)
{
if (state->ysf_txt[i][j] != 0x2A)
event_struct->Event_History_Items[0].text_message[k++] = state->ysf_txt[i][j];
else event_struct->Event_History_Items[0].text_message[k++] = 0x20; //space
}
event_struct->Event_History_Items[0].text_message[k] = 0; //terminate
}
}
else sprintf (event_struct->Event_History_Items[0].text_message, "%s", "BUMBLEBEETUNA");
sprintf (sysid_string, "%s", "YSF");
char temp_str[20];
memset(temp_str, 0, sizeof(temp_str));
//set src string as a non-spaced non-garbo char string
for (uint8_t i = 0; i < 10; i++)
{
if (state->ysf_src[i] == 0x20) //spaces to underscore
temp_str[i] = 0x5F;
else if (state->ysf_src[i] > 0x20 && state->ysf_src[i] < 0x7F) //copy normal ascii range characters
temp_str[i] = state->ysf_src[i];
else if (state->ysf_src[i] == 0) break; //hit the terminator, so stop
else temp_str[i] = 0x5F; //unknown to underscore
}
sprintf (src_str, "%s", temp_str);
//same for tgt str
memset(temp_str, 0, sizeof(temp_str));
for (uint8_t i = 0; i < 10; i++)
{
if (state->ysf_tgt[i] == 0x20) //spaces to underscore
temp_str[i] = 0x5F;
else if (state->ysf_tgt[i] > 0x20 && state->ysf_tgt[i] < 0x7F) //copy normal ascii range characters
temp_str[i] = state->ysf_tgt[i];
else if (state->ysf_tgt[i] == 0) break; //hit the terminator, so stop
else temp_str[i] = 0x5F; //unknown to underscore
}
sprintf (tgt_str, "%s", temp_str);
}
if (state->lastsynctype == 8 || state->lastsynctype == 9 || state->lastsynctype == 16 || state->lastsynctype == 17) //M17 STR
{
target_id = (uint32_t)state->m17_dst;
source_id = (uint32_t)state->m17_src;
sys_id1 = state->m17_can;
sprintf (sysid_string, "M17_CAN_%d", sys_id1);
sprintf (src_str, "%s", state->m17_src_csd);
sprintf (tgt_str, "%s", state->m17_dst_csd);
}
if (state->lastsynctype == 6 || state->lastsynctype == 7 || state->lastsynctype == 18 || state->lastsynctype == 19) //DSTAR
{
source_id = 0;
for (uint8_t i = 0; i < 12; i++)
source_id += state->dstar_src[i]; //convert to sum value to make a distinct enough src value
//need a strncmp here for 8 spaces in this field first so we don't blip a blank into the event history
if (strncmp(state->dstar_src, " ", 8) == 0)
source_id = 0;
sprintf (sysid_string, "%s", "DSTAR");
char temp_str[20];
memset(temp_str, 0, sizeof(temp_str));
//set src string as a non-spaced non-garbo char string
for (uint8_t i = 0; i < 12; i++)
{
if (state->dstar_src[i] == 0x20) //spaces to underscore
temp_str[i] = 0x5F;
else if (state->dstar_src[i] > 0x20 && state->dstar_src[i] < 0x7F) //copy normal ascii range characters
temp_str[i] = state->dstar_src[i];
else if (state->dstar_src[i] == 0) break; //hit the terminator, so stop
else temp_str[i] = 0x5F; //unknown to underscore
}
sprintf (src_str, "%s", temp_str);
//same for tgt str
memset(temp_str, 0, sizeof(temp_str));
for (uint8_t i = 0; i < 8; i++)
{
if (state->dstar_dst[i] == 0x20) //spaces to underscore
temp_str[i] = 0x5F;
else if (state->dstar_dst[i] > 0x20 && state->dstar_dst[i] < 0x7F) //copy normal ascii range characters
temp_str[i] = state->dstar_dst[i];
else if (state->dstar_dst[i] == 0) break; //hit the terminator, so stop
else temp_str[i] = 0x5F; //unknown to underscore
}
sprintf (tgt_str, "%s", temp_str);
}
if (state->lastsynctype == 20 || state->lastsynctype == 24 || state->lastsynctype == 21 || state->lastsynctype == 25 || state->lastsynctype == 22 || state->lastsynctype == 26 || state->lastsynctype == 23 || state->lastsynctype == 27) //dPMR
{
source_id = 0;
for (uint8_t i = 0; i < 20; i++)
source_id += state->dpmr_caller_id[i]; //convert to sum value to make a distinct enough src value
//need a strncmp here for 8 spaces in this field first so we don't blip a blank into the event history
if (strncmp(state->dpmr_caller_id, " ", 6) == 0)
source_id = 0;
sprintf (sysid_string, "DPMR_CC_%d", state->dpmr_color_code);
sprintf (src_str, "%s", state->dpmr_caller_id);
sprintf (tgt_str, "%s", state->dpmr_target_id);
}
if (state->lastsynctype == 14 || state->lastsynctype == 15 || state->lastsynctype == 37 || state->lastsynctype == 38) //EDACS Calls
{
source_id = 0;
if (opts->p25_is_tuned == 1)
{
source_id = state->lastsrc;
channel = state->edacs_tuned_lcn;
}
sys_id1 = state->edacs_site_id;
sys_id2 = state->edacs_area_code;
sys_id3 = state->edacs_sys_id;
svc_opts = state->edacs_vc_call_type;
char sup_str[200]; memset (sup_str, 0, sizeof(sup_str));
sprintf (sup_str, "%s", "_");
if (svc_opts & 0x02)
strcat (sup_str, "Digital_");
else strcat (sup_str, "Analog_");
if (svc_opts & 0x04)
strcat (sup_str, "Emergency_");
if (svc_opts & 0x08)
strcat (sup_str, "Group_");
if (svc_opts & 0x10)
strcat (sup_str, "I_");
if (svc_opts & 0x20)
strcat (sup_str, "ALL_");
if (svc_opts & 0x40)
strcat (sup_str, "INTER_");
if (svc_opts & 0x80)
strcat (sup_str, "TEST_");
if (svc_opts & 0x100)
strcat (sup_str, "AGENCY_");
if (svc_opts & 0x200)
strcat (sup_str, "FLEET_");
if (svc_opts & 0x01)
strcat (sup_str, "Voice_");
strcat (sup_str, "Call");
sprintf (sysid_string, "EDACS_SITE_%03d", sys_id1);
strcat (sysid_string, sup_str);
if (state->ea_mode == 0)
{
int afs = state->lasttg;
sprintf(src_str, "%s", ""); sprintf(tgt_str, "%s", "");
int a = (afs >> state->edacs_a_shift) & state->edacs_a_mask;
int f = (afs >> state->edacs_f_shift) & state->edacs_f_mask;
int s = afs & state->edacs_s_mask;
sprintf (tgt_str, "%03d_AFS_%02d_%02d%01d", afs, a, f, s);
if (state->lastsrc != 0x800 && state->lastsrc != 0)
sprintf (src_str, "LID_%d", state->lastsrc);
else sprintf (src_str, "LID_UNK");
}
}
}
//if we have a group_array import, search and load it here
//will search and load both target values, and src values if available
uint8_t t_name_loaded = 0;
uint8_t s_name_loaded = 0;
if (target_id != 0)
{
for (int i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == target_id)
{
sprintf (t_name, "%s", state->group_array[i].groupName);
sprintf (t_mode, "%s", state->group_array[i].groupMode);
t_name_loaded = 1;
break;
}
}
}
if (source_id != 0) //&& state->gi[slot] == 1
{
for (int i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == source_id)
{
sprintf (s_name, "%s", state->group_array[i].groupName);
sprintf (s_mode, "%s", state->group_array[i].groupMode);
s_name_loaded = 1;
break;
}
}
}
//system type string (P25, DMR, etc)
const char * sys_string = "Digital";
if (state->lastsynctype != -1)
sys_string = SyncTypes[state->lastsynctype];
//date and time strings
char * timestr = getTimeN(time(NULL));
char * datestr = getDateN(time(NULL));
if (source_id != 0)
{
event_struct->Event_History_Items[0].write = 0;
state->event_history_s[slot].Event_History_Items[0].color_pair = color_pair;
if (state->lastsynctype != -1)
event_struct->Event_History_Items[0].systype = state->lastsynctype;
else event_struct->Event_History_Items[0].systype = 39; //generic digital call
event_struct->Event_History_Items[0].subtype = subtype; //voice
event_struct->Event_History_Items[0].gi = state->gi[slot]; //need this add this to link control messages
event_struct->Event_History_Items[0].sys_id1 = sys_id1;
event_struct->Event_History_Items[0].sys_id2 = sys_id2;
event_struct->Event_History_Items[0].sys_id3 = sys_id3;
event_struct->Event_History_Items[0].sys_id4 = sys_id4;
event_struct->Event_History_Items[0].sys_id5 = sys_id5;
event_struct->Event_History_Items[0].enc = enc;
event_struct->Event_History_Items[0].enc_alg = alg_id;
event_struct->Event_History_Items[0].enc_key = key_id;
event_struct->Event_History_Items[0].mi = mi;
event_struct->Event_History_Items[0].svc = svc_opts;
event_struct->Event_History_Items[0].source_id = source_id;
event_struct->Event_History_Items[0].target_id = target_id;
event_struct->Event_History_Items[0].channel = channel; //need to add this to trunking messages, if tuned from call grant
if (opts->playfiles == 0) //if playing back .mbe files with a time in it, don't set this
event_struct->Event_History_Items[0].event_time = time(NULL);
sprintf (event_struct->Event_History_Items[0].sysid_string, "%s", sysid_string);
sprintf (event_struct->Event_History_Items[0].src_str, "%s", src_str);
sprintf (event_struct->Event_History_Items[0].tgt_str, "%s", tgt_str);
sprintf (event_struct->Event_History_Items[0].t_name, "%s", t_name);
sprintf (event_struct->Event_History_Items[0].s_name, "%s", s_name);
sprintf (event_struct->Event_History_Items[0].t_mode, "%s", t_mode);
sprintf (event_struct->Event_History_Items[0].s_mode, "%s", s_mode);
}
//Craft an event string for ncurses event history, and a more complex string for logging
char event_string[2000]; memset(event_string, 0, sizeof(event_string));
//WIP: Seperate Voice Call Event Strings when SRC/TGT values are numerical,
//and a seperate one for when they are string values (M17, YSF, DSTAR, and dPMR, or use special formatting)
if (state->lastsynctype == 30 || state->lastsynctype == 31) //YSF Fusion //TODO: Data calls dumping a lot of events as VOICE
{
//TODO: See if we can add some decoded data as well in the future to an event string
sprintf (event_string, "%s %s %s TGT: %s SRC: %s ", datestr, timestr, sys_string, state->ysf_tgt, state->ysf_src);
}
else if (state->lastsynctype == 16 || state->lastsynctype == 17) //M17
{
//TODO: See if we can add some decoded data as well in the future to an event string
if (state->m17_dst == 0xFFFFFFFFFFFF)
sprintf (event_string, "%s %s %s TGT: %s SRC: %s CAN: %02d;", datestr, timestr, sys_string, "BROADCAST", state->m17_src_str, state->m17_can);
else
sprintf (event_string, "%s %s %s TGT: %s SRC: %s CAN: %02d;", datestr, timestr, sys_string, state->m17_dst_str, state->m17_src_str, state->m17_can);
}
else if (state->lastsynctype == 6 || state->lastsynctype == 7 || state->lastsynctype == 18 || state->lastsynctype == 19) //DSTAR
{
//TODO: See if we can add some decoded data as well in the future to an event string
sprintf (event_string, "%s %s %s TGT: %s SRC: %s ", datestr, timestr, sys_string, state->dstar_dst, state->dstar_src);
}
else if (state->lastsynctype == 20 || state->lastsynctype == 24 || state->lastsynctype == 21 || state->lastsynctype == 25 || state->lastsynctype == 22 || state->lastsynctype == 26 || state->lastsynctype == 23 || state->lastsynctype == 27) //dPMR
{
//TODO: See if we can add some decoded data as well in the future to an event string
sprintf (event_string, "%s %s %s CC: %02d; TGT: %s; SRC: %s; ", datestr, timestr, sys_string, state->dpmr_color_code, state->dpmr_target_id, state->dpmr_caller_id);
if (state->dPMRVoiceFS2Frame.Version[0] == 3)
strcat (event_string, "Scrambler Enc; ");
}
else if (state->lastsynctype == 14 || state->lastsynctype == 15 || state->lastsynctype == 37 || state->lastsynctype == 38) //EDACS Calls
{
svc_opts = state->edacs_vc_call_type;
char sup_str[200]; memset (sup_str, 0, sizeof(sup_str));
sprintf (sup_str, "%s", "");
if (svc_opts & 0x02)
strcat (sup_str, "Digital ");
else strcat (sup_str, "Analog ");
if (svc_opts & 0x04)
strcat (sup_str, "Emergency ");
if (svc_opts & 0x08)
strcat (sup_str, "Group ");
if (svc_opts & 0x10)
strcat (sup_str, "I ");
if (svc_opts & 0x20)
strcat (sup_str, "ALL ");
if (svc_opts & 0x40)
strcat (sup_str, "INTER ");
if (svc_opts & 0x80)
strcat (sup_str, "TEST ");
if (svc_opts & 0x100)
strcat (sup_str, "AGENCY ");
if (svc_opts & 0x200)
strcat (sup_str, "FLEET ");
if (svc_opts & 0x01)
strcat (sup_str, "Voice ");
strcat (sup_str, "Call");
if (state->ea_mode == 1)
{
sprintf (event_string, "%s %s %s TGT: %07d; SRC: %07d; LCN: %02d; SITE: %d:%d.%04X; %s;", datestr, timestr, sys_string, target_id, source_id, channel, sys_id1, sys_id2, sys_id3, sup_str);
}
else
{
int afs = state->lasttg;
int a = (afs >> state->edacs_a_shift) & state->edacs_a_mask;
int f = (afs >> state->edacs_f_shift) & state->edacs_f_mask;
int s = afs & state->edacs_s_mask;
char afs_str[8];
getAfsString(state, afs_str, a, f, s);
char lid_str[20]; memset(lid_str, 0, sizeof(lid_str));
sprintf(lid_str, "%s", "");
if (state->lastsrc != 0 && state->lastsrc != 0x800)
sprintf (lid_str, "LID: %05d;", state->lastsrc);
else sprintf (lid_str, "LID: __UNK;");
sprintf (event_string, "%s %s %s AFS: %s (%04d); %s LCN: %02d; Site: %d; %s; ", datestr, timestr, sys_string, afs_str, afs, lid_str, channel, sys_id1, sup_str);
}
}
else if (state->lastsynctype == 10 || state->lastsynctype == 11 || state->lastsynctype == 12 || state->lastsynctype == 13 ||
state->lastsynctype == 32 || state->lastsynctype == 33 || state->lastsynctype == 34 ) //DMR
{
if (sys_id1)
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; CC: %02d; SYS: %X; ", datestr, timestr, sys_string, target_id, source_id, sys_id2, sys_id1);
else
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; CC: %02d; ", datestr, timestr, sys_string, target_id, source_id, sys_id2);
if (enc)
strcat(event_string, "ENC; ");
if (alg_id != 0)
{
char ess_str[30];
sprintf (ess_str, "ALG: %02X; KID: %02X; ", alg_id, key_id);
strcat(event_string, ess_str);
}
//monitor for misc link control that may set a SO without having SO inside of it,
//those could cause misc issues here, will need to observe and make adjustments
if (svc_opts & 0x80)
strcat (event_string, "Emergency; ");
if (svc_opts & 0x08)
strcat (event_string, "Broadcast; ");
if (svc_opts & 0x04)
strcat (event_string, "OVCM; ");
if (state->gi[slot] == 0)
strcat (event_string, "Group; ");
else if (state->gi[slot] == 1)
strcat (event_string, "Private; ");
if (mfid == 0x10)
{
if (svc_opts & 0x20)
strcat (event_string, "TXI; ");
else if (svc_opts & 0x10)
strcat (event_string, "TXI; "); //this is the svc opt bit that tells you when the next VC6 will be pre-empted, but not helpful here
if (svc_opts & 0x03)
strcat (event_string, "PRIORITY; "); //need to break this apart into each one, but need to double check the decoded value is accurate
}
}
else if (state->lastsynctype == 0 || state->lastsynctype == 1 || state->lastsynctype == 35 || state->lastsynctype == 36)
{
if (sys_id1)
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; NAC: %03X; NET_STS: %05X:%03X:%d.%d; ", datestr, timestr, sys_string, target_id, source_id, sys_id3, sys_id1, sys_id2, sys_id4, sys_id5);
else
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; NAC: %03X; ", datestr, timestr, sys_string, target_id, source_id, sys_id3);
if (alg_id != 0 && alg_id != 0x80)
{
char ess_str[30];
sprintf (ess_str, "ENC; ALG: %02X; KID: %04X; ", alg_id, key_id);
strcat(event_string, ess_str);
}
if (svc_opts & 0x80)
strcat (event_string, "Emergency; ");
if (state->gi[slot] == 0)
strcat (event_string, "Group; ");
else if (state->gi[slot] == 1)
strcat (event_string, "Private; ");
}
else if (state->lastsynctype == 28 || state->lastsynctype == 29)
{
if (sys_id1)
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; RAN: %02d; SYS: %d.%d; ", datestr, timestr, sys_string, target_id, source_id, sys_id3, sys_id2, sys_id1);
else
sprintf (event_string, "%s %s %s TGT: %08d; SRC: %08d; RAN: %02d; ", datestr, timestr, sys_string, target_id, source_id, sys_id3);
if (enc)
strcat(event_string, "ENC; ");
if (alg_id != 0)
{
char ess_str[30];
sprintf (ess_str, "ALG: %d; KID: %02X; ", alg_id, key_id);
strcat(event_string, ess_str);
}
if (state->gi[slot] == 0)
strcat (event_string, "Group; ");
else if (state->gi[slot] == 1)
strcat (event_string, "Private; ");
}
if (t_name_loaded)
{
char group[420];
sprintf (group, "TName: %s; Mode: %s; ", t_name, t_mode);
strcat (event_string, group);
}
if (s_name_loaded)
{
char private[420];
sprintf (private, "SName: %s; Mode: %s; ", s_name, s_mode);
strcat (event_string, private);
}
sprintf (event_struct->Event_History_Items[0].event_string, "%s", event_string);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
void watchdog_event_datacall (dsd_opts * opts, dsd_state * state, uint32_t src, uint32_t dst, char * data_string, uint8_t slot)
{
UNUSED(opts);
state->event_history_s[slot].Event_History_Items[0].write = 0;
if (state->event_history_s[slot].Event_History_Items[0].color_pair == 4) //if not set previously by specific decoder //don't touch this one
state->event_history_s[slot].Event_History_Items[0].color_pair = 4; //default data color //you can change this one
state->event_history_s[slot].Event_History_Items[0].systype = state->lastsynctype;
state->event_history_s[slot].Event_History_Items[0].subtype = 6; //data
state->event_history_s[slot].Event_History_Items[0].gi = state->gi[slot];
state->event_history_s[slot].Event_History_Items[0].enc = 0;
state->event_history_s[slot].Event_History_Items[0].enc_alg = 0;
state->event_history_s[slot].Event_History_Items[0].enc_key = 0;
state->event_history_s[slot].Event_History_Items[0].mi = 0;
state->event_history_s[slot].Event_History_Items[0].svc = 0;
state->event_history_s[slot].Event_History_Items[0].source_id = src;
state->event_history_s[slot].Event_History_Items[0].target_id = dst;
state->event_history_s[slot].Event_History_Items[0].channel = 0;
state->event_history_s[slot].Event_History_Items[0].event_time = time(NULL);
//date and time strings //getTimeN(time(NULL)); //getDateN(time(NULL));
char * timestr = getTimeN(time(NULL));
char * datestr = getDateN(time(NULL));
char event_string[2000]; memset (event_string, 0, sizeof(event_string));
sprintf (event_string, "%s %s ", datestr, timestr);
strcat (event_string, data_string); //may need to check for potential overflow of this
sprintf (state->event_history_s[slot].Event_History_Items[0].event_string, "%s", event_string); //could change this to a strncpy to prevent potential overflow
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
//call alert on data calls
if (opts->call_alert)
beeper (opts, state, slot, 80, 20, 3);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,48 @@
// DMR filter
#include "dsd.h"
//M17 Filter -- RRC Alpha = 0.5 S/s 48000 with 81 taps
#define M17ZEROS 80
float m17gain = 3.16227766f; //sqrt of 10.0f
static float m17xv[81];
//sample RRC filter for 48kHz sample rate
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)
float m17coeffs[81] = //replaced old ones with ones from libm17
{
-0.003195702904062073f, -0.002930279157647190f, -0.001940667871554463f,
-0.000356087678023658f, 0.001547011339077758f, 0.003389554791179751f,
0.004761898604225673f, 0.005310860846138910f, 0.004824746306020221f,
0.003297923526848786f, 0.000958710871218619f, -0.001749908029791816f,
-0.004238694106631223f, -0.005881783042101693f, -0.006150256456781309f,
-0.004745376707651645f, -0.001704189656473565f, 0.002547854551539951f,
0.007215575568844704f, 0.011231038205363532f, 0.013421952197060707f,
0.012730475385624438f, 0.008449554307303753f, 0.000436744366018287f,
-0.010735380379191660f, -0.023726883538258272f, -0.036498030780605324f,
-0.046500883189991064f, -0.050979050575999614f, -0.047340680079891187f,
-0.033554880492651755f, -0.008513823955725943f, 0.027696543159614194f,
0.073664520037517042f, 0.126689053778116234f, 0.182990955139333916f,
0.238080025892859704f, 0.287235637987091563f, 0.326040247765297220f,
0.350895727088112619f, 0.359452932027607974f, 0.350895727088112619f,
0.326040247765297220f, 0.287235637987091563f, 0.238080025892859704f,
0.182990955139333916f, 0.126689053778116234f, 0.073664520037517042f,
0.027696543159614194f, -0.008513823955725943f, -0.033554880492651755f,
-0.047340680079891187f, -0.050979050575999614f, -0.046500883189991064f,
-0.036498030780605324f, -0.023726883538258272f, -0.010735380379191660f,
0.000436744366018287f, 0.008449554307303753f, 0.012730475385624438f,
0.013421952197060707f, 0.011231038205363532f, 0.007215575568844704f,
0.002547854551539951f, -0.001704189656473565f, -0.004745376707651645f,
-0.006150256456781309f, -0.005881783042101693f, -0.004238694106631223f,
-0.001749908029791816f, 0.000958710871218619f, 0.003297923526848786f,
0.004824746306020221f, 0.005310860846138910f, 0.004761898604225673f,
0.003389554791179751f, 0.001547011339077758f, -0.000356087678023658f,
-0.001940667871554463f, -0.002930279157647190f, -0.003195702904062073f
};
// Original DMR filter
#define NZEROS 60
float ngain = 7.423339364f;
static float xv[NZEROS+1];
float xcoeffs[] =
float xcoeffs[61] =
{ -0.0083649323f, -0.0265444850f, -0.0428141462f, -0.0537571943f,
-0.0564141052f, -0.0489161045f, -0.0310068662f, -0.0043393881f,
+0.0275375106f, +0.0595423283f, +0.0857543325f, +0.1003565948f,
@@ -21,70 +61,48 @@ float xcoeffs[] =
-0.0083649323f,
};
// NXDN48 filter
//#define NXZEROS 134
//float nxgain = 15.95930463f;
#define NXZEROS 91 //Osmocom OP25
float nxgain = 1.0f; //Osmocom OP25
//reverted to original NXDN filters, do better with LICH/Data handling
// NXDN48 filter - Original Version
#define NXZEROS 134
float nxgain = 15.95930463f;
static float nxv[NXZEROS+1];
//OP25 Osmocom NXDN48 Coeffs seem to do well, will want to do some VS testing
float nxcoeffs[] =
{ 0.00203767f, 0.00491622f, 0.00748189f, 0.00934561f, 0.01017049f, 0.00972167f,
0.00790748f, 0.00480597f, 0.00067202f, -0.00407743f, -0.00890019f, -0.01318478f,
-0.01632047f, -0.01777371f, -0.01716241f, -0.01431852f, -0.00933066f, -0.00255979f,
0.00537624f, 0.01364992f, 0.02130038f, 0.02733235f, 0.03082824f, 0.03106179f,
0.02760061f, 0.02038545f, 0.00977572f, -0.0034462f, -0.01811514f, -0.03276675f,
-0.04575844f, -0.05541762f, -0.06020353f, -0.0588669f, -0.05059129f, -0.03510097f,
-0.01272309f, 0.01560398f, 0.04837926f, 0.08364189f, 0.11912012f, 0.15241359f,
0.18119246f, 0.20339503f, 0.21740525f, 0.2221932f, 0.21740525f, 0.20339503f,
0.18119246f, 0.15241359f, 0.11912012f, 0.08364189f, 0.04837926f, 0.01560398f,
-0.01272309f, -0.03510097f, -0.05059129f, -0.0588669f, -0.06020353f, -0.05541762f,
-0.04575844f, -0.03276675f, -0.01811514f, -0.0034462f, 0.00977572f, 0.02038545f,
0.02760061f, 0.03106179f, 0.03082824f, 0.02733235f, 0.02130038f, 0.01364992f,
0.00537624f, -0.00255979f, -0.00933066f, -0.01431852f, -0.01716241f, -0.01777371f,
-0.01632047f, -0.01318478f, -0.00890019f, -0.00407743f, 0.00067202f, 0.00480597f,
0.00790748f, 0.00972167f, 0.01017049f, 0.00934561f, 0.00748189f, 0.00491622f,
0.00203767f};
//OLD nxCOEFFS
// { +0.031462429f, +0.031747267f, +0.030401148f, +0.027362877f,
// +0.022653298f, +0.016379869f, +0.008737200f, +0.000003302f,
// -0.009468531f, -0.019262057f, -0.028914291f, -0.037935027f,
// -0.045828927f, -0.052119261f, -0.056372283f, -0.058221106f,
// -0.057387924f, -0.053703443f, -0.047122444f, -0.037734535f,
// -0.025769308f, -0.011595336f, +0.004287292f, +0.021260954f,
// +0.038610717f, +0.055550276f, +0.071252765f, +0.084885375f,
// +0.095646450f, +0.102803611f, +0.105731303f, +0.103946126f,
// +0.097138329f, +0.085197939f, +0.068234131f, +0.046586711f,
// +0.020828821f, -0.008239664f, -0.039608255f, -0.072081234f,
// -0.104311776f, -0.134843790f, -0.162160200f, -0.184736015f,
// -0.201094346f, -0.209863285f, -0.209831516f, -0.200000470f,
// -0.179630919f, -0.148282051f, -0.105841323f, -0.052543664f,
// +0.011020985f, +0.083912428f, +0.164857408f, +0.252278939f,
// +0.344336996f, +0.438979335f, +0.534000832f, +0.627109358f,
// +0.715995947f, +0.798406824f, +0.872214756f, +0.935487176f,
// +0.986548646f, +1.024035395f, +1.046939951f, +1.054644241f,
// +1.046939951f, +1.024035395f, +0.986548646f, +0.935487176f,
// +0.872214756f, +0.798406824f, +0.715995947f, +0.627109358f,
// +0.534000832f, +0.438979335f, +0.344336996f, +0.252278939f,
// +0.164857408f, +0.083912428f, +0.011020985f, -0.052543664f,
// -0.105841323f, -0.148282051f, -0.179630919f, -0.200000470f,
// -0.209831516f, -0.209863285f, -0.201094346f, -0.184736015f,
// -0.162160200f, -0.134843790f, -0.104311776f, -0.072081234f,
// -0.039608255f, -0.008239664f, +0.020828821f, +0.046586711f,
// +0.068234131f, +0.085197939f, +0.097138329f, +0.103946126f,
// +0.105731303f, +0.102803611f, +0.095646450f, +0.084885375f,
// +0.071252765f, +0.055550276f, +0.038610717f, +0.021260954f,
// +0.004287292f, -0.011595336f, -0.025769308f, -0.037734535f,
// -0.047122444f, -0.053703443f, -0.057387924f, -0.058221106f,
// -0.056372283f, -0.052119261f, -0.045828927f, -0.037935027f,
// -0.028914291f, -0.019262057f, -0.009468531f, +0.000003302f,
// +0.008737200f, +0.016379869f, +0.022653298f, +0.027362877f,
// +0.030401148f, +0.031747267f, +0.031462429f,
// };
float nxcoeffs[135] =
{ +0.031462429f, +0.031747267f, +0.030401148f, +0.027362877f,
+0.022653298f, +0.016379869f, +0.008737200f, +0.000003302f,
-0.009468531f, -0.019262057f, -0.028914291f, -0.037935027f,
-0.045828927f, -0.052119261f, -0.056372283f, -0.058221106f,
-0.057387924f, -0.053703443f, -0.047122444f, -0.037734535f,
-0.025769308f, -0.011595336f, +0.004287292f, +0.021260954f,
+0.038610717f, +0.055550276f, +0.071252765f, +0.084885375f,
+0.095646450f, +0.102803611f, +0.105731303f, +0.103946126f,
+0.097138329f, +0.085197939f, +0.068234131f, +0.046586711f,
+0.020828821f, -0.008239664f, -0.039608255f, -0.072081234f,
-0.104311776f, -0.134843790f, -0.162160200f, -0.184736015f,
-0.201094346f, -0.209863285f, -0.209831516f, -0.200000470f,
-0.179630919f, -0.148282051f, -0.105841323f, -0.052543664f,
+0.011020985f, +0.083912428f, +0.164857408f, +0.252278939f,
+0.344336996f, +0.438979335f, +0.534000832f, +0.627109358f,
+0.715995947f, +0.798406824f, +0.872214756f, +0.935487176f,
+0.986548646f, +1.024035395f, +1.046939951f, +1.054644241f,
+1.046939951f, +1.024035395f, +0.986548646f, +0.935487176f,
+0.872214756f, +0.798406824f, +0.715995947f, +0.627109358f,
+0.534000832f, +0.438979335f, +0.344336996f, +0.252278939f,
+0.164857408f, +0.083912428f, +0.011020985f, -0.052543664f,
-0.105841323f, -0.148282051f, -0.179630919f, -0.200000470f,
-0.209831516f, -0.209863285f, -0.201094346f, -0.184736015f,
-0.162160200f, -0.134843790f, -0.104311776f, -0.072081234f,
-0.039608255f, -0.008239664f, +0.020828821f, +0.046586711f,
+0.068234131f, +0.085197939f, +0.097138329f, +0.103946126f,
+0.105731303f, +0.102803611f, +0.095646450f, +0.084885375f,
+0.071252765f, +0.055550276f, +0.038610717f, +0.021260954f,
+0.004287292f, -0.011595336f, -0.025769308f, -0.037734535f,
-0.047122444f, -0.053703443f, -0.057387924f, -0.058221106f,
-0.056372283f, -0.052119261f, -0.045828927f, -0.037935027f,
-0.028914291f, -0.019262057f, -0.009468531f, +0.000003302f,
+0.008737200f, +0.016379869f, +0.022653298f, +0.027362877f,
+0.030401148f, +0.031747267f, +0.031462429f,
};
// DMR filter F4EXB
#define DMRNZEROS 60
@@ -96,20 +114,66 @@ const float dmrgain = 6.82973073748f;
static float dxv[DMRNZEROS+1];
// DMR filter F4EXB - root raised cosine alpha=0.7 Ts = 6650 S/s Fc = 48kHz
const float dmrcoeffs[] =
{0.0301506278, 0.0269200615, 0.0159662432, -0.0013114705, -0.0216605133,
-0.0404938748, -0.0528141756, -0.0543747957, -0.0428325003, -0.0186176083,
0.0147202645, 0.0508418571, 0.0816392577, 0.0988113688, 0.0957187780,
0.0691512084, 0.0206194642, -0.0431564563, -0.1107569268, -0.1675773224,
-0.1981519842, -0.1889130786, -0.1308939560, -0.0218608492, 0.1325685970,
0.3190962499, 0.5182530574, 0.7070497652, 0.8623526878, 0.9644213921,
1.0000000000, 0.9644213921, 0.8623526878, 0.7070497652, 0.5182530574,
0.3190962499, 0.1325685970, -0.0218608492, -0.1308939560, -0.1889130786,
-0.1981519842, -0.1675773224, -0.1107569268, -0.0431564563, 0.0206194642,
0.0691512084, 0.0957187780, 0.0988113688, 0.0816392577, 0.0508418571,
0.0147202645, -0.0186176083, -0.0428325003, -0.0543747957, -0.0528141756,
const float dmrcoeffs[61] =
{0.0301506278, 0.0269200615, 0.0159662432, -0.0013114705, -0.0216605133,
-0.0404938748, -0.0528141756, -0.0543747957, -0.0428325003, -0.0186176083,
0.0147202645, 0.0508418571, 0.0816392577, 0.0988113688, 0.0957187780,
0.0691512084, 0.0206194642, -0.0431564563, -0.1107569268, -0.1675773224,
-0.1981519842, -0.1889130786, -0.1308939560, -0.0218608492, 0.1325685970,
0.3190962499, 0.5182530574, 0.7070497652, 0.8623526878, 0.9644213921,
1.0000000000, 0.9644213921, 0.8623526878, 0.7070497652, 0.5182530574,
0.3190962499, 0.1325685970, -0.0218608492, -0.1308939560, -0.1889130786,
-0.1981519842, -0.1675773224, -0.1107569268, -0.0431564563, 0.0206194642,
0.0691512084, 0.0957187780, 0.0988113688, 0.0816392577, 0.0508418571,
0.0147202645, -0.0186176083, -0.0428325003, -0.0543747957, -0.0528141756,
-0.0404938748, -0.0216605133, -0.0013114705, 0.0159662432, 0.0269200615, 0.0301506278};
// dPMR filter, version of F4EXB
static float dpmrxv[NXZEROS+1];
// dPMR filter, version of F4EXB
#define DPMRNZEROS 134
// dPMR filter, version of F4EXB
const float dpmrgain = 14.6083498224f;
// dPMR filter - root raised cosine alpha=0.2 Ts = 3325 S/s Fc = 48 kHz - zero at boundaries appears to be slightly better
const float dpmrcoeffs[135] =
{-0.0000983004, 0.0058388841, 0.0119748846, 0.0179185547, 0.0232592816,
0.0275919612, 0.0305433586, 0.0317982965, 0.0311240307,
0.0283911865, 0.0235897433, 0.0168387650, 0.0083888763,
-0.0013831396, -0.0119878087, -0.0228442151, -0.0333082708,
-0.0427067804, -0.0503756642, -0.0557003599, -0.0581561791,
-0.0573462646, -0.0530347941, -0.0451732069, -0.0339174991,
-0.0196350217, -0.0028997157, 0.0155246961, 0.0347134030,
0.0536202583, 0.0711271166, 0.0861006725, 0.0974542022,
0.1042112035, 0.1055676660, 0.1009496091, 0.0900625944,
0.0729301774, 0.0499186839, 0.0217462748, -0.0105250265,
-0.0455148664, -0.0815673067, -0.1168095612, -0.1492246435,
-0.1767350726, -0.1972941202, -0.2089805758, -0.2100926829,
-0.1992367833, -0.1754063031, -0.1380470370, -0.0871052089,
-0.0230554989, 0.0530929052, 0.1398131936, 0.2351006721,
0.3365341927, 0.4413570929, 0.5465745033, 0.6490630781,
0.7456885564, 0.8334261381, 0.9094784589, 0.9713859928,
1.0171250045, 1.0451886943, 1.0546479089, 1.0451886943,
1.0171250045, 0.9713859928, 0.9094784589, 0.8334261381,
0.7456885564, 0.6490630781, 0.5465745033, 0.4413570929,
0.3365341927, 0.2351006721, 0.1398131936, 0.0530929052,
-0.0230554989, -0.0871052089, -0.1380470370, -0.1754063031,
-0.1992367833, -0.2100926829, -0.2089805758, -0.1972941202,
-0.1767350726, -0.1492246435, -0.1168095612, -0.0815673067,
-0.0455148664, -0.0105250265, 0.0217462748, 0.0499186839,
0.0729301774, 0.0900625944, 0.1009496091, 0.1055676660,
0.1042112035, 0.0974542022, 0.0861006725, 0.0711271166,
0.0536202583, 0.0347134030, 0.0155246961, -0.0028997157,
-0.0196350217, -0.0339174991, -0.0451732069, -0.0530347941,
-0.0573462646, -0.0581561791, -0.0557003599, -0.0503756642,
-0.0427067804, -0.0333082708, -0.0228442151, -0.0119878087,
-0.0013831396, 0.0083888763, 0.0168387650, 0.0235897433,
0.0283911865, 0.0311240307, 0.0317982965, 0.0305433586,
0.0275919612, 0.0232592816, 0.0179185547, 0.0119748846,
0.0058388841, -0.0000983004};
short dsd_input_filter(short sample, int mode);
@@ -123,7 +187,18 @@ dmr_filter(short sample)
short
nxdn_filter(short sample)
{
return dsd_input_filter(sample, 2);
return dsd_input_filter(sample, 4);
}
short
dpmr_filter(short sample)
{
return dsd_input_filter(sample, 4);
}
short m17_filter (short sample)
{
return dsd_input_filter(sample, 5);
}
@@ -144,7 +219,7 @@ dsd_input_filter(short sample, int mode)
case 2:
gain = nxgain;
v = nxv;
coeffs = nxcoeffs;
coeffs = (float *)nxcoeffs;
zeros = NXZEROS;
break;
case 3:
@@ -153,18 +228,41 @@ dsd_input_filter(short sample, int mode)
coeffs = (float *)dmrcoeffs;
zeros = DMRNZEROS;
break;
case 4:
gain = dpmrgain;
v = dpmrxv;
coeffs = (float *)dpmrcoeffs;
zeros = DPMRNZEROS;
break;
case 5:
gain = m17gain;
v = m17xv;
coeffs = (float *)m17coeffs;
zeros = M17ZEROS;
break;
default:
return sample;
}
for (i = 0; i < zeros; i++)
v[i] = v[i+1];
v[zeros] = sample; // unfiltered sample in
v[zeros] = (float)sample; // unfiltered sample in
sum = 0.0f;
for (i = 0; i <= zeros; i++)
sum += (coeffs[i] * v[i]);
return (short)(sum / gain); // filtered sample out
}
void init_rrc_filter_memory()
{
memset (m17xv, 0, 81*sizeof(float));
memset (xv, 0, 61*sizeof(float));
memset (dxv, 0, 61*sizeof(float));
memset (nxv, 0, 135*sizeof(float));
memset (dpmrxv, 0, 135*sizeof(float));
}

View File

@@ -26,29 +26,23 @@ void
printFrameInfo (dsd_opts * opts, dsd_state * state)
{
int level;
UNUSED(opts);
level = (int) state->max / 164;
if (opts->verbose > 0)
{
//fprintf (stderr,"inlvl: %2i%% ", level);
}
if (state->nac != 0)
{
fprintf (stderr, "%s", KCYN);
fprintf (stderr,"nac: [%4X] ", state->nac);
fprintf (stderr, "%s", KNRM);
}
fprintf (stderr, "%s", KCYN);
if (state->p2_wacn != 0)
fprintf (stderr, "WACN: %05llX; ", state->p2_wacn);
if (state->p2_sysid != 0)
fprintf (stderr, "SYS: %03llX; ", state->p2_sysid);
if (state->p2_cc != 0)
fprintf (stderr, "NAC/CC: %03llX; ", state->p2_cc);
else fprintf (stderr, "NAC: %03X; ", state->nac);
if (opts->verbose > 1)
{
fprintf (stderr, "%s", KGRN);
fprintf (stderr,"src: [%8i] ", state->lastsrc);
fprintf (stderr, "%s", KNRM);
}
fprintf (stderr, "%s", KGRN);
fprintf (stderr,"tg: [%5i] ", state->lasttg);
if (state->p2_rfssid != 0)
fprintf (stderr, "RFSS: %03lld; ", state->p2_rfssid);
if (state->p2_siteid != 0)
fprintf (stderr, "Site: %03lld; ", state->p2_siteid);
fprintf (stderr, "%s", KNRM);
}
void
@@ -59,8 +53,10 @@ processFrame (dsd_opts * opts, dsd_state * state)
char duid[3];
char nac[13];
int level;
UNUSED2(nac, level);
char status_0;
UNUSED(status_0);
char bch_code[63];
int index_bch_code;
unsigned char parity;
@@ -84,184 +80,133 @@ processFrame (dsd_opts * opts, dsd_state * state)
state->minref = state->min;
}
if ((state->synctype == 8) || (state->synctype == 9)) //NXDN Voice
{
//state->rf_mod = 2; //wrong type of modulation HERE HERE
state->nac = 0;
state->lastsrc = 0;
state->lasttg = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr, "inlvl: %2i%% ", level);
}
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " VOICE ");
processNXDNVoice (opts, state);
//ProcessNXDNFrame (opts, state, 0);
return;
}
else if ((state->synctype == 16) || (state->synctype == 17)) //NXDN Data
{
//state->rf_mod = 2;
state->nac = 0;
state->lastsrc = 0;
state->lasttg = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr, "inlvl: %2i%% ", level);
}
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " DATA ");
processNXDNData (opts, state);
//ProcessNXDNFrame (opts, state, 0);
return;
}
//NXDN FSW
if ((state->synctype == 28) || (state->synctype == 29))
{
//MBEout restored, is not handled internally by nxdn_frame.c
nxdn_frame (opts, state);
return;
}
//DSTAR
else if ((state->synctype == 6) || (state->synctype == 7))
{
state->nac = 0;
state->lastsrc = 0;
state->lasttg = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " VOICE ");
processDSTAR (opts, state);
return;
}
{
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
openMbeOutFile (opts, state);
sprintf (state->fsubtype, " VOICE ");
processDSTAR (opts, state);
return;
}
else if ((state->synctype == 18) || (state->synctype == 19))
{
state->nac = 0;
state->lastsrc = 0;
state->lasttg = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " DATA ");
processDSTAR_HD (opts, state);
return;
}
{
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
openMbeOutFile (opts, state);
sprintf (state->fsubtype, " DATA ");
processDSTAR_HD (opts, state);
return;
}
//Start DMR Types
else if ((state->synctype >= 10) && (state->synctype <= 13) || (state->synctype == 32) || (state->synctype == 33) || (state->synctype == 34) ) //32-34 DMR MS and RC
else if ((state->synctype >= 10 && state->synctype <= 13) || (state->synctype == 32) || (state->synctype == 33) || (state->synctype == 34) ) //32-34 DMR MS and RC
{
//print manufacturer strings to branding, disabled 0x10 moto other systems can use that fid set
//0x06 is trident, but when searching, apparently, they developed con+, but was bought by moto?
if (state->dmr_mfid == 0x10) ; //sprintf (state->dmr_branding, "%s", "Motorola");
else if (state->dmr_mfid == 0x68) sprintf (state->dmr_branding, "%s", " Hytera");
else if (state->dmr_mfid == 0x58) sprintf (state->dmr_branding, "%s", " Tait");
//disabling these due to random data decodes setting an odd mfid, could be legit, but only for that one packet?
//or, its just a decode error somewhere
// else if (state->dmr_mfid == 0x20) sprintf (state->dmr_branding, "%s", "JVC Kenwood");
// else if (state->dmr_mfid == 0x04) sprintf (state->dmr_branding, "%s", "Flyde Micro");
// else if (state->dmr_mfid == 0x05) sprintf (state->dmr_branding, "%s", "PROD-EL SPA");
// else if (state->dmr_mfid == 0x06) sprintf (state->dmr_branding, "%s", "Motorola"); //trident/moto con+
// else if (state->dmr_mfid == 0x07) sprintf (state->dmr_branding, "%s", "RADIODATA");
// else if (state->dmr_mfid == 0x08) sprintf (state->dmr_branding, "%s", "Hytera");
// else if (state->dmr_mfid == 0x09) sprintf (state->dmr_branding, "%s", "ASELSAN");
// else if (state->dmr_mfid == 0x0A) sprintf (state->dmr_branding, "%s", "Kirisun");
// else if (state->dmr_mfid == 0x0B) sprintf (state->dmr_branding, "%s", "DMR Association");
// else if (state->dmr_mfid == 0x13) sprintf (state->dmr_branding, "%s", "EMC S.P.A.");
// else if (state->dmr_mfid == 0x1C) sprintf (state->dmr_branding, "%s", "EMC S.P.A.");
// else if (state->dmr_mfid == 0x33) sprintf (state->dmr_branding, "%s", "Radio Activity");
// else if (state->dmr_mfid == 0x3C) sprintf (state->dmr_branding, "%s", "Radio Activity");
// else if (state->dmr_mfid == 0x77) sprintf (state->dmr_branding, "%s", "Vertex Standard");
//disable so radio id doesn't blink in and out during ncurses and aggressive_framesync
state->nac = 0;
//state->lastsrc = 0;
//state->lasttg = 0;
//state->lastsrcR = 0;
//state->lasttgR = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
}
if ( (state->synctype == 11) || (state->synctype == 12) || (state->synctype == 32) ) //DMR Voice Modes
{
sprintf (state->fsubtype, " VOICE ");
if (opts->dmr_stereo == 0 && state->synctype < 32)
{
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL) && opts->dmr_stereo == 0)
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " VOICE ");
if (opts->dmr_stereo == 0 && state->synctype < 32) // -T option for DMR (TDMA) stereo
{
sprintf (state->slot1light, " slot1 ");
sprintf (state->slot2light, " slot2 ");
processDMRvoice (opts, state);
}
if (opts->dmr_stereo == 0 && state->synctype == 32)
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, "Please use XDMA or DMR Stereo to decode MS/Simplex \n");
fprintf (stderr, "%s", KNRM);
}
if (opts->dmr_stereo == 1) //opts->dmr_stereo == 1
{
state->dmr_stereo = 1; //set the state to 1 when handling pure voice frames
if (state->synctype > 31 )
{
dmrMSBootstrap (opts, state); //bootstrap into MS Bootstrap (voice only)
}
else dmrBSBootstrap (opts, state); //bootstrap into BS Bootstrap
}
sprintf (state->slot1light, " slot1 ");
sprintf (state->slot2light, " slot2 ");
//we can safely open MBE on any MS or mono handling
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
if (opts->p25_trunk == 0) dmrMSBootstrap (opts, state);
}
if (opts->dmr_mono == 1 && state->synctype == 32)
{
//we can safely open MBE on any MS or mono handling
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
if (opts->p25_trunk == 0) dmrMSBootstrap (opts, state);
}
if (opts->dmr_stereo == 1) //opts->dmr_stereo == 1
{
state->dmr_stereo = 1; //set the state to 1 when handling pure voice frames
if (state->synctype > 31 )
{
//we can safely open MBE on any MS or mono handling
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
if (opts->p25_trunk == 0) dmrMSBootstrap (opts, state); //bootstrap into MS Bootstrap (voice only)
}
else dmrBSBootstrap (opts, state); //bootstrap into BS Bootstrap
}
}
else if ( (state->synctype == 33) || (state->synctype == 34) ) //MS Data and RC data
{
if (opts->dmr_stereo == 0)
{
closeMbeOutFile (opts, state);
state->err_str[0] = 0;
fprintf (stderr, "%s", KRED);
fprintf (stderr, "Please use XDMA or DMR Stereo to decode MS/Simplex \n");
fprintf (stderr, "%s", KNRM);
}
if (opts->dmr_stereo == 1)
{
dmrMSData (opts, state);
}
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
if (opts->p25_trunk == 0) dmrMSData (opts, state);
}
else
{
if (opts->dmr_stereo == 0)
{
closeMbeOutFile (opts, state);
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
state->err_str[0] = 0;
sprintf (state->slot1light, " slot1 ");
sprintf (state->slot2light, " slot2 ");
state->payload_miP = 0; //zero out when switching back to data sync
processDMRdata (opts, state);
dmr_data_sync (opts, state);
}
//switch dmr_stereo to 0 when handling BS data frame syncs with processDMRdata
if (opts->dmr_stereo == 1)
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
state->dmr_stereo = 0; //set the state to zero for handling pure data frames
sprintf (state->slot1light, " slot1 ");
sprintf (state->slot2light, " slot2 ");
state->payload_miP = 0; //zero out when switching back to data sync
processDMRdata (opts, state);
dmr_data_sync (opts, state);
}
}
return;
}
else if ((state->synctype >= 2) && (state->synctype <= 5))
//X2-TDMA
else if ((state->synctype >= 2) && (state->synctype <= 5))
{
state->nac = 0;
if (opts->errorbars == 1)
@@ -271,15 +216,15 @@ processFrame (dsd_opts * opts, dsd_state * state)
if ((state->synctype == 3) || (state->synctype == 4))
{
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " VOICE ");
processX2TDMAvoice (opts, state);
}
else
{
closeMbeOutFile (opts, state);
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
state->err_str[0] = 0;
processX2TDMAdata (opts, state);
}
@@ -287,48 +232,57 @@ processFrame (dsd_opts * opts, dsd_state * state)
}
else if ((state->synctype == 14) || (state->synctype == 15))
{
state->nac = 0;
state->lastsrc = 0;
state->lasttg = 0;
if (opts->errorbars == 1)
{
if (opts->verbose > 0)
{
if (opts->verbose > 0)
{
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
level = (int) state->max / 164;
//fprintf (stderr,"inlvl: %2i%% ", level);
}
}
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
{
openMbeOutFile (opts, state);
}
sprintf (state->fsubtype, " VOICE ");
processProVoice (opts, state);
return;
}
//edacs
else if ((state->synctype == 37) || (state->synctype == 38))
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
edacs (opts, state);
return;
}
//ysf
else if ((state->synctype == 30) || (state->synctype == 31))
{
//Do stuff
//fprintf(stderr, "YSF Sync! \n");
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
//openMbeOutFile (opts, state);
}
//sprintf(state->fsubtype, " VOICE ");
//relocate MBEout to inside frame handling -- Not Working Currently for YSF
processYSF(opts, state);
return;
}
//M17
else if ((state->synctype == 16) || (state->synctype == 9) || (state->synctype == 17) || (state->synctype == 8) ||
(state->synctype == 76) || (state->synctype == 77) || (state->synctype == 86) || (state->synctype == 87) ||
(state->synctype == 99) || (state->synctype == 98) )
{
if (state->synctype == 98 || state->synctype == 99) //preamble only
skipDibit(opts, state, 8); //skip dibits to prime the demodulator
else if (state->synctype == 16 || state->synctype == 17)
processM17STR(opts, state);
else if (state->synctype == 76 || state->synctype == 77) {} //Not available yet
// processM17BRT(opts, state); //Not available yet
else if (state->synctype == 86 || state->synctype == 87)
processM17PKT(opts, state);
else
processM17LSF(opts, state);
return;
}
//P25 P2
else if ((state->synctype == 35) || (state->synctype == 36))
{
//Do stuff
//fprintf(stderr, "YSF Sync! \n");
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
//openMbeOutFile (opts, state);
}
//sprintf(state->fsubtype, " VOICE ");
//relocate MBEout to inside frame handling
processP2(opts, state);
return;
}
@@ -337,6 +291,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
{
/* dPMR Frame Sync 1 */
fprintf(stderr, "dPMR Frame Sync 1 ");
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
else if ((state->synctype == 21) || (state->synctype == 25))
{
@@ -355,12 +310,12 @@ processFrame (dsd_opts * opts, dsd_state * state)
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf(state->fsubtype, " VOICE ");
processdPMRvoice (opts, state);
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf(state->fsubtype, " VOICE ");
processdPMRvoice (opts, state);
return;
@@ -369,11 +324,13 @@ processFrame (dsd_opts * opts, dsd_state * state)
{
/* dPMR Frame Sync 3 */
fprintf(stderr, "dPMR Frame Sync 3 ");
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
else if ((state->synctype == 23) || (state->synctype == 27))
{
/* dPMR Frame Sync 4 */
fprintf(stderr, "dPMR Frame Sync 4 ");
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
//dPMR
else //P25
@@ -446,7 +403,8 @@ processFrame (dsd_opts * opts, dsd_state * state)
if (new_nac != state->nac) {
// NAC fixed by error correction
state->nac = new_nac;
if (state->p2_hardset == 0 && new_nac != 0)
//apparently, both 0 and 0xFFF can the BCH code on signal drop
if (state->p2_hardset == 0 && new_nac != 0 && new_nac != 0xFFF)
{
state->p2_cc = new_nac;
}
@@ -472,15 +430,15 @@ processFrame (dsd_opts * opts, dsd_state * state)
{
// Header Data Unit
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," HDU\n");
}
{
printFrameInfo (opts, state);
fprintf (stderr," HDU\n");
}
if (opts->mbe_out_dir[0] != 0)
{
closeMbeOutFile (opts, state);
openMbeOutFile (opts, state);
}
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_f == NULL) openMbeOutFile (opts, state);
}
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
state->lastp25type = 2;
state->dmrburstL = 25;
@@ -492,26 +450,22 @@ processFrame (dsd_opts * opts, dsd_state * state)
{
// Logical Link Data Unit 1
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," LDU1 ");
}
{
printFrameInfo (opts, state);
fprintf (stderr," LDU1 ");
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f == NULL)
{
if (opts->mbe_out_f == NULL)
{
openMbeOutFile (opts, state);
}
openMbeOutFile (opts, state);
}
}
state->lastp25type = 1;
state->dmrburstL = 26;
state->currentslot = 0;
sprintf (state->fsubtype, " LDU1 ");
state->numtdulc = 0;
if (state->payload_algid == 0x81)
{
fprintf (stderr, "\n");
}
processLDU1 (opts, state);
}
@@ -523,27 +477,27 @@ processFrame (dsd_opts * opts, dsd_state * state)
if (state->lastp25type != 1)
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr,"\n Ignoring LDU2 not preceeded by LDU1\n");
}
{
printFrameInfo (opts, state);
fprintf (stderr,"\n Ignoring LDU2 not preceeded by LDU1\n");
}
state->lastp25type = 0;
sprintf (state->fsubtype, " ");
}
else
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," LDU2 ");
}
{
printFrameInfo (opts, state);
fprintf (stderr," LDU2 ");
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f == NULL)
{
if (opts->mbe_out_f == NULL)
{
openMbeOutFile (opts, state);
}
openMbeOutFile (opts, state);
}
}
state->lastp25type = 2;
sprintf (state->fsubtype, " LDU2 ");
state->numtdulc = 0;
@@ -555,25 +509,25 @@ processFrame (dsd_opts * opts, dsd_state * state)
// Terminator with subsequent Link Control
state->dmrburstL = 28;
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," TDULC\n");
}
{
printFrameInfo (opts, state);
fprintf (stderr," TDULC\n");
}
if (opts->mbe_out_dir[0] != 0)
{
closeMbeOutFile (opts, state);
}
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
state->lasttg = 0;
state->lastsrc = 0;
// state->lasttg = 0;
// state->lastsrc = 0;
state->lastp25type = 0;
state->err_str[0] = 0;
sprintf (state->fsubtype, " TDULC ");
state->numtdulc++;
if ((opts->resume > 0) && (state->numtdulc > opts->resume))
{
resumeScan (opts, state);
}
{
resumeScan (opts, state);
}
processTDULC (opts, state);
state->err_str[0] = 0;
}
@@ -582,14 +536,14 @@ processFrame (dsd_opts * opts, dsd_state * state)
// Terminator without subsequent Link Control
state->dmrburstL = 28;
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," TDU\n");
}
{
printFrameInfo (opts, state);
fprintf (stderr," TDU\n");
}
if (opts->mbe_out_dir[0] != 0)
{
closeMbeOutFile (opts, state);
}
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
state->lasttg = 0;
state->lastsrc = 0;
@@ -603,120 +557,59 @@ processFrame (dsd_opts * opts, dsd_state * state)
{
state->dmrburstL = 29;
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," TSBK");
}
{
printFrameInfo (opts, state);
fprintf (stderr," TSBK");
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
}
if (opts->resume > 0)
{
resumeScan (opts, state);
}
{
resumeScan (opts, state);
}
state->lasttg = 0;
state->lastsrc = 0;
state->lastp25type = 3;
sprintf (state->fsubtype, " TSBK ");
// Now processing NID
processTSBK(opts, state);
}
else if (strcmp (duid, "30") == 0)
{
state->dmrburstL = 29;
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," PDU\n");
}
{
printFrameInfo (opts, state);
fprintf (stderr," MPDU\n"); //multi block format PDU
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
}
if (opts->resume > 0)
{
resumeScan (opts, state);
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f == NULL)
{
openMbeOutFile (opts, state);
}
}
{
resumeScan (opts, state);
}
state->lastp25type = 4;
sprintf (state->fsubtype, " PDU ");
}
// try to guess based on previous frame if unknown type
else if (state->lastp25type == 1)
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr,"(LDU2) ");
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f == NULL)
{
openMbeOutFile (opts, state);
}
}
//state->lastp25type = 0;
// Guess that the state is LDU2
state->lastp25type = 2;
sprintf (state->fsubtype, "(LDU2) ");
state->numtdulc = 0;
processLDU2 (opts, state);
}
else if (state->lastp25type == 2)
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr,"(LDU1) ");
}
if (opts->mbe_out_dir[0] != 0)
{
if (opts->mbe_out_f == NULL)
{
openMbeOutFile (opts, state);
}
}
//state->lastp25type = 0;
// Guess that the state is LDU1
state->lastp25type = 1;
sprintf (state->fsubtype, "(LDU1) ");
state->numtdulc = 0;
processLDU1 (opts, state);
}
else if (state->lastp25type == 3)
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," (TSBK)\n");
}
//state->lastp25type = 0;
// Guess that the state is TSBK
state->lastp25type = 3;
sprintf (state->fsubtype, "(TSBK) ");
sprintf (state->fsubtype, " MPDU ");
// Now processing NID
skipDibit (opts, state, 328-25);
}
else if (state->lastp25type == 4)
{
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," (PDU)\n");
}
state->lastp25type = 0;
processMPDU(opts, state);
}
else
{
state->lastp25type = 0;
sprintf (state->fsubtype, " ");
if (opts->errorbars == 1)
{
state->lastp25type = 0;
sprintf (state->fsubtype, " ");
if (opts->errorbars == 1)
{
printFrameInfo (opts, state);
fprintf (stderr," duid:%s *Unknown DUID*\n", duid); //prints on dPMR frame 3
// fprintf (stderr, "\n"); //prints on dPMR frame 3
}
printFrameInfo (opts, state);
// fprintf (stderr," duid:%s *Unknown DUID*\n", duid);
fprintf (stderr," duid:%s \n", duid); //DUID ERR
}
}
}

File diff suppressed because it is too large Load Diff

837
src/dsd_gps.c Normal file
View File

@@ -0,0 +1,837 @@
/*-------------------------------------------------------------------------------
* dsd_gps.c
* GPS Handling Functions for Various Protocols
*
* LWVMOBILE
* 2023-12 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
void lip_protocol_decoder (dsd_opts * opts, dsd_state * state, uint8_t * input)
{
//NOTE: This is defined in ETSI TS 102 361-4 V1.12.1 (2023-07) p208
//6.6.11.3.2 USBD Polling Service Poll Response PDU for LIP (That's a mouthful)
int slot = state->currentslot;
//May need to set this in the UDT header, or pass it into this function to be sure
// uint32_t src = 0;
// if (slot == 0)
// src = state->lastsrc;
// else src = state->lastsrcR;
//NOTE: This format is pretty much the same as DMR EMB GPS, but has a few extra elements,
//so I got lazy and just lifted most of the code from there, also assuming same lat/lon calcs
//since those have been tested to work in DMR EMB GPS and units are same in LIP
fprintf (stderr, "Location Information Protocol; ");
// uint8_t service_type = (uint8_t)ConvertBitIntoBytes(&input[0], 4); //checked before arrival here
uint8_t time_elapsed = (uint8_t)ConvertBitIntoBytes(&input[6], 2);
uint8_t lon_sign = input[8];
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&input[9], 24); //8, 25
uint8_t lat_sign = input[33];
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&input[34], 23); //33, 24
uint8_t pos_err = (uint8_t)ConvertBitIntoBytes(&input[57], 2);
uint8_t hor_vel = (uint8_t)ConvertBitIntoBytes(&input[59], 7);
uint8_t dir_tra = (uint8_t)ConvertBitIntoBytes(&input[66], 4);
uint8_t reason = (uint8_t)ConvertBitIntoBytes(&input[70], 3);
uint8_t add_hash = (uint8_t)ConvertBitIntoBytes(&input[73], 8); //MS Source Address Hash
//NOTE: May need to use double instead of float to avoid rounding errors
double latitude, longitude = 0.0f;
double lat_unit = (double)180/ pow (2.0, 24); //180 divided by 2^24 -- 6.3.30
double lon_unit = (double)360/ pow (2.0, 25); //360 divided by 2^25 -- 6.3.50
double lon_sf = 1.0f; //float value we can multiple longitude with
double lat_sf = 1.0f; //float value we can multiple latitude with
char latstr[3];
char lonstr[3];
sprintf (latstr, "%s", "N");
sprintf (lonstr, "%s", "E");
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
//lat and lon calculations
if (lat_sign)
{
lat = 0x800001 - lat;
sprintf (latstr, "%s", "S");
lat_sf = -1.0f;
}
latitude = ((double)lat * lat_unit);
if (lon_sign)
{
lon = 0x1000001 - lon;
sprintf (lonstr, "%s", "W");
lon_sf = -1.0f;
}
longitude = ((double)lon * lon_unit);
//6.3.63 Position Error
//6.3.17 Horizontal velocity
/*
Horizontal velocity shall be encoded for speeds 0 km/h to 28 km/h in 1 km/h steps and
from 28 km/h onwards using equation: v = C × (1 + x)^(K-A) + B where:
*/
float v = 0.0f;
float C = 16.0f;
float x = 0.038f;
float A = 13.0f;
float K = (float)hor_vel;
float B = 0.0f;
if (hor_vel > 28)
v = C * (pow(1+x, K-A)) + B; //I think this pow function is set up correctly
else v = (float)hor_vel;
float dir = (((float)dir_tra + 11.25f)/22.5f); //page 68, Table 6.45
//truncated and rounded forms
int vt = (int)v;
int dt = (int)dir;
//sanity check
if (fabs (latitude) < 90 && fabs(longitude) < 180)
{
fprintf (stderr, "Src(Hash); %03d; Lat: %.5lf%s%s Lon: %.5lf%s%s (%.5lf, %.5lf); Spd: %d km/h; Dir: %d%s",add_hash, latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, lat_sf * latitude, lon_sf * longitude, vt, dt, deg_glyph);
//6.3.63 Position Error
uint16_t position_error = 2 * pow(10, pos_err); //2 * 10^pos_err
if (pos_err == 0x7 ) fprintf (stderr, "\n Position Error: Unknown or Invalid;");
else fprintf (stderr, "\n Position Error: Less than %dm;", position_error);
//Reason For Sending 6.6.11.3.3 Table 6.80
if (reason) fprintf (stderr, " Reserved: %d;", reason);
else fprintf (stderr, " Request Response; ");
//6.3.78 Time elapsed
if (time_elapsed == 0) fprintf (stderr, " TE: < 5s;");
if (time_elapsed == 1) fprintf (stderr, " TE: < 5m;");
if (time_elapsed == 2) fprintf (stderr, " TE: < 30m;");
if (time_elapsed == 3) fprintf (stderr, " TE: NA or UNK;"); //not applicable or unknown
//save to array for ncurses
if (pos_err != 0x7)
{
sprintf (state->dmr_embedded_gps[slot], "%03d; LIP: %.5lf%s%s %.5lf%s%s; Err: %dm; Spd: %d km/h; Dir: %d%s", add_hash, latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, position_error, vt, dt, deg_glyph);
}
else sprintf (state->dmr_embedded_gps[slot], "%03d; LIP: %.5lf%s%s %.5lf%s%s Unknown Pos Err; Spd: %d km/h; Dir %d%s", add_hash, latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, vt, dt, deg_glyph);
//save to event history string
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr );
fprintf (pFile, "%08d\t", add_hash);
fprintf (pFile, "%.5lf\t", latitude);
fprintf (pFile, "%.5lf\t", longitude);
fprintf (pFile, "%d\t", vt); //speed in km/h
fprintf (pFile, "%d\t", dt); //direction of travel
fprintf (pFile, "\n");
fclose (pFile);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
}
else fprintf (stderr, " Position Calculation Error;");
}
void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint32_t src, int type)
{
int slot = state->currentslot;
//NOTE: The Only difference between Short (type == 1) and Long Format (type == 2)
//is the utc_ss3 on short vs utc_ss6 and inclusion of COG value on long
//NOTE: MFID Specific Formats are not handled here, unknown, could be added if worked out
//they could share most of the same elements and use the large spare bits in block 2 for extra
// uint8_t mfid = (uint8_t)ConvertBitIntoBytes(&input[88], 8); //on type 3, last octet of first block carries MFID
// uint8_t nmea_c = input[0]; //encrypted -- checked before we get here
uint8_t nmea_ns = input[1]; //north/south (lat sign)
uint8_t nmea_ew = input[2]; //east/west (lon sign)
uint8_t nmea_q = input[3]; //Quality Indicator (no fix or fix valid)
uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[4], 7); //speed in knots (127 = greater than 126 knots)
//Latitude Bits
uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[11], 7); //Latitude Degrees
uint8_t nmea_nmin = (uint8_t)ConvertBitIntoBytes(&input[18], 6); //Latitude Minutes
uint16_t nmea_nminf = (uint16_t)ConvertBitIntoBytes(&input[24], 14); //Latitude Fractions of Minutes
//Longitude Bits
uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[38], 8); //Longitude Degrees
uint8_t nmea_emin = (uint8_t)ConvertBitIntoBytes(&input[46], 6); //Longitude Minutes
uint16_t nmea_eminf = (uint16_t)ConvertBitIntoBytes(&input[52], 14); //Longitude Fractions of Minutes
//UTC Time and COG
uint8_t nmea_utc_hh = (uint8_t)ConvertBitIntoBytes(&input[66], 5);
uint8_t nmea_utc_mm = (uint8_t)ConvertBitIntoBytes(&input[71], 6);
//seconds and the addition of COG is the difference between short and long formats
uint8_t nmea_utc_ss3 = (uint8_t)ConvertBitIntoBytes(&input[77], 3) * 10; //seconds in 10s
uint8_t nmea_utc_ss6 = (uint8_t)ConvertBitIntoBytes(&input[77], 6); //seconds in 1s
uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[103], 9); //course over ground in degrees
//lat and lon conversion
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
float latitude = 0.0f;
float longitude = 0.0f;
// float m_unit = 1.0f / 60.0f; //unit to convert min into decimal value - (1/60)*60 minutes = 1 degree
// float mm_unit = 1.0f / 10000.0f; //unit to convert minf into decimal value - (0000 - 9999) 0.0001×9999 = .9999 minutes, so its sub 1 minute decimal
//testing w/ Harris NMEA like values (ran tests over there with this code, this seems to work on those values)
float m_unit = 1.0f / 60.0f; //unit to convert min into decimal value - (1/60)*60 minutes = 1 degree
float mm_unit = 1.0f / 600000.0f; //unit to convert minf into decimal value - (0000 - 9999) 0.0001×9999 = .9999 minutes, so its sub 1 minute decimal
//speed conversion
float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values
fmps = (float)nmea_speed * 0.514444; UNUSED(fmps);
fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph);
fkph = (float)nmea_speed * 1.852f;
//calculate decimal representation of latidude and longitude (need some samples to test)
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
fprintf (stderr, " GPS: %f%s, %f%s;", latitude, deg_glyph, longitude, deg_glyph);
//Speed in Knots
if (nmea_speed > 126)
fprintf (stderr, " SPD > 126 knots or %f kph;", fkph);
else
fprintf (stderr, " SPD: %d knots; %f kph;", nmea_speed, fkph);
//Print UTC Time and COG according to Format Type
if (type == 1)
fprintf (stderr, " FIX: %d; %02d:%02d:%02d UTC; Short Format;", nmea_q, nmea_utc_hh, nmea_utc_mm, nmea_utc_ss3);
if (type == 2)
fprintf (stderr, " FIX: %d; %02d:%02d:%02d UTC; COG: %d%s; Long Format;", nmea_q, nmea_utc_hh, nmea_utc_mm, nmea_utc_ss6, nmea_cog, deg_glyph);
//save to ncurses string
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
//save to event history string
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "(%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
int s = (int)fkph; //rounded interger format for the log report
int a = 0;
if (type == 2)
a = nmea_cog; //long format only
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr ); //could switch to UTC time if desired, but would require local user offset
fprintf (pFile, "%08d\t", src);
fprintf (pFile, "%.6lf\t", latitude);
fprintf (pFile, "%.6lf\t", longitude);
fprintf (pFile, "%d\t ", s);
fprintf (pFile, "%d\t ", a);
fprintf (pFile, "\n");
fclose (pFile);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
}
//restructured the Harris GPS to flow more like the DMR UDT NMEA Format when possible
void nmea_harris (dsd_opts * opts, dsd_state * state, uint8_t * input, uint32_t src, int slot)
{
//GPS working, Time Working (old method), COG and Speed are logical on due west sample
//TODO: Fiddle/Test various ns and ew bits for proper signs in case its located elsewhere
//UPDATE: Found two contiguous bits that always work on all my accumulated samples
//the bits also place it with the 'lone' flagged bit observed prior
uint8_t nmea_ns = input[88]; //north/south (lat sign) //72 previously used bit
uint8_t nmea_ew = input[89]; //east/west (lon sign) //88 previously used bit
uint8_t nmea_q = input[147]; //Quality Indicator (last fix or current fix)
// uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 7); //129,7
uint8_t nmea_speed = (uint8_t)ConvertBitIntoBytes(&input[129], 6); //this is one bit shorter than called for, but I believe it works
//Latitude Bits
uint8_t nmea_ndeg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //Latitude Degrees
uint8_t nmea_nmin = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //Latitude Minutes
uint16_t nmea_nminf = (uint16_t)ConvertBitIntoBytes(&input[42], 14); //Latitude Fractions of Minutes
//Longitude Bits
uint8_t nmea_edeg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //Longitude Degrees
uint8_t nmea_emin = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //Longitude Minutes
uint16_t nmea_eminf = (uint16_t)ConvertBitIntoBytes(&input[74], 14); //Longitude Fractions of Minutes
//NOTE: Removed UTC hh.mm.ss6 format found in DMR UDT, could not make it work
//with bits already established for time and it works extremely well as is
//Course Over Ground in Degrees (0-360)
uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[135], 9) % 360; //course over ground in degrees //working on due west sample without %360
//timestamp (16-bit value w/ appended 17th bit to MSB)
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16);
rtime |= input[144] << 16; //this bit is flagged on after 0xFFFF rollover in the late afternoon
uint32_t thour = rtime / 3600;
uint32_t tmin = (rtime % 3600) / 60;
uint32_t tsec = (rtime % 3600) % 60;
//lat and lon conversion
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
float latitude = 0.0f;
float longitude = 0.0f;
float m_unit = 1.0f / 60.0f;
float mm_unit = 1.0f / 600000.0f;
//speed conversion
float fmps, fmph, fkph = 0.0f; //conversion of knots to mps, kph, and mph values
fmps = (float)nmea_speed * 0.514444; UNUSED(fmps);
fmph = (float)nmea_speed * 1.15078f; UNUSED(fmph);
fkph = (float)nmea_speed * 1.852f; UNUSED(fkph);
//calculate decimal representation of latidude and longitude (need some samples to test)
latitude = ( (float)nmea_ndeg + ((float)nmea_nmin*m_unit) + ((float)nmea_nminf*mm_unit) );
longitude = ( (float)nmea_edeg + ((float)nmea_emin*m_unit) + ((float)nmea_eminf*mm_unit) );
//This is opposite (seemingly) compared to the version specified by DMR UDT NMEA, could still be different bits involved (to be tested)
// if (nmea_ns) latitude *= -1.0f; //1 is South, 0 is North
// if (nmea_ew) longitude *= -1.0f; //1 is West, 0 is East
//DMR UDT NMEA original version (working now with new bit selection 88 and 89 like how DMR UDT NMEA format specifies)
if (!nmea_ns) latitude *= -1.0f; //0 is South, 1 is North
if (!nmea_ew) longitude *= -1.0f; //0 is West, 1 is East
//is this from LCW, or MAC?
uint16_t header = (uint16_t)ConvertBitIntoBytes(&input[0], 16);
fprintf (stderr, "\n");
if (header == 0x2AA4)
fprintf (stderr, " SRC: %08d;", src);
else
fprintf (stderr, " VCH: %d - SRC: %08d;", slot, src);
fprintf (stderr, " GPS: %f%s, %f%s;", latitude, deg_glyph, longitude, deg_glyph);
//Speed in Knots (assuming in knots, and not in mps, or kph)
if (header != 0x2AA4) //can't yet verify this is present or accurate on LCW
{
if (nmea_speed > 126)
fprintf (stderr, " SPD > 126 knots or %f MPH;", fmph); //using MPH here, its Harris, they're in the U.S.
else
fprintf (stderr, " SPD: %d knots; %f MPH;", nmea_speed, fmph);
}
//Course Over Ground (COG)
fprintf (stderr, " COG: %03d%s;", nmea_cog, deg_glyph); //%360
//debug speed
// fprintf (stderr, " RSPD: %02X;", nmea_speed);
//debug cog
// fprintf (stderr, " RCOG: %03X;", nmea_cog >> 0);
//UTC Time
fprintf (stderr, " T: %02d:%02d:%02d UTC;", thour, tmin, tsec);
//Fix Indicator
if (nmea_q) fprintf (stderr, " Current Fix;");
else fprintf (stderr, " Last Fix;");
//save to ncurses string
sprintf (state->dmr_embedded_gps[slot], "(%f%s, %f%s)", latitude, deg_glyph, longitude, deg_glyph);
//save to event history string
if (state->event_history_s[slot].Event_History_Items[0].source_id == src && src != 0)
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
//rounded interger formats for the log report
int s = (int)fkph;
int a = nmea_cog;
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr ); //could switch to UTC time on PDU if desired
fprintf (pFile, "%08d\t", src);
fprintf (pFile, "%.6lf\t", latitude);
fprintf (pFile, "%.6lf\t", longitude);
fprintf (pFile, "%d\t ", s);
fprintf (pFile, "%d\t ", a);
fprintf (pFile, "\n");
fclose (pFile);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
//NOTE: There seems to be a few more octets left undecoded in this PDU
//not including the CRC obviously, unsure of their meaning, could relate
//to other GPS functions like precision, etc, unknown.
//NOTE2: All these values are just best effort based on observation and
//making map points match using logic and distance over time for speed and course
//without any documentation, any of these values may still be wrong
}
//fallback version (if desired/required)
void harris_gps(dsd_opts * opts, dsd_state * state, int slot, uint8_t * input)
{
uint8_t lat_sign, lat_deg, lat_min = 0;
uint8_t lon_sign, lon_deg, lon_min = 0;
uint16_t lat_mmin = 0;
uint16_t lon_mmin = 0;
//potentially in this PDU, but unverifiable without documentation or reasonable
//mathematical proof vs map points and direction of travel / distance over time (assuming the radio is facing that direction)
uint16_t rspeed = (uint16_t)ConvertBitIntoBytes(&input[136], 8); //MSB //136
rspeed = (rspeed << 8) + (uint16_t)ConvertBitIntoBytes(&input[128], 8); //LSB //128
//this works okay for example of driver driving due west at the speed limit of the road (fluke?)
uint16_t rangle = (uint16_t)ConvertBitIntoBytes(&input[120], 8); //120,8
float fspeed = (float)rspeed;
float fangle = (float)rangle;
fspeed /= 255.0f; //unit value of 1 bit
fspeed *= 1.56f; //this is based on an observation of a driver moving approx 210 meters in about 8 seconds and this makes it just under the speed limit on the road there
// fangle *= 360.0f/255.0f; //unit value of 1 bit
fangle *= 2.0f; //may exceed 360 degrees as is (use %)
int s, a = 0;
s = (int)fspeed * 3.6;
a = (int)fangle % 360;
//fix and quality indicators?
uint8_t fix = input[147]; UNUSED(fix);
uint8_t quality = (uint16_t)ConvertBitIntoBytes(&input[148], 3); UNUSED(quality);
//timestamp (16-bit value w/ appended 17th bit to MSB)
uint32_t rtime = (uint32_t)ConvertBitIntoBytes(&input[104], 16); //seconds since midnight since last GPS fix (whatever the radio has as internal time)
rtime |= input[144] << 16; //test appending this as bit 17 (observed this bit set after the afternoon 0xFFFF rollover)
uint32_t thour = rtime / 3600;
uint32_t tmin = (rtime % 3600) / 60;
uint32_t tsec = (rtime % 3600) % 60;
float lat_dec = 0.0f;
float lon_dec = 0.0f;
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
//This appears to be similar to the NMEA GPGGA format (DDmm.mm) but
//octets are ordered in least significant to most significant value
lat_mmin = (uint16_t)ConvertBitIntoBytes(&input[40], 16); //? bits required, but grabbing two octets
lat_min = (uint8_t)ConvertBitIntoBytes(&input[58], 6); //6 bits required to get 60
lat_deg = (uint8_t)ConvertBitIntoBytes(&input[65], 7); //7 bits required to get 90
lat_sign = input[72]; //64
lon_mmin = (uint16_t)ConvertBitIntoBytes(&input[72], 16); //? bits required, but grabbing two octets
lon_min = (uint8_t)ConvertBitIntoBytes(&input[90], 6); //6 bits required to get 60
lon_deg = (uint8_t)ConvertBitIntoBytes(&input[96], 8); //8 bits required to get 180
lon_sign = input[88]; //88, unsure of a correct location, but on the sample with 0 minutes, this lonely bit was flagged on
int src = 0;
if (slot == 0) src = state->lastsrc;
if (slot == 1) src = state->lastsrcR;
//calculate decimal representation (was a pain to figure out the sub minute values)
lat_dec = ( (float)lat_deg + ((float)lat_min/60.0f) + ((float)lat_mmin/600000.0f) );
lon_dec = ( (float)lon_deg + ((float)lon_min/60.0f) + ((float)lon_mmin/600000.0f) );
if (lat_sign)
lat_dec *= -1.0f;
if (lon_sign)
lon_dec *= -1.0f;
//line break
fprintf (stderr, "\n");
fprintf (stderr, " GPS: %f%s, %f%s;", lat_dec, deg_glyph, lon_dec, deg_glyph);
//gps fix time
// fprintf (stderr, " RT: %05X;", rtime); //debug
fprintf (stderr, " LTS: %02d:%02d:%02d UTC;", thour, tmin, tsec); //last time synced to GPS
//speed and direction
// fprintf (stderr, " RSPD: %04X;", rspeed); //debug
// fprintf (stderr, " RANG: %02X;", rangle); //debug
// fprintf (stderr, " MPS: %06.02f;", fspeed);
// fprintf (stderr, " KPH: %06.02f;", fspeed * 3.6f);
// fprintf (stderr, " MPH: %06.02f;", fspeed * 2.2369f);
fprintf (stderr, " DIR: %03d%s;", a, deg_glyph);
// fprintf (stderr, " FIX: %d", fix);
// fprintf (stderr, " QLT: %02d", quality);
// fprintf (stderr, " SRC: %08d;", src);
//save to array for ncurses
sprintf (state->dmr_embedded_gps[slot], "GPS: (%f%s, %f%s)", lat_dec, deg_glyph, lon_dec, deg_glyph);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr );
fprintf (pFile, "%08d\t", src);
fprintf (pFile, "%.6lf\t", lat_dec);
fprintf (pFile, "%.6lf\t", lon_dec);
fprintf (pFile, "%d\t ", s);
fprintf (pFile, "%d\t ", a);
fprintf (pFile, "\n");
fclose (pFile);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
//NOTE: Thanks to DSheirer (SDRTrunk) for helping me work out a few of the things in here
//not entirely convinced on some of these calcs (speed, angle, and TS) but sure these bits
//are actual speed/direction/timestamps judging from what the coordinates show on a map
}
//externalize embedded GPS - Confirmed working now on NE, NW, SE, and SW coordinates
void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
{
UNUSED(opts);
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " Embedded GPS:");
uint8_t slot = state->currentslot;
uint8_t pf = lc_bits[0];
uint8_t res_a = lc_bits[1];
uint8_t res_b = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 4);
uint8_t pos_err = (uint8_t)ConvertBitIntoBytes(&lc_bits[20], 3);
UNUSED2(res_a, res_b);
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
uint32_t lon_sign = lc_bits[23];
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24);
uint32_t lat_sign = lc_bits[48];
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
double lon_sf = 1.0f; //float value we can multiple longitude with
double lat_sf = 1.0f; //float value we can multiple latitude with
double lat_unit = (double)180/ pow (2.0, 24); //180 divided by 2^24
double lon_unit = (double)360/ pow (2.0, 25); //360 divided by 2^25
char latstr[3];
char lonstr[3];
sprintf (latstr, "%s", "N");
sprintf (lonstr, "%s", "E");
//run calculations and print
//7.2.16 and 7.2.17 (two's compliment)
double latitude = 0;
double longitude = 0;
if (pf) fprintf (stderr, " Protected");
else
{
if (lat_sign)
{
lat = 0x800001 - lat;
sprintf (latstr, "%s", "S");
lat_sf = -1.0f;
}
latitude = ((double)lat * lat_unit);
if (lon_sign)
{
lon = 0x1000001 - lon;
sprintf (lonstr, "%s", "W");
lon_sf = -1.0f;
}
longitude = ((double)lon * lon_unit);
//sanity check
if (fabs(latitude) < 90 && fabs(longitude) < 180)
{
fprintf (stderr, " Lat: %.5lf%s%s Lon: %.5lf%s%s (%.5lf, %.5lf)", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, lat_sf * latitude, lon_sf * longitude);
//7.2.15 Position Error
uint16_t position_error = 2 * pow(10, pos_err); //2 * 10^pos_err
if (pos_err == 0x7 ) fprintf (stderr, "\n Position Error: Unknown or Invalid");
else fprintf (stderr, "\n Position Error: Less than %dm", position_error);
//save to array for ncurses
if (pos_err != 0x7)
{
sprintf (state->dmr_embedded_gps[slot], "GPS: %.5lf%s%s %.5lf%s%s Err: %dm", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, position_error);
}
else sprintf (state->dmr_embedded_gps[slot], "GPS: %.5lf%s%s %.5lf%s%s Unknown Pos Err", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr);
uint32_t src = 0;
if (slot == 0) src = state->lasttg;
if (slot == 1) src = state->lasttgR;
//save to event history string
if (state->event_history_s[slot].Event_History_Items[0].source_id == src)
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr );
fprintf (pFile, "%08d\t", src);
fprintf (pFile, "%.5lf\t", latitude);
fprintf (pFile, "%.5lf\t", longitude);
fprintf (pFile, "0\t " ); //zero for velocity
fprintf (pFile, "0\t " ); //zero for azimuth
fprintf (pFile, "\n");
fclose (pFile);
}
}
}
fprintf (stderr, "%s", KNRM);
}
//This Function needs testing, is tested working for NW and NE lat and
//long coordinates, but not for SE and SW coordinates
void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
{
fprintf (stderr, "%s", KYEL);
fprintf (stderr, " GPS:");
uint8_t slot = state->currentslot;
uint8_t pf = lc_bits[0];
uint8_t res_a = lc_bits[1];
uint8_t res_b = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 7);
uint8_t expired = lc_bits[23]; //this bit seems to indicate that the GPS coordinates are out of date or fresh
char deg_glyph[4];
sprintf (deg_glyph, "%s", "°");
uint32_t lon_sign = lc_bits[48];
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
uint32_t lat_sign = lc_bits[24];
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[25], 23);
double lat_unit = 90.0f / 0x7FFFFF;
double lon_unit = 180.0f / 0x7FFFFF;
char latstr[3];
char lonstr[3];
char valid[12];
sprintf (latstr, "%s", "N");
sprintf (lonstr, "%s", "E");
sprintf (valid, "%s", "Current Fix");
double latitude = 0;
double longitude = 0;
if (pf) fprintf (stderr, " Protected");
else
{
latitude = ((double)lat * lat_unit);
if (lat_sign)
{
latitude -= 90.0f;
sprintf (latstr, "%s", "S");
}
longitude = ((double)lon * lon_unit);
if (lon_sign)
{
longitude -= 180.0f;
sprintf (lonstr, "%s", "W");
}
//sanity check
if (fabs ((float)latitude) < 90 && fabs((float)longitude) < 180)
{
fprintf (stderr, " Lat: %.5lf%s%s Lon: %.5lf%s%s (%.5lf, %.5lf) ", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, latitude, longitude);
if (expired)
{
fprintf (stderr, "Last Fix; ");
sprintf (valid, "%s", "Last Fix");
}
else if (!expired)
fprintf (stderr, "Current Fix; ");
if (res_a)
fprintf (stderr, "RES_A: %d; ", res_a);
if (res_b)
fprintf (stderr, "RES_B: %02X; ", res_b);
uint32_t src = 0;
if (slot == 0) src = state->lastsrc;
if (slot == 1) src = state->lastsrcR;
//save to array for ncurses
sprintf (state->dmr_embedded_gps[slot], "GPS: %lf%s%s %lf%s%s (%lf, %lf) %s", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, latitude, longitude, valid);
//save to event history string
if (state->event_history_s[slot].Event_History_Items[0].source_id == src)
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_embedded_gps[slot]);
//save to LRRP report for mapping/logging
FILE * pFile; //file pointer
if (opts->lrrp_file_output == 1)
{
char * datestr = getDate();
char * timestr = getTime();
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->lrrp_out_file, "a");
fprintf (pFile, "%s\t", datestr );
fprintf (pFile, "%s\t", timestr );
fprintf (pFile, "%08d\t", src);
fprintf (pFile, "%.5lf\t", latitude);
fprintf (pFile, "%.5lf\t", longitude);
fprintf (pFile, "0\t " ); //zero for velocity
fprintf (pFile, "0\t " ); //zero for azimuth
fprintf (pFile, "\n");
fclose (pFile);
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
}
}
}
fprintf (stderr, "%s", KNRM);
}
void decode_cellocator(dsd_opts * opts, dsd_state * state, uint8_t * input, int len)
{
//TODO: This
UNUSED(opts);
UNUSED(state);
UNUSED(input);
UNUSED(len);
//UTF8 Text: MCGP (0x4D434750) followed by data values
//(0417D1050000F45FD1DD00010000000097BDD56C81000009AAAABF12864C)
utf8_to_text(state, 0, 4, input);
fprintf (stderr, " Cellocator:");
uint8_t type = input[4];
if (type == 1) fprintf (stderr, " Platform Manifest Data;");
else if (type == 2) fprintf (stderr, " CAN Data;");
else if (type == 3) fprintf (stderr, " CAN Trigger Data;");
else if (type == 4) fprintf (stderr, " Time and Location Data;");
else if (type == 5) fprintf (stderr, " Accelerometer Data;");
else if (type == 6) fprintf (stderr, " PSP Alarm System Data;");
else if (type == 7) fprintf (stderr, " Usage Counter Data;");
else if (type == 8) fprintf (stderr, " Command Authentication Table Data;");
else if (type == 9) fprintf (stderr, " GSM Neighbor List Data;");
else if (type == 10) fprintf (stderr, " Maintenance Server Platform Manifest Data;");
else fprintf (stderr, " Unknown Data;");
//Data afterwards appears to be an arbitrary len so has variable reporting data
//will need to establish a len value for data and contents
}
void decode_ars(dsd_opts * opts, dsd_state * state, uint8_t * input, int len)
{
//TODO: This
UNUSED(opts);
UNUSED(state);
UNUSED(input);
UNUSED(len);
}

280
src/dsd_import.c Normal file
View File

@@ -0,0 +1,280 @@
#include "dsd.h"
#define BSIZE 999
int csvGroupImport(dsd_opts * opts, dsd_state * state)
{
char filename[1024] = "filename.csv";
sprintf (filename, "%s", opts->group_in_file);
//filename[1023] = '\0'; //necessary?
char buffer[BSIZE];
FILE * fp;
fp = fopen(filename, "r");
if (fp == NULL) {
printf("Unable to open group file '%s'\n", filename);
exit(1);
}
int row_count = 0;
int field_count = 0;
long int group_number = 0; //local group number for array index value
UNUSED(group_number);
int i = 0;
while (fgets(buffer, BSIZE, fp)) {
field_count = 0;
row_count++;
if (row_count == 1)
continue; //don't want labels
char * field = strtok(buffer, ","); //seperate by comma
while (field) {
if (field_count == 0)
{
//group_number = atol(field);
state->group_array[i].groupNumber = atol(field);
fprintf (stderr, "%ld, ", state->group_array[i].groupNumber);
}
if (field_count == 1)
{
strcpy(state->group_array[i].groupMode, field);
fprintf (stderr, "%s, ", state->group_array[i].groupMode);
}
if (field_count == 2)
{
strcpy(state->group_array[i].groupName, field);
fprintf (stderr, "%s ", state->group_array[i].groupName);
}
field = strtok(NULL, ",");
field_count++;
}
fprintf (stderr, "\n");
i++;
state->group_tally++;
}
fclose(fp);
return 0;
}
//LCN import for EDACS, migrated to channel map (channel map does both)
int csvLCNImport(dsd_opts * opts, dsd_state * state)
{
char filename[1024] = "filename.csv";
sprintf (filename, "%s", opts->lcn_in_file);
//filename[1023] = '\0'; //necessary?
char buffer[BSIZE];
FILE * fp;
fp = fopen(filename, "r");
if (fp == NULL) {
printf("Unable to open lcn file '%s'\n", filename);
//have this return -1 and handle it inside of main
exit(1);
}
int row_count = 0;
int field_count = 0;
while (fgets(buffer, BSIZE, fp)) {
field_count = 0;
row_count++;
if (row_count == 1)
continue; //don't want labels
char * field = strtok(buffer, ","); //seperate by comma
while (field) {
state->trunk_lcn_freq[field_count] = atol (field);
state->lcn_freq_count++; //keep tally of number of Frequencies imported
fprintf (stderr, "LCN [%d] [%ld]", field_count+1, state->trunk_lcn_freq[field_count]);
fprintf (stderr, "\n");
field = strtok(NULL, ",");
field_count++;
}
fprintf (stderr, "LCN Count %d\n", state->lcn_freq_count);
}
fclose(fp);
return 0;
}
int csvChanImport(dsd_opts * opts, dsd_state * state) //channel map import
{
char filename[1024] = "filename.csv";
sprintf (filename, "%s", opts->chan_in_file);
char buffer[BSIZE];
FILE * fp;
fp = fopen(filename, "r");
if (fp == NULL) {
printf("Unable to open channel map file '%s'\n", filename);
//have this return -1 and handle it inside of main
exit(1);
}
int row_count = 0;
int field_count = 0;
long int chan_number;
while (fgets(buffer, BSIZE, fp)) {
field_count = 0;
row_count++;
if (row_count == 1)
continue; //don't want labels
char * field = strtok(buffer, ","); //seperate by comma
while (field) {
if (field_count == 0)
{
sscanf (field, "%ld", &chan_number);
}
if (field_count == 1)
{
sscanf (field, "%ld", &state->trunk_chan_map[chan_number]);
//adding this should be compatible with EDACS, test and obsolete the LCN Import function if desired
sscanf (field, "%ld", &state->trunk_lcn_freq[state->lcn_freq_count]);
state->lcn_freq_count++; //keep tally of number of Frequencies imported
}
field = strtok(NULL, ",");
field_count++;
}
fprintf (stderr, "Channel [%05ld] [%09ld]", chan_number, state->trunk_chan_map[chan_number]);
fprintf (stderr, "\n");
}
fclose(fp);
return 0;
}
//Decimal Variant of Key Import
int csvKeyImportDec(dsd_opts * opts, dsd_state * state) //multi-key support
{
char filename[1024] = "filename.csv";
sprintf (filename, "%s", opts->key_in_file);
char buffer[BSIZE];
FILE * fp;
fp = fopen(filename, "r");
if (fp == NULL) {
printf("Unable to open file '%s'\n", filename);
exit(1);
}
int row_count = 0;
int field_count = 0;
unsigned long long int keynumber = 0;
unsigned long long int keyvalue = 0;
uint16_t hash = 0;
uint8_t hash_bits[24];
memset (hash_bits, 0, sizeof(hash_bits));
while (fgets(buffer, BSIZE, fp)) {
field_count = 0;
row_count++;
if (row_count == 1)
continue; //don't want labels
char * field = strtok(buffer, ","); //seperate by comma
while (field) {
if (field_count == 0)
{
sscanf (field, "%lld", &keynumber);
if (keynumber > 0xFFFF) //if larger than 16-bits, get its hash instead
{
keynumber = keynumber & 0xFFFFFF; //truncate to 24-bits (max allowed)
for (int i = 0; i < 24; i++)
{
hash_bits[i] = ((keynumber << i) & 0x800000) >> 23; //load into array for CRC16
}
hash = ComputeCrcCCITT16d (hash_bits, 24);
keynumber = hash & 0xFFFF; //make sure its no larger than 16-bits
fprintf (stderr, "Hashed ");
}
}
if (field_count == 1)
{
sscanf (field, "%lld", &keyvalue);
state->rkey_array[keynumber] = keyvalue & 0xFFFFFFFFFF; //doesn't exceed 40-bit value
}
field = strtok(NULL, ",");
field_count++;
}
fprintf (stderr, "Key [%03lld] [%05lld]", keynumber, state->rkey_array[keynumber]);
fprintf (stderr, "\n");
hash = 0;
}
fclose(fp);
return 0;
}
//Hex Variant of Key Import
int csvKeyImportHex(dsd_opts * opts, dsd_state * state) //key import for hex keys
{
char filename[1024] = "filename.csv";
sprintf (filename, "%s", opts->key_in_file);
char buffer[BSIZE];
FILE * fp;
fp = fopen(filename, "r");
if (fp == NULL) {
printf("Unable to open file '%s'\n", filename);
exit(1);
}
int row_count = 0;
int field_count = 0;
unsigned long long int keynumber;
while (fgets(buffer, BSIZE, fp)) {
field_count = 0;
row_count++;
if (row_count == 1)
continue; //don't want labels
char * field = strtok(buffer, ","); //seperate by comma
while (field) {
if (field_count == 0)
{
sscanf (field, "%llX", &keynumber);
}
if (field_count == 1)
{
sscanf (field, "%llX", &state->rkey_array[keynumber]);
}
//this could also theoretically nuke other keys that are at the same offset
if (field_count == 2)
{
sscanf (field, "%llX", &state->rkey_array[keynumber+0x101]);
}
if (field_count == 3)
{
sscanf (field, "%llX", &state->rkey_array[keynumber+0x201]);
}
if (field_count == 4)
{
sscanf (field, "%llX", &state->rkey_array[keynumber+0x301]);
}
field = strtok(NULL, ",");
field_count++;
}
fprintf (stderr, "Key [%04llX] [%016llX]", keynumber, state->rkey_array[keynumber]);
//if longer key is loaded (or clash with the 0x101, 0x201, 0x301 offset, then print the full key listing)
if ( (state->rkey_array[keynumber+0x101] != 0) || (state->rkey_array[keynumber+0x201] != 0) || (state->rkey_array[keynumber+0x301] != 0) )
fprintf (stderr, " [%016llX] [%016llX] [%016llX]", state->rkey_array[keynumber+0x101], state->rkey_array[keynumber+0x201], state->rkey_array[keynumber+0x301]);
fprintf (stderr, "\n");
}
fclose(fp);
return 0;
}

7
src/dsd_ks.c Normal file
View File

@@ -0,0 +1,7 @@
/*-------------------------------------------------------------------------------
* dsd_ks.c
* Placeholder File 6 -- This file is for temporary code storage
*
*
*
*-----------------------------------------------------------------------------*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

179
src/dsd_mbe2.c Normal file
View File

@@ -0,0 +1,179 @@
/*-------------------------------------------------------------------------------
*
*
*
* TODO: Fill me in'
*
*
* LWVMOBILE
* 2023-07 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
//new and simplified/organized ambe and imbe handling
//moving all audio handling and decryption to seperate files for simplicity (eventually)
#include "dsd.h"
//the initial functions will ONLY return demodulated ambe or imbe frames, THAT'S IT!
//decryption and audio handling etc will be handled at a different area
//using soft_demod will also allow for not compiling mbelib and also using a DVstick in the future
//P25p1 IMBE 7200 or AMBE+2 EFR
void soft_demod_imbe7200 (dsd_state * state, char imbe_fr7200[8][23], char imbe_d[88])
{
state->errs = mbe_eccImbe7200x4400C0 (imbe_fr7200);
state->errs2 = state->errs;
mbe_demodulateImbe7200x4400Data (imbe_fr7200);
state->errs2 += mbe_eccImbe7200x4400Data (imbe_fr7200, imbe_d);
state->debug_audio_errors += state->errs2;
}
//ProVoice IMBE 7100
void soft_demod_imbe7100 (dsd_state * state, char imbe_fr7100[7][24], char imbe_d[88])
{
state->errs = mbe_eccImbe7100x4400C0 (imbe_fr7100);
state->errs2 = state->errs;
mbe_demodulateImbe7100x4400Data (imbe_fr7100);
state->errs2 += mbe_eccImbe7100x4400Data (imbe_fr7100, imbe_d);
state->debug_audio_errors += state->errs2;
}
//AMBE+2 EHR
void soft_demod_ambe2_ehr(dsd_state * state, char ambe2_ehr[4][24], char ambe_d[49])
{
state->errs = mbe_eccAmbe3600x2450C0 (ambe2_ehr);
state->errs2 = state->errs;
mbe_demodulateAmbe3600x2450Data (ambe2_ehr);
state->errs2 += mbe_eccAmbe3600x2450Data (ambe2_ehr, ambe_d);
}
//AMBE One Shot (DSTAR)
void soft_demod_ambe_dstar(dsd_opts * opts, dsd_state * state, char ambe_fr[4][24], char ambe_d[49])
{
mbe_processAmbe3600x2400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2,
state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->floating_point == 1)
memcpy (state->f_l, state->audio_out_temp_buf, sizeof(state->f_l));
else processAudio(opts, state);
}
//AMBE+2 One Shot (X2-TDMA)
void soft_demod_ambe_x2(dsd_opts * opts, dsd_state * state, char ambe_fr[4][24], char ambe_d[49])
{
mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2,
state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->floating_point == 1)
memcpy (state->f_l, state->audio_out_temp_buf, sizeof(state->f_l));
else processAudio(opts, state);
}
void soft_mbe (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24])
{
int i;
char ambe_d[49];
char imbe_d[88];
int slot = state->currentslot;
memset (ambe_d, 0, sizeof(ambe_d));
memset (imbe_d, 0, sizeof(imbe_d));
UNUSED(i);
//P25p1, YSF FR, NXDN EFR
if (state->synctype == 0 || state->synctype == 1)
{
soft_demod_imbe7200(state, imbe_fr, imbe_d);
//handle decryption here
//print IMBE frame
mbe_processImbe4400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str,
imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
//send to playback here
}
//ProVoice
else if (state->synctype == 14 || state->synctype == 15)
{
soft_demod_imbe7100(state, imbe7100_fr, imbe_d);
//nothing to do
//convert to 7200
mbe_convertImbe7100to7200(imbe_d);
mbe_processImbe4400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str,
imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
//send to playback here
}
//D-STAR AMBE
else if (state->synctype == 6 || state->synctype == 7)
{
soft_demod_ambe_dstar(opts, state, ambe_fr, ambe_d);
if(opts->payload == 1)
PrintAMBEData (opts, state, ambe_d);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceFM(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceFS(opts, state);
if (opts->wav_out_f != NULL && opts->dmr_stereo_wav == 1)
writeSynthesizedVoice (opts, state);
//single wav file handled by playSynthesizedVoiceMS
if (opts->mbe_out_f != NULL)
saveAmbe2450Data (opts, state, ambe_d);
}
//X2-TDMA AMBE
else if (state->synctype >= 2 && state->synctype <= 5)
{
soft_demod_ambe_x2(opts, state, ambe_fr, ambe_d);
if(opts->payload == 1)
PrintAMBEData (opts, state, ambe_d);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceFM(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceFS(opts, state);
if (opts->wav_out_f != NULL)
writeSynthesizedVoice (opts, state);
if (opts->mbe_out_f != NULL)
saveAmbe2450Data (opts, state, ambe_d);
}
//AMBE+2 EHR (NXDN, DMR, P25p2, YSF VD/1)
else
{
soft_demod_ambe2_ehr (state, ambe_fr, ambe_d);
//decrypt here
if(opts->payload == 1)
PrintAMBEData (opts, state, ambe_d);
//make left or right channel decision
if (slot == 0)
{
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str,
ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
}
if (slot == 1)
{
mbe_processAmbe2450Dataf (state->audio_out_temp_bufR, &state->errsR, &state->errs2R, state->err_strR,
ambe_d, state->cur_mp2, state->prev_mp2, state->prev_mp_enhanced2, opts->uvquality);
}
}
}

618
src/dsd_misc.c Normal file
View File

@@ -0,0 +1,618 @@
/*-------------------------------------------------------------------------------
* dsd_misc.c
* Misc Code that needs to be reorganized and sorted out
*
*
*
*-----------------------------------------------------------------------------*/
#include "dsd.h"
static const int PARITY[] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};
// trellis_1_2 encode: source is in bits, result in bits
void trellis_encode(uint8_t result[], const uint8_t source[], int result_len, int reg)
{
for (int i=0; i<result_len; i+=2) {
reg = (reg << 1) | source[i>>1];
result[i] = PARITY[reg & 0x19];
result[i+1] = PARITY[reg & 0x17];
}
}
// simplified trellis 2:1 decode; source and result in bits
// assumes that encoding was done with NTEST trailing zero bits
// result_len should be set to the actual number of data bits
// in the original unencoded message (excl. these trailing bits)
void trellis_decode(uint8_t result[], const uint8_t source[], int result_len)
{
int reg = 0;
int min_d;
int min_bt;
static const int NTEST = 4;
static const int NTESTC = 1 << NTEST;
uint8_t bt[NTEST];
uint8_t tt[NTEST*2];
int dstats[4];
int sum;
for (int p=0; p < 4; p++)
dstats[p] = 0;
for (int p=0; p < result_len; p++) {
for (int i=0; i<NTESTC; i++) {
bt[0] = (i&8)>>3;
bt[1] = (i&4)>>2;
bt[2] = (i&2)>>1;
bt[3] = (i&1);
trellis_encode(tt, bt, NTEST*2, reg);
sum=0;
for (int j=0; j<NTEST*2; j++) {
sum += tt[j] ^ source[p*2+j];
}
if (i == 0 || sum < min_d) {
min_d = sum;
min_bt = bt[0];
}
}
result[p] = min_bt;
reg = (reg << 1) | min_bt;
dstats[(min_d > 3) ? 3 : min_d] += 1;
}
//debug output
// fprintf (stderr, "\n stats\t%d %d %d %d\n", dstats[0], dstats[1], dstats[2], dstats[3]);
}
//Original Copyright/License
/* -*- c++ -*- */
/*
* NXDN Encoder/Decoder (C) Copyright 2019 Max H. Parke KA1RBI
*
* This file is part of OP25
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
//Ripped from libM17
#define K 5 //constraint length
#define NUM_STATES (1 << (K - 1)) //number of states
static uint32_t prevMetrics[NUM_STATES];
static uint32_t currMetrics[NUM_STATES];
static uint32_t prevMetricsData[NUM_STATES];
static uint32_t currMetricsData[NUM_STATES];
static uint16_t viterbi_history[244];
/**
* @brief Decode unpunctured convolutionally encoded data.
*
* @param out Destination array where decoded data is written.
* @param in Input data.
* @param len Input length in bits.
* @return Number of bit errors corrected.
*/
uint32_t viterbi_decode(uint8_t* out, const uint16_t* in, const uint16_t len)
{
if(len > 244*2)
fprintf(stderr, "Input size exceeds max history\n");
viterbi_reset();
size_t pos = 0;
for(size_t i = 0; i < len; i += 2)
{
uint16_t s0 = in[i];
uint16_t s1 = in[i + 1];
viterbi_decode_bit(s0, s1, pos);
pos++;
}
uint32_t err = viterbi_chainback(out, pos, len/2);
//debug
// fprintf (stderr, "\n vcb: \n");
// for (size_t i = 0; i < len; i++)
// fprintf (stderr, "%02X", out[i]);
return err;
}
/**
* @brief Decode punctured convolutionally encoded data.
*
* @param out Destination array where decoded data is written.
* @param in Input data.
* @param punct Puncturing matrix.
* @param in_len Input data length.
* @param p_len Puncturing matrix length (entries).
* @return Number of bit errors corrected.
*/
uint32_t viterbi_decode_punctured(uint8_t* out, const uint16_t* in, const uint8_t* punct, const uint16_t in_len, const uint16_t p_len)
{
if(in_len > 244*2)
fprintf(stderr, "Input size exceeds max history\n");
uint16_t umsg[244*2]; //unpunctured message
uint8_t p=0; //puncturer matrix entry
uint16_t u=0; //bits count - unpunctured message
uint16_t i=0; //bits read from the input message
while(i<in_len)
{
if(punct[p])
{
umsg[u]=in[i];
i++;
}
else
{
umsg[u]=0x7FFF;
}
u++;
p++;
p%=p_len;
}
//debug
// fprintf (stderr, " p: %d, u: %d; p_len: %d; len: %d;", p, u, p_len, (u-in_len)*0x7FFF);
return viterbi_decode(out, umsg, u) - (u-in_len)*0x7FFF;
}
/**
* @brief Decode one bit and update trellis.
*
* @param s0 Cost of the first symbol.
* @param s1 Cost of the second symbol.
* @param pos Bit position in history.
*/
void viterbi_decode_bit(uint16_t s0, uint16_t s1, const size_t pos)
{
static const uint16_t COST_TABLE_0[] = {0, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
static const uint16_t COST_TABLE_1[] = {0, 0xFFFF, 0xFFFF, 0, 0, 0xFFFF, 0xFFFF, 0};
for(uint8_t i = 0; i < NUM_STATES/2; i++)
{
uint32_t metric = q_abs_diff(COST_TABLE_0[i], s0)
+ q_abs_diff(COST_TABLE_1[i], s1);
uint32_t m0 = prevMetrics[i] + metric;
uint32_t m1 = prevMetrics[i + NUM_STATES/2] + (0x1FFFE - metric);
uint32_t m2 = prevMetrics[i] + (0x1FFFE - metric);
uint32_t m3 = prevMetrics[i + NUM_STATES/2] + metric;
uint8_t i0 = 2 * i;
uint8_t i1 = i0 + 1;
if(m0 >= m1)
{
viterbi_history[pos]|=(1<<i0);
currMetrics[i0] = m1;
}
else
{
viterbi_history[pos]&=~(1<<i0);
currMetrics[i0] = m0;
}
if(m2 >= m3)
{
viterbi_history[pos]|=(1<<i1);
currMetrics[i1] = m3;
}
else
{
viterbi_history[pos]&=~(1<<i1);
currMetrics[i1] = m2;
}
}
//swap
uint32_t tmp[NUM_STATES];
for(uint8_t i=0; i<NUM_STATES; i++)
{
tmp[i]=currMetrics[i];
}
for(uint8_t i=0; i<NUM_STATES; i++)
{
currMetrics[i]=prevMetrics[i];
prevMetrics[i]=tmp[i];
}
}
/**
* @brief History chainback to obtain final byte array.
*
* @param out Destination byte array for decoded data.
* @param pos Starting position for the chainback.
* @param len Length of the output in bits.
* @return Minimum Viterbi cost at the end of the decode sequence.
*/
uint32_t viterbi_chainback(uint8_t* out, size_t pos, uint16_t len)
{
uint8_t state = 0;
size_t bitPos = len+4;
memset(out, 0, (len-1)/8+1);
while(pos > 0)
{
bitPos--;
pos--;
uint16_t bit = viterbi_history[pos]&((1<<(state>>4)));
state >>= 1;
if(bit)
{
state |= 0x80;
out[bitPos/8]|=1<<(7-(bitPos%8));
}
}
uint32_t cost = prevMetrics[0];
for(size_t i = 0; i < NUM_STATES; i++)
{
uint32_t m = prevMetrics[i];
if(m < cost) cost = m;
}
//debug
// fprintf (stderr, "\n cb: \n");
// for (size_t i = 0; i < len; i++)
// fprintf (stderr, "%02X", out[i]);
return cost;
}
/**
* @brief Reset the decoder state. No args.
*
*/
void viterbi_reset(void)
{
memset((uint8_t*)viterbi_history, 0, 2*244);
memset((uint8_t*)currMetrics, 0, 4*NUM_STATES);
memset((uint8_t*)prevMetrics, 0, 4*NUM_STATES);
memset((uint8_t*)currMetricsData, 0, 4*NUM_STATES);
memset((uint8_t*)prevMetricsData, 0, 4*NUM_STATES);
}
uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2)
{
if(v2 > v1) return v2 - v1;
return v1 - v2;
}
//original sources
//--------------------------------------------------------------------
// M17 C library - decode/viterbi.c
//
// This file contains:
// - the Viterbi decoder
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// M17 C library - math/math.c
//
// This file contains:
// - absolute difference value
// - Euclidean norm (L2) calculation for n-dimensional vectors (float)
// - soft-valued arrays to integer conversion (and vice-versa)
// - fixed-valued multiplication and division
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
//audio filter stuff sourced from: https://github.com/NedSimao/FilteringLibrary
//no license / information provided in source code
#define PI 3.141592653
//do we need this for test input sthit?
// #define PLOT_POINTS 100
// #define SAMPLE_TIME_S 0.001
// #define CUTOFFFREQ_HZ 50
// #define sine_freq 40
// #define sine_freq_1 500
// #define HFC 50
// #define LFC 100
void LPFilter_Init(LPFilter *filter, float cutoffFreqHz, float sampleTimeS)
{
float RC=0.0;
RC=1.0/(2*PI*cutoffFreqHz);
filter->coef[0]=sampleTimeS/(sampleTimeS+RC);
filter->coef[1]=RC/(sampleTimeS+RC);
filter->v_out[0]=0.0;
filter->v_out[1]=0.0;
}
float LPFilter_Update(LPFilter *filter, float v_in)
{
filter->v_out[1]=filter->v_out[0];
filter->v_out[0]=(filter->coef[0]*v_in) + (filter->coef[1]*filter->v_out[1]);
return (filter->v_out[0]);
}
/********************************************************************************************************
* HIGH PASS FILTER
********************************************************************************************************/
void HPFilter_Init(HPFilter *filter, float cutoffFreqHz, float sampleTimeS)
{
float RC=0.0;
RC=1.0/(2*PI*cutoffFreqHz);
filter->coef=RC/(sampleTimeS+RC);
filter->v_in[0]=0.0;
filter->v_in[1]=0.0;
filter->v_out[0]=0.0;
filter->v_out[1]=0.0;
}
float HPFilter_Update(HPFilter *filter, float v_in)
{
filter->v_in[1]=filter->v_in[0];
filter->v_in[0]=v_in;
filter->v_out[1]=filter->v_out[0];
filter->v_out[0]=filter->coef * (filter->v_in[0] - filter->v_in[1]+filter->v_out[1]);
return (filter->v_out[0]);
}
/********************************************************************************************************
* BAND PASS FILTER
********************************************************************************************************/
void PBFilter_Init(PBFilter *filter, float HPF_cutoffFreqHz, float LPF_cutoffFreqHz, float sampleTimeS)
{
LPFilter_Init(&filter->lpf, LPF_cutoffFreqHz, sampleTimeS);
HPFilter_Init(&filter->hpf, HPF_cutoffFreqHz, sampleTimeS);
filter->out_in=0.0;
}
float PBFilter_Update(PBFilter *filter, float v_in)
{
filter->out_in=HPFilter_Update(&filter->hpf, v_in);
filter->out_in=LPFilter_Update(&filter->lpf, filter->out_in);
return (filter->out_in);
}
/********************************************************************************************************
* NOTCH FILTER
********************************************************************************************************/
void NOTCHFilter_Init(NOTCHFilter *filter, float centerFreqHz, float notchWidthHz, float sampleTimeS)
{
//filter frequency to angular (rad/s)
float w0_rps=2.0 * PI *centerFreqHz;
float ww_rps=2.0 * PI *notchWidthHz;
//pre warp center frequency
float w0_pw_rps=(2.0/sampleTimeS) * tanf(0.5 * w0_rps * sampleTimeS);
//computing filter coefficients
filter->alpha=4.0 + w0_rps*w0_pw_rps*sampleTimeS*sampleTimeS;
filter->beta=2.0*ww_rps*sampleTimeS;
//clearing input and output buffers
for (uint8_t n=0; n<3; n++)
{
filter->vin[n]=0;
filter->vout[n]=0;
}
}
float NOTCHFilter_Update(NOTCHFilter *filter, float vin)
{
//shifting samples
filter->vin[2]=filter->vin[1];
filter->vin[1]=filter->vin[0];
filter->vout[2]=filter->vout[1];
filter->vout[1]=filter->vout[0];
filter->vin[0]=vin;
//compute new output
filter->vout[0]=(filter->alpha*filter->vin[0] + 2.0 *(filter->alpha -8.0)*filter->vin[1] + filter->alpha*filter->vin[2]
-(2.0f*(filter->alpha-8.0)*filter->vout[1]+(filter->alpha-filter->beta)*filter->vout[2]))/(filter->alpha+filter->beta);
return (filter->vout[0]);
}
void init_audio_filters (dsd_state * state)
{
//still not sure if this is even correct or not, but 48k sounds good now
LPFilter_Init(&state->RCFilter, 960, (float)1/(float)48000);
HPFilter_Init(&state->HRCFilter, 960, (float)1/(float)48000);
//left and right variants for stereo output testing on digital voice samples
LPFilter_Init(&state->RCFilterL, 960, (float)1/(float)16000);
HPFilter_Init(&state->HRCFilterL, 960, (float)1/(float)16000);
LPFilter_Init(&state->RCFilterR, 960, (float)1/(float)16000);
HPFilter_Init(&state->HRCFilterR, 960, (float)1/(float)16000);
//PBFilter_Init(PBFilter *filter, float HPF_cutoffFreqHz, float LPF_cutoffFreqHz, float sampleTimeS);
//NOTCHFilter_Init(NOTCHFilter *filter, float centerFreqHz, float notchWidthHz, float sampleTimeS);
//NOTE: PBFilter_init also inits a LPF and HPF, but on another set of filters, might be worth
//testing just using the PBFilter by itself and see how it does without the hpf used
//passband filter working (seems to be), notch filter unsure which values to use, doesn't have any appreciable affect when used as is
PBFilter_Init(&state->PBF, 8000, 12000, (float)1/(float)1536000); //RTL Sampling at 1536000 S/s.
NOTCHFilter_Init(&state->NF, 1000, 4000, (float)1/(float)1536000);
}
//FUNCTIONS for handing use of above filters
//lpf
void lpf(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = LPFilter_Update(&state->RCFilter, input[i]);
// fprintf (stderr, "\n out: %05d", input[i]);
}
}
//hpf
void hpf(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = HPFilter_Update(&state->HRCFilter, input[i]);
// fprintf (stderr, "\n out: %05d", input[i]);
}
}
//hpf digital left
void hpf_dL(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = HPFilter_Update(&state->HRCFilterL, input[i]);
// fprintf (stderr, "\n out: %05d", input[i]);
}
}
//hpf digital right
void hpf_dR(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = HPFilter_Update(&state->HRCFilterR, input[i]);
// fprintf (stderr, "\n out: %05d", input[i]);
}
}
//nf
void nf(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = NOTCHFilter_Update(&state->NF, input[i]);
// fprintf (stderr, "\n out: %05d", input[i]);
}
}
//pbf
void pbf(dsd_state * state, short * input, int len)
{
int i;
for (i = 0; i < len; i++)
{
// fprintf (stderr, "\n in: %05d", input[i]);
input[i] = PBFilter_Update(&state->PBF, input[i]);
}
}
//Generic RMS function derived from RTL_FM (RTL_SDR) RMS code (doesnt' really work correctly outside of RTL)
long int raw_rms(int16_t *samples, int len, int step) //use samplespersymbol as len
{
int i;
long int rms;
long p, t, s;
double dc, err;
p = t = 0L;
for (i=0; i<len; i+=step) {
s = (long)samples[i];
t += s;
p += s * s;
}
/* correct for dc offset in squares */
dc = (double)(t*step) / (double)len;
err = t * 2 * dc - dc * dc * len;
rms = (long int)sqrt((p-err) / len);
if (rms < 0) rms = 150;
return rms;
}
/*
* Mean power (RMS^2 proxy) without sqrt, modeled after mean_power() in rtl_sdr_fm.cpp.
* Computes a DC-corrected average of squares to avoid costly sqrt operations.
*/
long int raw_pwr(int16_t *samples, int len, int step)
{
int64_t p = 0;
int64_t t = 0;
for (int i = 0; i < len; i += step) {
int64_t s = (int64_t)samples[i];
t += s;
p += s * s;
}
/* DC-corrected energy ≈ p - (t^2)/len with rounded division */
int64_t dc_corr = 0;
if (len > 0) {
int64_t tt = t * t;
dc_corr = (tt + (len / 2)) / len;
}
int64_t energy = p - dc_corr;
if (energy < 0) energy = 0;
return (long int)(energy / (len > 0 ? len : 1));
}

File diff suppressed because it is too large Load Diff

940
src/dsd_ncurses_handler.c Normal file
View File

@@ -0,0 +1,940 @@
/*-------------------------------------------------------------------------------
* dsd_ncurses_handler.c
* DSD-FME ncurses terminal user input handler
*
* LWVMOBILE
* 2025-05 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
uint8_t ncurses_input_handler(dsd_opts * opts, dsd_state * state, int c)
{
struct stat st_wav = {0};
// //debug char value
// if (c != -1)
// fprintf (stderr, "\n User Input: %i / %c ;;", c, c);
//TEST: Handle Escape Characters
//if issues arise, just go back to the way it was before
//this is primarly a fix for scroll wheel activatign the menu
//and Windows Powershell right-click doing a copy and paste
//and sendign tons of garbage getch chars here and changing things
if (c == '\033')
{
//TODO: Find way to getch all the chars immediately after, or just
//run getch in a loop in case of somebody copying and pasting a ton of things accidentally
for (int i = 0; i < 100000; i++) //wonder how slow this will be
getch();
c = -1;
return 1;
}
//keyboard shortcuts - codes same as ascii codes
if (c == 10) //Return / Enter key, open menu
{
if (opts->m17encoder == 0) //don't allow menu if using M17 encoder
ncursesMenu (opts, state);
}
//use k and l keys to test tg hold toggles on slots 1 and slots 2
if (c == 107) //'k' key, hold tg on slot 1 for trunking purposes, or toggle clear
{
if (state->tg_hold == 0)
state->tg_hold = state->lasttg;
else state->tg_hold = 0;
if ( (opts->frame_nxdn48 == 1 || opts->frame_nxdn96 == 1) && (state->tg_hold == 0) )
state->tg_hold = state->nxdn_last_tg;
else if (opts->frame_provoice == 1 && state->ea_mode == 0)
state->tg_hold = state->lastsrc;
}
if (c == 108) //'l' key, hold tg on slot 2 for trunking purposes, or toggle clear
{
if (state->tg_hold == 0)
state->tg_hold = state->lasttgR;
else state->tg_hold = 0;
}
//toggling when 48k/1 OSS still has some lag -- needed to clear out the buffer when switching
if (c == 49) // '1' key, toggle slot1 on
{
//switching, but want to control each seperately plz
if (opts->slot1_on == 1)
{
opts->slot1_on = 0; if (opts->slot_preference == 0) opts->slot_preference = 2;
// opts->slot_preference = 1; //slot 2
//clear any previously buffered audio
state->audio_out_float_buf_p = state->audio_out_float_buf + 100;
state->audio_out_buf_p = state->audio_out_buf + 100;
memset (state->audio_out_float_buf, 0, 100 * sizeof (float));
memset (state->audio_out_buf, 0, 100 * sizeof (short));
state->audio_out_idx2 = 0;
state->audio_out_idx = 0;
}
else if (opts->slot1_on == 0)
{
opts->slot1_on = 1;
if (opts->audio_out_type == 5) //OSS 48k/1
{
opts->slot_preference = 0; //slot 1
// opts->slot2_on = 0; //turn off slot 2
}
}
}
if (c == 50) // '2' key, toggle slot2 on
{
//switching, but want to control each seperately plz
if (opts->slot2_on == 1)
{
opts->slot2_on = 0;
opts->slot_preference = 0; //slot 1
//clear any previously buffered audio
state->audio_out_float_buf_pR = state->audio_out_float_bufR + 100;
state->audio_out_buf_pR = state->audio_out_bufR + 100;
memset (state->audio_out_float_bufR, 0, 100 * sizeof (float));
memset (state->audio_out_bufR, 0, 100 * sizeof (short));
state->audio_out_idx2R = 0;
state->audio_out_idxR = 0;
}
else if (opts->slot2_on == 0)
{
opts->slot2_on = 1;
if (opts->audio_out_type == 5) //OSS 48k/1
{
opts->slot_preference = 1; //slot 2
// opts->slot1_on = 0; //turn off slot 1
}
}
}
// if (c == 51) //'3' key, toggle slot preference on 48k/1
// {
// if (opts->slot_preference == 1) opts->slot_preference = 0;
// else opts->slot_preference = 1;
// }
if (c == 51) //'3' key, cycle slot preference
{
if (opts->slot_preference == 0 || opts->slot_preference == 1) opts->slot_preference++;
else opts->slot_preference = 0;
}
if (c == 43) //+ key, increment audio_gain
{
if (opts->audio_gain < 50)
opts->audio_gain++;
state->aout_gain = opts->audio_gain;
state->aout_gainR = opts->audio_gain;
opts->audio_gainR = opts->audio_gain;
}
if (c == 45) //- key, decrement audio_gain
{
if (opts->audio_gain > 0)
opts->audio_gain--;
state->aout_gain = opts->audio_gain;
state->aout_gainR = opts->audio_gain;
//reset to default on 0 for auto
if (opts->audio_gain == 0)
{
state->aout_gain = 25;
state->aout_gainR = 25;
}
opts->audio_gainR = opts->audio_gain;
}
if (c == 42) // * key, increment audio_gainA
{
if (opts->audio_gainA < 100)
opts->audio_gainA++;
}
if (c == 47) // / key, decrement audio_gainA
{
if (opts->audio_gainA > 0)
opts->audio_gainA--;
}
if (c == 122) //'z' key, toggle payload to console
{
if (opts->payload == 1) opts->payload = 0;
else opts->payload = 1;
}
if (c == 99) //'c' key, toggle compact mode
{
if (opts->ncurses_compact == 1) opts->ncurses_compact = 0;
else opts->ncurses_compact = 1;
}
if (c == 116) //'t' key, toggle trunking
{
if (opts->p25_trunk == 1) opts->p25_trunk = 0;
else opts->p25_trunk = 1;
}
if (c == 121) //'y' key, toggle scanner mode
{
if (opts->scanner_mode == 1) opts->scanner_mode = 0;
else opts->scanner_mode = 1;
opts->p25_trunk = 0; //turn off trunking mode
}
if (c == 97) //'a' key, toggle call alert beep
{
if (opts->call_alert == 1) opts->call_alert = 0;
else opts->call_alert = 1;
}
if (c == 104) //'h' key, cycle history off, short, long
{
opts->ncurses_history++;
opts->ncurses_history %= 3;
}
if (c == 113) //'q' key, quit
{
exitflag = 1;
}
if (c == 52) // '4' key, toggle force privacy key over fid and svc (dmr)
{
if (state->M == 1 || state->M == 0x21) state->M = 0;
else state->M = 1;
}
if (c == 54) // '6' key, toggle force rc4 key over missing pi header/late entry
{
if (state->M == 1 || state->M == 0x21) state->M = 0;
else state->M = 0x21;
}
if (c == 105) //'i' key, toggle signal inversion on inverted types
{
//Set all signal for inversion or uninversion
if (opts->inverted_dmr == 0)
{
opts->inverted_dmr = 1;
opts->inverted_dpmr = 1;
opts->inverted_x2tdma = 1;
opts->inverted_ysf = 1;
opts->inverted_m17 = 1;
}
else
{
opts->inverted_dmr = 0;
opts->inverted_dpmr = 0;
opts->inverted_x2tdma = 0;
opts->inverted_ysf = 0;
opts->inverted_m17 = 0;
}
}
if (c == 109) //'m' key, toggle qpsk/c4fm - everything but phase 2
{
if (state->rf_mod == 0)
{
opts->mod_c4fm = 0;
opts->mod_qpsk = 1;
opts->mod_gfsk = 0;
state->rf_mod = 1;
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
else
{
opts->mod_c4fm = 1;
opts->mod_qpsk = 0;
opts->mod_gfsk = 0;
state->rf_mod = 0;
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
}
if (c == 77) //'M' key, toggle qpsk - phase 2 6000 sps
{
if (state->rf_mod == 0)
{
opts->mod_c4fm = 0;
opts->mod_qpsk = 1;
opts->mod_gfsk = 0;
state->rf_mod = 1;
state->samplesPerSymbol = 8;
state->symbolCenter = 3;
}
else
{
opts->mod_c4fm = 1;
opts->mod_qpsk = 0;
opts->mod_gfsk = 0;
state->rf_mod = 0;
state->samplesPerSymbol = 8;
state->symbolCenter = 3;
}
}
if (c == 82) //'R', save symbol capture bin with date/time string as name
{
//for filenames (no colons, etc)
char * timestr = getTime();
char * datestr = getDate();
sprintf (opts->symbol_out_file, "%s_%s_dibit_capture.bin", datestr, timestr);
openSymbolOutFile (opts, state);
//add a system event to echo in the event history
state->event_history_s[0].Event_History_Items[0].color_pair = 4;
char event_str[2000]; memset (event_str, 0, sizeof(event_str));
sprintf (event_str, "DSD-FME Dibit Capture File Started: %s;", opts->symbol_out_file);
watchdog_event_datacall (opts, state, 0xFFFFFF, 0xFFFFFF, event_str, 0);
state->lastsrc = 0; //this could wipe a call src if they hit 'R' while call in slot 1 in progress
watchdog_event_history(opts, state, 0);
watchdog_event_current(opts, state, 0);
//allocated memory pointer needs to be free'd
if (timestr != NULL)
{
free (timestr);
timestr = NULL;
}
if (datestr != NULL)
{
free (datestr);
datestr = NULL;
}
opts->symbol_out_file_creation_time = time(NULL);
opts->symbol_out_file_is_auto = 1;
}
if (c == 114) //'r' key, stop capturing symbol capture bin file
{
if (opts->symbol_out_f)
{
closeSymbolOutFile (opts, state);
sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file);
//add a system event to echo in the event history
state->event_history_s[0].Event_History_Items[0].color_pair = 4;
char event_str[2000]; memset (event_str, 0, sizeof(event_str));
sprintf (event_str, "DSD-FME Dibit Capture File Closed: %s;", opts->symbol_out_file);
watchdog_event_datacall (opts, state, 0xFFFFFF, 0xFFFFFF, event_str, 0);
state->lastsrc = 0; //this could wipe a call src if they hit 'R' while call in slot 1 in progress
watchdog_event_history(opts, state, 0);
watchdog_event_current(opts, state, 0);
}
opts->symbol_out_file_is_auto = 0;
}
#ifdef __CYGWIN__
//do nothing
#else
if (c == 32) //'space bar' replay last bin file (rework to do wav files too?)
{
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev);
goto SKIPR;
}
if (S_ISREG(stat_buf.st_mode))
{
opts->symbolfile = fopen(opts->audio_in_dev, "r");
opts->audio_in_type = 4; //symbol capture bin files
}
SKIPR: ; //do nothing
}
#endif
if (c == 80) //'P' key - start per call wav files //TODO: Fix
{
char wav_file_directory[1024];
sprintf (wav_file_directory, "%s", opts->wav_out_dir);
wav_file_directory[1023] = '\0';
if (stat(wav_file_directory, &st_wav) == -1)
{
fprintf (stderr, "%s wav file directory does not exist\n", wav_file_directory);
fprintf (stderr, "Creating directory %s to save decoded wav files\n", wav_file_directory);
mkdir(wav_file_directory, 0700);
}
fprintf (stderr,"\n Per Call Wav File Enabled to Directory: %s;.\n", opts->wav_out_dir);
srand(time(NULL)); //seed random for filenames (so two filenames aren't the exact same datetime string on initailization)
opts->wav_out_f = open_wav_file(opts->wav_out_dir, opts->wav_out_file, 8000, 0);
opts->wav_out_fR = open_wav_file(opts->wav_out_dir, opts->wav_out_fileR, 8000, 0);
opts->dmr_stereo_wav = 1;
}
if (c == 112) //'p' key - stop all per call wav files //TODO: Fix
{
//TODO: Add Closing of RAW files as well?
opts->wav_out_f = close_and_rename_wav_file(opts->wav_out_f, opts->wav_out_file, opts->wav_out_dir, &state->event_history_s[0]);
opts->wav_out_fR = close_and_rename_wav_file(opts->wav_out_fR, opts->wav_out_fileR, opts->wav_out_dir, &state->event_history_s[1]);
opts->wav_out_file[0] = 0; //Bugfix for decoded wav file display after disabling
opts->wav_out_fileR[0] = 0;
opts->dmr_stereo_wav = 0;
}
//
#ifdef __CYGWIN__ //this might be okay on Aero as well, will need to look into and/or test
//
#else
if (c == 115) //'s' key, stop playing wav or symbol in files
{
if (opts->symbolfile != NULL)
{
if (opts->audio_in_type == 4)
{
fclose(opts->symbolfile);
}
}
if (opts->audio_in_type == 2) //wav input file
{
sf_close(opts->audio_in_file);
}
if (opts->audio_out_type == 0)
{
opts->audio_in_type = 0;
openPulseInput(opts);
}
else opts->audio_in_type = 5; //exitflag = 1;
}
#endif
//makes buzzing sound when locked out in new audio config and short, probably something to do with processaudio running or not running
if (state->lasttg != 0 && opts->frame_provoice != 1 && c == 33) //SHIFT+'1' key (exclamation point), lockout slot 1 or conventional tg from tuning/playback during session
{
state->group_array[state->group_tally].groupNumber = state->lasttg;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "B");
sprintf (state->group_array[state->group_tally].groupName, "%s", "LOCKOUT");
state->group_tally++;
sprintf (state->event_history_s[0].Event_History_Items[0].internal_str, "Target: %d; has been locked out; User Lock Out.", state->lasttg);
watchdog_event_current(opts, state, 0);
sprintf (state->call_string[0], "%s", " "); //21 spaces
//if we have an opened group file, let's write a group lock out into it to make it permanent
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,B,LOCKOUT,%02X\n", state->lasttg, state->payload_algid);
fclose (pFile);
}
//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));
memset (state->active_channel, 0, sizeof(state->active_channel));
//reset dmr blocks
dmr_reset_blocks (opts, state);
//zero out additional items
state->lasttg = 0;
state->lasttgR = 0;
state->lastsrc = 0;
state->lastsrcR = 0;
state->payload_algid = 0;
state->payload_algidR = 0;
state->payload_keyid = 0;
state->payload_keyidR = 0;
state->payload_mi = 0;
state->payload_miR = 0;
state->payload_miP = 0;
state->payload_miN = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
//tune back to the control channel -- NOTE: Doesn't work correctly on EDACS Analog Voice
//RIGCTL
if (opts->p25_trunk == 1 && opts->use_rigctl == 1)
{
//drop all items (failsafe)
noCarrier(opts, state);
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
}
//rtl
#ifdef USE_RTLSDR
if (opts->p25_trunk == 1 && opts->audio_in_type == 3)
{
//drop all items (failsafe)
noCarrier(opts, state);
rtl_dev_tune (opts, state->p25_cc_freq);
}
#endif
state->last_cc_sync_time = time(NULL);
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
if (state->p25_cc_is_tdma == 0)
{
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
}
if (state->lasttgR != 0 && opts->frame_provoice != 1 && c == 64) //SHIFT+'2' key (@ at sign), lockout slot 2 tdma tgR from tuning/playback during session
{
state->group_array[state->group_tally].groupNumber = state->lasttgR;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "B");
sprintf (state->group_array[state->group_tally].groupName, "%s", "LOCKOUT");
state->group_tally++;
sprintf (state->event_history_s[1].Event_History_Items[0].internal_str, "Target: %d; has been locked out; User Lock Out.", state->lasttgR);
watchdog_event_current(opts, state, 1);
sprintf (state->call_string[1], "%s", " "); //21 spaces
//if we have an opened group file, let's write a group lock out into it to make it permanent
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,B,LOCKOUT,%02X\n", state->lasttgR, state->payload_algidR);
fclose (pFile);
}
//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));
memset (state->active_channel, 0, sizeof(state->active_channel));
//reset dmr blocks
dmr_reset_blocks (opts, state);
//zero out additional items
state->lasttg = 0;
state->lasttgR = 0;
state->lastsrc = 0;
state->lastsrcR = 0;
state->payload_algid = 0;
state->payload_algidR = 0;
state->payload_keyid = 0;
state->payload_keyidR = 0;
state->payload_mi = 0;
state->payload_miR = 0;
state->payload_miP = 0;
state->payload_miN = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
//tune back to the control channel -- NOTE: Doesn't work correctly on EDACS Analog Voice
//RIGCTL
if (opts->p25_trunk == 1 && opts->use_rigctl == 1)
{
//drop all items (failsafe)
noCarrier(opts, state);
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
}
//rtl
#ifdef USE_RTLSDR
if (opts->p25_trunk == 1 && opts->audio_in_type == 3)
{
//drop all items (failsafe)
noCarrier(opts, state);
rtl_dev_tune (opts, state->p25_cc_freq);
}
#endif
state->last_cc_sync_time = time(NULL);
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
if (state->p25_cc_is_tdma == 0)
{
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
}
if (opts->p25_trunk == 1 && c == 119) //'w' key, toggle white list/black list mode
{
if (opts->trunk_use_allow_list == 1) opts->trunk_use_allow_list = 0;
else opts->trunk_use_allow_list = 1;
}
if (opts->p25_trunk == 1 && c == 117) //'u' key, toggle tune private calls
{
if (opts->trunk_tune_private_calls == 1) opts->trunk_tune_private_calls = 0;
else opts->trunk_tune_private_calls = 1;
}
if (opts->p25_trunk == 1 && c == 100) //'d' key, toggle tune data calls
{
if (opts->trunk_tune_data_calls == 1) opts->trunk_tune_data_calls = 0;
else opts->trunk_tune_data_calls = 1;
}
if (opts->p25_trunk == 1 && c == 101) //'e' key, toggle tune enc calls (P25 only on certain grants)
{
if (opts->trunk_tune_enc_calls == 1) opts->trunk_tune_enc_calls = 0;
else opts->trunk_tune_enc_calls = 1;
}
if (opts->p25_trunk == 1 && c == 103) //'g' key, toggle tune group calls
{
if (opts->trunk_tune_group_calls == 1) opts->trunk_tune_group_calls = 0;
else opts->trunk_tune_group_calls = 1;
}
if (c == 70) //'F' key - toggle agressive sync/crc failure/ras
{
if (opts->aggressive_framesync == 0) opts->aggressive_framesync = 1;
else opts->aggressive_framesync = 0;
}
if (c == 68) //'D' key - Reset DMR Site Parms/Call Strings, etc.
{
//dmr trunking/ncurses stuff
state->dmr_rest_channel = -1; //init on -1
state->dmr_mfid = -1; //
//dmr mfid branding and site parms
sprintf(state->dmr_branding_sub, "%s", "");
sprintf(state->dmr_branding, "%s", "");
sprintf (state->dmr_site_parms, "%s", "");
//DMR Location Area - DMRLA B***S***
opts->dmr_dmrla_is_set = 0;
opts->dmr_dmrla_n = 0;
//reset NXDN info
state->nxdn_location_site_code = 0;
state->nxdn_location_sys_code = 0;
sprintf (state->nxdn_location_category, "%s", " ");
state->nxdn_last_ran = -1; //0
state->nxdn_ran = 0; //0
state->nxdn_rcn = 0;
state->nxdn_base_freq = 0;
state->nxdn_step = 0;
state->nxdn_bw = 0;
}
//Debug/Troubleshooting Option
if (c == 90) //'Z' key - Simulate NoCarrier/No VC/CC sync to zero out more stuff (capital Z)
{
// opts->p25_is_tuned = 0;
state->last_cc_sync_time = 0;
state->last_vc_sync_time = 0;
noCarrier(opts, state);
}
if (c == 93) //']' key - increment event history indexer
{
state->eh_index++;
}
if (c == 91) //'[' key - decrement event history indexer
{
state->eh_index--;
}
if (c == 92) //'\' key - toggle events for slot displayed, and reset eh_index
{
state->eh_slot ^= 1;
state->eh_index = 0;
}
//attempt retry to TCP Audio server
if (c == 56) // '8' key, try audio in type 8 (TCP Audio Server connection) using defaults OR whatever the user last specified
{
opts->tcp_sockfd = Connect(opts->tcp_hostname, opts->tcp_portno);
if (opts->tcp_sockfd != 0)
{
//reset audio input stream
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
opts->audio_in_file_info->channels=1;
opts->audio_in_file_info->seekable=0;
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
opts->tcp_file_in = sf_open_fd(opts->tcp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
if(opts->tcp_file_in == NULL)
{
fprintf(stderr, "Error, couldn't Connect to TCP with libsndfile: %s\n", sf_strerror(NULL));
}
else
{
//close pulse input if it is currently open
if (opts->audio_in_type == 0) closePulseInput(opts);
fprintf (stderr, "TCP Socket Connected Successfully.\n");
opts->audio_in_type = 8;
}
}
else fprintf (stderr, "TCP Socket Connection Error.\n");
}
if (c == 57) //'9' key, try rigctl connection with default values
{
//use same or last specified host for TCP audio sink for connection
memcpy (opts->rigctlhostname, opts->tcp_hostname, sizeof (opts->rigctlhostname) );
opts->rigctl_sockfd = Connect(opts->rigctlhostname, opts->rigctlportno);
if (opts->rigctl_sockfd != 0) opts->use_rigctl = 1;
else opts->use_rigctl = 0;
}
//if trunking and user wants to just go back to the control channel and skip this call
if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && c == 67) //Capital C key - Return to CC
{
//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));
memset (state->active_channel, 0, sizeof(state->active_channel));
//reset dmr blocks
dmr_reset_blocks (opts, state);
//zero out additional items
state->lasttg = 0;
state->lasttgR = 0;
state->lastsrc = 0;
state->lastsrcR = 0;
state->payload_algid = 0;
state->payload_algidR = 0;
state->payload_keyid = 0;
state->payload_keyidR = 0;
state->payload_mi = 0;
state->payload_miR = 0;
state->payload_miP = 0;
state->payload_miN = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
//tune back to the control channel -- NOTE: Doesn't work correctly on EDACS Analog Voice
//RIGCTL
if (opts->p25_trunk == 1 && opts->use_rigctl == 1)
{
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
}
//rtl
#ifdef USE_RTLSDR
if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_dev_tune (opts, state->p25_cc_freq);
#endif
state->last_cc_sync_time = time(NULL);
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
if (state->p25_cc_is_tdma == 0)
{
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
//if P25p1 Data Revert on P25p2 TDMA CC, flip symbolrate
if (state->p25_cc_is_tdma == 1)
{
state->samplesPerSymbol = 8;
state->symbolCenter = 3;
}
fprintf (stderr, "\n User Activated Return to CC; \n ");
}
//if trunking or scanning, manually cycle forward through channels loaded (can be run without trunking or scanning enabled)
if ( (opts->use_rigctl == 1 || opts->audio_in_type == 3) && c == 76) //Capital L key - Cycle Channels Forward
{
//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));
memset (state->active_channel, 0, sizeof(state->active_channel));
//reset dmr blocks
dmr_reset_blocks (opts, state);
//zero out additional items
state->lasttg = 0;
state->lasttgR = 0;
state->lastsrc = 0;
state->lastsrcR = 0;
state->payload_algid = 0;
state->payload_algidR = 0;
state->payload_keyid = 0;
state->payload_keyidR = 0;
state->payload_mi = 0;
state->payload_miR = 0;
state->payload_miP = 0;
state->payload_miN = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
//just copy and pasted the cycle logic for CC/signal hunting on no sync
if (state->lcn_freq_roll >= state->lcn_freq_count) //fixed this to skip the extra wait out at the end of the list
{
state->lcn_freq_roll = 0; //reset to zero
}
//roll an extra value up if the current is the same as what's already loaded -- faster hunting on Cap+, etc
if (state->lcn_freq_roll != 0)
{
if (state->trunk_lcn_freq[state->lcn_freq_roll-1] == state->trunk_lcn_freq[state->lcn_freq_roll])
{
state->lcn_freq_roll++;
//check roll again if greater than expected, then go back to zero
if (state->lcn_freq_roll >= state->lcn_freq_count)
{
state->lcn_freq_roll = 0; //reset to zero
}
}
}
//check that we have a non zero value first, then tune next frequency
if (state->trunk_lcn_freq[state->lcn_freq_roll] != 0)
{
//rigctl
if (opts->use_rigctl == 1)
{
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]);
}
//rtl
if (opts->audio_in_type == 3)
{
#ifdef USE_RTLSDR
rtl_dev_tune (opts, state->trunk_lcn_freq[state->lcn_freq_roll]);
#endif
}
fprintf (stderr, "\n User Activated Channel Cycle;");
fprintf (stderr, " Tuning to Frequency: %.06lf MHz\n",
(double)state->trunk_lcn_freq[state->lcn_freq_roll]/1000000);
}
state->lcn_freq_roll++;
state->last_cc_sync_time = time(NULL);
//may need to test to see if we want to do the conditional below or not for symbol rate flipping
//if P25p2 VCH and going back to P25p1 CC, flip symbolrate
if (state->p25_cc_is_tdma == 0)
{
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
}
//if P25p1 Data Revert on P25p2 TDMA CC, flip symbolrate
if (state->p25_cc_is_tdma == 1)
{
state->samplesPerSymbol = 8;
state->symbolCenter = 3;
}
}
if (c == 118 && opts->audio_in_type == 3) //'v' key, cycle rtl volume multiplier, when active
{
if (opts->rtl_volume_multiplier == 1 || opts->rtl_volume_multiplier == 2) opts->rtl_volume_multiplier++;
else opts->rtl_volume_multiplier = 1;
}
if (c == 86) // 'V' Key, toggle LPF
{
if (opts->use_lpf == 0) opts->use_lpf = 1;
else opts->use_lpf = 0;
}
if (c == 66) // 'B' Key, toggle HPF
{
if (opts->use_hpf == 0) opts->use_hpf = 1;
else opts->use_hpf = 0;
}
if (c == 78) // 'N' Key, toggle PBF
{
if (opts->use_pbf == 0) opts->use_pbf = 1;
else opts->use_pbf = 0;
}
if (c == 72) // 'H' Key, toggle HPF on digital
{
if (opts->use_hpf_d == 0) opts->use_hpf_d = 1;
else opts->use_hpf_d = 0;
}
if (opts->m17encoder == 1 && c == 92) //'\' key - toggle M17 encoder Encode + TX
{
if (state->m17encoder_tx == 0) state->m17encoder_tx = 1;
else state->m17encoder_tx = 0;
//flag on the EOT marker to send last frame after toggling encoder to zero
if (state->m17encoder_tx == 0) state->m17encoder_eot = 1;
}
if(opts->frame_provoice == 1 && c == 65) //'A' Key, toggle ESK mask 0xA0
{
if (state->esk_mask == 0) state->esk_mask = 0xA0;
else state->esk_mask = 0;
}
if(opts->frame_provoice == 1 && c == 83) //'S' Key, toggle STD or EA mode and reset
{
if (state->ea_mode == -1) state->ea_mode = 0;
else if (state->ea_mode == 0) state->ea_mode = 1;
else state->ea_mode = 0;
//reset -- test to make sure these don't do weird things when reset
state->edacs_site_id = 0;
state->edacs_lcn_count = 0;
state->edacs_cc_lcn = 0;
state->edacs_vc_lcn = 0;
state->edacs_tuned_lcn = -1;
state->edacs_vc_call_type = 0;
state->p25_cc_freq = 0;
opts->p25_is_tuned = 0;
state->lasttg = 0;
state->lastsrc = 0;
}
//RTL PPM Manual Adjustment
if (c == 125)
opts->rtlsdr_ppm_error++;
if (c == 123)
opts->rtlsdr_ppm_error--;
//anything with an entry box will need the inputs and outputs stopped first
//so probably just write a function to handle c input, and when c = certain values
//needing an entry box, then stop all of those
return 0;
} //end ncursesPrinter

1629
src/dsd_ncurses_menu.c Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More