mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 09:17:20 -05:00
Compare commits
95 Commits
win32
...
v.2.0_fina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae58fabb72 | ||
|
|
e390251b9d | ||
|
|
f7ad3e638f | ||
|
|
a16c99994c | ||
|
|
7f187ff6d8 | ||
|
|
8485be965b | ||
|
|
d1e1572139 | ||
|
|
95e74c8e28 | ||
|
|
815fbb026f | ||
|
|
d1ce0121be | ||
|
|
a55db055d4 | ||
|
|
443b7c3031 | ||
|
|
4bebb361ec | ||
|
|
6f538fd166 | ||
|
|
fef36e3761 | ||
|
|
19df3dd7f1 | ||
|
|
acd2b0b134 | ||
|
|
0908baa47c | ||
|
|
c507ed229c | ||
|
|
3101bbde28 | ||
|
|
5e24ff505d | ||
|
|
4a8bf144dd | ||
|
|
d872818e03 | ||
|
|
f967b80217 | ||
|
|
f3d94ddc2a | ||
|
|
18bec720ae | ||
|
|
456687ba86 | ||
|
|
ba0e422f23 | ||
|
|
ce75acb41a | ||
|
|
68862296bf | ||
|
|
f3c0199b32 | ||
|
|
c8e8e041b7 | ||
|
|
85eea59598 | ||
|
|
304b5545ba | ||
|
|
313759333e | ||
|
|
1737c1f7e9 | ||
|
|
bd94f83318 | ||
|
|
5d7988ea0f | ||
|
|
432495c1ad | ||
|
|
9c75583323 | ||
|
|
b9389742f6 | ||
|
|
fb59406a28 | ||
|
|
339323695f | ||
|
|
d8e7c4c3aa | ||
|
|
1dc6737cc2 | ||
|
|
c1ed3fe038 | ||
|
|
d86b370a22 | ||
|
|
b7bfa98a50 | ||
|
|
da41dcd5c9 | ||
|
|
0c27de102d | ||
|
|
54c75e20c9 | ||
|
|
3102770353 | ||
|
|
477ca97830 | ||
|
|
5b51adfc95 | ||
|
|
4ab16b5935 | ||
|
|
fe5ec8b0b4 | ||
|
|
58d8ad8a8c | ||
|
|
df5d755345 | ||
|
|
9a7a836eca | ||
|
|
4243fc9692 | ||
|
|
c999c97445 | ||
|
|
569f72508a | ||
|
|
d78f516afe | ||
|
|
6e4a373d26 | ||
|
|
2f644f5ba6 | ||
|
|
37c24d0ca7 | ||
|
|
9cdbd35e51 | ||
|
|
67e28c4655 | ||
|
|
591df8657a | ||
|
|
c708ea5911 | ||
|
|
a4ecfdca30 | ||
|
|
ac1fd7897c | ||
|
|
a02f992a25 | ||
|
|
630d3f362c | ||
|
|
6666424ff8 | ||
|
|
b0fc20cea6 | ||
|
|
f61dbd4fe7 | ||
|
|
f369d645b1 | ||
|
|
7148e653e5 | ||
|
|
bb5da93fcd | ||
|
|
d2d750e920 | ||
|
|
485161f42d | ||
|
|
67661c2fb0 | ||
|
|
dcb21f2cd0 | ||
|
|
9f03bbc8a1 | ||
|
|
b4ecdf7820 | ||
|
|
35cc358101 | ||
|
|
db23968a6f | ||
|
|
9efd950b9f | ||
|
|
08461492ee | ||
|
|
b2ccd3a878 | ||
|
|
9b8a382ea5 | ||
|
|
235eeedcda | ||
|
|
0cff92101c | ||
|
|
c44e039772 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,3 +5,6 @@ build
|
|||||||
*.sh
|
*.sh
|
||||||
*.csv
|
*.csv
|
||||||
examples
|
examples
|
||||||
|
*.bin
|
||||||
|
*.ans
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,43 @@
|
|||||||
|
#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)
|
project(dsd-fme)
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
|
||||||
|
|
||||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
|
||||||
#Set curses to ncurses, and wide true for ascii
|
#Set curses to ncurses, and wide true for ascii
|
||||||
set(CURSES_NEED_NCURSES TRUE)
|
set(CURSES_NEED_NCURSES TRUE)
|
||||||
set(CURSES_NEED_WIDE TRUE)
|
set(CURSES_NEED_WIDE TRUE)
|
||||||
|
|
||||||
|
#use cmake option -DCOLORS=OFF to disable color output
|
||||||
|
option(COLORS
|
||||||
|
"Build with Colors Enabled" ON)
|
||||||
|
if (COLORS)
|
||||||
|
add_definitions(-DPRETTY_COLORS)
|
||||||
|
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 -DNXDN=ON to enable new NXDN Sync Pattern Testing
|
||||||
|
option(NXDN
|
||||||
|
"Build with new NXDN Sync Pattern Testing Enabled" OFF)
|
||||||
|
if (NXDN)
|
||||||
|
add_definitions(-DNXDNTESTSYNC)
|
||||||
|
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 ()
|
||||||
|
|
||||||
include(git_revision)
|
include(git_revision)
|
||||||
git_describe(GIT_TAG)
|
git_describe(GIT_TAG)
|
||||||
|
|
||||||
@@ -14,7 +46,7 @@ find_package(MBE REQUIRED)
|
|||||||
find_package(ITPP REQUIRED)
|
find_package(ITPP REQUIRED)
|
||||||
find_package(RTLSDR)
|
find_package(RTLSDR)
|
||||||
find_package(Curses REQUIRED)
|
find_package(Curses REQUIRED)
|
||||||
find_package(PULSEAUDIO REQUIRED)
|
find_package(PulseAudio REQUIRED)
|
||||||
|
|
||||||
include_directories(SYSTEM ${LIBSNDFILE_INCLUDE_DIR} ${MBE_INCLUDE_DIR} ${ITPP_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR})
|
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})
|
set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${CURSES_LIBRARY})
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -2,13 +2,9 @@
|
|||||||
# Digital Speech Decoder - Florida Man Edition
|
# Digital Speech Decoder - Florida Man Edition
|
||||||
|
|
||||||
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
|
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"), [SDTRunk](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, OP25 Capture Bin compatability, etc. DSD-FME is primarily focused with Linux Desktop users, so please understand that this version may not compile, compile easily, or run correctly in other environments.
|
[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, 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.
|
||||||
|
|
||||||
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 others for the many hours of wav samples submitted 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. Thank you everybody.
|
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, 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. Thank you everybody.
|
||||||
|
|
||||||
Click image below for video of current DMR/P25 trunking capabilities.
|
|
||||||
|
|
||||||
[](https://www.youtube.com/watch?v=hGIijBbbUxg "DSD-FME Trunking Demo")
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -18,10 +14,6 @@ Click image below for video of current DMR/P25 trunking capabilities.
|
|||||||
|
|
||||||
See the [examples](https://github.com/lwvmobile/dsd-fme/tree/main/examples "examples") folder for information on [cloning and installing](https://github.com/lwvmobile/dsd-fme/blob/main/examples/Install_Notes.md "cloning and installing"), [example usage](https://github.com/lwvmobile/dsd-fme/blob/main/examples/Example_Usage.md "example usage"), and [trunking examples](https://github.com/lwvmobile/dsd-fme/blob/main/examples/trunking.sh "trunking examples").
|
See the [examples](https://github.com/lwvmobile/dsd-fme/tree/main/examples "examples") folder for information on [cloning and installing](https://github.com/lwvmobile/dsd-fme/blob/main/examples/Install_Notes.md "cloning and installing"), [example usage](https://github.com/lwvmobile/dsd-fme/blob/main/examples/Example_Usage.md "example usage"), and [trunking examples](https://github.com/lwvmobile/dsd-fme/blob/main/examples/trunking.sh "trunking examples").
|
||||||
|
|
||||||
## Notice
|
|
||||||
|
|
||||||
The pulseaudio branch has been deleted in favor of the new main branch which also uses Pulse Audio. Users moving to the main branch should review the help file and example usage files for changes in syntax. Users can download the last pulse audio branch version from the release link if they prefer the older version. Any pre-compiled windows versions found in the release link will be considered legacy as well, and do not feature trunking support and have older handling for some other modes. Users are free to use those, but keep in mind the use case syntax may and will be different between versions. Furthermore, any wiki articles with 'auto intstall scripts' made for windows users may contain outdated information for building the deleted pulseaudio branch, please adjust any information found in those accordingly.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Copyright (C) 2010 DSD Author
|
Copyright (C) 2010 DSD Author
|
||||||
GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
|
GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
|
||||||
|
|||||||
BIN
dsd-fme.png
BIN
dsd-fme.png
Binary file not shown.
|
Before Width: | Height: | Size: 706 KiB |
BIN
dsd-fme2.png
BIN
dsd-fme2.png
Binary file not shown.
|
Before Width: | Height: | Size: 315 KiB After Width: | Height: | Size: 125 KiB |
BIN
dsd-fme3.png
BIN
dsd-fme3.png
Binary file not shown.
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 251 KiB |
@@ -16,6 +16,24 @@
|
|||||||
-fx X2-TDMA
|
-fx X2-TDMA
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## New -- Experimental Conventional Frequency "Fast Scanner"
|
||||||
|
This feature is used to allow DSD-FME to use RIGCTL or RTL input and cycle through frequencies as fast as possible 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 rapidly 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 fast scanner switch.
|
||||||
|
|
||||||
|
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 NXDN98 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 is purely set by your CPU/GPU, and also by other factors like using SDR++ server to connect to a SDR++ client, or RTL_TCP server to client, etc, so faster computers scan faster, and slower will scan slower, slower scans may require multiple duplicate entries into your scanner csv file if you make a really large one.
|
||||||
|
|
||||||
|
Please Note: DMR Simplex may not behave well on fast 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
|
## Trunking Examples
|
||||||
Please see trunking.sh for sample start up scripts or scroll down to the bottom for more explanation.
|
Please see trunking.sh for sample start up scripts or scroll down to the bottom for more explanation.
|
||||||
|
|
||||||
@@ -117,14 +135,18 @@ Trunking Note3: DMR Trunking has been coded, and some testing and tweaks have be
|
|||||||
|
|
||||||
Use channel 54 in your import file, which would correspond to dsdplus channels 109 and 110 (109 = TS0 / 110 = TS1).
|
Use channel 54 in your import file, which would correspond to dsdplus channels 109 and 110 (109 = TS0 / 110 = TS1).
|
||||||
|
|
||||||
For Connect Plus, enumerate your list from 1 to the last channel and add the frequency. For Capacity Plus, Rest Channels 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 RF frequency as two seperate channels, 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 will lose the rest channel and will have to hunt through all frequencies to find it again.
|
For Connect Plus, enumerate your list from 1 to the last channel and add the frequency. For Capacity Plus, Rest Channels 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 will lose the rest channel and will have to hunt through all frequencies to find it again.
|
||||||
|
|
||||||
Currently uncoded/unknown DMR trunking systems include Hytera XPT.
|
Trunking Note4: NXDN Trunking v1 will require a channel map. Please see the example folder for an appropriate channel map. NOTICE: NXDN trunking will not work properly with RTL input method due to the internal handling of the RTL dongle, when using squelch, it will effectively stop all processing (including trunking/tuning) until signal is regained, but squelch is required on NXDN to prevent false sync patterns.
|
||||||
|
|
||||||
Trunking Note4: NXDN Trunking may also require a channel map file, depending on the system. If it uses a custom range (above 800), then channels will need to be mapped. If channels do not require mapping (have channels below 800) but you are not tuning properly, then please use a channel_map and please report the issue in the issues along with the channels you are tuning and the actual rf frequency so corrections can be made.
|
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.
|
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: Experimental 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 ##
|
## 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:
|
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:
|
||||||
@@ -147,6 +169,7 @@ s - stop playing symbol capture bin or wav input file
|
|||||||
P - start per call decoded wav files
|
P - start per call decoded wav files
|
||||||
p - stop per call decoded wav files
|
p - stop per call decoded wav files
|
||||||
t - toggle trunking (needs either rtl input, or rigctl connection)
|
t - toggle trunking (needs either rtl input, or rigctl connection)
|
||||||
|
y - toggle scanner (needs either rtl input, or rigctl connection)
|
||||||
1 - Lockout Tuning/Playback of TG in Slot 1 or Conventional (Current Session Only)
|
1 - Lockout Tuning/Playback of TG in Slot 1 or Conventional (Current Session Only)
|
||||||
2 - Lockout Tuning/Playback of TG in Slot 2 (Current Session Only)
|
2 - Lockout Tuning/Playback of TG in Slot 2 (Current Session Only)
|
||||||
0 - Toggle Audio Smoothing - May produce crackling if enabled on RTL/TCP or wav/bin files
|
0 - Toggle Audio Smoothing - May produce crackling if enabled on RTL/TCP or wav/bin files
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ Optional 'Virtual Sinks' for routing audio from SDR++ or GQRX, Media Players, et
|
|||||||
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.
|
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
|
pactl 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
|
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:
|
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:
|
||||||
|
|||||||
10
examples/hytera_xpt_chan.csv
Normal file
10
examples/hytera_xpt_chan.csv
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
LSN Number(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
|
||||||
|
|
||||||
|
6
examples/multi_key.csv
Normal file
6
examples/multi_key.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
key id or tg id (dec), key number or value (dec) //NXDN, BP, 10-char Hytera BP only
|
||||||
|
2,70
|
||||||
|
1,123
|
||||||
|
100,70
|
||||||
|
12,48713912656
|
||||||
|
672560,254
|
||||||
|
8
examples/nxdn_chan_map.csv
Normal file
8
examples/nxdn_chan_map.csv
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
channel(dec), freq(Hz)
|
||||||
|
141,423862500
|
||||||
|
142,424337500
|
||||||
|
143,424912500
|
||||||
|
203,424100000
|
||||||
|
204,424625000
|
||||||
|
271,422650000
|
||||||
|
302,423287500
|
||||||
|
5
examples/nxdn_sc_key.csv
Normal file
5
examples/nxdn_sc_key.csv
Normal 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
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#dsd-fme -i tcp:192.168.7.8:7355 -U 4532 -T -f2 -m2 -N 2> log.ans
|
#dsd-fme -i tcp:192.168.7.8:7355 -U 4532 -T -f2 -m2 -N 2> log.ans
|
||||||
#dsd-fme -i rtl:0:855.625M:26:-2:12:0:6020 -T -f2 -m2 -N 2> log.ans
|
#dsd-fme -i rtl:0:855.625M:26:-2:12:0:6020 -T -f2 -m2 -N 2> log.ans
|
||||||
|
|
||||||
#DMR TIII, Con+, Cap+
|
#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 tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans
|
||||||
#dsd-fme -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans
|
#dsd-fme -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans
|
||||||
|
|
||||||
@@ -21,13 +21,13 @@ dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans
|
|||||||
#dsd-fme -fp -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
|
#dsd-fme -fp -i tcp:192.168.7.5:7355 -U 4532 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
|
||||||
#dsd-fme -fp -i rtl:0:850M:26:-2:24:0:6020 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
|
#dsd-fme -fp -i rtl:0:850M:26:-2:24:0:6020 -T -C edacs_channel_map.csv -G group.csv -N 2> log.ans
|
||||||
|
|
||||||
#NXDN48 Trunking with Standard Band Plan (Channels 0-800)
|
|
||||||
#dsd-fme -fi -i tcp -T -U 4532 -N 2> log.ans
|
|
||||||
#dsd-fme -fi -i rtl:0:450M:26:-2:8:75:6020 -T -G group.csv -N 2> log.ans
|
|
||||||
|
|
||||||
#NXDN48 Trunking with Channel Map (Custom Channels > 800)
|
#NXDN48 Trunking with Channel Map (Custom Channels > 800)
|
||||||
#dsd-fme -fi -i tcp -T -U 4532 -C channel_map.csv -N 2> log.ans
|
#dsd-fme -fi -i tcp -T -U 4532 -C channel_map.csv -N 2> log.ans
|
||||||
#dsd-fme -fi -i rtl:0:450M:26:-2:8:75:6020 -T -G group.csv -C channel_map.csv -N 2> log.ans
|
#NOTE! NXDN Trunking will not work correctly with the RTL input method
|
||||||
|
|
||||||
|
#NXDN96 Trunking with Channel Map (Custom Channels > 800)
|
||||||
|
#dsd-fme -fn -i tcp -T -U 4532 -C channel_map.csv -N 2> log.ans
|
||||||
|
#NOTE! NXDN Trunking will not work correctly with the RTL input method
|
||||||
|
|
||||||
#Notes: parameters after -i tcp can be omitted if using localhost as the default hostname to connect
|
#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
|
#and 7355 as the default port number. -U is the port number for RIGCTL and will mirror the tcp hostname
|
||||||
|
|||||||
126
include/dsd.h
126
include/dsd.h
@@ -17,7 +17,8 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//pretty pretty colors
|
//defined by CMakeLists.txt -- Disable by using cmake -DCOLORS=OFF ..
|
||||||
|
#ifdef PRETTY_COLORS
|
||||||
#define KNRM "\x1B[0m"
|
#define KNRM "\x1B[0m"
|
||||||
#define KRED "\x1B[31m"
|
#define KRED "\x1B[31m"
|
||||||
#define KGRN "\x1B[32m"
|
#define KGRN "\x1B[32m"
|
||||||
@@ -26,6 +27,16 @@
|
|||||||
#define KMAG "\x1B[35m"
|
#define KMAG "\x1B[35m"
|
||||||
#define KCYN "\x1B[36m"
|
#define KCYN "\x1B[36m"
|
||||||
#define KWHT "\x1B[37m"
|
#define KWHT "\x1B[37m"
|
||||||
|
#else
|
||||||
|
#define KNRM ""
|
||||||
|
#define KRED ""
|
||||||
|
#define KGRN ""
|
||||||
|
#define KYEL ""
|
||||||
|
#define KBLU ""
|
||||||
|
#define KMAG ""
|
||||||
|
#define KCYN ""
|
||||||
|
#define KWHT ""
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -199,8 +210,10 @@ typedef struct
|
|||||||
int playoffsetR;
|
int playoffsetR;
|
||||||
char mbe_out_dir[1024];
|
char mbe_out_dir[1024];
|
||||||
char mbe_out_file[1024];
|
char mbe_out_file[1024];
|
||||||
|
char mbe_out_fileR[1024]; //second slot on a TDMA system
|
||||||
char mbe_out_path[2048]; //1024
|
char mbe_out_path[2048]; //1024
|
||||||
FILE *mbe_out_f;
|
FILE *mbe_out_f;
|
||||||
|
FILE *mbe_out_fR; //second slot on a TDMA system
|
||||||
FILE *symbol_out_f;
|
FILE *symbol_out_f;
|
||||||
float audio_gain;
|
float audio_gain;
|
||||||
float audio_gainR;
|
float audio_gainR;
|
||||||
@@ -214,6 +227,7 @@ typedef struct
|
|||||||
char szNumbers[1024]; //**tera 10/32/64 char str
|
char szNumbers[1024]; //**tera 10/32/64 char str
|
||||||
short int symbol_out;
|
short int symbol_out;
|
||||||
short int mbe_out; //flag for mbe out, don't attempt fclose more than once
|
short int mbe_out; //flag for mbe out, don't attempt fclose more than once
|
||||||
|
short int mbe_outR; //flag for mbe out, don't attempt fclose more than once
|
||||||
SNDFILE *wav_out_f;
|
SNDFILE *wav_out_f;
|
||||||
SNDFILE *wav_out_fR;
|
SNDFILE *wav_out_fR;
|
||||||
SNDFILE *wav_out_raw;
|
SNDFILE *wav_out_raw;
|
||||||
@@ -318,12 +332,15 @@ typedef struct
|
|||||||
|
|
||||||
int p25_trunk; //experimental P25 trunking with RIGCTL (or RTLFM)
|
int p25_trunk; //experimental P25 trunking with RIGCTL (or RTLFM)
|
||||||
int p25_is_tuned; //set to 1 if currently on VC, set back to 0 if on CC
|
int p25_is_tuned; //set to 1 if currently on VC, set back to 0 if on CC
|
||||||
int trunk_hangtime; //hangtime in seconds before tuning back to CC
|
float trunk_hangtime; //hangtime in seconds before tuning back to CC
|
||||||
|
|
||||||
|
int scanner_mode; //experimental -- use the channel map as a conventional scanner, quicker tuning, but no CC
|
||||||
|
|
||||||
//csv import filenames
|
//csv import filenames
|
||||||
char group_in_file[1024];
|
char group_in_file[1024];
|
||||||
char lcn_in_file[1024];
|
char lcn_in_file[1024];
|
||||||
char chan_in_file[1024];
|
char chan_in_file[1024];
|
||||||
|
char key_in_file[1024];
|
||||||
//end import filenames
|
//end import filenames
|
||||||
|
|
||||||
//reverse mute
|
//reverse mute
|
||||||
@@ -348,6 +365,13 @@ typedef struct
|
|||||||
//Trunking - Tune Data Calls
|
//Trunking - Tune Data Calls
|
||||||
uint8_t trunk_tune_data_calls;
|
uint8_t trunk_tune_data_calls;
|
||||||
|
|
||||||
|
//Trunking - Tune Enc Calls (P25 only on applicable grants with svc opts)
|
||||||
|
uint8_t trunk_tune_enc_calls;
|
||||||
|
|
||||||
|
//'DSP' Format Output
|
||||||
|
uint8_t use_dsp_output;
|
||||||
|
char dsp_out_file[2048];
|
||||||
|
|
||||||
} dsd_opts;
|
} dsd_opts;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -501,27 +525,32 @@ typedef struct
|
|||||||
|
|
||||||
unsigned int dmr_fid;
|
unsigned int dmr_fid;
|
||||||
unsigned int dmr_so;
|
unsigned int dmr_so;
|
||||||
|
unsigned int dmr_flco;
|
||||||
|
|
||||||
unsigned int dmr_fidR;
|
unsigned int dmr_fidR;
|
||||||
unsigned int dmr_soR;
|
unsigned int dmr_soR;
|
||||||
|
unsigned int dmr_flcoR;
|
||||||
|
|
||||||
char slot1light[8];
|
char slot1light[8];
|
||||||
char slot2light[8];
|
char slot2light[8];
|
||||||
int directmode;
|
int directmode;
|
||||||
|
|
||||||
int dmr_stereo_payload[144]; //load up 144 dibit buffer for every single DMR TDMA frame
|
int dmr_stereo_payload[144]; //load up 144 dibit buffer for every single DMR TDMA frame
|
||||||
uint8_t data_header_blocks[2]; //collect number of blocks to follow from data header per slot
|
int data_header_blocks[2]; //collect number of blocks to follow from data header per slot
|
||||||
|
int data_block_counter[2]; //counter for number of data blocks collected
|
||||||
|
uint8_t data_header_valid[2]; //flag for verifying the data header if still valid (in case of tact/burst fec errs)
|
||||||
uint8_t data_header_padding[2]; //collect number of padding octets in last block per slot
|
uint8_t data_header_padding[2]; //collect number of padding octets in last block per slot
|
||||||
uint8_t data_header_format[2]; //collect format of data header (conf or unconf) per slot
|
uint8_t data_header_format[2]; //collect format of data header (conf or unconf) per slot
|
||||||
uint8_t data_header_sap[2]; //collect sap info per slot
|
uint8_t data_header_sap[2]; //collect sap info per slot
|
||||||
uint8_t data_block_counter[2]; //counter for number of data blocks collected
|
|
||||||
uint8_t data_p_head[2]; //flag for dmr proprietary header to follow
|
uint8_t data_p_head[2]; //flag for dmr proprietary header to follow
|
||||||
|
|
||||||
//new stuff below here
|
//new stuff below here
|
||||||
uint8_t data_conf_data[2]; //flag for confirmed data blocks per slot
|
uint8_t data_conf_data[2]; //flag for confirmed data blocks per slot
|
||||||
uint8_t dmr_pdu_sf[2][288]; //unified pdu 'superframe' //[slot][byte]
|
uint8_t dmr_pdu_sf[2][288]; //unified pdu 'superframe' //[slot][byte]
|
||||||
|
uint8_t cap_plus_csbk_bits[2][12*8*8]; //CSBK Cap+ FL initial and appended block bit storage, by slot
|
||||||
|
uint8_t cap_plus_block_num[2]; //received block number storage -- per time slot
|
||||||
uint8_t data_block_crc_valid[2][25]; //flag each individual block as good crc on confirmed data
|
uint8_t data_block_crc_valid[2][25]; //flag each individual block as good crc on confirmed data
|
||||||
char dmr_embedded_signalling[2][6][48]; //embedded signalling 2 slots by 6 vc by 48 bits (replacing TS1SuperFrame.TimeSlotRawVoiceFrame.Sync structure)
|
char dmr_embedded_signalling[2][7][48]; //embedded signalling 2 slots by 6 vc by 48 bits (replacing TS1SuperFrame.TimeSlotRawVoiceFrame.Sync structure)
|
||||||
|
|
||||||
char dmr_cach_fragment[4][17]; //unsure of size, will need to check/verify
|
char dmr_cach_fragment[4][17]; //unsure of size, will need to check/verify
|
||||||
int dmr_cach_counter; //counter for dmr_cach_fragments 0-3; not sure if needed yet.
|
int dmr_cach_counter; //counter for dmr_cach_fragments 0-3; not sure if needed yet.
|
||||||
@@ -534,12 +563,14 @@ typedef struct
|
|||||||
char dmr_lrrp_gps[2][200]; //2 slots by 99 char string for string lrrp gps
|
char dmr_lrrp_gps[2][200]; //2 slots by 99 char string for string lrrp gps
|
||||||
char dmr_site_parms[200]; //string for site/net info depending on type of DMR system (TIII or Con+)
|
char dmr_site_parms[200]; //string for site/net info depending on type of DMR system (TIII or Con+)
|
||||||
char call_string[2][200]; //string for call information
|
char call_string[2][200]; //string for call information
|
||||||
|
char active_channel[31][200]; //string for storing and displaying active trunking channels
|
||||||
|
|
||||||
|
|
||||||
dPMRVoiceFS2Frame_t dPMRVoiceFS2Frame;
|
dPMRVoiceFS2Frame_t dPMRVoiceFS2Frame;
|
||||||
|
|
||||||
unsigned char * dpmr_caller_id;
|
char dpmr_caller_id[20];
|
||||||
unsigned char * dpmr_target_id;
|
char dpmr_target_id[20];
|
||||||
|
|
||||||
int dpmr_color_code;
|
int dpmr_color_code;
|
||||||
|
|
||||||
short int dmr_stereo; //need state variable for upsample function
|
short int dmr_stereo; //need state variable for upsample function
|
||||||
@@ -564,6 +595,8 @@ typedef struct
|
|||||||
unsigned long long int p2_wacn;
|
unsigned long long int p2_wacn;
|
||||||
unsigned long long int p2_sysid;
|
unsigned long long int p2_sysid;
|
||||||
unsigned long long int p2_cc; //p1 NAC
|
unsigned long long int p2_cc; //p1 NAC
|
||||||
|
unsigned long long int p2_siteid;
|
||||||
|
unsigned long long int p2_rfssid;
|
||||||
int p2_hardset; //flag for checking whether or not P2 wacn and sysid are hard set by user
|
int p2_hardset; //flag for checking whether or not P2 wacn and sysid are hard set by user
|
||||||
int p2_scramble_offset; //offset counter for scrambling application
|
int p2_scramble_offset; //offset counter for scrambling application
|
||||||
int p2_vch_chan_num; //vch channel number (0 or 1, not the 0-11 TS)
|
int p2_vch_chan_num; //vch channel number (0 or 1, not the 0-11 TS)
|
||||||
@@ -572,6 +605,7 @@ typedef struct
|
|||||||
int p2_is_lcch; //flag to tell us when a frame is lcch and not sacch
|
int p2_is_lcch; //flag to tell us when a frame is lcch and not sacch
|
||||||
|
|
||||||
//iden freq storage for frequency calculations
|
//iden freq storage for frequency calculations
|
||||||
|
int p25_chan_tdma[16]; //set from iden_up vs iden_up_tdma
|
||||||
int p25_chan_iden;
|
int p25_chan_iden;
|
||||||
int p25_chan_type[16];
|
int p25_chan_type[16];
|
||||||
int p25_trans_off[16];
|
int p25_trans_off[16];
|
||||||
@@ -617,6 +651,7 @@ typedef struct
|
|||||||
int lcn_freq_roll; //number we have 'rolled' to in search of the CC
|
int lcn_freq_roll; //number we have 'rolled' to in search of the CC
|
||||||
time_t last_cc_sync_time; //use this to start hunting for CC after signal lost
|
time_t last_cc_sync_time; //use this to start hunting for CC after signal lost
|
||||||
time_t last_vc_sync_time; //flag for voice activity bursts, tune back on con+ after more than x seconds no voice
|
time_t last_vc_sync_time; //flag for voice activity bursts, tune back on con+ after more than x seconds no voice
|
||||||
|
time_t last_active_time; //time the a 'call grant' was received, used to clear the active_channel strings after x seconds
|
||||||
int is_con_plus; //con_plus flag for knowing its safe to skip payload channel after x seconds of no voice sync
|
int is_con_plus; //con_plus flag for knowing its safe to skip payload channel after x seconds of no voice sync
|
||||||
|
|
||||||
//new nxdn stuff
|
//new nxdn stuff
|
||||||
@@ -628,11 +663,22 @@ typedef struct
|
|||||||
uint8_t nxdn_sacch_frame_segcrc[4];
|
uint8_t nxdn_sacch_frame_segcrc[4];
|
||||||
uint8_t nxdn_alias_block_number;
|
uint8_t nxdn_alias_block_number;
|
||||||
char nxdn_alias_block_segment[4][4][8];
|
char nxdn_alias_block_segment[4][4][8];
|
||||||
|
|
||||||
//site/srv/cch info
|
//site/srv/cch info
|
||||||
char nxdn_location_category[14];
|
char nxdn_location_category[14];
|
||||||
uint32_t nxdn_location_sys_code;
|
uint32_t nxdn_location_sys_code;
|
||||||
uint16_t nxdn_location_site_code;
|
uint16_t nxdn_location_site_code;
|
||||||
|
|
||||||
|
//channel access information
|
||||||
|
uint8_t nxdn_rcn;
|
||||||
|
uint8_t nxdn_base_freq;
|
||||||
|
uint8_t nxdn_step;
|
||||||
|
uint8_t nxdn_bw;
|
||||||
|
|
||||||
|
//multi-key array
|
||||||
|
unsigned long long int rkey_array[0xFFFF];
|
||||||
|
int keyloader; //let us know the keyloader is active
|
||||||
|
|
||||||
//dmr late entry mi
|
//dmr late entry mi
|
||||||
uint64_t late_entry_mi_fragment[2][7][3];
|
uint64_t late_entry_mi_fragment[2][7][3];
|
||||||
|
|
||||||
@@ -704,6 +750,26 @@ typedef struct
|
|||||||
#define INV_PROVOICE_EA_SYNC "13313133113113333311313133133311"
|
#define INV_PROVOICE_EA_SYNC "13313133113113333311313133133311"
|
||||||
#define PROVOICE_EA_SYNC "31131311331331111133131311311133"
|
#define PROVOICE_EA_SYNC "31131311331331111133131311311133"
|
||||||
|
|
||||||
|
//define the provoice conventional string pattern to default 85/85 if not enabled, else mute it so we won't double sync on accident in frame_sync
|
||||||
|
#ifdef PVCONVENTIONAL
|
||||||
|
#define PROVOICE_CONV "00000000000000000000000000000000" //all zeroes should be unobtainable string in the frame_sync synctests
|
||||||
|
#define INV_PROVOICE_CONV "00000000000000000000000000000000" //all zeroes should be unobtainable string in the frame_sync synctests
|
||||||
|
#else
|
||||||
|
#define PROVOICE_CONV "13131333111311311313131313131313" //TX 85 RX 85 (default programming value)
|
||||||
|
#define INV_PROVOICE_CONV "31313111333133133131313131313131" //TX 85 RX 85 (default programming value)
|
||||||
|
#endif
|
||||||
|
//we use the short sync instead of the default 85/85 wnen PVCONVENTIONAL is defined by cmake
|
||||||
|
#define PROVOICE_CONV_SHORT "1313133311131131" //16-bit short pattern, last 16-bits change based on TX an RX values
|
||||||
|
#define INV_PROVOICE_CONV_SHORT "3131311133313313"
|
||||||
|
//In this pattern (inverted polarity, the norm for PV) 3 is bit 0, and 1 is bit 1 (2 level GFSK)
|
||||||
|
//same pattern //TX //RX
|
||||||
|
// Sync Pattern = 3131311133313313 31331131 31331131 TX/RX 77 -- 31331131 symbol = 01001101 binary = 77 decimal
|
||||||
|
// Sync Pattern = 3131311133313313 33333333 33333333 TX/RX 0 -- 33333333 symbol = 00000000 binary = 0 decimal
|
||||||
|
// Sync Pattern = 3131311133313313 33333331 33333331 TX/RX 1 -- 33333331 symbol = 00000001 binary = 1 decimal
|
||||||
|
// Sync Pattern = 3131311133313313 13131133 13131133 TX/RX 172 -- 13131133 symbol = 10101100 binary = 172 decimal
|
||||||
|
// Sync Pattern = 3131311133313313 11333111 11333111 TX/RX 199 -- 11333111 symbol = 11000111 binary = 199 decimal
|
||||||
|
// Sync Pattern = 3131311133313313 31313131 31313131 TX/RX 85 -- 31313131 symbol = 01010101 binary = 85 decimal
|
||||||
|
|
||||||
#define EDACS_SYNC "313131313131313131313111333133133131313131313131"
|
#define EDACS_SYNC "313131313131313131313111333133133131313131313131"
|
||||||
#define INV_EDACS_SYNC "131313131313131313131333111311311313131313131313"
|
#define INV_EDACS_SYNC "131313131313131313131333111311311313131313131313"
|
||||||
|
|
||||||
@@ -742,13 +808,16 @@ int get_dibit_and_analog_signal (dsd_opts * opts, dsd_state * state, int * out_a
|
|||||||
void skipDibit (dsd_opts * opts, dsd_state * state, int count);
|
void skipDibit (dsd_opts * opts, dsd_state * state, int count);
|
||||||
void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
||||||
void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
||||||
|
void saveAmbe2450DataR (dsd_opts * opts, dsd_state * state, char *ambe_d); //tdma slot 2
|
||||||
void PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
void PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
||||||
void PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
void PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
||||||
int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
|
||||||
int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
|
||||||
void openMbeInFile (dsd_opts * opts, dsd_state * state);
|
void openMbeInFile (dsd_opts * opts, dsd_state * state);
|
||||||
void closeMbeOutFile (dsd_opts * opts, dsd_state * state);
|
void closeMbeOutFile (dsd_opts * opts, dsd_state * state);
|
||||||
|
void closeMbeOutFileR (dsd_opts * opts, dsd_state * state); //tdma slot 2
|
||||||
void openMbeOutFile (dsd_opts * opts, dsd_state * state);
|
void openMbeOutFile (dsd_opts * opts, dsd_state * state);
|
||||||
|
void openMbeOutFileR (dsd_opts * opts, dsd_state * state); //tdma slot 2
|
||||||
void openWavOutFile (dsd_opts * opts, dsd_state * state);
|
void openWavOutFile (dsd_opts * opts, dsd_state * state);
|
||||||
void openWavOutFileL (dsd_opts * opts, dsd_state * state);
|
void openWavOutFileL (dsd_opts * opts, dsd_state * state);
|
||||||
void openWavOutFileR (dsd_opts * opts, dsd_state * state);
|
void openWavOutFileR (dsd_opts * opts, dsd_state * state);
|
||||||
@@ -782,6 +851,9 @@ int getSymbol (dsd_opts * opts, dsd_state * state, int have_sync);
|
|||||||
void upsample (dsd_state * state, float invalue);
|
void upsample (dsd_state * state, float invalue);
|
||||||
void processDSTAR (dsd_opts * opts, dsd_state * state);
|
void processDSTAR (dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
|
//new p25lcw
|
||||||
|
void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t irrecoverable_errors);
|
||||||
|
|
||||||
void processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, char *lcinfo);
|
void processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, char *lcinfo);
|
||||||
void processHDU (dsd_opts * opts, dsd_state * state);
|
void processHDU (dsd_opts * opts, dsd_state * state);
|
||||||
void processLDU1 (dsd_opts * opts, dsd_state * state);
|
void processLDU1 (dsd_opts * opts, dsd_state * state);
|
||||||
@@ -794,14 +866,14 @@ void processX2TDMAvoice (dsd_opts * opts, dsd_state * state);
|
|||||||
void processDSTAR_HD (dsd_opts * opts, dsd_state * state);
|
void processDSTAR_HD (dsd_opts * opts, dsd_state * state);
|
||||||
void processYSF(dsd_opts * opts, dsd_state * state); //YSF
|
void processYSF(dsd_opts * opts, dsd_state * state); //YSF
|
||||||
void processP2(dsd_opts * opts, dsd_state * state); //P2
|
void processP2(dsd_opts * opts, dsd_state * state); //P2
|
||||||
void processTSBK(dsd_opts * opts, dsd_state * state);
|
void processTSBK(dsd_opts * opts, dsd_state * state); //P25 Trunking Single Block
|
||||||
|
void processMPDU(dsd_opts * opts, dsd_state * state); //P25 Multi Block PDU (SAP 0x61 FMT 0x15 or 0x17 for Trunking Blocks)
|
||||||
short dmr_filter(short sample);
|
short dmr_filter(short sample);
|
||||||
short nxdn_filter(short sample);
|
short nxdn_filter(short sample);
|
||||||
short dpmr_filter(short sample);
|
short dpmr_filter(short sample);
|
||||||
|
|
||||||
int strncmperr(const char *s1, const char *s2, size_t size, int MaxErr);
|
int strncmperr(const char *s1, const char *s2, size_t size, int MaxErr);
|
||||||
/* Global functions */
|
uint64_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength);
|
||||||
uint32_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength);
|
|
||||||
|
|
||||||
void ncursesOpen (dsd_opts * opts, dsd_state * state);
|
void ncursesOpen (dsd_opts * opts, dsd_state * state);
|
||||||
void ncursesPrinter (dsd_opts * opts, dsd_state * state);
|
void ncursesPrinter (dsd_opts * opts, dsd_state * state);
|
||||||
@@ -810,10 +882,15 @@ void ncursesClose ();
|
|||||||
//new NXDN Functions start here!
|
//new NXDN Functions start here!
|
||||||
void nxdn_frame (dsd_opts * opts, dsd_state * state);
|
void nxdn_frame (dsd_opts * opts, dsd_state * state);
|
||||||
void nxdn_descramble (uint8_t dibits[], int len);
|
void nxdn_descramble (uint8_t dibits[], int len);
|
||||||
|
//nxdn deinterleaving/depuncturing functions
|
||||||
void nxdn_deperm_facch (dsd_opts * opts, dsd_state * state, uint8_t bits[144]);
|
void nxdn_deperm_facch (dsd_opts * opts, dsd_state * state, uint8_t bits[144]);
|
||||||
void nxdn_deperm_sacch (dsd_opts * opts, dsd_state * state, uint8_t bits[60]);
|
void nxdn_deperm_sacch (dsd_opts * opts, dsd_state * state, uint8_t bits[60]);
|
||||||
void nxdn_deperm_cac (dsd_opts * opts, dsd_state * state, uint8_t bits[300]);
|
void nxdn_deperm_cac (dsd_opts * opts, dsd_state * state, uint8_t bits[300]);
|
||||||
void nxdn_deperm_facch2_udch (dsd_opts * opts, dsd_state * state, uint8_t bits[348]);
|
void nxdn_deperm_facch2_udch (dsd_opts * opts, dsd_state * state, uint8_t bits[348], uint8_t type);
|
||||||
|
//type-d 'idas' deinterleaving/depuncturing functions
|
||||||
|
void nxdn_deperm_scch(dsd_opts * opts, dsd_state * state, uint8_t bits[60], uint8_t direction);
|
||||||
|
void nxdn_deperm_facch3_udch2(dsd_opts * opts, dsd_state * state, uint8_t bits[288], uint8_t type);
|
||||||
|
//end
|
||||||
void nxdn_message_type (dsd_opts * opts, dsd_state * state, uint8_t MessageType);
|
void nxdn_message_type (dsd_opts * opts, dsd_state * state, uint8_t MessageType);
|
||||||
void nxdn_voice (dsd_opts * opts, dsd_state * state, int voice, uint8_t dbuf[182]);
|
void nxdn_voice (dsd_opts * opts, dsd_state * state, int voice, uint8_t dbuf[182]);
|
||||||
|
|
||||||
@@ -823,6 +900,7 @@ static uint8_t crc6(const uint8_t buf[], int len);
|
|||||||
static uint16_t crc12f(const uint8_t buf[], int len);
|
static uint16_t crc12f(const uint8_t buf[], int len);
|
||||||
static uint16_t crc15(const uint8_t buf[], int len);
|
static uint16_t crc15(const uint8_t buf[], int len);
|
||||||
static uint16_t crc16cac(const uint8_t buf[], int len);
|
static uint16_t crc16cac(const uint8_t buf[], int len);
|
||||||
|
static uint8_t crc7_scch(uint8_t bits[], int len); //converted from op25 crc6
|
||||||
|
|
||||||
/* NXDN Convolution functions */
|
/* NXDN Convolution functions */
|
||||||
void CNXDNConvolution_start(void);
|
void CNXDNConvolution_start(void);
|
||||||
@@ -845,7 +923,9 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
|
|||||||
void NXDN_decode_cch_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
void NXDN_decode_cch_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
||||||
void NXDN_decode_srv_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
void NXDN_decode_srv_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
||||||
void NXDN_decode_site_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
void NXDN_decode_site_info(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
||||||
void nxdn_location_id_handler (dsd_state * state, uint32_t location_id);
|
void NXDN_decode_adj_site(dsd_opts * opts, dsd_state * state, uint8_t * Message);
|
||||||
|
//Type-D SCCH Message Decoder
|
||||||
|
void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uint8_t direction);
|
||||||
|
|
||||||
void dPMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state);
|
void dPMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
@@ -861,7 +941,7 @@ int32_t GetdPmrColorCode(uint8_t ChannelCodeBit[24]);
|
|||||||
void BPTCDeInterleaveDMRData(uint8_t * Input, uint8_t * Output);
|
void BPTCDeInterleaveDMRData(uint8_t * Input, uint8_t * Output);
|
||||||
uint32_t BPTC_196x96_Extract_Data(uint8_t InputDeInteleavedData[196], uint8_t DMRDataExtracted[96], uint8_t R[3]);
|
uint32_t BPTC_196x96_Extract_Data(uint8_t InputDeInteleavedData[196], uint8_t DMRDataExtracted[96], uint8_t R[3]);
|
||||||
uint32_t BPTC_128x77_Extract_Data(uint8_t InputDataMatrix[8][16], uint8_t DMRDataExtracted[77]);
|
uint32_t BPTC_128x77_Extract_Data(uint8_t InputDataMatrix[8][16], uint8_t DMRDataExtracted[77]);
|
||||||
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);
|
||||||
|
|
||||||
//Reed Solomon (12,9) functions
|
//Reed Solomon (12,9) functions
|
||||||
void rs_12_9_calc_syndrome(rs_12_9_codeword_t *codeword, rs_12_9_poly_t *syndrome);
|
void rs_12_9_calc_syndrome(rs_12_9_codeword_t *codeword, rs_12_9_poly_t *syndrome);
|
||||||
@@ -874,6 +954,9 @@ uint16_t ComputeCrcCCITT(uint8_t * DMRData);
|
|||||||
uint16_t ComputeCrcCCITT16d(const uint8_t buf[], uint8_t len);
|
uint16_t ComputeCrcCCITT16d(const uint8_t buf[], uint8_t len);
|
||||||
uint32_t ComputeAndCorrectFullLinkControlCrc(uint8_t * FullLinkControlDataBytes, uint32_t * CRCComputed, uint32_t CRCMask);
|
uint32_t ComputeAndCorrectFullLinkControlCrc(uint8_t * FullLinkControlDataBytes, uint32_t * CRCComputed, uint32_t CRCMask);
|
||||||
uint8_t ComputeCrc5Bit(uint8_t * DMRData);
|
uint8_t ComputeCrc5Bit(uint8_t * DMRData);
|
||||||
|
uint16_t ComputeCrc9Bit(uint8_t * DMRData, uint32_t NbData);
|
||||||
|
uint32_t ComputeCrc32Bit(uint8_t * DMRData, uint32_t NbData);
|
||||||
|
|
||||||
|
|
||||||
//new simplified dmr functions
|
//new simplified dmr functions
|
||||||
void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t databurst);
|
void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t databurst);
|
||||||
@@ -897,11 +980,12 @@ void dmrMSData (dsd_opts * opts, dsd_state * state);
|
|||||||
void dmrMSBootstrap (dsd_opts * opts, dsd_state * state);
|
void dmrMSBootstrap (dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
//dmr data header and multi block types (header, 1/2, 3/4, 1, Unified)
|
//dmr data header and multi block types (header, 1/2, 3/4, 1, Unified)
|
||||||
void dmr_dheader (dsd_opts * opts, dsd_state * state, uint8_t dheader[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors);
|
void dmr_dheader (dsd_opts * opts, dsd_state * state, uint8_t dheader[], uint8_t dheader_bits[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors);
|
||||||
void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_bytes[], uint8_t block_len, uint8_t databurst, uint8_t type);
|
void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_bytes[], uint8_t block_len, uint8_t databurst, uint8_t type);
|
||||||
void dmr_pdu (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[]);
|
void dmr_pdu (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[]);
|
||||||
void dmr_reset_blocks (dsd_opts * opts, dsd_state * state);
|
void dmr_reset_blocks (dsd_opts * opts, dsd_state * state);
|
||||||
uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[]);
|
void dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[]);
|
||||||
|
void dmr_locn (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[]);
|
||||||
|
|
||||||
//dmr alg stuff
|
//dmr alg stuff
|
||||||
void dmr_alg_reset (dsd_opts * opts, dsd_state * state);
|
void dmr_alg_reset (dsd_opts * opts, dsd_state * state);
|
||||||
@@ -909,14 +993,19 @@ void dmr_alg_refresh (dsd_opts * opts, dsd_state * state);
|
|||||||
void dmr_late_entry_mi_fragment (dsd_opts * opts, dsd_state * state, uint8_t vc, char ambe_fr[4][24], char ambe_fr2[4][24], char ambe_fr3[4][24]);
|
void dmr_late_entry_mi_fragment (dsd_opts * opts, dsd_state * state, uint8_t vc, char ambe_fr[4][24], char ambe_fr2[4][24], char ambe_fr3[4][24]);
|
||||||
void dmr_late_entry_mi (dsd_opts * opts, dsd_state * state);
|
void dmr_late_entry_mi (dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
|
//handle Single Burst (Voice Burst F) or Reverse Channel Signalling
|
||||||
|
void dmr_sbrc (dsd_opts * opts, dsd_state * state, uint8_t power);
|
||||||
|
|
||||||
//DMR FEC/CRC from Boatbod - OP25
|
//DMR FEC/CRC from Boatbod - OP25
|
||||||
bool Hamming17123(uint8_t* d);
|
bool Hamming17123(uint8_t* d);
|
||||||
uint8_t crc8(uint8_t bits[], unsigned int len);
|
uint8_t crc8(uint8_t bits[], unsigned int len);
|
||||||
bool crc8_ok(uint8_t bits[], unsigned int len);
|
bool crc8_ok(uint8_t bits[], unsigned int len);
|
||||||
|
uint8_t crc7(uint8_t bits[], unsigned int len);
|
||||||
|
|
||||||
//LFSR code courtesy of https://github.com/mattames/LFSR/
|
//LFSR code courtesy of https://github.com/mattames/LFSR/
|
||||||
void LFSR(dsd_state * state);
|
void LFSR(dsd_state * state);
|
||||||
void LFSRN (char * BufferIn, char * BufferOut, dsd_state * state);
|
void LFSRN (char * BufferIn, char * BufferOut, dsd_state * state);
|
||||||
|
void LFSR64(dsd_state * state);
|
||||||
|
|
||||||
void Hamming_7_4_init();
|
void Hamming_7_4_init();
|
||||||
void Hamming_7_4_encode(unsigned char *origBits, unsigned char *encodedBits);
|
void Hamming_7_4_encode(unsigned char *origBits, unsigned char *encodedBits);
|
||||||
@@ -1001,6 +1090,7 @@ unsigned long long int edacs_bch (unsigned long long int message);
|
|||||||
int csvGroupImport(dsd_opts * opts, dsd_state * state);
|
int csvGroupImport(dsd_opts * opts, dsd_state * state);
|
||||||
int csvLCNImport(dsd_opts * opts, dsd_state * state);
|
int csvLCNImport(dsd_opts * opts, dsd_state * state);
|
||||||
int csvChanImport(dsd_opts * opts, dsd_state * state);
|
int csvChanImport(dsd_opts * opts, dsd_state * state);
|
||||||
|
int csvKeyImport(dsd_opts * opts, dsd_state * state);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -1026,7 +1116,7 @@ bool CDMRTrellisDecode(const unsigned char* data, unsigned char* payload);
|
|||||||
int ez_rs28_ess (int payload[96], int parity[168]); //ezpwd bridge for FME
|
int ez_rs28_ess (int payload[96], int parity[168]); //ezpwd bridge for FME
|
||||||
int ez_rs28_facch (int payload[156], int parity[114]); //ezpwd bridge for FME
|
int ez_rs28_facch (int payload[156], int parity[114]); //ezpwd bridge for FME
|
||||||
int ez_rs28_sacch (int payload[180], int parity[132]); //ezpwd bridge for FME
|
int ez_rs28_sacch (int payload[180], int parity[132]); //ezpwd bridge for FME
|
||||||
unsigned long long int isch_lookup (unsigned long long int isch); //isch map lookup
|
int isch_lookup (unsigned long long int isch); //isch map lookup
|
||||||
int bd_bridge (int payload[196], uint8_t decoded[12]); //bridge to Michael Ossmann Block De-interleaver and 1/2 rate trellis decoder
|
int bd_bridge (int payload[196], uint8_t decoded[12]); //bridge to Michael Ossmann Block De-interleaver and 1/2 rate trellis decoder
|
||||||
int crc16_lb_bridge (int payload[190], int len);
|
int crc16_lb_bridge (int payload[190], int len);
|
||||||
int crc12_xb_bridge (int payload[190], int len);
|
int crc12_xb_bridge (int payload[190], int len);
|
||||||
|
|||||||
62
src/bptc.c
62
src/bptc.c
@@ -134,6 +134,13 @@ const uint8_t DeInterleaveReverseChannelBptc[32] =
|
|||||||
24, 9, 26, 11, 28, 13, 30, 15
|
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 ----------------------------------------------------------------*/
|
/* 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) */
|
/* 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][0] = 0; /* R(2) */
|
||||||
DataMatrix[0][1] = 0; /* R(1) */
|
// DataMatrix[0][1] = 0; /* R(1) */
|
||||||
DataMatrix[0][2] = 0; /* R(0) */
|
// DataMatrix[0][2] = 0; /* R(0) */
|
||||||
|
|
||||||
/* Init the Hamming (15,11,3) library
|
/* Init the Hamming (15,11,3) library
|
||||||
* Not needed because it has already been done
|
* 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 the number of irrecoverable Hamming errors */
|
||||||
return HammingIrrecoverableErrorNb;
|
return HammingIrrecoverableErrorNb;
|
||||||
} /* End BPTC_196x96_Extract_Data() */
|
} /* 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[11..15] = Hamming data
|
||||||
* DMRDataExtracted[16..31] = 16 bits of odd parity (to be checked)
|
* 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
|
* @return 0 = All is OK
|
||||||
* Other = Error - Irrecoverable Hamming parity check error number
|
* 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;
|
uint32_t i;
|
||||||
uint8_t DataMatrix[32];
|
uint8_t DataMatrix[32];
|
||||||
uint8_t LineUncorrected[16];
|
uint8_t LineUncorrected[16];
|
||||||
uint8_t LineCorrected[11];
|
uint8_t LineCorrected[11];
|
||||||
uint32_t HammingIrrecoverableErrorNb = 0;
|
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++)
|
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 */
|
/* Copy the entire input buffer to the output buffer */
|
||||||
for(i = 0; i < 32; i++)
|
for(i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
DMRDataExtracted[i] = DataMatrix[i];
|
DMRDataExtracted[i] = DataMatrix[i] & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the line to be corrected */
|
/* Prepare the line to be corrected */
|
||||||
for(i = 0; i < 16; i++)
|
for(i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
LineUncorrected[i] = DataMatrix[i];
|
LineUncorrected[i] = DataMatrix[i] & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply Hamming (16,11,4) code correction */
|
/* 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 */
|
/* Copy the corrected content to the output buffer */
|
||||||
for(i = 0; i < 11; i++)
|
for(i = 0; i < 11; i++)
|
||||||
{
|
{
|
||||||
DMRDataExtracted[i] = LineCorrected[i];
|
DMRDataExtracted[i] = LineCorrected[i] & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check Parity bits */
|
/* 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
|
/* Odd parity ==> If data = 1 then parity = 0
|
||||||
* If data = 0 then parity = 1 */
|
* 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 +
|
/* Return the number of irrecoverable Hamming errors +
|
||||||
* the number of parity check error */
|
* the number of parity check error */
|
||||||
return (HammingIrrecoverableErrorNb + ParityCheckErrorNb);
|
if(ParityCheckTypeOdd) return (HammingIrrecoverableErrorNb + ParityCheckOddErrorNb);
|
||||||
|
else return (HammingIrrecoverableErrorNb + ParityCheckEvenErrorNb);
|
||||||
|
|
||||||
} /* End BPTC_16x2_Extract_Data() */
|
} /* End BPTC_16x2_Extract_Data() */
|
||||||
|
|
||||||
|
|||||||
896
src/dmr_block.c
896
src/dmr_block.c
File diff suppressed because it is too large
Load Diff
152
src/dmr_bs.c
152
src/dmr_bs.c
@@ -42,6 +42,11 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
uint8_t vc1;
|
uint8_t vc1;
|
||||||
uint8_t vc2;
|
uint8_t vc2;
|
||||||
|
|
||||||
|
//assign as nonsensical numbers
|
||||||
|
uint8_t cc = 25;
|
||||||
|
uint8_t power = 9; //power and pre-emption indicator
|
||||||
|
uint8_t lcss = 9;
|
||||||
|
|
||||||
//would be ideal to grab all dibits and break them into bits to pass to new data handler?
|
//would be ideal to grab all dibits and break them into bits to pass to new data handler?
|
||||||
uint8_t dummy_bits[196];
|
uint8_t dummy_bits[196];
|
||||||
memset (dummy_bits, 0, sizeof(dummy_bits));
|
memset (dummy_bits, 0, sizeof(dummy_bits));
|
||||||
@@ -109,13 +114,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
//disabled for dmr_cach testing
|
//disabled for dmr_cach testing
|
||||||
tact_okay = 0;
|
tact_okay = 0;
|
||||||
if ( Hamming_7_4_decode (tact_bits) ) tact_okay = 1;
|
if ( Hamming_7_4_decode (tact_bits) ) tact_okay = 1;
|
||||||
if (tact_okay != 1)
|
if (tact_okay != 1) goto END; //when going to end for bad tact or emb, consider using getdibit or skipdibit to 'stash' dibits and get better return on next sync pattern? in data particularly
|
||||||
{
|
|
||||||
if (opts->aggressive_framesync == 1)
|
|
||||||
{
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internalslot = state->currentslot = tact_bits[1];
|
internalslot = state->currentslot = tact_bits[1];
|
||||||
|
|
||||||
@@ -189,13 +189,13 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
syncdata[(2*i)+1] = (1 & dibit); // bit 0
|
syncdata[(2*i)+1] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
//embedded link control
|
//embedded link control
|
||||||
if(internalslot == 0 && vc1 > 1 && vc1 < 6) //grab on vc1 values 2-5 B C D and E
|
if(internalslot == 0 && vc1 > 1 && vc1 < 7) //grab on vc1 values 2-5 B C D and E (F for Single/RC)
|
||||||
{
|
{
|
||||||
state->dmr_embedded_signalling[internalslot][vc1-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
state->dmr_embedded_signalling[internalslot][vc1-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
||||||
state->dmr_embedded_signalling[internalslot][vc1-1][i*2+1] = (1 & dibit); // bit 0
|
state->dmr_embedded_signalling[internalslot][vc1-1][i*2+1] = (1 & dibit); // bit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if(internalslot == 1 && vc2 > 1 && vc2 < 6) //grab on vc2 values 2-5 B C D and E
|
if(internalslot == 1 && vc2 > 1 && vc2 < 7) //grab on vc2 values 2-5 B C D and E (F for Single/RC)
|
||||||
{
|
{
|
||||||
state->dmr_embedded_signalling[internalslot][vc2-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
state->dmr_embedded_signalling[internalslot][vc2-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
||||||
state->dmr_embedded_signalling[internalslot][vc2-1][i*2+1] = (1 & dibit); // bit 0
|
state->dmr_embedded_signalling[internalslot][vc2-1][i*2+1] = (1 & dibit); // bit 0
|
||||||
@@ -265,6 +265,9 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
else fprintf (stderr,"Sync: -DMR ");
|
else fprintf (stderr,"Sync: -DMR ");
|
||||||
|
|
||||||
vc1 = 1;
|
vc1 = 1;
|
||||||
|
|
||||||
|
//close MBEout file - slot 1
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
if (internalslot == 1)
|
if (internalslot == 1)
|
||||||
{
|
{
|
||||||
@@ -276,6 +279,9 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
vc2 = 1;
|
vc2 = 1;
|
||||||
|
|
||||||
|
//close MBEout file - slot 2
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
|
||||||
}
|
}
|
||||||
dmr_data_sync (opts, state);
|
dmr_data_sync (opts, state);
|
||||||
skipcount++;
|
skipcount++;
|
||||||
@@ -294,9 +300,9 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
if ( (strcmp (sync, DMR_BS_VOICE_SYNC) != 0) && emb_ok == 0) goto END; //fprintf (stderr, "EMB BAD? ");
|
if ( (strcmp (sync, DMR_BS_VOICE_SYNC) != 0) && emb_ok == 0) goto END; //fprintf (stderr, "EMB BAD? ");
|
||||||
else if (emb_ok == 1)
|
else if (emb_ok == 1)
|
||||||
{
|
{
|
||||||
uint8_t cc = ((EmbeddedSignalling[0] << 3) + (EmbeddedSignalling[1] << 2) + (EmbeddedSignalling[2] << 1) + EmbeddedSignalling[3]);
|
cc = ((EmbeddedSignalling[0] << 3) + (EmbeddedSignalling[1] << 2) + (EmbeddedSignalling[2] << 1) + EmbeddedSignalling[3]);
|
||||||
uint8_t power = EmbeddedSignalling[4];
|
power = EmbeddedSignalling[4];
|
||||||
uint8_t lcss = ((EmbeddedSignalling[5] << 1) + EmbeddedSignalling[6]);
|
lcss = ((EmbeddedSignalling[5] << 1) + EmbeddedSignalling[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -312,12 +318,16 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
state->dmrburstL = 16;
|
state->dmrburstL = 16;
|
||||||
vc = vc1;
|
vc = vc1;
|
||||||
sprintf (light, "%s", " [SLOT1] slot2 ");
|
sprintf (light, "%s", " [SLOT1] slot2 ");
|
||||||
|
//open MBEout file - slot 1
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state->dmrburstR = 16;
|
state->dmrburstR = 16;
|
||||||
vc = vc2;
|
vc = vc2;
|
||||||
sprintf (light, "%s", " slot1 [SLOT2] ");
|
sprintf (light, "%s", " slot1 [SLOT2] ");
|
||||||
|
//open MBEout file - slot 2
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_fR == NULL)) openMbeOutFileR (opts, state);
|
||||||
}
|
}
|
||||||
if (opts->inverted_dmr == 0) sprintf (polarity, "%s", "+");
|
if (opts->inverted_dmr == 0) sprintf (polarity, "%s", "+");
|
||||||
else sprintf (polarity, "%s", "-");
|
else sprintf (polarity, "%s", "-");
|
||||||
@@ -329,6 +339,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
//process embedded link control
|
//process embedded link control
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
||||||
|
//check the single burst/reverse channel opportunity
|
||||||
|
dmr_sbrc (opts, state, power);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internalslot == 1 && vc2 == 6)
|
if (internalslot == 1 && vc2 == 6)
|
||||||
@@ -336,6 +348,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
//process embedded link control
|
//process embedded link control
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
||||||
|
//check the single burst/reverse channel opportunity
|
||||||
|
dmr_sbrc (opts, state, power);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->payload == 1) fprintf (stderr, "\n"); //extra line break necessary here
|
if (opts->payload == 1) fprintf (stderr, "\n"); //extra line break necessary here
|
||||||
@@ -352,7 +366,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
||||||
|
|
||||||
cach_err = dmr_cach (opts, state, cachdata);
|
cach_err = dmr_cach (opts, state, cachdata);
|
||||||
fprintf (stderr, "\n");
|
if (opts->payload == 0) fprintf (stderr, "\n");
|
||||||
|
|
||||||
// run alg refresh after vc6 ambe processing
|
// run alg refresh after vc6 ambe processing
|
||||||
if (internalslot == 0 && vc1 == 6) dmr_alg_refresh (opts, state);
|
if (internalslot == 0 && vc1 == 6) dmr_alg_refresh (opts, state);
|
||||||
@@ -371,11 +385,36 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//'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 ", internalslot+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);
|
||||||
|
}
|
||||||
|
fprintf (pFile, "\n%d 10 ", internalslot+1); //0x10 for voice burst
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
//reset err checks
|
//reset err checks
|
||||||
cach_err = 1;
|
cach_err = 1;
|
||||||
tact_okay = 0;
|
tact_okay = 0;
|
||||||
emb_ok = 0;
|
emb_ok = 0;
|
||||||
|
|
||||||
|
//reset emb components
|
||||||
|
cc = 25;
|
||||||
|
power = 9;
|
||||||
|
lcss = 9;
|
||||||
|
|
||||||
//Extra safeguards to break loop
|
//Extra safeguards to break loop
|
||||||
// if ( (vc1 > 7 && vc2 > 7) ) goto END;
|
// if ( (vc1 > 7 && vc2 > 7) ) goto END;
|
||||||
if ( (vc1 > 14 || vc2 > 14) ) goto END;
|
if ( (vc1 > 14 || vc2 > 14) ) goto END;
|
||||||
@@ -407,6 +446,10 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
state->errs2R = 0;
|
state->errs2R = 0;
|
||||||
state->errs2 = 0;
|
state->errs2 = 0;
|
||||||
|
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
|
||||||
//if we have a tact or emb err, then produce sync pattern/err message
|
//if we have a tact or emb err, then produce sync pattern/err message
|
||||||
if (tact_okay != 1 || emb_ok != 1)
|
if (tact_okay != 1 || emb_ok != 1)
|
||||||
{
|
{
|
||||||
@@ -417,18 +460,16 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
|
|||||||
fprintf (stderr, "| VOICE CACH/EMB ERR");
|
fprintf (stderr, "| VOICE CACH/EMB ERR");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
//run LFSR if either slot had an active MI in it.
|
//run refresh if either slot had an active MI in it.
|
||||||
if (state->payload_algid >= 0x21)
|
if (state->payload_algid != 0)
|
||||||
{
|
{
|
||||||
state->currentslot = 0;
|
state->currentslot = 0;
|
||||||
LFSR(state);
|
dmr_alg_refresh (opts, state);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
if (state->payload_algidR >= 0x21)
|
if (state->payload_algidR != 0)
|
||||||
{
|
{
|
||||||
state->currentslot = 1;
|
state->currentslot = 1;
|
||||||
LFSR(state);
|
dmr_alg_refresh (opts, state);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//failsafe to reset all data header and blocks when bad tact or emb
|
//failsafe to reset all data header and blocks when bad tact or emb
|
||||||
@@ -458,6 +499,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
uint8_t cach_err = 0;
|
uint8_t cach_err = 0;
|
||||||
uint8_t sync_okay = 1;
|
uint8_t sync_okay = 1;
|
||||||
|
|
||||||
|
uint8_t internalslot;
|
||||||
|
|
||||||
char cachdata[25];
|
char cachdata[25];
|
||||||
int cachInterleave[24] =
|
int cachInterleave[24] =
|
||||||
@@ -490,10 +532,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = *dibit_p;
|
dibit = *dibit_p;
|
||||||
dibit_p++;
|
dibit_p++;
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
{
|
|
||||||
dibit = (dibit ^ 2);
|
|
||||||
}
|
|
||||||
state->dmr_stereo_payload[i] = dibit;
|
state->dmr_stereo_payload[i] = dibit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,15 +552,10 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
//decode and correct tact and compare
|
//decode and correct tact and compare
|
||||||
if ( Hamming_7_4_decode (tact_bits) ) tact_okay = 1;
|
if ( Hamming_7_4_decode (tact_bits) ) tact_okay = 1;
|
||||||
if (tact_okay != 1)
|
if (tact_okay != 1) goto END;
|
||||||
{
|
|
||||||
if (opts->aggressive_framesync == 1)
|
|
||||||
{
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state->currentslot = tact_bits[1];
|
|
||||||
|
internalslot = state->currentslot = tact_bits[1];
|
||||||
|
|
||||||
//Setup for first AMBE Frame
|
//Setup for first AMBE Frame
|
||||||
|
|
||||||
@@ -577,17 +611,15 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
if ( strcmp (sync, DMR_BS_VOICE_SYNC) != 0)
|
if ( strcmp (sync, DMR_BS_VOICE_SYNC) != 0)
|
||||||
{
|
{
|
||||||
if (opts->aggressive_framesync == 1)
|
sync_okay = 0;
|
||||||
{
|
goto END;
|
||||||
sync_okay = 0;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Continue Second AMBE Frame, 18 after Sync or EmbeddedSignalling
|
//Continue Second AMBE Frame, 18 after Sync or EmbeddedSignalling
|
||||||
for(i = 0; i < 18; i++)
|
for(i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
|
state->dmr_stereo_payload[i+90] = dibit;
|
||||||
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
@@ -610,6 +642,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 36; i++)
|
for(i = 0; i < 36; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
|
state->dmr_stereo_payload[i+108] = dibit;
|
||||||
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
ambe_fr3[*y][*z] = (1 & dibit); // bit 0
|
ambe_fr3[*y][*z] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
@@ -620,6 +653,26 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//'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 ", internalslot+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);
|
||||||
|
}
|
||||||
|
fprintf (pFile, "\n%d 10 ", internalslot+1); //0x10 for "voice burst"
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr,"%s ", getTime());
|
fprintf (stderr,"%s ", getTime());
|
||||||
char polarity[3];
|
char polarity[3];
|
||||||
char light[18];
|
char light[18];
|
||||||
@@ -627,10 +680,14 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->currentslot == 0)
|
if (state->currentslot == 0)
|
||||||
{
|
{
|
||||||
sprintf (light, "%s", " [SLOT1] slot2 ");
|
sprintf (light, "%s", " [SLOT1] slot2 ");
|
||||||
|
//open MBEout file - slot 1
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (light, "%s", " slot1 [SLOT2] ");
|
sprintf (light, "%s", " slot1 [SLOT2] ");
|
||||||
|
//open MBEout file - slot 2
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_fR == NULL)) openMbeOutFileR (opts, state);
|
||||||
}
|
}
|
||||||
if (opts->inverted_dmr == 0) sprintf (polarity, "%s", "+");
|
if (opts->inverted_dmr == 0) sprintf (polarity, "%s", "+");
|
||||||
else sprintf (polarity, "%s", "-");
|
else sprintf (polarity, "%s", "-");
|
||||||
@@ -652,10 +709,10 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
||||||
|
|
||||||
//collect the mi fragment
|
//collect the mi fragment
|
||||||
dmr_late_entry_mi_fragment (opts, state, 1, ambe_fr, ambe_fr2, ambe_fr3);
|
dmr_late_entry_mi_fragment (opts, state, 1, m1, m2, m3);
|
||||||
|
|
||||||
cach_err = dmr_cach (opts, state, cachdata);
|
cach_err = dmr_cach (opts, state, cachdata);
|
||||||
fprintf (stderr, "\n");
|
if (opts->payload == 0) fprintf (stderr, "\n");
|
||||||
|
|
||||||
//update voice sync time for trunking purposes (particularly Con+)
|
//update voice sync time for trunking purposes (particularly Con+)
|
||||||
if (opts->p25_is_tuned == 1) state->last_vc_sync_time = time(NULL);
|
if (opts->p25_is_tuned == 1) state->last_vc_sync_time = time(NULL);
|
||||||
@@ -670,18 +727,17 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
fprintf (stderr, "%s", KRED);
|
fprintf (stderr, "%s", KRED);
|
||||||
fprintf (stderr, "| VOICE CACH/SYNC ERR");
|
fprintf (stderr, "| VOICE CACH/SYNC ERR");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
//run LFSR if either slot had an active MI in it.
|
fprintf (stderr, "\n");
|
||||||
if (state->payload_algid >= 0x21)
|
//run refresh if either slot had an active MI in it.
|
||||||
|
if (state->payload_algid != 0)
|
||||||
{
|
{
|
||||||
state->currentslot = 0;
|
state->currentslot = 0;
|
||||||
LFSR(state);
|
dmr_alg_refresh (opts, state);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
if (state->payload_algidR >= 0x21)
|
if (state->payload_algidR != 0)
|
||||||
{
|
{
|
||||||
state->currentslot = 1;
|
state->currentslot = 1;
|
||||||
LFSR(state);
|
dmr_alg_refresh (opts, state);
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//failsafe to reset all data header and blocks when bad tact or emb
|
//failsafe to reset all data header and blocks when bad tact or emb
|
||||||
|
|||||||
968
src/dmr_csbk.c
968
src/dmr_csbk.c
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[i];
|
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 & (dibit >> 1)); // bit 1
|
||||||
cachdata[cachInterleave[(i*2)+1]] = (1 & dibit); // bit 0
|
cachdata[cachInterleave[(i*2)+1]] = (1 & dibit); // bit 0
|
||||||
@@ -74,12 +75,10 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
if ( Hamming_7_4_decode (tact_bits) ) cach_okay = 1;
|
if ( Hamming_7_4_decode (tact_bits) ) cach_okay = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
cach_okay = -1;
|
cach_okay = -1;
|
||||||
if (opts->aggressive_framesync == 1)
|
SlotTypeOk = 0;
|
||||||
{
|
goto END;
|
||||||
SlotTypeOk = 0;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state->currentslot = tact_bits[1];
|
state->currentslot = tact_bits[1];
|
||||||
@@ -103,6 +102,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[i+12];
|
dibit = (int)state->dmr_stereo_payload[i+12];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[i+12] = dibit;
|
||||||
info[2*i] = (1 & (dibit >> 1)); // bit 1
|
info[2*i] = (1 & (dibit >> 1)); // bit 1
|
||||||
info[(2*i)+1] = (1 & dibit); // bit 0
|
info[(2*i)+1] = (1 & dibit); // bit 0
|
||||||
}
|
}
|
||||||
@@ -118,6 +118,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[61];
|
dibit = (int)state->dmr_stereo_payload[61];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[61] = dibit;
|
||||||
|
|
||||||
SlotType[0] = (1 & (dibit >> 1)); // bit 1
|
SlotType[0] = (1 & (dibit >> 1)); // bit 1
|
||||||
SlotType[1] = (1 & dibit); // bit 0
|
SlotType[1] = (1 & dibit); // bit 0
|
||||||
@@ -132,6 +133,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[62];
|
dibit = (int)state->dmr_stereo_payload[62];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[62] = dibit;
|
||||||
|
|
||||||
SlotType[2] = (1 & (dibit >> 1)); // bit 1
|
SlotType[2] = (1 & (dibit >> 1)); // bit 1
|
||||||
SlotType[3] = (1 & dibit); // bit 0
|
SlotType[3] = (1 & dibit); // bit 0
|
||||||
@@ -146,6 +148,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[63];
|
dibit = (int)state->dmr_stereo_payload[63];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[63] = dibit;
|
||||||
|
|
||||||
SlotType[4] = (1 & (dibit >> 1)); // bit 1
|
SlotType[4] = (1 & (dibit >> 1)); // bit 1
|
||||||
SlotType[5] = (1 & dibit); // bit 0
|
SlotType[5] = (1 & dibit); // bit 0
|
||||||
@@ -160,6 +163,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[64];
|
dibit = (int)state->dmr_stereo_payload[64];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[64] = dibit;
|
||||||
|
|
||||||
SlotType[6] = (1 & (dibit >> 1)); // bit 1
|
SlotType[6] = (1 & (dibit >> 1)); // bit 1
|
||||||
SlotType[7] = (1 & dibit); // bit 0
|
SlotType[7] = (1 & dibit); // bit 0
|
||||||
@@ -175,6 +179,8 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = (int)state->dmr_stereo_payload[65];
|
dibit = (int)state->dmr_stereo_payload[65];
|
||||||
}
|
}
|
||||||
|
else state->dmr_stereo_payload[65] = dibit;
|
||||||
|
|
||||||
SlotType[8] = (1 & (dibit >> 1)); // bit 1
|
SlotType[8] = (1 & (dibit >> 1)); // bit 1
|
||||||
SlotType[9] = (1 & dibit); // bit 0
|
SlotType[9] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
@@ -191,6 +197,8 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
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 & (dibit >> 1)); // bit 1
|
||||||
syncdata[(2*i)+1] = (1 & dibit); // bit 0
|
syncdata[(2*i)+1] = (1 & dibit); // bit 0
|
||||||
sync[i] = (dibit | 1) + 48;
|
sync[i] = (dibit | 1) + 48;
|
||||||
@@ -236,6 +244,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->dmr_stereo == 0)
|
if (state->dmr_stereo == 0)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
|
state->dmr_stereo_payload[i+90] = dibit;
|
||||||
}
|
}
|
||||||
if (state->dmr_stereo == 1)
|
if (state->dmr_stereo == 1)
|
||||||
{
|
{
|
||||||
@@ -251,12 +260,9 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
if( Golay_20_8_decode(SlotType) ) SlotTypeOk = 1;
|
if( Golay_20_8_decode(SlotType) ) SlotTypeOk = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SlotTypeOk = -1;
|
|
||||||
if (opts->aggressive_framesync == 1)
|
SlotTypeOk = 0;
|
||||||
{
|
goto END;
|
||||||
SlotTypeOk = 0;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state->color_code = (SlotType[0] << 3) + (SlotType[1] << 2) +(SlotType[2] << 1) + (SlotType[3] << 0);
|
state->color_code = (SlotType[0] << 3) + (SlotType[1] << 2) +(SlotType[2] << 1) + (SlotType[3] << 0);
|
||||||
@@ -277,6 +283,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->dmr_stereo == 0)
|
if (state->dmr_stereo == 0)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
|
state->dmr_stereo_payload[i+95] = dibit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->dmr_stereo == 1)
|
if (state->dmr_stereo == 1)
|
||||||
@@ -288,10 +295,11 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
info[(2*i) + 99] = (1 & dibit); // bit 0
|
info[(2*i) + 99] = (1 & dibit); // bit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
dmr_data_burst_handler(opts, state, (uint8_t *)info, burst);
|
//don't run on MS Reverse Channel Data
|
||||||
|
if (state->dmr_ms_rc == 0) dmr_data_burst_handler(opts, state, (uint8_t *)info, burst);
|
||||||
|
|
||||||
//don't run cach on simplex or mono
|
//don't run cach on simplex or mono
|
||||||
if (state->dmr_ms_mode == 0 || opts->dmr_mono == 0)
|
if (state->dmr_ms_mode == 0 && opts->dmr_mono == 0)
|
||||||
{
|
{
|
||||||
cach_err = dmr_cach (opts, state, cachdata);
|
cach_err = dmr_cach (opts, state, cachdata);
|
||||||
}
|
}
|
||||||
@@ -337,6 +345,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
|||||||
//zero out vc frequencies
|
//zero out vc frequencies
|
||||||
state->p25_vc_freq[0] = 0;
|
state->p25_vc_freq[0] = 0;
|
||||||
state->p25_vc_freq[1] = 0;
|
state->p25_vc_freq[1] = 0;
|
||||||
|
memset (state->active_channel, 0, sizeof(state->active_channel));
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
state->is_con_plus = 0; //con+ flag off
|
state->is_con_plus = 0; //con+ flag off
|
||||||
}
|
}
|
||||||
|
|||||||
304
src/dmr_dburst.c
304
src/dmr_dburst.c
@@ -9,9 +9,11 @@
|
|||||||
* 2022-12 DSD-FME Florida Man Edition
|
* 2022-12 DSD-FME Florida Man Edition
|
||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//TODO: CRC9 on confirmed data blocks; CRC32 on completed data sf;
|
//WIP: Unified Single Block Data - USBD -- TODO: USBD LIP Protocol Handling
|
||||||
//TODO: Reverse Channel Signalling - RC single burst BPTC/7-bit CRC
|
//WIP: UDT Header and Blocks (coded - need samples)
|
||||||
//TODO: Single Burst Embedded LC - Non-RC single burst LC - Look for Late Entry Alg/Key
|
//WIP: CRC9/CRC32 on Rate 1 Data (need samples)
|
||||||
|
//WIP: Reverse Channel Signalling - RC single burst BPTC/7-bit CRC (rc interleave) and when to run RC and not SB
|
||||||
|
//WIP: Single Burst Embedded LC - Non-RC single burst LC - Look for Late Entry Alg/Key
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
|
||||||
@@ -26,6 +28,12 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
uint8_t slot = state->currentslot;
|
uint8_t slot = state->currentslot;
|
||||||
uint8_t block = state->data_block_counter[slot];
|
uint8_t block = state->data_block_counter[slot];
|
||||||
|
|
||||||
|
//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));
|
||||||
|
|
||||||
//BPTC 196x96 Specific
|
//BPTC 196x96 Specific
|
||||||
uint8_t BPTCDeInteleavedData[196];
|
uint8_t BPTCDeInteleavedData[196];
|
||||||
uint8_t BPTCDmrDataBit[96];
|
uint8_t BPTCDmrDataBit[96];
|
||||||
@@ -37,26 +45,31 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
uint8_t LC_DataBytes[10];
|
uint8_t LC_DataBytes[10];
|
||||||
int Burst = -1;
|
int Burst = -1;
|
||||||
|
|
||||||
//Unified PDU (is this the best nomenclature) Bytes
|
//PDU Bytes and Bits
|
||||||
uint8_t DMR_PDU[25]; //using 25 bytes as the max for now
|
uint8_t DMR_PDU[25];
|
||||||
uint8_t DMR_PDU_bits[196]; //bitwise version of unified payload, will probably be a lot easier to use this w/ manual
|
uint8_t DMR_PDU_bits[196];
|
||||||
memset (DMR_PDU, 0, sizeof (DMR_PDU));
|
memset (DMR_PDU, 0, sizeof (DMR_PDU));
|
||||||
memset (DMR_PDU_bits, 0, sizeof (DMR_PDU_bits));
|
memset (DMR_PDU_bits, 0, sizeof (DMR_PDU_bits));
|
||||||
|
|
||||||
uint8_t R[3];
|
uint8_t R[3];
|
||||||
uint8_t BPTCReservedBits = 0;
|
uint8_t BPTCReservedBits = 0;
|
||||||
|
uint8_t is_ras = 0;
|
||||||
|
uint8_t crc_original_validity = 0;
|
||||||
|
|
||||||
uint32_t crcmask = 0;
|
uint32_t crcmask = 0;
|
||||||
uint8_t crclen = 0;
|
uint8_t crclen = 0;
|
||||||
|
|
||||||
uint8_t is_bptc = 0;
|
uint8_t is_bptc = 0;
|
||||||
uint8_t is_trellis = 0;
|
uint8_t is_trellis = 0;
|
||||||
uint8_t is_emb = 0;
|
uint8_t is_emb = 0;
|
||||||
uint8_t is_lc = 0;
|
uint8_t is_lc = 0;
|
||||||
uint8_t is_full = 0;
|
uint8_t is_full = 0;
|
||||||
|
uint8_t is_udt = 0;
|
||||||
uint8_t pdu_len = 0;
|
uint8_t pdu_len = 0;
|
||||||
uint8_t pdu_start = 0; //starting value of pdu (0 normal, 2 for confirmed)
|
uint8_t pdu_start = 0; //starting value of pdu (0 normal, 2 for confirmed)
|
||||||
|
|
||||||
|
uint8_t usbd_st = 0; //usbd service type
|
||||||
|
|
||||||
switch(databurst){
|
switch(databurst){
|
||||||
case 0x00: //PI
|
case 0x00: //PI
|
||||||
is_bptc = 1;
|
is_bptc = 1;
|
||||||
@@ -108,32 +121,36 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
pdu_len = 12; //12 bytes
|
pdu_len = 12; //12 bytes
|
||||||
sprintf(state->fsubtype, " DATA");
|
sprintf(state->fsubtype, " DATA");
|
||||||
break;
|
break;
|
||||||
//TODO - 1/2 0x0F0 - 3/4 0x1FF - Rate 1 0x10F
|
|
||||||
//going to set crclen and mask according to confirmed data here,
|
|
||||||
//use block assmebler to carry out completed message crc
|
|
||||||
case 0x07: //1/2 Rate Data
|
case 0x07: //1/2 Rate Data
|
||||||
is_bptc = 1;
|
is_bptc = 1;
|
||||||
crclen = 9; //confirmed data only
|
crclen = 9; //confirmed data only
|
||||||
crcmask = 0x0F0;
|
crcmask = 0x0F0;
|
||||||
pdu_len = 12; //12 bytes unconfirmed
|
pdu_len = 12; //12 bytes unconfirmed
|
||||||
|
sprintf(state->fsubtype, " R12U ");
|
||||||
if (state->data_conf_data[slot] == 1)
|
if (state->data_conf_data[slot] == 1)
|
||||||
{
|
{
|
||||||
pdu_len = 10;
|
pdu_len = 10;
|
||||||
pdu_start = 2; //start at plus two when assembling
|
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;
|
||||||
|
sprintf(state->fsubtype, " UDTC ");
|
||||||
}
|
}
|
||||||
sprintf(state->fsubtype, " R12D ");
|
|
||||||
break;
|
break;
|
||||||
case 0x08: //3/4 Rate Data
|
case 0x08: //3/4 Rate Data
|
||||||
is_trellis = 1;
|
is_trellis = 1;
|
||||||
crclen = 9; //confirmed data only
|
crclen = 9; //confirmed data only
|
||||||
crcmask = 0x1FF;
|
crcmask = 0x1FF;
|
||||||
pdu_len = 18; //18 bytes unconfirmed
|
pdu_len = 18; //18 bytes unconfirmed
|
||||||
|
sprintf(state->fsubtype, " R34U ");
|
||||||
if (state->data_conf_data[slot] == 1)
|
if (state->data_conf_data[slot] == 1)
|
||||||
{
|
{
|
||||||
pdu_len = 16;
|
pdu_len = 16;
|
||||||
pdu_start = 2; //start at plus two when assembling
|
pdu_start = 2; //start at plus two when assembling
|
||||||
|
sprintf(state->fsubtype, " R34C ");
|
||||||
}
|
}
|
||||||
sprintf(state->fsubtype, " R34D ");
|
|
||||||
break;
|
break;
|
||||||
case 0x09: //Idle
|
case 0x09: //Idle
|
||||||
//pseudo-random data fill, no need to do anything with this
|
//pseudo-random data fill, no need to do anything with this
|
||||||
@@ -141,33 +158,70 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
break;
|
break;
|
||||||
case 0x0A: //1 Rate Data
|
case 0x0A: //1 Rate Data
|
||||||
crclen = 9; //confirmed data only
|
crclen = 9; //confirmed data only
|
||||||
crcmask = 0x1FF;
|
crcmask = 0x10F;
|
||||||
is_full = 1;
|
is_full = 1;
|
||||||
pdu_len = 25; //196 bits - 24.5 bytes
|
pdu_len = 25; //196 bits - 24.5 bytes
|
||||||
sprintf(state->fsubtype, " R_1D ");
|
sprintf(state->fsubtype, " R_1U ");
|
||||||
|
if (state->data_conf_data[slot] == 1)
|
||||||
|
{
|
||||||
|
pdu_len = 23;
|
||||||
|
pdu_start = 2; //start at plus two when assembling
|
||||||
|
sprintf(state->fsubtype, " R_1C ");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x0B: //Unified Data
|
case 0x0B: //Unified Single Block Data USBD
|
||||||
is_bptc = 1;
|
is_bptc = 1;
|
||||||
crclen = 16;
|
crclen = 16;
|
||||||
crcmask = 0x3333;
|
crcmask = 0x3333;
|
||||||
pdu_len = 12; //12 bytes
|
pdu_len = 12; //12 bytes
|
||||||
sprintf(state->fsubtype, " UDAT ");
|
sprintf(state->fsubtype, " USBD ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//special types (not real data 'sync' bursts)
|
//special types (not real data 'sync' bursts)
|
||||||
case 0xEB: //Embedded Signalling
|
case 0xEB: //Embedded Signalling
|
||||||
|
crclen = 5;
|
||||||
is_emb = 1;
|
is_emb = 1;
|
||||||
pdu_len = 9;
|
pdu_len = 9;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
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 (databurst != 0xEB)
|
||||||
{
|
{
|
||||||
if (state->dmr_ms_mode == 0) fprintf(stderr, "| Color Code=%02d ", state->dmr_color_code);
|
if (state->dmr_ms_mode == 0) fprintf(stderr, "| Color Code=%02d ", state->dmr_color_code);
|
||||||
fprintf(stderr, "|%s", state->fsubtype);
|
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
|
//Most Data Sync Burst types will use the bptc 196x96
|
||||||
@@ -184,7 +238,10 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
IrrecoverableErrors = BPTC_196x96_Extract_Data(BPTCDeInteleavedData, BPTCDmrDataBit, R);
|
IrrecoverableErrors = BPTC_196x96_Extract_Data(BPTCDeInteleavedData, BPTCDmrDataBit, R);
|
||||||
|
|
||||||
/* Fill the reserved bit (R(0)-R(2) of the BPTC(196,96) block) */
|
/* 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) & 0x08);
|
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 */
|
/* Convert the 96 bits BPTC data into 12 bytes */
|
||||||
k = 0;
|
k = 0;
|
||||||
@@ -213,20 +270,59 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
/* Check/correct the BPTC data and compute the Reed-Solomon (12,9) CRC */
|
/* Check/correct the BPTC data and compute the Reed-Solomon (12,9) CRC */
|
||||||
if (is_lc) CRCCorrect = ComputeAndCorrectFullLinkControlCrc(BPTCDmrDataByte, &CRCComputed, crcmask);
|
if (is_lc) CRCCorrect = ComputeAndCorrectFullLinkControlCrc(BPTCDmrDataByte, &CRCComputed, crcmask);
|
||||||
|
|
||||||
//TODO: run CRC9 on confirmed 1/2 data blocks
|
//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] == 1)
|
else if (state->data_conf_data[slot] == 0 && databurst == 0x7)
|
||||||
{
|
{
|
||||||
//run CRC on individual blocks according to type and validate each individual block
|
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
|
//run CCITT on other data forms
|
||||||
else //will still run on unconfirmed data (shouldn't matter other than a possible bogus warning message)
|
else
|
||||||
{
|
{
|
||||||
CRCComputed = ComputeCrcCCITT(BPTCDmrDataBit);
|
CRCComputed = ComputeCrcCCITT(BPTCDmrDataBit);
|
||||||
if (CRCComputed == CRCExtracted) CRCCorrect = 1;
|
if (CRCComputed == CRCExtracted) CRCCorrect = 1;
|
||||||
else CRCCorrect = 0;
|
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 (databurst == 0x04 || databurst == 0x06) //MBC Header, Data Header
|
||||||
{
|
{
|
||||||
if (CRCCorrect)
|
if (CRCCorrect)
|
||||||
@@ -249,7 +345,7 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
BPTCDmrDataBit[j + 7] = (BPTCDmrDataByte[i+pdu_start] >> 0) & 0x01;
|
BPTCDmrDataBit[j + 7] = (BPTCDmrDataByte[i+pdu_start] >> 0) & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
//convert to unified DMR_PDU and DMR_PDU_bits
|
//convert to DMR_PDU and DMR_PDU_bits
|
||||||
for (i = 0; i < pdu_len; i++)
|
for (i = 0; i < pdu_len; i++)
|
||||||
{
|
{
|
||||||
DMR_PDU[i] = BPTCDmrDataByte[i+pdu_start];
|
DMR_PDU[i] = BPTCDmrDataByte[i+pdu_start];
|
||||||
@@ -295,11 +391,7 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
IrrecoverableErrors = BPTC_128x77_Extract_Data(BptcDataMatrix, LC_DataBit);
|
IrrecoverableErrors = BPTC_128x77_Extract_Data(BptcDataMatrix, LC_DataBit);
|
||||||
|
|
||||||
/* Reconstitute the 5 bit CRC */
|
/* Reconstitute the 5 bit CRC */
|
||||||
CRCExtracted = (LC_DataBit[72] & 1) << 4;
|
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&LC_DataBit[72], 5);
|
||||||
CRCExtracted |= (LC_DataBit[73] & 1) << 3;
|
|
||||||
CRCExtracted |= (LC_DataBit[74] & 1) << 2;
|
|
||||||
CRCExtracted |= (LC_DataBit[75] & 1) << 1;
|
|
||||||
CRCExtracted |= (LC_DataBit[76] & 1) << 0;
|
|
||||||
|
|
||||||
/* Compute the 5 bit CRC */
|
/* Compute the 5 bit CRC */
|
||||||
CRCComputed = ComputeCrc5Bit(LC_DataBit);
|
CRCComputed = ComputeCrc5Bit(LC_DataBit);
|
||||||
@@ -348,6 +440,50 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
DMR_PDU[i] = (uint8_t)TrellisReturn[i+pdu_start];
|
DMR_PDU[i] = (uint8_t)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
|
||||||
|
//confirmed working now!
|
||||||
|
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
|
||||||
|
{
|
||||||
|
// IrrecoverableErrors = 9; //set as a shim since the trellis decoder is a pain to fix
|
||||||
|
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)
|
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 + 0] = (TrellisReturn[i+pdu_start] >> 7) & 0x01;
|
||||||
@@ -360,17 +496,13 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
DMR_PDU_bits[j + 7] = (TrellisReturn[i+pdu_start] >> 0) & 0x01;
|
DMR_PDU_bits[j + 7] = (TrellisReturn[i+pdu_start] >> 0) & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: run CRC9 on confirmed 3/4 data blocks
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_full) //Rate 1 Data
|
if (is_full) //Rate 1 Data
|
||||||
{
|
{
|
||||||
CRCExtracted = 0;
|
CRCExtracted = 0;
|
||||||
CRCComputed = 0;
|
CRCComputed = 0;
|
||||||
IrrecoverableErrors = 0;
|
IrrecoverableErrors = 0; //implicit, since there is no encoding
|
||||||
|
|
||||||
//TODO: run CRC9 on confirmed data
|
|
||||||
|
|
||||||
for (i = 0; i < 24; i++)
|
for (i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
@@ -381,6 +513,32 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
DMR_PDU[25] = (uint8_t)ConvertBitIntoBytes(&info[192], 4);
|
DMR_PDU[25] = (uint8_t)ConvertBitIntoBytes(&info[192], 4);
|
||||||
DMR_PDU[25] = DMR_PDU[25] << 4;
|
DMR_PDU[25] = DMR_PDU[25] << 4;
|
||||||
|
|
||||||
|
//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
|
||||||
|
//unconfirmed, haven't seen any samples with rate 1 data
|
||||||
|
for(i = 0; i < 176; i++) confdatabits[i] = info[i + 16];
|
||||||
|
for(i = 0; i < 7; i++) confdatabits[i + 176] = info[i];
|
||||||
|
|
||||||
|
CRCComputed = ComputeCrc9Bit(confdatabits, 183);
|
||||||
|
if (CRCExtracted == CRCComputed)
|
||||||
|
{
|
||||||
|
CRCCorrect = 1;
|
||||||
|
state->data_block_crc_valid[slot][blockcounter] = 1;
|
||||||
|
}
|
||||||
|
else state->data_block_crc_valid[slot][blockcounter] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//copy info to dmr_pdu_bits
|
//copy info to dmr_pdu_bits
|
||||||
memcpy(DMR_PDU_bits, info, sizeof(DMR_PDU_bits));
|
memcpy(DMR_PDU_bits, info, sizeof(DMR_PDU_bits));
|
||||||
|
|
||||||
@@ -395,27 +553,75 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
if (databurst == 0x02) dmr_flco (opts, state, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors, 2); //TLC
|
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
|
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, Unified) - type 1
|
//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, CRCCorrect, IrrecoverableErrors);
|
if (databurst == 0x06) dmr_dheader (opts, state, DMR_PDU, DMR_PDU_bits, CRCCorrect, IrrecoverableErrors);
|
||||||
if (databurst == 0x07) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //1/2 Rate Data
|
|
||||||
if (databurst == 0x08) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //3/4 Rate Data
|
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 - Disabled until further testing can be done
|
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
|
||||||
|
|
||||||
//is unified data handled like normal data, or control signalling data?
|
//control signalling types (CSBK, MBC)
|
||||||
if (databurst == 0x0B) dmr_block_assembler (opts, state, DMR_PDU, pdu_len, databurst, 1); //Unified Data
|
|
||||||
//if (databurst == 0x0B) dmr_cspdu (opts, state, DMR_PDU_bits, DMR_PDU, CRCCorrect, IrrecoverableErrors);
|
|
||||||
|
|
||||||
//control signalling types (CSBK, MBC, UDT)
|
|
||||||
if (databurst == 0x03) dmr_cspdu (opts, state, DMR_PDU_bits, DMR_PDU, CRCCorrect, IrrecoverableErrors);
|
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
|
//both MBC header and MBC continuation will go to the block_assembler - type 2, and then to dmr_cspdu
|
||||||
if (databurst == 0x04)
|
if (databurst == 0x04)
|
||||||
{
|
{
|
||||||
state->data_block_counter[slot] = 0; //zero block counter before running header
|
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);
|
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);
|
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, " Unified Single Block Data - ");
|
||||||
|
if (usbd_st == 0) fprintf (stderr, "Location Information Protocol");
|
||||||
|
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 != 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
|
//print the unified PDU format here, if not slot idle
|
||||||
if (opts->payload == 1 && databurst != 0x09)
|
if (opts->payload == 1 && databurst != 0x09)
|
||||||
{
|
{
|
||||||
@@ -427,20 +633,12 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
|||||||
fprintf (stderr, "[%02X]", DMR_PDU[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);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
// fprintf (stderr, "%s", KCYN);
|
|
||||||
// fprintf (stderr, "\n Hex to Ascii - ");
|
|
||||||
// for (i = 0; i < 12; i++)
|
|
||||||
// {
|
|
||||||
// if (DMR_PDU[i] <= 0x7E && DMR_PDU[i] >=0x20)
|
|
||||||
// {
|
|
||||||
// fprintf (stderr, "%c", DMR_PDU[i]);
|
|
||||||
// }
|
|
||||||
// else fprintf (stderr, ".");
|
|
||||||
// }
|
|
||||||
|
|
||||||
fprintf (stderr,"%s", KNRM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
451
src/dmr_flco.c
451
src/dmr_flco.c
@@ -25,73 +25,272 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
uint8_t so = 0;
|
uint8_t so = 0;
|
||||||
uint32_t target = 0;
|
uint32_t target = 0;
|
||||||
uint32_t source = 0;
|
uint32_t source = 0;
|
||||||
|
uint8_t capsite = 0;
|
||||||
int restchannel = -1;
|
int restchannel = -1;
|
||||||
int is_cap_plus = 0;
|
int is_cap_plus = 0;
|
||||||
int is_alias = 0;
|
int is_alias = 0;
|
||||||
int is_gps = 0;
|
int is_gps = 0;
|
||||||
|
|
||||||
|
//XPT 'Things'
|
||||||
|
int is_xpt = 0;
|
||||||
|
uint8_t xpt_hand = 0; //handshake
|
||||||
|
uint8_t xpt_free = 0; //free repeater
|
||||||
|
uint8_t xpt_int = 0; //xpt channel to interrupt (channel/repeater call should occur on?)
|
||||||
|
uint8_t xpt_res_a = 0; //unknown values of other bits of the XPT LC
|
||||||
|
uint8_t xpt_res_b = 0; //unknown values of other bits of the XPT LC
|
||||||
|
uint8_t xpt_res_c = 0; //unknown values of other bits of the XPT LC
|
||||||
|
uint8_t target_hash[24]; //for XPT (and others if desired, get the hash and compare against SLC or XPT Status CSBKs)
|
||||||
|
uint8_t tg_hash = 0; //value of the hashed TG
|
||||||
|
|
||||||
uint8_t slot = state->currentslot;
|
uint8_t slot = state->currentslot;
|
||||||
|
uint8_t unk = 0; //flag for unknown FLCO + FID combo
|
||||||
|
|
||||||
|
pf = (uint8_t)(lc_bits[0]); //Protect Flag -- Hytera XPT uses this to signify which TS the PDU is on
|
||||||
pf = (uint8_t)(lc_bits[0]); //Protect Flag
|
reserved = (uint8_t)(lc_bits[1]); //Reserved -- Hytera XPT G/I bit; 0 - Individual; 1 - Group;
|
||||||
reserved = (uint8_t)(lc_bits[1]); //Reserved
|
|
||||||
flco = (uint8_t)ConvertBitIntoBytes(&lc_bits[2], 6); //Full Link Control Opcode
|
flco = (uint8_t)ConvertBitIntoBytes(&lc_bits[2], 6); //Full Link Control Opcode
|
||||||
fid = (uint8_t)ConvertBitIntoBytes(&lc_bits[8], 8); //Feature set ID (FID)
|
fid = (uint8_t)ConvertBitIntoBytes(&lc_bits[8], 8); //Feature set ID (FID)
|
||||||
so = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 8); //Service Options
|
so = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 8); //Service Options
|
||||||
target = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24); //Target or Talk Group
|
target = (uint32_t)ConvertBitIntoBytes(&lc_bits[24], 24); //Target or Talk Group
|
||||||
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[48], 24);
|
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[48], 24);
|
||||||
|
|
||||||
//look for Cap+ on VLC header, then set source and/or rest channel appropriately
|
//read ahead a little to get this for the xpt flag
|
||||||
if (type == 1 && fid == 0x10 && flco == 0x04)
|
if (IrrecoverableErrors == 0 && flco == 0x09 && fid == 0x68)
|
||||||
{
|
{
|
||||||
is_cap_plus = 1;
|
sprintf (state->dmr_branding, "%s", " Hytera");
|
||||||
restchannel = (int)ConvertBitIntoBytes(&lc_bits[48], 8);
|
sprintf (state->dmr_branding_sub, "XPT ");
|
||||||
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[56], 16);
|
|
||||||
sprintf (state->dmr_branding, "%s", "Motorola");
|
|
||||||
sprintf (state->dmr_branding_sub, "%s", "Cap+ ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//look at the dmr_branding_sub for the XPT string
|
||||||
|
//branding sub is set at CSBK(68-3A and 3B), SLCO 8, and here on 0x09
|
||||||
|
if (strcmp (state->dmr_branding_sub, "XPT ") == 0) is_xpt = 1;
|
||||||
|
|
||||||
|
//hytera XPT -- disable the pf flag, is used for TS value in some Hytera XPT PDUs
|
||||||
|
if (is_xpt) pf = 0;
|
||||||
|
|
||||||
|
//check protect flag
|
||||||
|
if (pf == 1)
|
||||||
|
{
|
||||||
|
if (type == 1) fprintf (stderr, "%s \n", KRED);
|
||||||
|
if (type == 2) fprintf (stderr, "%s \n", KRED);
|
||||||
|
if (type == 3) fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Protected LC ");
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
if (IrrecoverableErrors == 0)
|
if (IrrecoverableErrors == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (slot == 0) state->dmr_flco = flco;
|
||||||
|
else state->dmr_flcoR = flco;
|
||||||
|
|
||||||
|
//FID 0x10 and FLCO 0x14, 0x15, 0x16 and 0x17 confirmed as Moto EMB Alias
|
||||||
|
//Can probably assume FID 0x10 FLCO 0x18 is Moto EMB GPS -- to be tested
|
||||||
|
if ( fid == 0x10 && (flco == 0x14 || flco == 0x15 || flco == 0x16 || flco == 0x17 || flco == 0x18) )
|
||||||
|
{
|
||||||
|
flco = flco - 0x10;
|
||||||
|
fid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//Embedded Talker Alias Header Only (format and len storage)
|
//Embedded Talker Alias Header Only (format and len storage)
|
||||||
if (type == 3 && flco == 0x04)
|
if ( (fid == 0 || fid == 0x68) && type == 3 && flco == 0x04)
|
||||||
{
|
{
|
||||||
dmr_embedded_alias_header(opts, state, lc_bits);
|
dmr_embedded_alias_header(opts, state, lc_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Embedded Talker Alias Header (continuation) and Blocks
|
//Embedded Talker Alias Header (continuation) and Blocks
|
||||||
if (type == 3 && flco > 0x3 && flco < 0x08)
|
if ( (fid == 0 || fid == 0x68) && type == 3 && flco > 0x03 && flco < 0x08)
|
||||||
{
|
{
|
||||||
is_alias = 1;
|
is_alias = 1;
|
||||||
dmr_embedded_alias_blocks(opts, state, lc_bits);
|
dmr_embedded_alias_blocks(opts, state, lc_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Embedded GPS
|
//Embedded GPS
|
||||||
if (type == 3 && flco == 0x08)
|
if ( (fid == 0 || fid == 0x68) && fid == 0 && type == 3 && flco == 0x08)
|
||||||
{
|
{
|
||||||
is_gps = 1;
|
is_gps = 1;
|
||||||
if (fid == 0) dmr_embedded_gps(opts, state, lc_bits); //issues with fid 0x10 and flco 0x08
|
dmr_embedded_gps(opts, state, lc_bits);
|
||||||
|
}
|
||||||
|
|
||||||
//NOTE: fid 0x10 and flco 0x08 produces a lot of 'zero' lat or lon values, I don't believe this is embedded gps
|
//look for Cap+ on VLC header, then set source and/or rest channel appropriately
|
||||||
|
if (type == 1 && fid == 0x10 && (flco == 0x04 || flco == 0x07) ) //0x07 appears to be a cap+ txi private call
|
||||||
|
{
|
||||||
|
is_cap_plus = 1;
|
||||||
|
capsite = (uint8_t)ConvertBitIntoBytes(&lc_bits[48], 4); //don't believe so
|
||||||
|
restchannel = (int)ConvertBitIntoBytes(&lc_bits[52], 4); //
|
||||||
|
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[56], 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unknown CapMax/Moto Things
|
||||||
|
if (fid == 0x10 && (flco == 0x08 || flco == 0x28))
|
||||||
|
{
|
||||||
|
//NOTE: fid 0x10 and flco 0x08 (emb) produces a lot of 'zero' bytes
|
||||||
//this has been observed to happen often on CapMax systems, so I believe it could be some CapMax 'thing'
|
//this has been observed to happen often on CapMax systems, so I believe it could be some CapMax 'thing'
|
||||||
//Unknown Link Control - FLCO=0x08 FID=0x10 SVC=0xC1 or FLCO=0x08 FID=0x10 SVC=0xC0 <-- have the enc bit set on svc, but these calls aren't enc?
|
//Unknown Link Control - FLCO=0x08 FID=0x10 SVC=0xC1 or FLCO=0x08 FID=0x10 SVC=0xC0 <- probably no SVC bits in the lc
|
||||||
//is this an encrypted embedded link control?
|
//flco 0x28 has also been observed lately but the tg and src values don't match
|
||||||
else
|
//another flco 0x10 does seem to match, so is probably capmax group call flco
|
||||||
|
if (type == 1) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 2) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 3) fprintf (stderr, "%s", KCYN);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Motorola");
|
||||||
|
unk = 1;
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//7.1.1.1 Terminator Data Link Control PDU - ETSI TS 102 361-3 V1.2.1 (2013-07)
|
||||||
|
if (type == 2 && flco == 0x30)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s \n", KRED);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Data Terminator (TD_LC) ");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
//reset data header format storage
|
||||||
|
state->data_header_format[slot] = 7;
|
||||||
|
//flag off data header validity
|
||||||
|
state->data_header_valid[slot] = 0;
|
||||||
|
//flag off conf data flag
|
||||||
|
state->data_conf_data[slot] = 0;
|
||||||
|
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unknown Tait Things
|
||||||
|
if (fid == 0x58)
|
||||||
|
{
|
||||||
|
//NOTE: fid 0x58 (tait) had a single flco 0x06 emb observed, but without the other blocks (4,5,7) for an alias
|
||||||
|
//will need to observe this one, or just remove it from the list, going to isolate tait lc for now
|
||||||
|
if (type == 1) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 2) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 3) fprintf (stderr, "%s", KCYN);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Tait");
|
||||||
|
unk = 1;
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//look for any Hytera XPT system, adjust TG to 16-bit allocation
|
||||||
|
//Groups use only 8 out of 16, but 16 always seems to be allocated
|
||||||
|
//private calls use 16-bit target values hashed to 8-bit in the site status csbk
|
||||||
|
//the TLC preceeds the VLC for a 'handshake' call setup in XPT
|
||||||
|
|
||||||
|
//truncate if XPT is set
|
||||||
|
if (is_xpt == 1)
|
||||||
|
{
|
||||||
|
target = (uint32_t)ConvertBitIntoBytes(&lc_bits[32], 16); //16-bit allocation
|
||||||
|
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[56], 16); //16-bit allocation
|
||||||
|
|
||||||
|
//the crc8 hash is the value represented in the CSBK when dealing with private calls
|
||||||
|
for (int i = 0; i < 16; i++) target_hash[i] = lc_bits[32+i];
|
||||||
|
tg_hash = crc8 (target_hash, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
//XPT Call 'Grant/Alert' Setup Occurs in TLC with a flco 0x09
|
||||||
|
if (fid == 0x68 && flco == 0x09)
|
||||||
|
{
|
||||||
|
//The CSBK always uses an 8-bit TG/TGT; The White Papers (user manuals) say 8-bit TG and 16-bit SRC addressing
|
||||||
|
//private calls and indiv data calls use a hash of their 8 bit tgt values in the CSBK
|
||||||
|
xpt_int = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 4); //This is consistent with an LCN value, not an LSN value
|
||||||
|
xpt_free = (uint8_t)ConvertBitIntoBytes(&lc_bits[24], 4); //24 and 4 on 0x09
|
||||||
|
xpt_hand = (uint8_t)ConvertBitIntoBytes(&lc_bits[28], 4); //handshake kind: 0 - ordinary; 1-2 Interrupts; 3-15 reserved;
|
||||||
|
|
||||||
|
target = (uint32_t)ConvertBitIntoBytes(&lc_bits[32], 16); //16-bit allocation
|
||||||
|
source = (uint32_t)ConvertBitIntoBytes(&lc_bits[56], 16); //16-bit allocation
|
||||||
|
|
||||||
|
//the bits that are left behind
|
||||||
|
xpt_res_a = (uint8_t)ConvertBitIntoBytes(&lc_bits[20], 4); //after the xpt_int channel, before the free repeater channel -- call being established = 7; call connected = 0; ??
|
||||||
|
xpt_res_b = (uint8_t)ConvertBitIntoBytes(&lc_bits[48], 8); //where the first 8 bits of the SRC would be
|
||||||
|
|
||||||
|
//the crc8 hash is the value represented in the CSBK when dealing with private calls
|
||||||
|
for (int i = 0; i < 16; i++) target_hash[i] = lc_bits[32+i];
|
||||||
|
tg_hash = crc8 (target_hash, 16);
|
||||||
|
|
||||||
|
fprintf (stderr, "%s \n", KGRN);
|
||||||
|
fprintf (stderr, " SLOT %d ", state->currentslot+1);
|
||||||
|
if (opts->payload == 1) fprintf(stderr, "FLCO=0x%02X FID=0x%02X ", flco, fid);
|
||||||
|
fprintf (stderr, "TGT=%u SRC=%u ", target, source);
|
||||||
|
|
||||||
|
fprintf (stderr, "Hytera XPT ");
|
||||||
|
|
||||||
|
//Group ID ranges from 1 to 240; emergency group call ID ranges from 250 to 254; all call ID is 255.
|
||||||
|
if (reserved == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KGRN);
|
fprintf (stderr, "Group "); //according to observation
|
||||||
fprintf (stderr, " Slot %d Unknown EMB LC - FLCO=0x%02X FID=0x%02X SVC=0x%02X ", slot+1, flco, fid, so);
|
if (target > 248 && target < 255) fprintf (stderr, "Emergency ");
|
||||||
fprintf (stderr, "%s", KNRM);
|
if (target == 255) fprintf (stderr, "All ");
|
||||||
}
|
}
|
||||||
|
else fprintf (stderr, "Private "); //according to observation
|
||||||
|
fprintf (stderr, "Call Alert "); //Alert or Grant
|
||||||
|
|
||||||
|
//reorganized all the 'extra' data to a second line and added extra verbosity
|
||||||
|
if (opts->payload == 1) fprintf (stderr, "\n ");
|
||||||
|
if (opts->payload == 1) fprintf (stderr, "%s", KYEL);
|
||||||
|
//only display the hashed tgt value if its a private call and not a group call
|
||||||
|
if (reserved == 0 && opts->payload == 1) fprintf(stderr, "TGT Hash=%d; ", tg_hash);
|
||||||
|
if (opts->payload == 1) fprintf(stderr, "HSK=%X; ", xpt_hand);
|
||||||
|
//extra verbosity on handshake types found in the patent
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Handshake - ");
|
||||||
|
if (xpt_hand == 0) fprintf (stderr, "Ordinary; ");
|
||||||
|
else if (xpt_hand == 1) fprintf (stderr, "Callback/Alarm Interrupt; ");
|
||||||
|
else if (xpt_hand == 2) fprintf (stderr, "Release Channel Interrupt; ");
|
||||||
|
else fprintf (stderr, "Reserved; ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// {
|
||||||
|
// if (xpt_res_a == 0) fprintf (stderr, "Call Connected; ");
|
||||||
|
// if (xpt_res_a == 1) fprintf (stderr, "Data Call Request; ");
|
||||||
|
// if (xpt_res_a == 7) fprintf (stderr, "Voice Call Request; ");
|
||||||
|
// if (xpt_res_a == 2) fprintf (stderr, "Unknown Status; ");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//logical repeater channel, not the logical slot value in the CSBK
|
||||||
|
if (opts->payload == 1) fprintf(stderr, "Call on LCN %d; ", xpt_int); //LCN channel call or 'interrupt' will occur on
|
||||||
|
// if (opts->payload == 1) fprintf(stderr, "RS A[%01X]B[%02X]C[%02X]; ", xpt_res_a, xpt_res_b, xpt_res_c); //leftover bits
|
||||||
|
if (opts->payload == 1) fprintf (stderr, "Free LCN %d; ", xpt_free); //current free repeater LCN channel
|
||||||
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
|
||||||
|
//add string for ncurses terminal display
|
||||||
|
sprintf (state->dmr_site_parms, "Free LCN - %d ", xpt_free);
|
||||||
|
|
||||||
|
is_xpt = 1;
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Hytera XPT 'Others' -- moved the patent opcodes here as well for now
|
||||||
|
if ( fid == 0x68 && (flco == 0x13 || flco == 0x31 || flco == 0x2E || flco == 0x2F) )
|
||||||
|
{
|
||||||
|
if (type == 1) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 2) fprintf (stderr, "%s \n", KCYN);
|
||||||
|
if (type == 3) fprintf (stderr, "%s", KCYN);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Hytera ");
|
||||||
|
unk = 1;
|
||||||
|
goto END_FLCO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//unknown other manufacturer or OTA ENC, etc.
|
||||||
|
//removed tait from the list, added hytera 0x08
|
||||||
|
if (fid != 0 && fid != 0x68 && fid != 0x10 && fid != 0x08)
|
||||||
|
{
|
||||||
|
if (type == 1) fprintf (stderr, "%s \n", KYEL);
|
||||||
|
if (type == 2) fprintf (stderr, "%s \n", KYEL);
|
||||||
|
if (type == 3) fprintf (stderr, "%s", KYEL);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " Unknown LC ");
|
||||||
|
unk = 1;
|
||||||
|
goto END_FLCO;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//will want to continue to observe for different flco and fid combinations to find out their meaning
|
//will want to continue to observe for different flco and fid combinations to find out their meaning
|
||||||
//Standard Addressing/Cap+ Addressing (trying to avoid embedded alias and gps, etc)
|
|
||||||
if(IrrecoverableErrors == 0 && is_alias == 0 && is_gps == 0)
|
if(IrrecoverableErrors == 0 && is_alias == 0 && is_gps == 0)
|
||||||
{
|
{
|
||||||
//set overarching manufacturer in use when non-standard feature id set is up
|
//set overarching manufacturer in use when non-standard feature id set is up
|
||||||
//may not want to set moto 0x10 here either, lots of radios use that set as well
|
|
||||||
if (fid != 0) state->dmr_mfid = fid;
|
if (fid != 0) state->dmr_mfid = fid;
|
||||||
|
|
||||||
if (type != 2) //VLC and EMB, set our target, source, so, and fid per channel
|
if (type != 2) //VLC and EMB, set our target, source, so, and fid per channel
|
||||||
@@ -131,6 +330,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
// state->lastsrc = 0;
|
// state->lastsrc = 0;
|
||||||
state->payload_algid = 0;
|
state->payload_algid = 0;
|
||||||
state->payload_mi = 0;
|
state->payload_mi = 0;
|
||||||
|
state->payload_keyid = 0;
|
||||||
}
|
}
|
||||||
if (state->currentslot == 1)
|
if (state->currentslot == 1)
|
||||||
{
|
{
|
||||||
@@ -140,6 +340,7 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
// state->lastsrcR = 0;
|
// state->lastsrcR = 0;
|
||||||
state->payload_algidR = 0;
|
state->payload_algidR = 0;
|
||||||
state->payload_miR = 0;
|
state->payload_miR = 0;
|
||||||
|
state->payload_keyidR = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,16 +361,40 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
|
|
||||||
fprintf (stderr, " SLOT %d ", state->currentslot+1);
|
fprintf (stderr, " SLOT %d ", state->currentslot+1);
|
||||||
fprintf(stderr, "TGT=%u SRC=%u ", target, source);
|
fprintf(stderr, "TGT=%u SRC=%u ", target, source);
|
||||||
|
if (opts->payload == 1 && is_xpt == 1 && flco == 0x3) fprintf(stderr, "HASH=%d ", tg_hash);
|
||||||
if (opts->payload == 1) fprintf(stderr, "FLCO=0x%02X FID=0x%02X SVC=0x%02X ", flco, fid, so);
|
if (opts->payload == 1) fprintf(stderr, "FLCO=0x%02X FID=0x%02X SVC=0x%02X ", flco, fid, so);
|
||||||
|
|
||||||
if (flco == 3) //UU_V_Ch_Usr
|
//0x04 and 0x05 on a TLC seem to indicate a Cap + Private Call Terminator (perhaps one for each MS)
|
||||||
|
//0x07 on a VLC seems to indicate a Cap+ Private Call Header
|
||||||
|
//0x23 on the Embedded Voice Burst Sync seems to indicate a Cap+ or Cap+ TXI Private Call in progress
|
||||||
|
//0x20 on the Embedded Voice Burst Sync seems to indicate a Moto (non-specific) Group Call in progress
|
||||||
|
//its possible that both EMB FID 0x10 FLCO 0x20 and 0x23 are just Moto but non-specific (observed 0x20 on Tier 2)
|
||||||
|
|
||||||
|
if (fid == 0x68) sprintf (state->call_string[slot], " Hytera ");
|
||||||
|
|
||||||
|
else if (flco == 0x4 || flco == 0x5 || flco == 0x7 || flco == 0x23) //Cap+ Things
|
||||||
{
|
{
|
||||||
sprintf (state->call_string[slot], " Private");
|
sprintf (state->call_string[slot], " Cap+");
|
||||||
|
fprintf (stderr, "Cap+ ");
|
||||||
|
if (flco == 0x4)
|
||||||
|
{
|
||||||
|
strcat (state->call_string[slot], " Grp");
|
||||||
|
fprintf (stderr, "Group ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcat (state->call_string[slot], " Pri");
|
||||||
|
fprintf (stderr, "Private ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (flco == 0x3) //UU_V_Ch_Usr
|
||||||
|
{
|
||||||
|
sprintf (state->call_string[slot], " Private ");
|
||||||
fprintf (stderr, "Private ");
|
fprintf (stderr, "Private ");
|
||||||
}
|
}
|
||||||
else //Grp_V_Ch_Usr
|
else //Grp_V_Ch_Usr -- still valid on hytera VLC
|
||||||
{
|
{
|
||||||
sprintf (state->call_string[slot], " Group");
|
sprintf (state->call_string[slot], " Group ");
|
||||||
fprintf (stderr, "Group ");
|
fprintf (stderr, "Group ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,70 +416,76 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
//REMUS! Uncomment Line Below if desired
|
//REMUS! Uncomment Line Below if desired
|
||||||
// else strcat (state->call_string[slot], " ");
|
// else strcat (state->call_string[slot], " ");
|
||||||
|
|
||||||
/* Check the "Service Option" bits */
|
//Motorola FID 0x10 Only
|
||||||
if(so & 0x30)
|
if (fid == 0x10)
|
||||||
{
|
{
|
||||||
/* Experimentally determined with DSD+,
|
/* Check the "Service Option" bits */
|
||||||
* is equal to 0x2, this is a TXI call */
|
if(so & 0x30)
|
||||||
if((so & 0x30) == 0x20)
|
|
||||||
{
|
{
|
||||||
//REMUS! Uncomment Line Below if desired
|
/* Experimentally determined with DSD+,
|
||||||
// strcat (state->call_string[slot], " TXI");
|
* is equal to 0x2, this is a TXI call */
|
||||||
fprintf(stderr, "TXI ");
|
if((so & 0x30) == 0x20)
|
||||||
|
{
|
||||||
|
//REMUS! Uncomment Line Below if desired
|
||||||
|
// strcat (state->call_string[slot], " TXI");
|
||||||
|
fprintf(stderr, "TXI ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//REMUS! Uncomment Line Below if desired
|
||||||
|
// strcat (state->call_string[slot], " RES");
|
||||||
|
fprintf(stderr, "RS%d ", (so & 0x30) >> 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if(so & 0x08)
|
||||||
{
|
{
|
||||||
//REMUS! Uncomment Line Below if desired
|
//REMUS! Uncomment Line Below if desired
|
||||||
// strcat (state->call_string[slot], " RES");
|
// strcat (state->call_string[slot], "-BC ");
|
||||||
fprintf(stderr, "Reserved=%d ", (so & 0x30) >> 4);
|
fprintf(stderr, "Broadcast ");
|
||||||
}
|
}
|
||||||
}
|
if(so & 0x04)
|
||||||
if(so & 0x08)
|
{
|
||||||
{
|
//REMUS! Uncomment Line Below if desired
|
||||||
//REMUS! Uncomment Line Below if desired
|
// strcat (state->call_string[slot], "-OVCM ");
|
||||||
// strcat (state->call_string[slot], "-BC ");
|
fprintf(stderr, "OVCM ");
|
||||||
fprintf(stderr, "Broadcast ");
|
}
|
||||||
}
|
if(so & 0x03)
|
||||||
if(so & 0x04)
|
{
|
||||||
{
|
if((so & 0x03) == 0x01)
|
||||||
//REMUS! Uncomment Line Below if desired
|
{
|
||||||
// strcat (state->call_string[slot], "-OVCM ");
|
//REMUS! Uncomment Line Below if desired
|
||||||
fprintf(stderr, "OVCM ");
|
// strcat (state->call_string[slot], "-P1");
|
||||||
}
|
fprintf(stderr, "Priority 1 ");
|
||||||
if(so & 0x03)
|
}
|
||||||
{
|
else if((so & 0x03) == 0x02)
|
||||||
if((so & 0x03) == 0x01)
|
{
|
||||||
{
|
//REMUS! Uncomment Line Below if desired
|
||||||
//REMUS! Uncomment Line Below if desired
|
// strcat (state->call_string[slot], "-P2");
|
||||||
// strcat (state->call_string[slot], "-P1");
|
fprintf(stderr, "Priority 2 ");
|
||||||
fprintf(stderr, "Priority 1 ");
|
}
|
||||||
}
|
else if((so & 0x03) == 0x03)
|
||||||
else if((so & 0x03) == 0x02)
|
{
|
||||||
{
|
//REMUS! Uncomment Line Below if desired
|
||||||
//REMUS! Uncomment Line Below if desired
|
// strcat (state->call_string[slot], "-P3");
|
||||||
// strcat (state->call_string[slot], "-P2");
|
fprintf(stderr, "Priority 3 ");
|
||||||
fprintf(stderr, "Priority 2 ");
|
}
|
||||||
}
|
else /* We should never go here */
|
||||||
else if((so & 0x03) == 0x03)
|
{
|
||||||
{
|
//REMUS! Uncomment Line Below if desired
|
||||||
//REMUS! Uncomment Line Below if desired
|
// strcat (state->call_string[slot], " ");
|
||||||
// strcat (state->call_string[slot], "-P3");
|
fprintf(stderr, "No Priority ");
|
||||||
fprintf(stderr, "Priority 3 ");
|
}
|
||||||
}
|
|
||||||
else /* We should never go here */
|
|
||||||
{
|
|
||||||
//REMUS! Uncomment Line Below if desired
|
|
||||||
// strcat (state->call_string[slot], " ");
|
|
||||||
fprintf(stderr, "No Priority ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//should rework this back into the upper portion
|
||||||
|
if (fid == 0x68) fprintf (stderr, "Hytera ");
|
||||||
|
if (is_xpt) fprintf (stderr, "XPT ");
|
||||||
|
if (fid == 0x68 && flco == 0x00) fprintf (stderr, "Group ");
|
||||||
|
if (fid == 0x68 && flco == 0x03) fprintf (stderr, "Private ");
|
||||||
|
|
||||||
fprintf(stderr, "Call ");
|
fprintf(stderr, "Call ");
|
||||||
|
|
||||||
fprintf (stderr, "%s", KRED);
|
|
||||||
if (CRCCorrect == 1) ; //CRCCorrect 1 is good, else is bad CRC; no print on good
|
|
||||||
else if(IrrecoverableErrors == 0) fprintf(stderr, "(FEC/RAS)");
|
|
||||||
else fprintf(stderr, "(FEC/CRC ERR)");
|
|
||||||
|
|
||||||
//check Cap+ rest channel info if available and good fec
|
//check Cap+ rest channel info if available and good fec
|
||||||
if (is_cap_plus == 1)
|
if (is_cap_plus == 1)
|
||||||
@@ -299,6 +530,23 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
END_FLCO:
|
||||||
|
if (unk == 1 || pf == 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, " FLCO=0x%02X FID=0x%02X ", flco, fid);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IrrecoverableErrors != 0)
|
||||||
|
{
|
||||||
|
if (type != 3) fprintf (stderr, "\n");
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " SLOT %d", state->currentslot+1);
|
||||||
|
fprintf (stderr, " FLCO FEC ERR ");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//externalized dmr cach - tact and slco fragment handling
|
//externalized dmr cach - tact and slco fragment handling
|
||||||
@@ -552,8 +800,17 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[])
|
|||||||
//Con+
|
//Con+
|
||||||
uint8_t con_netid = (uint8_t)ConvertBitIntoBytes(&slco_bits[8], 8);
|
uint8_t con_netid = (uint8_t)ConvertBitIntoBytes(&slco_bits[8], 8);
|
||||||
uint8_t con_siteid = (uint8_t)ConvertBitIntoBytes(&slco_bits[16], 8);
|
uint8_t con_siteid = (uint8_t)ConvertBitIntoBytes(&slco_bits[16], 8);
|
||||||
|
|
||||||
//Cap+
|
//Cap+
|
||||||
uint8_t restchannel = (uint8_t)ConvertBitIntoBytes(&slco_bits[12], 8);
|
uint8_t capsite = (uint8_t)ConvertBitIntoBytes(&slco_bits[22], 3); //Seems more consistent
|
||||||
|
uint8_t restchannel = (uint8_t)ConvertBitIntoBytes(&slco_bits[16], 4);
|
||||||
|
uint8_t cap_reserved = (uint8_t)ConvertBitIntoBytes(&slco_bits[20], 2); //significant value?
|
||||||
|
|
||||||
|
//Hytera XPT
|
||||||
|
uint8_t xpt_free = (uint8_t)ConvertBitIntoBytes(&slco_bits[12], 4); //free repeater
|
||||||
|
//the next two per SDRTrunk, but only 0 values ever observed here
|
||||||
|
uint8_t xpt_pri = (uint8_t)ConvertBitIntoBytes(&slco_bits[16], 4); //priority repeater
|
||||||
|
uint8_t xpt_hash = (uint8_t)ConvertBitIntoBytes(&slco_bits[20], 8); //priority TG hash
|
||||||
|
|
||||||
//initial line break
|
//initial line break
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
@@ -602,18 +859,12 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[])
|
|||||||
fprintf (stderr, " SLCO Activity Update TS1: %X Hash: %02X TS2: %X Hash: %02X", ts1_act, ts1_hash, ts2_act, ts2_hash); //102 361-2 7.1.3.2
|
fprintf (stderr, " SLCO Activity Update TS1: %X Hash: %02X TS2: %X Hash: %02X", ts1_act, ts1_hash, ts2_act, ts2_hash); //102 361-2 7.1.3.2
|
||||||
else if (slco == 0x9)
|
else if (slco == 0x9)
|
||||||
{
|
{
|
||||||
state->dmr_mfid = 0x10;
|
|
||||||
sprintf (state->dmr_branding, "%s", "Motorola");
|
|
||||||
sprintf (state->dmr_branding_sub, "%s", "Con+ ");
|
|
||||||
fprintf (stderr, " SLCO Connect Plus Voice Channel - Net ID: %d Site ID: %d", con_netid, con_siteid);
|
fprintf (stderr, " SLCO Connect Plus Voice Channel - Net ID: %d Site ID: %d", con_netid, con_siteid);
|
||||||
sprintf (state->dmr_site_parms, "%d-%d ", con_netid, con_siteid);
|
sprintf (state->dmr_site_parms, "%d-%d ", con_netid, con_siteid);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (slco == 0xA)
|
else if (slco == 0xA)
|
||||||
{
|
{
|
||||||
state->dmr_mfid = 0x10;
|
|
||||||
sprintf (state->dmr_branding, "%s", "Motorola");
|
|
||||||
sprintf (state->dmr_branding_sub, "%s", "Con+ ");
|
|
||||||
fprintf (stderr, " SLCO Connect Plus Control Channel - Net ID: %d Site ID: %d", con_netid, con_siteid);
|
fprintf (stderr, " SLCO Connect Plus Control Channel - Net ID: %d Site ID: %d", con_netid, con_siteid);
|
||||||
sprintf (state->dmr_site_parms, "%d-%d ", con_netid, con_siteid);
|
sprintf (state->dmr_site_parms, "%d-%d ", con_netid, con_siteid);
|
||||||
|
|
||||||
@@ -627,19 +878,24 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[])
|
|||||||
|
|
||||||
else if (slco == 0xF)
|
else if (slco == 0xF)
|
||||||
{
|
{
|
||||||
state->dmr_mfid = 0x10;
|
fprintf (stderr, " SLCO Capacity Plus Site: %d - Rest Channel %d - RS: %02X", capsite, restchannel, cap_reserved);
|
||||||
sprintf (state->dmr_branding, "%s", "Motorola");
|
|
||||||
sprintf (state->dmr_branding_sub, "%s", "Cap+ ");
|
|
||||||
fprintf (stderr, " SLCO Capacity Plus Rest Channel %d", restchannel);
|
|
||||||
state->dmr_rest_channel = restchannel;
|
|
||||||
//assign to cc freq if available
|
//assign to cc freq if available
|
||||||
if (state->trunk_chan_map[restchannel] != 0)
|
if (state->trunk_chan_map[restchannel] != 0)
|
||||||
{
|
{
|
||||||
state->p25_cc_freq = state->trunk_chan_map[restchannel];
|
state->p25_cc_freq = state->trunk_chan_map[restchannel];
|
||||||
}
|
}
|
||||||
|
|
||||||
//nullify any previous TIII data (bugfix for bad assignments or system type switching)
|
}
|
||||||
sprintf(state->dmr_site_parms, "%s", "");
|
else if (slco == 0x08)
|
||||||
|
{
|
||||||
|
//The Priority Repeater and Priority Hash values stem from SDRTrunk, but I've never seen these values not be zeroes
|
||||||
|
fprintf (stderr, " SLCO Hytera XPT - Free LCN %d - PRI LCN %d - PRI HASH: %02X", xpt_free, xpt_pri, xpt_hash);
|
||||||
|
//NOTE: on really busy systems, this free repeater assignment can lag due to the 4 TS requirment to get SLC
|
||||||
|
// fprintf (stderr, " SLCO Hytera XPT - Free LCN %d ", xpt_free);
|
||||||
|
sprintf (state->dmr_branding_sub, "XPT ");
|
||||||
|
|
||||||
|
//add string for ncurses terminal display
|
||||||
|
sprintf (state->dmr_site_parms, "Free LCN - %d ", xpt_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
else fprintf (stderr, " SLCO Unknown - %d ", slco);
|
else fprintf (stderr, " SLCO Unknown - %d ", slco);
|
||||||
@@ -651,6 +907,7 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "[%02X]", slco_bytes[i]);
|
fprintf (stderr, "[%02X]", slco_bytes[i]);
|
||||||
}
|
}
|
||||||
|
fprintf (stderr, "\n"); //if its a voice frame, we need the line break
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
@@ -691,6 +948,10 @@ void dmr_embedded_alias_blocks (dsd_opts * opts, dsd_state * state, uint8_t lc_b
|
|||||||
uint8_t len = state->dmr_alias_len[slot];
|
uint8_t len = state->dmr_alias_len[slot];
|
||||||
uint8_t start; //starting position depends on context of block and format
|
uint8_t start; //starting position depends on context of block and format
|
||||||
|
|
||||||
|
//Cap Max Variation
|
||||||
|
uint8_t fid = (uint8_t)ConvertBitIntoBytes(&lc_bits[8], 8);
|
||||||
|
if (fid == 0x10) block = block - 0x10; //CapMax adds 0x10 to its FLCO (block num) in its Embedded Aliasing
|
||||||
|
|
||||||
//there is some issue with the next three lines of code that prevent proper assignments, not sure what.
|
//there is some issue with the next three lines of code that prevent proper assignments, not sure what.
|
||||||
//if (block > 4) start = 16;
|
//if (block > 4) start = 16;
|
||||||
//else if (block == 4 && format > 0) start = 23; //8-bit and 16-bit chars
|
//else if (block == 4 && format > 0) start = 23; //8-bit and 16-bit chars
|
||||||
|
|||||||
181
src/dmr_le.c
181
src/dmr_le.c
@@ -77,6 +77,12 @@ void dmr_late_entry_mi (dsd_opts * opts, dsd_state * state)
|
|||||||
state->payload_mi = mi_final;
|
state->payload_mi = mi_final;
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
|
//run afterwards, or le verification won't match up properly
|
||||||
|
if (state->payload_algid != 0x21)
|
||||||
|
{
|
||||||
|
LFSR64 (state);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (slot == 1 && state->payload_algidR != 0)
|
if (slot == 1 && state->payload_algidR != 0)
|
||||||
{
|
{
|
||||||
@@ -87,6 +93,12 @@ void dmr_late_entry_mi (dsd_opts * opts, dsd_state * state)
|
|||||||
state->payload_miR = mi_final;
|
state->payload_miR = mi_final;
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
|
//run afterwards, or le verification won't match up properly
|
||||||
|
if (state->payload_algidR != 0x21)
|
||||||
|
{
|
||||||
|
LFSR64 (state);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -104,11 +116,13 @@ void dmr_alg_refresh (dsd_opts * opts, dsd_state * state)
|
|||||||
state->DMRvcL = 0;
|
state->DMRvcL = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->payload_algid >= 0x21)
|
if (state->payload_algid == 0x21)
|
||||||
{
|
{
|
||||||
LFSR (state);
|
LFSR (state);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
//LFSR64 carried out after LE verification in order to keep it from constantly resetting the MI to the previous value
|
||||||
|
|
||||||
}
|
}
|
||||||
if (state->currentslot == 1)
|
if (state->currentslot == 1)
|
||||||
{
|
{
|
||||||
@@ -119,11 +133,13 @@ void dmr_alg_refresh (dsd_opts * opts, dsd_state * state)
|
|||||||
state->DMRvcR = 0;
|
state->DMRvcR = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->payload_algidR >= 0x21)
|
if (state->payload_algidR == 0x21)
|
||||||
{
|
{
|
||||||
LFSR (state);
|
LFSR (state);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
//LFSR64 carried out after LE verification in order to keep it from constantly resetting the MI to the previous value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -135,5 +151,166 @@ void dmr_alg_reset (dsd_opts * opts, dsd_state * state)
|
|||||||
state->DMRvcL = 0;
|
state->DMRvcL = 0;
|
||||||
state->DMRvcR = 0;
|
state->DMRvcR = 0;
|
||||||
state->payload_miP = 0;
|
state->payload_miP = 0;
|
||||||
|
state->payload_miN = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//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];
|
||||||
|
memset (sbrc_interleaved, 0, sizeof(sbrc_interleaved));
|
||||||
|
memset (sbrc_return, 0, sizeof(sbrc_return));
|
||||||
|
uint32_t irr_err = 0;
|
||||||
|
uint32_t sbrc_hex = 0;
|
||||||
|
uint16_t crc_extracted = 7777;
|
||||||
|
uint16_t crc_computed = 9999;
|
||||||
|
uint8_t crc_okay = 0;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
//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
|
||||||
|
//unknown what the other values are (see Cap+ 0x313 and 0x643)
|
||||||
|
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, 11);
|
||||||
|
if (crc_extracted == crc_computed) crc_okay = 1;
|
||||||
|
}
|
||||||
|
else crc_okay = 1; //SB
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide the sb/rc behind the payload printer, won't be useful to most people right now
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n %s", KCYN);
|
||||||
|
if (power == 0) fprintf (stderr, " SB: ");
|
||||||
|
if (power == 1) fprintf (stderr, " RC: ");
|
||||||
|
for(i = 0; i < 11; i++)
|
||||||
|
{
|
||||||
|
sbrc_hex = sbrc_hex << 1;
|
||||||
|
sbrc_hex |= sbrc_return[i] & 1; //sbrc_return
|
||||||
|
fprintf (stderr, "%d", sbrc_return[i]);
|
||||||
|
}
|
||||||
|
fprintf (stderr, " - %03X", sbrc_hex);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
if (crc_okay == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
if (opts->payload == 1) fprintf (stderr, " CRC EXT %02X, CRC CMP %02X", crc_extracted, crc_computed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disabling the lower portion until this can be completely ironed out
|
||||||
|
|
||||||
|
//sbrc_hex value of 0x313 seems to be some Cap+ Thing,
|
||||||
|
//also observed 0x643 on another cap+ system (site id, status? something?)
|
||||||
|
// uint8_t sbrc_opcode = sbrc_hex;
|
||||||
|
// uint8_t alg = sbrc_hex & 0x7;
|
||||||
|
// uint8_t key = (sbrc_hex >> 3) & 0xFF;
|
||||||
|
|
||||||
|
//this pattern seems to fit the multiple cap+ systems I've observed
|
||||||
|
//test on site '7' to make sure (works on 1 and 4)
|
||||||
|
// uint8_t cap_site = (sbrc_hex >> 4) & 0x7;
|
||||||
|
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// {
|
||||||
|
// if (irr_err != 0) fprintf (stderr, "%s (FEC ERR) %d %s", KRED, irr_err, KNRM);
|
||||||
|
// if (irr_err == 0)
|
||||||
|
// {
|
||||||
|
// if (sbrc_hex == 0) ; //NULL
|
||||||
|
// else if (strcmp (state->dmr_branding_sub, "Cap+ ") == 0)
|
||||||
|
// {
|
||||||
|
// //Cap+ Site ID seems to fit here on samples I've seen with the alternate SB signalling, but no idea what signals that info and not the emb alg/key info
|
||||||
|
// fprintf (stderr, "%s ", KYEL);
|
||||||
|
// fprintf (stderr, "\n ");
|
||||||
|
// fprintf (stderr, " Capacity Plus Site %d", cap_site);
|
||||||
|
// fprintf (stderr, "%s ", KNRM);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
|
||||||
|
// if (slot == 0)
|
||||||
|
// {
|
||||||
|
// //key and alg only present SOME times, not all,
|
||||||
|
// //also, intermixed with other signalling
|
||||||
|
// //needs more study first!
|
||||||
|
// if (state->dmr_so & 0x40 && key != 0 && state->payload_keyid == 0)
|
||||||
|
// {
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// {
|
||||||
|
// fprintf (stderr, "%s ", KYEL);
|
||||||
|
// fprintf (stderr, "\n Slot 1");
|
||||||
|
// fprintf (stderr, " DMR LE SB ALG ID: %X KEY ID: %0X", alg + 0x20, key);
|
||||||
|
// fprintf (stderr, "%s ", KNRM);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //needs more study before assignment
|
||||||
|
// // state->payload_keyid = key;
|
||||||
|
// // state->payload_algid = alg + 0x20; //assuming DMRA approved alg values (moto patent)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (slot == 1)
|
||||||
|
// {
|
||||||
|
// if (state->dmr_soR & 0x40 && key != 0 && state->payload_keyidR == 0)
|
||||||
|
// {
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// {
|
||||||
|
// fprintf (stderr, "%s ", KYEL);
|
||||||
|
// fprintf (stderr, "\n Slot 2");
|
||||||
|
// fprintf (stderr, " DMR LE SB ALG ID: %X KEY ID: %0X", alg + 0x20, key);
|
||||||
|
// fprintf (stderr, "%s ", KNRM);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //needs more study before assignment
|
||||||
|
// // state->payload_keyidR = key;
|
||||||
|
// // state->payload_algidR = alg + 0x20; //assuming DMRA approved alg values (moto patent)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
SBRC_END:
|
||||||
|
|
||||||
|
//'DSP' output to file -- only RC, or RC and SB?
|
||||||
|
if (power == 1 && opts->use_dsp_output == 1 && sbrc_hex != 0) //if not NULL
|
||||||
|
{
|
||||||
|
FILE * pFile; //file pointer
|
||||||
|
pFile = fopen (opts->dsp_out_file, "a");
|
||||||
|
fprintf (pFile, "\n%d 99 ", slot+1); //'99' is RC designation value
|
||||||
|
int k = 0;
|
||||||
|
for (i = 0; i < 24; i++) //12 bytes, SB or RC
|
||||||
|
{
|
||||||
|
//check to see if k++ starts at zero, or at 1
|
||||||
|
int sbrc_nib = (state->dmr_embedded_signalling[slot][5][k++] << 3) | (state->dmr_embedded_signalling[slot][5][k++] << 2) | (state->dmr_embedded_signalling[slot][5][k++] << 1) | (state->dmr_embedded_signalling[slot][5][k++] << 0);
|
||||||
|
fprintf (pFile, "%X", sbrc_nib);
|
||||||
|
}
|
||||||
|
fclose (pFile);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
122
src/dmr_ms.c
122
src/dmr_ms.c
@@ -50,6 +50,11 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
uint8_t internalslot;
|
uint8_t internalslot;
|
||||||
uint8_t vc;
|
uint8_t vc;
|
||||||
|
|
||||||
|
//assign as nonsensical numbers
|
||||||
|
uint8_t cc = 25;
|
||||||
|
uint8_t power = 9; //power and pre-emption indicator
|
||||||
|
uint8_t lcss = 9;
|
||||||
|
|
||||||
//dummy bits to pass to dburst for link control
|
//dummy bits to pass to dburst for link control
|
||||||
uint8_t dummy_bits[196];
|
uint8_t dummy_bits[196];
|
||||||
memset (dummy_bits, 0, sizeof (dummy_bits));
|
memset (dummy_bits, 0, sizeof (dummy_bits));
|
||||||
@@ -87,7 +92,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 12; i++)
|
for(i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
cachdata[i] = dibit;
|
cachdata[i] = dibit;
|
||||||
state->dmr_stereo_payload[i] = dibit;
|
state->dmr_stereo_payload[i] = dibit;
|
||||||
@@ -119,7 +124,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 36; i++)
|
for(i = 0; i < 36; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
state->dmr_stereo_payload[i+12] = dibit;
|
state->dmr_stereo_payload[i+12] = dibit;
|
||||||
|
|
||||||
@@ -144,7 +149,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 18; i++)
|
for(i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
state->dmr_stereo_payload[i+48] = dibit;
|
state->dmr_stereo_payload[i+48] = dibit;
|
||||||
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
@@ -161,7 +166,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 24; i++)
|
for(i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
state->dmr_stereo_payload[i+66] = dibit;
|
state->dmr_stereo_payload[i+66] = dibit;
|
||||||
|
|
||||||
@@ -171,7 +176,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
sync[i] = (dibit | 1) + 48;
|
sync[i] = (dibit | 1) + 48;
|
||||||
|
|
||||||
// load the superframe to do embedded signal processing
|
// load the superframe to do embedded signal processing
|
||||||
if(vc > 1 && vc < 6) //grab on vc1 values 2-5 B C D and E
|
if(vc > 1) //grab on vc1 values 2-5 B C D and E (F for Single/RC)
|
||||||
{
|
{
|
||||||
state->dmr_embedded_signalling[internalslot][vc-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
state->dmr_embedded_signalling[internalslot][vc-1][i*2] = (1 & (dibit >> 1)); // bit 1
|
||||||
state->dmr_embedded_signalling[internalslot][vc-1][i*2+1] = (1 & dibit); // bit 0
|
state->dmr_embedded_signalling[internalslot][vc-1][i*2+1] = (1 & dibit); // bit 0
|
||||||
@@ -180,17 +185,40 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sync[24] = 0;
|
sync[24] = 0;
|
||||||
|
|
||||||
|
//test for RC sync pattern in MS sourced audio
|
||||||
|
if ( strcmp (sync, DMR_RC_DATA_SYNC) == 0)
|
||||||
|
{
|
||||||
|
state->dmr_ms_rc = 1;
|
||||||
|
fprintf (stderr, "%s ", getTime());
|
||||||
|
if (opts->inverted_dmr == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,"Sync: +DMR MS/DM MODE/MONO ");
|
||||||
|
}
|
||||||
|
else fprintf (stderr,"Sync: -DMR MS/DM MODE/MONO ");
|
||||||
|
|
||||||
|
fprintf (stderr, "| RC ");
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < 8; i++) EmbeddedSignalling[i] = syncdata[i];
|
||||||
|
for(i = 0; i < 8; i++) EmbeddedSignalling[i + 8] = syncdata[i + 40];
|
||||||
|
|
||||||
EmbeddedSignallingOk = -1;
|
EmbeddedSignallingOk = -1;
|
||||||
if(QR_16_7_6_decode(EmbeddedSignalling))
|
if(QR_16_7_6_decode(EmbeddedSignalling))
|
||||||
{
|
{
|
||||||
EmbeddedSignallingOk = 1;
|
EmbeddedSignallingOk = 1;
|
||||||
|
cc = ((EmbeddedSignalling[0] << 3) + (EmbeddedSignalling[1] << 2) + (EmbeddedSignalling[2] << 1) + EmbeddedSignalling[3]);
|
||||||
|
power = EmbeddedSignalling[4];
|
||||||
|
lcss = ((EmbeddedSignalling[5] << 1) + EmbeddedSignalling[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Continue Second AMBE Frame, 18 after Sync or EmbeddedSignalling
|
//Continue Second AMBE Frame, 18 after Sync or EmbeddedSignalling
|
||||||
for(i = 0; i < 18; i++)
|
for(i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
state->dmr_stereo_payload[i+90] = dibit;
|
state->dmr_stereo_payload[i+90] = dibit;
|
||||||
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
@@ -214,7 +242,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
for(i = 0; i < 36; i++)
|
for(i = 0; i < 36; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
|
|
||||||
state->dmr_stereo_payload[i+108] = dibit;
|
state->dmr_stereo_payload[i+108] = dibit;
|
||||||
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
@@ -227,6 +255,20 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//'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 10 ", state->currentslot+1); //0x10 for "voice burst", forced to slot 1
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
state->dmr_ms_mode = 1;
|
state->dmr_ms_mode = 1;
|
||||||
|
|
||||||
memcpy (ambe_fr4, ambe_fr2, sizeof(ambe_fr2));
|
memcpy (ambe_fr4, ambe_fr2, sizeof(ambe_fr2));
|
||||||
@@ -238,22 +280,28 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
memcpy (m2, ambe_fr2, sizeof(m2));
|
memcpy (m2, ambe_fr2, sizeof(m2));
|
||||||
memcpy (m3, ambe_fr3, sizeof(m3));
|
memcpy (m3, ambe_fr3, sizeof(m3));
|
||||||
|
|
||||||
if (state->directmode == 0)
|
if (state->dmr_ms_rc == 0)
|
||||||
{
|
{
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
if (state->directmode == 0)
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
|
{
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
||||||
}
|
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
|
||||||
else
|
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
||||||
{
|
}
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr4, NULL); //play duplicate of 2 here to smooth audio on tdma direct
|
else
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
|
{
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
processMbeFrame (opts, state, NULL, ambe_fr4, NULL); //play duplicate of 2 here to smooth audio on tdma direct
|
||||||
|
processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
|
||||||
|
processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vc == 6)
|
if (vc == 6)
|
||||||
{
|
{
|
||||||
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
|
||||||
|
//check the single burst/reverse channel opportunity
|
||||||
|
dmr_sbrc (opts, state, power);
|
||||||
|
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
dmr_alg_refresh (opts, state);
|
dmr_alg_refresh (opts, state);
|
||||||
}
|
}
|
||||||
@@ -268,6 +316,12 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
||||||
vc++;
|
vc++;
|
||||||
|
|
||||||
|
//reset emb components
|
||||||
|
cc = 25;
|
||||||
|
power = 9; //power and pre-emption indicator
|
||||||
|
lcss = 9;
|
||||||
|
|
||||||
//this is necessary because we need to skip and collect dibits, not just skip them
|
//this is necessary because we need to skip and collect dibits, not just skip them
|
||||||
if (vc > 6) goto END;
|
if (vc > 6) goto END;
|
||||||
|
|
||||||
@@ -292,7 +346,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if (opts->inverted_dmr == 1)
|
if (opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
state->dmr_stereo_payload[i] = dibit;
|
state->dmr_stereo_payload[i] = dibit;
|
||||||
|
|
||||||
@@ -379,7 +433,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = state->dmr_stereo_payload[i];
|
dibit = state->dmr_stereo_payload[i];
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
cachdata[i] = dibit;
|
cachdata[i] = dibit;
|
||||||
}
|
}
|
||||||
@@ -398,7 +452,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = state->dmr_stereo_payload[i+12];
|
dibit = state->dmr_stereo_payload[i+12];
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
state->dmr_stereo_payload[i+12] = dibit;
|
state->dmr_stereo_payload[i+12] = dibit;
|
||||||
ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
@@ -425,7 +479,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = state->dmr_stereo_payload[i+48];
|
dibit = state->dmr_stereo_payload[i+48];
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
||||||
@@ -443,8 +497,9 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
|
state->dmr_stereo_payload[i+90] = dibit;
|
||||||
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
@@ -469,8 +524,9 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1)
|
if(opts->inverted_dmr == 1)
|
||||||
{
|
{
|
||||||
dibit = (dibit ^ 2);
|
dibit = (dibit ^ 2) & 3;
|
||||||
}
|
}
|
||||||
|
state->dmr_stereo_payload[i+108] = dibit;
|
||||||
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
|
||||||
ambe_fr3[*y][*z] = (1 & dibit); // bit 0
|
ambe_fr3[*y][*z] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
@@ -481,6 +537,20 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//'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 10 ", state->currentslot+1); //0x10 for "voice burst", force to slot 1
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s ", getTime());
|
fprintf (stderr, "%s ", getTime());
|
||||||
if (opts->inverted_dmr == 0)
|
if (opts->inverted_dmr == 0)
|
||||||
{
|
{
|
||||||
@@ -517,7 +587,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//collect the mi fragment
|
//collect the mi fragment
|
||||||
dmr_late_entry_mi_fragment (opts, state, 1, ambe_fr, ambe_fr2, ambe_fr3);
|
dmr_late_entry_mi_fragment (opts, state, 1, m1, m2, m3);
|
||||||
|
|
||||||
//errors due to skipping other slot
|
//errors due to skipping other slot
|
||||||
// cach_err = dmr_cach (opts, state, cachdata);
|
// cach_err = dmr_cach (opts, state, cachdata);
|
||||||
@@ -558,7 +628,7 @@ void dmrMSData (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
dibit = *dibit_p;
|
dibit = *dibit_p;
|
||||||
dibit_p++;
|
dibit_p++;
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
state->dmr_stereo_payload[i] = dibit;
|
state->dmr_stereo_payload[i] = dibit;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -566,7 +636,7 @@ void dmrMSData (dsd_opts * opts, dsd_state * state)
|
|||||||
for (i = 0; i < 54; i++)
|
for (i = 0; i < 54; i++)
|
||||||
{
|
{
|
||||||
dibit = getDibit(opts, state);
|
dibit = getDibit(opts, state);
|
||||||
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2);
|
if(opts->inverted_dmr == 1) dibit = (dibit ^ 2) & 3;
|
||||||
state->dmr_stereo_payload[i+90] = dibit;
|
state->dmr_stereo_payload[i+90] = dibit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
240
src/dmr_pdu.c
240
src/dmr_pdu.c
@@ -44,9 +44,9 @@ void dmr_pdu (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR
|
|||||||
uint8_t padding = state->data_header_padding[slot];
|
uint8_t padding = state->data_header_padding[slot];
|
||||||
uint8_t lrrp_conf = 0;
|
uint8_t lrrp_conf = 0;
|
||||||
|
|
||||||
//consider disabling on prop_head data blocks if bad/false decodes
|
//check for more available flag info, etc on these prior to running
|
||||||
//if (state->data_p_head[slot] == 0)
|
if (DMR_PDU[0] == 0x01) dmr_locn (opts, state, block_len, DMR_PDU);
|
||||||
lrrp_conf = dmr_lrrp (opts, state, block_len, DMR_PDU);
|
else dmr_lrrp (opts, state, block_len, DMR_PDU);
|
||||||
|
|
||||||
//maybe one day we will have more things to do here
|
//maybe one day we will have more things to do here
|
||||||
state->data_conf_data[slot] = 0; //flag off confirmed data after processing it
|
state->data_conf_data[slot] = 0; //flag off confirmed data after processing it
|
||||||
@@ -57,7 +57,7 @@ void dmr_pdu (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR
|
|||||||
//The contents of this function are mostly my reversed engineered efforts by observing DSDPlus output and matching data bytes
|
//The contents of this function are mostly my reversed engineered efforts by observing DSDPlus output and matching data bytes
|
||||||
//combined with a few external sources such as OK-DMR for some token values and extra data values (rad and alt)
|
//combined with a few external sources such as OK-DMR for some token values and extra data values (rad and alt)
|
||||||
//this is by no means an extensive LRRP list and is prone to error (unless somebody has the manual or something)
|
//this is by no means an extensive LRRP list and is prone to error (unless somebody has the manual or something)
|
||||||
uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[])
|
void dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[])
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
uint16_t message_len = 0;
|
uint16_t message_len = 0;
|
||||||
@@ -82,12 +82,15 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
|
|
||||||
//lat-long-radius-alt
|
//lat-long-radius-alt
|
||||||
uint32_t lat = 0;
|
uint32_t lat = 0;
|
||||||
uint8_t lat_sign = 0;
|
|
||||||
uint32_t lon = 0;
|
uint32_t lon = 0;
|
||||||
uint16_t rad = 0;
|
uint16_t rad = 0; //or Azimuth in Circle 3D?
|
||||||
uint8_t alt = 0;
|
uint8_t alt = 0;
|
||||||
double lat_unit = (double)180/(double)4294967295;
|
double lat_unit = (double)180/(double)4294967295;
|
||||||
double lon_unit = (double)360/(double)4294967295;
|
double lon_unit = (double)360/(double)4294967295;
|
||||||
|
double lat_fin = 0.0; //calculated values
|
||||||
|
double lon_fin = 0.0; //calculated values
|
||||||
|
int lat_sign = 1; //positive 1, or negative 1
|
||||||
|
int lon_sign = 1; //positive 1, or negative 1
|
||||||
|
|
||||||
//speed/velocity
|
//speed/velocity
|
||||||
uint16_t vel = 0;
|
uint16_t vel = 0;
|
||||||
@@ -98,26 +101,17 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
uint8_t degrees = 0;
|
uint8_t degrees = 0;
|
||||||
uint8_t deg_set = 0;
|
uint8_t deg_set = 0;
|
||||||
|
|
||||||
|
char deg_glyph[4];
|
||||||
|
sprintf (deg_glyph, "%s", "°");
|
||||||
|
// sprintf (deg_glyph, "%s", "d");
|
||||||
|
|
||||||
//triggered information report
|
//triggered information report
|
||||||
uint8_t report = 0;
|
uint8_t report = 0;
|
||||||
uint8_t pot_report = 0; //potential report by finding 0x0D and backtracking a few bytes
|
uint8_t pot_report = 0; //potential report by finding 0x0D and backtracking a few bytes
|
||||||
|
|
||||||
uint8_t is_p_head = 0;
|
|
||||||
|
|
||||||
//shim for getting LRRP out of some prop head data blocks
|
|
||||||
if (state->data_p_head[slot] == 1)
|
|
||||||
{
|
|
||||||
if (DMR_PDU[1] != 0x10) goto LRRP_END; //check to see if FID is 0x10
|
|
||||||
i = 0;
|
|
||||||
message_len = blocks * block_len;
|
|
||||||
source = state->dmr_lrrp_source[state->currentslot];
|
|
||||||
is_p_head = 1;
|
|
||||||
}
|
|
||||||
else i = 12;
|
|
||||||
|
|
||||||
|
|
||||||
//start looking for tokens (using my best understanding of the ok-dmr library xml and python files)
|
//start looking for tokens (using my best understanding of the ok-dmr library xml and python files)
|
||||||
for (i; i < ( (blocks*block_len) - (padding+4) ); i++)
|
for (i = 0; i < ( (blocks*block_len) - (padding+4) ); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch(DMR_PDU[i]){
|
switch(DMR_PDU[i]){
|
||||||
@@ -174,20 +168,22 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//RESULT TOKEN or Request ID!
|
//RESULT TOKEN or Request ID!
|
||||||
|
case 0x22: //same comment as below, observed followed the message len
|
||||||
case 0x23: //this value has been seen after the 0x0D message len, appears to be a 2-byte value, was tripping a false on time stamp
|
case 0x23: //this value has been seen after the 0x0D message len, appears to be a 2-byte value, was tripping a false on time stamp
|
||||||
i += 2;
|
i += 2;
|
||||||
break;
|
break;
|
||||||
//answer and report tokens
|
//answer and report tokens
|
||||||
case 0x51: //circle-2d
|
case 0x51: //circle-2d
|
||||||
case 0x54: //circle-3d
|
case 0x54: //circle-3d
|
||||||
case 0x55: //circle-3d <- false positives on one sample, so either an earlier token occurred (that we don't have) or just random data?
|
case 0x55: //circle-3d
|
||||||
if (message_len > 0 && lat == 0)
|
if (message_len > 0 && lat == 0)
|
||||||
{
|
{
|
||||||
if (DMR_PDU[i+1] & 0x80) lat_sign = 1;
|
// lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
// lon = ( ( ((DMR_PDU[i+5] & 0x7F ) << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
|
lat = ( ( (DMR_PDU[i+1] << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
rad = (DMR_PDU[i+9] << 8) + DMR_PDU[i+10];
|
rad = (DMR_PDU[i+9] << 8) + DMR_PDU[i+10];
|
||||||
i += 10; //double check
|
i += 10;
|
||||||
if (lat > 0 && lon > 0) lrrp_confidence++; //would be better to set by absolute boundary (180 and 90?)
|
if (lat > 0 && lon > 0) lrrp_confidence++; //would be better to set by absolute boundary (180 and 90?)
|
||||||
else lat = 0;
|
else lat = 0;
|
||||||
}
|
}
|
||||||
@@ -213,10 +209,11 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
case 0x66: //point-2d
|
case 0x66: //point-2d
|
||||||
if (message_len > 0 && lat == 0)
|
if (message_len > 0 && lat == 0)
|
||||||
{
|
{
|
||||||
if (DMR_PDU[i+1] & 0x80) lat_sign = 1;
|
// lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
// lon = ( ( ((DMR_PDU[i+5] & 0x7F ) << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
|
lat = ( ( (DMR_PDU[i+1] << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
i += 8; //check
|
i += 8;
|
||||||
lrrp_confidence++;
|
lrrp_confidence++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -224,12 +221,13 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
case 0x6A: //point-3d
|
case 0x6A: //point-3d
|
||||||
if (message_len > 0 && lat == 0)
|
if (message_len > 0 && lat == 0)
|
||||||
{
|
{
|
||||||
if (DMR_PDU[i+1] & 0x80) lat_sign = 1;
|
// lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lat = ( ( ((DMR_PDU[i+1] & 0x7F ) << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
// lon = ( ( ((DMR_PDU[i+5] & 0x7F ) << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
|
lat = ( ( (DMR_PDU[i+1] << 24 ) + (DMR_PDU[i+2] << 16) + (DMR_PDU[i+3] << 8) + DMR_PDU[i+4]) * 1 );
|
||||||
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
lon = ( ( (DMR_PDU[i+5] << 24 ) + (DMR_PDU[i+6] << 16) + (DMR_PDU[i+7] << 8) + DMR_PDU[i+8]) * 1 );
|
||||||
alt = DMR_PDU[i+9];
|
alt = DMR_PDU[i+9];
|
||||||
i += 9; //check
|
i += 9;
|
||||||
if (lat > 0 && lon > 0) lrrp_confidence++; //would be better to set by absolute boundary (180 and 90?)
|
if (lat > 0 && lon > 0) lrrp_confidence++;
|
||||||
else lat = 0;
|
else lat = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -273,7 +271,7 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
fprintf (stderr, "\n LRRP Confidence: %d - Message Len: %d Octets", lrrp_confidence, message_len);
|
fprintf (stderr, "\n LRRP Confidence: %d - Message Len: %d Octets", lrrp_confidence, message_len);
|
||||||
if (lrrp_confidence >= 4) //find the sweet magical number
|
if (lrrp_confidence >= 3) //find the sweet magical number
|
||||||
{
|
{
|
||||||
//now we can open our lrrp file and write to it as well
|
//now we can open our lrrp file and write to it as well
|
||||||
FILE * pFile; //file pointer
|
FILE * pFile; //file pointer
|
||||||
@@ -285,9 +283,10 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
if (!year) fprintf (pFile, "%s\t", getDateL() ); //current date, only add this IF no included timestamp in LRRP data?
|
if (!year) fprintf (pFile, "%s\t", getDateL() ); //current date, only add this IF no included timestamp in LRRP data?
|
||||||
if (!year) fprintf (pFile, "%s\t", getTimeL() ); //current timestamp, only add this IF no included timestamp in LRRP data?
|
if (!year) fprintf (pFile, "%s\t", getTimeL() ); //current timestamp, only add this IF no included timestamp in LRRP data?
|
||||||
if (year) fprintf (pFile, "%04d/%02d/%02d\t%02d:%02d:%02d\t", year, month, day, hour, minute, second); //add timestamp from decoded audio if available
|
if (year) fprintf (pFile, "%04d/%02d/%02d\t%02d:%02d:%02d\t", year, month, day, hour, minute, second); //add timestamp from decoded audio if available
|
||||||
//write data header source (or destination?) if not available in lrrp data
|
//write data header source if not available in lrrp data
|
||||||
if (!source) fprintf (pFile, "%08lld\t", state->dmr_lrrp_source[state->currentslot]); //source address from data header
|
if (!source) fprintf (pFile, "%08lld\t", state->dmr_lrrp_source[state->currentslot]); //source address from data header
|
||||||
if (source) fprintf (pFile, "%08d\t", source); //add source form decoded audio if available, else its from the header
|
if (source) fprintf (pFile, "%08d\t", source); //add source form decoded audio if available, else its from the header
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pot_report)
|
if (pot_report)
|
||||||
@@ -327,31 +326,45 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
if (lat)
|
if (lat)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
if (lat_sign) //print a '-' in front of the value
|
//need to check these new calcs for accuracy accross the globe, both lat and lon
|
||||||
fprintf (stderr, " LRRP - Lat: -%.5lf", (double)lat * lat_unit);
|
|
||||||
else fprintf (stderr, " LRRP - Lat: %.5lf", (double)lat * lat_unit);
|
//two's compliment-ish testing on these bytes
|
||||||
fprintf (stderr, " Lon: %.5lf", (double)lon * lon_unit);
|
if (lat & 0x80000000) //8
|
||||||
if (lat_sign)
|
{
|
||||||
fprintf (stderr, " (-%.5lf, %.5lf)", (double)lat * lat_unit , (double)lon * lon_unit);
|
lat = lat & 0x7FFFFFFF;
|
||||||
else fprintf (stderr, " (%.5lf, %.5lf)", (double)lat * lat_unit , (double)lon * lon_unit);
|
lat_sign = -1;
|
||||||
|
// lat = 0x80000000 - lat; //not sure why this doesn't work here like it does on lon, extra bit?
|
||||||
|
}
|
||||||
|
if (lon & 0x80000000)
|
||||||
|
{
|
||||||
|
lon = lon & 0x7FFFFFFF;
|
||||||
|
lon_sign = -1;
|
||||||
|
lon = 0x80000000 - lon;
|
||||||
|
}
|
||||||
|
|
||||||
|
lat_fin = (double)lat * lat_unit * lat_sign;
|
||||||
|
lon_fin = (double)lon * lon_unit * lon_sign;
|
||||||
|
|
||||||
|
fprintf (stderr, " LRRP - Lat: %.5lf", lat_fin);
|
||||||
|
fprintf (stderr, " Lon: %.5lf", lon_fin);
|
||||||
|
fprintf (stderr, " (%.5lf, %.5lf)", lat_fin , lon_fin);
|
||||||
|
|
||||||
if (opts->lrrp_file_output == 1)
|
if (opts->lrrp_file_output == 1)
|
||||||
{
|
{
|
||||||
if (lat_sign) fprintf (pFile, "-");
|
fprintf (pFile, "%.5lf\t", lat_fin);
|
||||||
fprintf (pFile, "%.5lf\t", (double)lat * lat_unit);
|
fprintf (pFile, "%.5lf\t", lon_fin);
|
||||||
fprintf (pFile, "%.5lf\t", (double)lon * lon_unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (rad)
|
if (rad)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " LRRP - Radius: %d", rad); //unsure of 'units' or calculation for radius (meters?)
|
fprintf (stderr, " LRRP - Radius: %dm", rad); //unsure of 'units' or calculation for radius (meters?)
|
||||||
}
|
}
|
||||||
if (alt)
|
if (alt)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " LRRP - Altitude: %d", alt); //unsure of 'units' or calculation for alt (meters?)
|
fprintf (stderr, " LRRP - Altitude: %dm", alt); //unsure of 'units' or calculation for alt (meters?)
|
||||||
}
|
}
|
||||||
if (vel_set)
|
if (vel_set)
|
||||||
{
|
{
|
||||||
@@ -362,7 +375,7 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
if (deg_set)
|
if (deg_set)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " LRRP - Track: %d Degrees", degrees);
|
fprintf (stderr, " LRRP - Track: %d%s", degrees, deg_glyph);
|
||||||
if (opts->lrrp_file_output == 1) fprintf (pFile, "%d\t",degrees);
|
if (opts->lrrp_file_output == 1) fprintf (pFile, "%d\t",degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,20 +386,17 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
fclose (pFile);
|
fclose (pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//save to array for ncurses
|
//save to string for ncurses
|
||||||
if (!source) source = state->dmr_lrrp_source[state->currentslot];
|
if (!source) source = state->dmr_lrrp_source[state->currentslot];
|
||||||
char sign[8];
|
|
||||||
char velstr[20];
|
char velstr[20];
|
||||||
char degstr[20];
|
char degstr[20];
|
||||||
char lrrpstr[100];
|
char lrrpstr[100];
|
||||||
sprintf (lrrpstr, "%s", "");
|
sprintf (lrrpstr, "%s", "");
|
||||||
sprintf (velstr, "%s", "");
|
sprintf (velstr, "%s", "");
|
||||||
sprintf (degstr, "%s", "");
|
sprintf (degstr, "%s", "");
|
||||||
if (lat_sign) sprintf (sign, "%s", "-");
|
if (lat) sprintf (lrrpstr, "LRRP %0d (%lf, %lf)", source, lat_fin, lon_fin);
|
||||||
else sprintf (sign, "%s", "");
|
|
||||||
if (lat) sprintf (lrrpstr, "LRRP %0d (%s%lf, %lf)", source, sign, (double)lat * lat_unit, (double)lon * lon_unit);
|
|
||||||
if (vel_set) sprintf (velstr, " %.4lf km/h", velocity * 3.6);
|
if (vel_set) sprintf (velstr, " %.4lf km/h", velocity * 3.6);
|
||||||
if (deg_set) sprintf (degstr, " %d deg", degrees);
|
if (deg_set) sprintf (degstr, " %d%s ", degrees, deg_glyph);
|
||||||
sprintf (state->dmr_lrrp_gps[slot], "%s%s%s", lrrpstr, velstr, degstr);
|
sprintf (state->dmr_lrrp_gps[slot], "%s%s%s", lrrpstr, velstr, degstr);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -399,16 +409,126 @@ uint8_t dmr_lrrp (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t
|
|||||||
fprintf (stderr, " Potential ARRP/LRRP Report (Debug): 0x%02X", report);
|
fprintf (stderr, " Potential ARRP/LRRP Report (Debug): 0x%02X", report);
|
||||||
}
|
}
|
||||||
|
|
||||||
// else //debug only, disabled
|
|
||||||
// {
|
|
||||||
// fprintf (stderr, "\n");
|
|
||||||
// fprintf (stderr, "\n LRRP Confidence: %d - Message Len: %d Octets", lrrp_confidence, message_len);
|
|
||||||
// }
|
|
||||||
|
|
||||||
LRRP_END:
|
LRRP_END:
|
||||||
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
}
|
||||||
return (lrrp_confidence);
|
|
||||||
|
void dmr_locn (dsd_opts * opts, dsd_state * state, uint8_t block_len, uint8_t DMR_PDU[])
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
uint8_t slot = state->currentslot;
|
||||||
|
uint8_t blocks = state->data_header_blocks[slot];
|
||||||
|
uint8_t padding = state->data_header_padding[slot];
|
||||||
|
uint8_t source = state->dmr_lrrp_source[slot];
|
||||||
|
|
||||||
|
//flags if certain data type is present
|
||||||
|
uint8_t time = 0;
|
||||||
|
uint8_t lat = 0;
|
||||||
|
uint8_t lon = 0;
|
||||||
|
|
||||||
|
//date-time variables
|
||||||
|
uint8_t hour = 0;
|
||||||
|
uint8_t minute = 0;
|
||||||
|
uint8_t second = 0;
|
||||||
|
uint8_t year = 0;
|
||||||
|
uint8_t month = 0;
|
||||||
|
uint8_t day = 0;
|
||||||
|
|
||||||
|
//need to experiment best way to do this portion
|
||||||
|
uint8_t lat_deg = 0;
|
||||||
|
uint8_t lat_min = 0;
|
||||||
|
uint16_t lat_sec = 0;
|
||||||
|
|
||||||
|
uint8_t lon_deg = 0;
|
||||||
|
uint8_t lon_min = 0;
|
||||||
|
uint16_t lon_sec = 0;
|
||||||
|
|
||||||
|
char lat_ord[2];
|
||||||
|
char lon_ord[2];
|
||||||
|
sprintf (lat_ord, "%s", "N");
|
||||||
|
sprintf (lon_ord, "%s", "E");
|
||||||
|
|
||||||
|
char deg_glyph[4];
|
||||||
|
sprintf (deg_glyph, "%s", "°");
|
||||||
|
// sprintf (deg_glyph, "%s", "d");
|
||||||
|
|
||||||
|
//more strings...
|
||||||
|
char locnstr[50];
|
||||||
|
char latstr[75];
|
||||||
|
char lonstr[75];
|
||||||
|
sprintf (locnstr, "%s", " ");
|
||||||
|
sprintf (latstr, "%s", " ");
|
||||||
|
sprintf (lonstr, "%s", " ");
|
||||||
|
|
||||||
|
//TODO: conversion to decimal format
|
||||||
|
//DD = d + (min/60) + (sec/3600)
|
||||||
|
//N is positive, E is positive?? Assuming its like a 2D plane
|
||||||
|
int lat_sign = 1; //positive 1 or negative 1
|
||||||
|
int lon_sign = 1; //positive 1 or negative 1
|
||||||
|
double lat_fin = 0;
|
||||||
|
double lon_fin = 0;
|
||||||
|
|
||||||
|
//start looking for specific bytes corresponding to 'letters' A (time), NSEW (ordinal directions), etc
|
||||||
|
for (i = 0; i < ( (blocks*block_len) - (padding+4) ); i++)
|
||||||
|
{
|
||||||
|
switch(DMR_PDU[i]){
|
||||||
|
case 0x41: //A -- time and date
|
||||||
|
time = 1;
|
||||||
|
hour = ((DMR_PDU[i+1] - 0x30) << 4) | (DMR_PDU[i+2] - 0x30);
|
||||||
|
minute = ((DMR_PDU[i+3] - 0x30) << 4) | (DMR_PDU[i+4] - 0x30);
|
||||||
|
second = ((DMR_PDU[i+5] - 0x30) << 4) | (DMR_PDU[i+6] - 0x30);
|
||||||
|
//think this is in day, mon, year format
|
||||||
|
day = ((DMR_PDU[i+7] - 0x30) << 4) | (DMR_PDU[i+8] - 0x30);
|
||||||
|
month = ((DMR_PDU[i+9] - 0x30) << 4) | (DMR_PDU[i+10] - 0x30);
|
||||||
|
year = ((DMR_PDU[i+11] - 0x30) << 4) | (DMR_PDU[i+12] - 0x30);
|
||||||
|
i += 12;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x53: //S -- South
|
||||||
|
sprintf (lat_ord, "%s", "S");
|
||||||
|
lat_sign = -1;
|
||||||
|
case 0x4E: //N -- North
|
||||||
|
lat = 1;
|
||||||
|
lat_deg = ((DMR_PDU[i+1] - 0x30) << 4) | (DMR_PDU[i+2] - 0x30);
|
||||||
|
lat_min = ((DMR_PDU[i+3] - 0x30) << 4) | (DMR_PDU[i+4] - 0x30);
|
||||||
|
lat_sec = ((DMR_PDU[i+6] - 0x30) << 12) | ((DMR_PDU[i+7] - 0x30) << 8) | ((DMR_PDU[i+8] - 0x30) << 4) | ((DMR_PDU[i+9] - 0x30) << 0);
|
||||||
|
i += 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x57: //W -- West
|
||||||
|
sprintf (lon_ord, "%s", "W");
|
||||||
|
lon_sign = -1;
|
||||||
|
case 0x45: //E -- East
|
||||||
|
lon = 1;
|
||||||
|
lon_deg = ((DMR_PDU[i+1] - 0x30) << 8) | ((DMR_PDU[i+2] - 0x30) << 4) | ((DMR_PDU[i+3] - 0x30) << 0);
|
||||||
|
lon_min = ((DMR_PDU[i+4] - 0x30) << 4) | (DMR_PDU[i+5] - 0x30);
|
||||||
|
lon_sec = ((DMR_PDU[i+7] - 0x30) << 12) | ((DMR_PDU[i+8] - 0x30) << 8) | ((DMR_PDU[i+9] - 0x30) << 4) | ((DMR_PDU[i+10] - 0x30) << 0);
|
||||||
|
i += 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
//do nothing
|
||||||
|
break;
|
||||||
|
|
||||||
|
} //end switch
|
||||||
|
|
||||||
|
} //for i
|
||||||
|
|
||||||
|
if (lat && lon)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
fprintf (stderr, "\n LOCN Report - Source: [%d]\n", source);
|
||||||
|
if (time) fprintf (stderr, " 20%02X/%02X/%02X %02X:%02X:%02X ", year, month, day, hour, minute, second);
|
||||||
|
fprintf (stderr, "Lat: %s %02X%s%02X\"%04X' Lon: %s %02X%s%02X\"%04X' ", lat_ord, lat_deg, deg_glyph, lat_min, lat_sec, lon_ord, lon_deg, deg_glyph, lon_min, lon_sec);
|
||||||
|
|
||||||
|
//string manip for ncurses terminal display
|
||||||
|
sprintf (locnstr, "LOCN %d ", source);
|
||||||
|
sprintf (latstr, "%s %02X%s%02X\"%04X' ", lat_ord, lat_deg, deg_glyph, lat_min, lat_sec);
|
||||||
|
sprintf (lonstr, "%s %02X%s%02X\"%04X' ", lon_ord, lon_deg, deg_glyph, lon_min, lon_sec);
|
||||||
|
sprintf (state->dmr_lrrp_gps[slot], "%s%s%s", locnstr, latstr, lonstr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
134
src/dmr_pi.c
134
src/dmr_pi.c
@@ -15,79 +15,62 @@ void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRC
|
|||||||
|
|
||||||
if((IrrecoverableErrors == 0))
|
if((IrrecoverableErrors == 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (state->currentslot == 0)
|
if (state->currentslot == 0)
|
||||||
{
|
{
|
||||||
|
state->payload_algid = PI_BYTE[0];
|
||||||
if (0 == 0)
|
state->payload_keyid = PI_BYTE[2];
|
||||||
{
|
|
||||||
state->payload_algid = PI_BYTE[0];
|
|
||||||
state->payload_keyid = PI_BYTE[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
state->payload_mi = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
state->payload_mi = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||||
if (state->payload_algid < 0x26)
|
if (state->payload_algid < 0x26)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s ", KYEL);
|
fprintf (stderr, "%s ", KYEL);
|
||||||
fprintf (stderr, "\n Slot 1");
|
fprintf (stderr, "\n Slot 1");
|
||||||
fprintf (stderr, " DMR PI Header ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi);
|
fprintf (stderr, " DMR PI H- ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi);
|
||||||
fprintf (stderr, "%s ", KNRM);
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
if (state->payload_algid != 0x21)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
LFSR64 (state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->payload_algid >= 0x26)
|
if (state->payload_algid >= 0x26)
|
||||||
{
|
{
|
||||||
if (0 == 0)
|
state->payload_algid = 0;
|
||||||
{
|
state->payload_keyid = 0;
|
||||||
state->payload_algid = 0;
|
state->payload_mi = 0;
|
||||||
state->payload_keyid = 0;
|
|
||||||
state->payload_mi = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->currentslot == 1)
|
if (state->currentslot == 1)
|
||||||
{
|
{
|
||||||
if (0 == 0)
|
|
||||||
{
|
|
||||||
state->payload_algidR = PI_BYTE[0];
|
|
||||||
state->payload_keyidR = PI_BYTE[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
state->payload_algidR = PI_BYTE[0];
|
||||||
|
state->payload_keyidR = PI_BYTE[2];
|
||||||
state->payload_miR = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
state->payload_miR = ( ((PI_BYTE[3]) << 24) + ((PI_BYTE[4]) << 16) + ((PI_BYTE[5]) << 8) + (PI_BYTE[6]) );
|
||||||
if (state->payload_algidR < 0x26)
|
if (state->payload_algidR < 0x26)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s ", KYEL);
|
fprintf (stderr, "%s ", KYEL);
|
||||||
fprintf (stderr, "\n Slot 2");
|
fprintf (stderr, "\n Slot 2");
|
||||||
fprintf (stderr, " DMR PI Header ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algidR, state->payload_keyidR, state->payload_miR);
|
fprintf (stderr, " DMR PI H- ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algidR, state->payload_keyidR, state->payload_miR);
|
||||||
fprintf (stderr, "%s ", KNRM);
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
if (state->payload_algidR != 0x21)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
LFSR64 (state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->payload_algidR >= 0x26)
|
if (state->payload_algidR >= 0x26)
|
||||||
{
|
{
|
||||||
if (0== 0)
|
state->payload_algidR = 0;
|
||||||
{
|
state->payload_keyidR = 0;
|
||||||
state->payload_algidR = 0;
|
state->payload_miR = 0;
|
||||||
state->payload_keyidR = 0;
|
|
||||||
state->payload_miR = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if((IrrecoverableErrors == 0) && CRCCorrect)
|
|
||||||
{
|
|
||||||
//fprintf (stderr, " (PI CRC Okay)");
|
|
||||||
}
|
}
|
||||||
else if((IrrecoverableErrors == 0))
|
|
||||||
{
|
|
||||||
//fprintf (stderr, " (PI FEC Okay)");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf (stderr, "%s", KRED);
|
|
||||||
fprintf (stderr, (" (PI FEC ERR)"));
|
|
||||||
fprintf (stderr, "%s ", KNRM);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LFSR(dsd_state * state)
|
void LFSR(dsd_state * state)
|
||||||
@@ -110,27 +93,64 @@ void LFSR(dsd_state * state)
|
|||||||
|
|
||||||
if (state->currentslot == 0)
|
if (state->currentslot == 0)
|
||||||
{
|
{
|
||||||
if (1 == 1)
|
fprintf (stderr, "%s", KYEL);
|
||||||
{
|
fprintf (stderr, " Slot 1");
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid);
|
||||||
fprintf (stderr, " Slot 1");
|
fprintf(stderr, " MI: 0x%08X", lfsr);
|
||||||
fprintf (stderr, " DMR PI Continuation ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid);
|
fprintf (stderr, "%s", KNRM);
|
||||||
fprintf(stderr, " Next MI: 0x%08X", lfsr);
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
|
||||||
}
|
|
||||||
state->payload_mi = lfsr;
|
state->payload_mi = lfsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->currentslot == 1)
|
if (state->currentslot == 1)
|
||||||
{
|
{
|
||||||
if (1 == 1)
|
|
||||||
{
|
fprintf (stderr, "%s", KYEL);
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, " Slot 2");
|
||||||
fprintf (stderr, " Slot 2");
|
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR);
|
||||||
fprintf (stderr, " DMR PI Continuation ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR);
|
fprintf(stderr, " MI: 0x%08X", lfsr);
|
||||||
fprintf(stderr, " Next MI: 0x%08X", lfsr);
|
fprintf (stderr, "%s", KNRM);
|
||||||
fprintf (stderr, "%s", KNRM);
|
|
||||||
}
|
|
||||||
state->payload_miR = lfsr;
|
state->payload_miR = lfsr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid);
|
||||||
|
fprintf (stderr, " MI: 0x%016llX", lfsr);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
state->payload_mi = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->currentslot == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
fprintf (stderr, " Slot 2");
|
||||||
|
fprintf (stderr, " DMR PI C- ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR);
|
||||||
|
fprintf (stderr, " MI: 0x%016llX", lfsr);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
state->payload_miR = lfsr & 0xFFFFFFFF; //truncate for next repitition and le verification
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
116
src/dmr_utils.c
116
src/dmr_utils.c
@@ -4,7 +4,7 @@
|
|||||||
//Original Source - https://github.com/LouisErigHerve/dsd
|
//Original Source - https://github.com/LouisErigHerve/dsd
|
||||||
|
|
||||||
//Additional Functions
|
//Additional Functions
|
||||||
//Hamming17123, crc8, crc8ok functions
|
//Hamming17123, crc7, crc8, crc8ok functions
|
||||||
//Original Souce - https://github.com/boatbod/op25
|
//Original Souce - https://github.com/boatbod/op25
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
@@ -121,6 +121,31 @@ bool crc8_ok(uint8_t bits[], unsigned int len)
|
|||||||
return (crc == crc8(bits,len));
|
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
|
* @brief : This function compute the CRC-CCITT of the DMR data
|
||||||
* by using the polynomial x^16 + x^12 + x^5 + 1
|
* by using the polynomial x^16 + x^12 + x^5 + 1
|
||||||
@@ -300,15 +325,15 @@ uint8_t ComputeCrc5Bit(uint8_t * DMRData)
|
|||||||
return CRC;
|
return CRC;
|
||||||
} /* End ComputeCrc5Bit() */
|
} /* End ComputeCrc5Bit() */
|
||||||
|
|
||||||
uint32_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength)
|
uint64_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength)
|
||||||
{
|
{
|
||||||
uint32_t Output = 0;
|
uint64_t Output = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for(i = 0; i < BitLength; i++)
|
for(i = 0; i < BitLength; i++)
|
||||||
{
|
{
|
||||||
Output <<= 1;
|
Output <<= 1;
|
||||||
Output |= (uint32_t)(BufferIn[i] & 1);
|
Output |= (uint64_t)(BufferIn[i] & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
@@ -330,3 +355,86 @@ uint32_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength)
|
|||||||
*
|
*
|
||||||
* @return The 9 bit CRC
|
* @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() */
|
||||||
|
|||||||
257
src/dpmr_voice.c
257
src/dpmr_voice.c
@@ -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 CCH[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
|
||||||
uint8_t CCHDescrambled[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 CCHDeInterleaved[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
|
||||||
uint8_t CCHDataHammingCorrected[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48] = {0};
|
uint8_t CCHDataHammingCorrected[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48];
|
||||||
uint8_t CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE] = {0};
|
uint8_t CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
|
||||||
uint8_t CCHDataCRCComputed[NB_OF_DPMR_VOICE_FRAME_TO_DECODE] = {0};
|
|
||||||
|
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};
|
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;
|
const int *w, *x, *y, *z;
|
||||||
uint32_t ScramblerLFSR = 0;
|
uint32_t ScramblerLFSR = 0;
|
||||||
bool correctable = true;
|
bool correctable = true;
|
||||||
@@ -56,11 +63,6 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
uint8_t CalledID[8] = {0};
|
uint8_t CalledID[8] = {0};
|
||||||
uint8_t CallingID[8] = {0};
|
uint8_t CallingID[8] = {0};
|
||||||
|
|
||||||
if (opts->errorbars == 1)
|
|
||||||
{
|
|
||||||
//fprintf(stderr, "VOICE e:");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First CCH (Control CHannel) - 72 bit */
|
/* First CCH (Control CHannel) - 72 bit */
|
||||||
k = 0;
|
k = 0;
|
||||||
|
|
||||||
@@ -76,7 +78,6 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
CCH[0][(i * 2)] = (1 & (dibit >> 1)); // bit 1
|
CCH[0][(i * 2)] = (1 & (dibit >> 1)); // bit 1
|
||||||
CCH[0][(i * 2) + 1] = (1 & dibit); // bit 0
|
CCH[0][(i * 2) + 1] = (1 & dibit); // bit 0
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4 TCH (Traffic CHannel) = 4 x 72 bit voice playload */
|
/* 4 TCH (Traffic CHannel) = 4 x 72 bit voice playload */
|
||||||
@@ -148,9 +149,6 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
/* 4 TCH (Traffic CHannel) = 4 x 72 bit voice playload */
|
/* 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;
|
k = 0;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
@@ -177,16 +175,10 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
x++;
|
x++;
|
||||||
y++;
|
y++;
|
||||||
z++;
|
z++;
|
||||||
//should be fixed now with the frame_sync t_max setup
|
|
||||||
//no more early breaking required
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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) */
|
/* Decoding all CCH (Control CHannel) */
|
||||||
for(i = 0; i < NB_OF_DPMR_VOICE_FRAME_TO_DECODE; i++)
|
for(i = 0; i < NB_OF_DPMR_VOICE_FRAME_TO_DECODE; i++)
|
||||||
{
|
{
|
||||||
@@ -207,22 +199,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
if(HammingCorrectable[i][j] == false) correctable = false;
|
if(HammingCorrectable[i][j] == false) correctable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(correctable)
|
if(correctable) HammingOk[i] = 1;
|
||||||
{
|
else HammingOk[i] = 0;
|
||||||
|
|
||||||
//fprintf(stderr, "CCH data corrected successfully\n");
|
|
||||||
|
|
||||||
|
|
||||||
HammingOk[i] = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
//fprintf(stderr, "ERROR !!! CCH data contains uncorrectable bit\n");
|
|
||||||
|
|
||||||
|
|
||||||
HammingOk[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reconstitute the 7 bit CRC */
|
/* Reconstitute the 7 bit CRC */
|
||||||
CCHDataCRC[i] = 0;
|
CCHDataCRC[i] = 0;
|
||||||
@@ -237,24 +215,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
/* Compute the 7 bit CRC */
|
/* Compute the 7 bit CRC */
|
||||||
CCHDataCRCComputed[i] = CRC7BitdPMR(CCHDataHammingCorrected[i], 41);
|
CCHDataCRCComputed[i] = CRC7BitdPMR(CCHDataHammingCorrected[i], 41);
|
||||||
|
|
||||||
if(CCHDataCRC[i] == CCHDataCRCComputed[i])
|
if(CCHDataCRC[i] == CCHDataCRCComputed[i]) CrcOk[i] = 1;
|
||||||
{
|
else CrcOk[i] = 0;
|
||||||
|
|
||||||
//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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill the frame number */
|
/* Fill the frame number */
|
||||||
CCH_FrameNumber[i] = ConvertBitIntoBytes(&CCHDataHammingCorrected[i][0], 2);
|
CCH_FrameNumber[i] = ConvertBitIntoBytes(&CCHDataHammingCorrected[i][0], 2);
|
||||||
@@ -300,45 +262,18 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
CallingID[7] = '\0';
|
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
|
/* To determine the part of the payload frame, we need to check the
|
||||||
* Hamming code result, the CRC and the frame number */
|
* Hamming code result, the CRC and the frame number */
|
||||||
|
|
||||||
// if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 0)) ||
|
// if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 0)) ||
|
||||||
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 1)))
|
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 1)))
|
||||||
|
|
||||||
if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 0)) ||
|
if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 0)) ||
|
||||||
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 1)))
|
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 1)))
|
||||||
{
|
{
|
||||||
/* First part of the super frame */
|
/* First part of the super frame */
|
||||||
PartOfSuperFrame = 1;
|
PartOfSuperFrame = 1;
|
||||||
|
|
||||||
|
|
||||||
//fprintf(stderr, "\nFirst part of the Super Frame");
|
|
||||||
|
|
||||||
|
|
||||||
/* The next part will normally be the second part */
|
/* The next part will normally be the second part */
|
||||||
opts->dPMR_next_part_of_superframe = 2;
|
opts->dPMR_next_part_of_superframe = 2;
|
||||||
|
|
||||||
@@ -366,20 +301,19 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
/* BUGFIX : Copy in all case the TG ID */
|
/* BUGFIX : Copy in all case the TG ID */
|
||||||
strcpy((char *)state->dPMRVoiceFS2Frame.CalledID, (char *)CalledID);
|
strcpy((char *)state->dPMRVoiceFS2Frame.CalledID, (char *)CalledID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To determine the part of the payload frame, we need to check the
|
/* To determine the part of the payload frame, we need to check the
|
||||||
* Hamming code result, the CRC and the frame number */
|
* Hamming code result, the CRC and the frame number */
|
||||||
|
|
||||||
// else if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 2)) ||
|
// else if( (HammingOk[0] && CrcOk[0] && (CCH_FrameNumber[0] == 2)) ||
|
||||||
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 3)))
|
// (HammingOk[1] && CrcOk[1] && (CCH_FrameNumber[1] == 3)))
|
||||||
|
|
||||||
else if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 2)) ||
|
else if(((CrcOk[0] || HammingCorrectable[0][0]) && (CCH_FrameNumber[0] == 2)) ||
|
||||||
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 3)))
|
((CrcOk[1] || HammingCorrectable[1][0]) && (CCH_FrameNumber[1] == 3)))
|
||||||
{
|
{
|
||||||
/* Second part of the super frame */
|
/* Second part of the super frame */
|
||||||
PartOfSuperFrame = 2;
|
PartOfSuperFrame = 2;
|
||||||
|
|
||||||
|
|
||||||
//fprintf(stderr, "\nSecond part of the Super Frame");
|
|
||||||
|
|
||||||
|
|
||||||
/* The next part will normally be the first part */
|
/* The next part will normally be the first part */
|
||||||
opts->dPMR_next_part_of_superframe = 1;
|
opts->dPMR_next_part_of_superframe = 1;
|
||||||
|
|
||||||
@@ -392,7 +326,9 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
CallingID[7] = '\0';
|
CallingID[7] = '\0';
|
||||||
|
|
||||||
/* Determine if the calling SRC ID is correct */
|
/* Determine if the calling SRC ID is correct */
|
||||||
|
|
||||||
//if(HammingOk[0] && CrcOk[0] && HammingOk[1] && CrcOk[1])
|
//if(HammingOk[0] && CrcOk[0] && HammingOk[1] && CrcOk[1])
|
||||||
|
|
||||||
if((CrcOk[0] || (HammingCorrectable[0][0] && HammingCorrectable[0][1])) &&
|
if((CrcOk[0] || (HammingCorrectable[0][0] && HammingCorrectable[0][1])) &&
|
||||||
(CrcOk[1] || (HammingCorrectable[1][0] && HammingCorrectable[1][1])))
|
(CrcOk[1] || (HammingCorrectable[1][0] && HammingCorrectable[1][1])))
|
||||||
{
|
{
|
||||||
@@ -420,133 +356,144 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
/* Set the next part of the superframe to receive */
|
/* Set the next part of the superframe to receive */
|
||||||
if(opts->dPMR_next_part_of_superframe == 1)
|
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 */
|
/* Set the next part as the second part */
|
||||||
opts->dPMR_next_part_of_superframe = 2;
|
opts->dPMR_next_part_of_superframe = 2;
|
||||||
}
|
}
|
||||||
else if(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 */
|
/* Set the next part as the first part */
|
||||||
opts->dPMR_next_part_of_superframe = 1;
|
opts->dPMR_next_part_of_superframe = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//fprintf(stderr, "Unknown part of the Super Frame\n");
|
|
||||||
|
|
||||||
|
|
||||||
/* Unknown current part, set to 0 */
|
/* Unknown current part, set to 0 */
|
||||||
opts->dPMR_next_part_of_superframe = 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) */
|
/* Display the destination ID (talk group - TG) */
|
||||||
//fprintf(stderr, "| TG=%s", CalledID);
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
if(state->dPMRVoiceFS2Frame.CalledIDOk)
|
if(state->dPMRVoiceFS2Frame.CalledIDOk)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KGRN);
|
fprintf (stderr, "%s", KGRN);
|
||||||
fprintf(stderr, "\n| TG=%s", CalledID);
|
fprintf(stderr, " TG=%s", CalledID);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
//strcpy (state->dpmr_target_id, CalledID); //HERE HERE
|
|
||||||
state->dpmr_target_id = CalledID;
|
//check other as well before assigning
|
||||||
//fprintf(stderr, " (CRC OK) ");
|
if(state->dPMRVoiceFS2Frame.CallingIDOk) 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))
|
if(state->dPMRVoiceFS2Frame.ColorCode[0] != (unsigned int)(-1))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KGRN);
|
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);
|
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
|
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, "%s", KRED);
|
||||||
fprintf(stderr, " (CRC ERR) \n");
|
fprintf(stderr, " Src=(CRC ERR) Channel Code =(CRC ERR)");
|
||||||
fprintf (stderr, "%s", KNRM);
|
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,
|
//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 start = 0;
|
||||||
short end = 4;
|
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++)
|
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
|
//depending on first or second TCH, set start and end variables appropriately
|
||||||
if (o == 1)
|
if (o == 1)
|
||||||
{
|
{
|
||||||
start = 4;
|
start = 4;
|
||||||
end = 8;
|
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]);
|
//this is used so we can simply pass the voice here to the
|
||||||
//fprintf (stderr, "Superframe Number: %d", state->dPMRVoiceFS2Frame.FrameNumbering[o]); //should be 1-4, but may be same number on TCH 1 or TCH 2
|
//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) ||
|
if((state->dPMRVoiceFS2Frame.CommunicationMode[o] == 0) ||
|
||||||
(state->dPMRVoiceFS2Frame.CommunicationMode[o] == 1) ||
|
(state->dPMRVoiceFS2Frame.CommunicationMode[o] == 1) ||
|
||||||
(state->dPMRVoiceFS2Frame.CommunicationMode[o] == 5))
|
(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;
|
||||||
|
|
||||||
|
//There are 4 AMBE voice frames per TCH
|
||||||
for(i = start; i < end; i++)
|
for(i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
processMbeFrame (opts, state, NULL, ambe_fr[i], NULL);
|
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
|
|
||||||
|
|
||||||
|
//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
|
//keep code below, could be handy cheat sheet for other info
|
||||||
#ifdef dPMR_PRINT_DEBUG_INFO
|
#ifdef dPMR_PRINT_DEBUG_INFO
|
||||||
//Display the CCH content
|
//Display the CCH content
|
||||||
|
|||||||
@@ -541,6 +541,9 @@ openAudioInDevice (dsd_opts * opts)
|
|||||||
const char ch = '.';
|
const char ch = '.';
|
||||||
extension = strrchr(opts->audio_in_dev, ch); //return extension if this is a .wav or .bin file
|
extension = strrchr(opts->audio_in_dev, ch); //return extension if this is a .wav or .bin file
|
||||||
|
|
||||||
|
//if no extension set, give default of .wav -- bugfix for github issue #105
|
||||||
|
// if (extension == NULL) extension = ".wav";
|
||||||
|
|
||||||
// get info of device/file
|
// get info of device/file
|
||||||
if (strncmp(opts->audio_in_dev, "-", 1) == 0)
|
if (strncmp(opts->audio_in_dev, "-", 1) == 0)
|
||||||
{
|
{
|
||||||
@@ -598,6 +601,25 @@ openAudioInDevice (dsd_opts * opts)
|
|||||||
{
|
{
|
||||||
opts->audio_in_type = 0;
|
opts->audio_in_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (strncmp(extension, ".bin", 3) == 0)
|
else if (strncmp(extension, ".bin", 3) == 0)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
|||||||
@@ -283,12 +283,11 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
|
|||||||
|
|
||||||
valid = 0;
|
valid = 0;
|
||||||
|
|
||||||
//only run estimate_symbol when we aren't trunking, otherwise noise/gain levels on other rf channels may impact performance severely
|
//disabling again, causing issues with trunking
|
||||||
//honestly can't say I've seen any improvement when using heuristics, but is detrimental to playing back multiple p25 samples
|
if (state->synctype == 1 && opts->p25_trunk == 1)
|
||||||
if (state->synctype == 1 && opts->p25_trunk == 0)
|
|
||||||
{
|
{
|
||||||
// Use the P25 heuristics if available
|
// Use the P25 heuristics if available
|
||||||
//valid = estimate_symbol(state->rf_mod, &(state->inv_p25_heuristics), state->last_dibit, symbol, &dibit);
|
// valid = estimate_symbol(state->rf_mod, &(state->inv_p25_heuristics), state->last_dibit, symbol, &dibit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid == 0)
|
if (valid == 0)
|
||||||
@@ -348,12 +347,11 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
|
|||||||
|
|
||||||
valid = 0;
|
valid = 0;
|
||||||
|
|
||||||
//only run estimate_symbol when we aren't trunking, otherwise noise/gain levels on other rf channels may impact performance severely
|
//disabling again, causing issues with trunking
|
||||||
//honestly can't say I've seen any improvement when using heuristics, but is detrimental to playing back multiple p25 samples
|
if (state->synctype == 0 && opts->p25_trunk == 1)
|
||||||
if (state->synctype == 0 && opts->p25_trunk == 0)
|
|
||||||
{
|
{
|
||||||
// Use the P25 heuristics if available
|
// Use the P25 heuristics if available
|
||||||
//valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit);
|
// valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid == 0)
|
if (valid == 0)
|
||||||
|
|||||||
235
src/dsd_file.c
235
src/dsd_file.c
@@ -45,8 +45,7 @@ char * getDateF(void) {
|
|||||||
return curr2;
|
return curr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
|
||||||
saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
|
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
@@ -56,36 +55,22 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
|
|||||||
fputc (err, opts->mbe_out_f);
|
fputc (err, opts->mbe_out_f);
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
if (opts->payload == 1) //make opt variable later on to toggle this
|
|
||||||
{
|
|
||||||
//fprintf(stderr, "\n IMBE ");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 11; i++)
|
for (i = 0; i < 11; i++)
|
||||||
{
|
{
|
||||||
b = 0;
|
b = 0;
|
||||||
|
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
{
|
{
|
||||||
b = b << 1;
|
b = b << 1;
|
||||||
b = b + imbe_d[k];
|
b = b + imbe_d[k];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
if (opts->payload == 1) //make opt variable later on to toggle this
|
fputc (b, opts->mbe_out_f);
|
||||||
{
|
}
|
||||||
//fprintf (stderr, "%02X", b);
|
|
||||||
}
|
|
||||||
fputc (b, opts->mbe_out_f);
|
|
||||||
}
|
|
||||||
if (opts->payload == 1)
|
|
||||||
{
|
|
||||||
//fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
|
|
||||||
}
|
|
||||||
fflush (opts->mbe_out_f);
|
fflush (opts->mbe_out_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
||||||
saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
@@ -95,42 +80,49 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
|||||||
fputc (err, opts->mbe_out_f);
|
fputc (err, opts->mbe_out_f);
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
if (opts->payload == 1) //make opt variable later on to toggle this
|
for (i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "\n AMBE ");
|
b = 0;
|
||||||
|
for (j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
b = b << 1;
|
||||||
|
b = b + ambe_d[k];
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
fputc (b, opts->mbe_out_f);
|
||||||
}
|
}
|
||||||
//for (i = 0; i < 6; i++)
|
|
||||||
for (i = 0; i < 6; i++) //using 7 seems to break older amb files where it was 6, need to test 7 on 7 some more
|
|
||||||
{
|
|
||||||
b = 0;
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
b = b << 1;
|
|
||||||
b = b + ambe_d[k];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this
|
|
||||||
{
|
|
||||||
//fprintf (stderr, "%02X", b);
|
|
||||||
}
|
|
||||||
if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit? value will be either 0x00 or 0x80?
|
|
||||||
{
|
|
||||||
//fprintf (stderr, "%02X", b & 0x80); //7th octet should only contain 1 bit?
|
|
||||||
}
|
|
||||||
|
|
||||||
fputc (b, opts->mbe_out_f);
|
|
||||||
}
|
|
||||||
if (opts->payload == 1)
|
|
||||||
{
|
|
||||||
//fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
|
|
||||||
}
|
|
||||||
b = ambe_d[48];
|
b = ambe_d[48];
|
||||||
fputc (b, opts->mbe_out_f);
|
fputc (b, opts->mbe_out_f);
|
||||||
fflush (opts->mbe_out_f);
|
fflush (opts->mbe_out_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void saveAmbe2450DataR (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
||||||
PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d) //for P25P1 and ProVoice
|
{
|
||||||
|
int i, j, k;
|
||||||
|
unsigned char b;
|
||||||
|
unsigned char err;
|
||||||
|
|
||||||
|
err = (unsigned char) state->errs2R;
|
||||||
|
fputc (err, opts->mbe_out_fR);
|
||||||
|
|
||||||
|
k = 0;
|
||||||
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
b = 0;
|
||||||
|
for (j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
b = b << 1;
|
||||||
|
b = b + ambe_d[k];
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
fputc (b, opts->mbe_out_fR);
|
||||||
|
}
|
||||||
|
b = ambe_d[48];
|
||||||
|
fputc (b, opts->mbe_out_fR);
|
||||||
|
fflush (opts->mbe_out_fR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d) //for P25P1 and ProVoice
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
@@ -165,8 +157,7 @@ PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d) //for P25P1 and
|
|||||||
//fprintf (stderr, "\n");
|
//fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
||||||
PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
@@ -333,14 +324,21 @@ openMbeInFile (dsd_opts * opts, dsd_state * state)
|
|||||||
cookie[2] = fgetc (opts->mbe_in_f);
|
cookie[2] = fgetc (opts->mbe_in_f);
|
||||||
cookie[3] = fgetc (opts->mbe_in_f);
|
cookie[3] = fgetc (opts->mbe_in_f);
|
||||||
cookie[4] = 0;
|
cookie[4] = 0;
|
||||||
|
//ambe+2
|
||||||
if (strstr (cookie, ".amb") != NULL)
|
if (strstr (cookie, ".amb") != NULL)
|
||||||
{
|
{
|
||||||
state->mbe_file_type = 1;
|
state->mbe_file_type = 1;
|
||||||
}
|
}
|
||||||
|
//p1 and pv
|
||||||
else if (strstr (cookie, ".imb") != NULL)
|
else if (strstr (cookie, ".imb") != NULL)
|
||||||
{
|
{
|
||||||
state->mbe_file_type = 0;
|
state->mbe_file_type = 0;
|
||||||
}
|
}
|
||||||
|
//d-star ambe
|
||||||
|
else if (strstr (cookie, ".dmb") != NULL)
|
||||||
|
{
|
||||||
|
state->mbe_file_type = 2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state->mbe_file_type = -1;
|
state->mbe_file_type = -1;
|
||||||
@@ -349,7 +347,7 @@ openMbeInFile (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//much simpler version
|
//slot 1
|
||||||
void closeMbeOutFile (dsd_opts * opts, dsd_state * state)
|
void closeMbeOutFile (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
if (opts->mbe_out == 1)
|
if (opts->mbe_out == 1)
|
||||||
@@ -360,48 +358,67 @@ void closeMbeOutFile (dsd_opts * opts, dsd_state * state)
|
|||||||
fclose (opts->mbe_out_f);
|
fclose (opts->mbe_out_f);
|
||||||
opts->mbe_out_f = NULL;
|
opts->mbe_out_f = NULL;
|
||||||
opts->mbe_out = 0;
|
opts->mbe_out = 0;
|
||||||
fprintf (stderr, "\nClosing MBE out file.");
|
fprintf (stderr, "\nClosing MBE out file 1.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
//slot 2
|
||||||
openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
void closeMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||||
|
{
|
||||||
|
if (opts->mbe_outR == 1)
|
||||||
|
{
|
||||||
|
if (opts->mbe_out_fR != NULL)
|
||||||
|
{
|
||||||
|
fflush (opts->mbe_out_fR);
|
||||||
|
fclose (opts->mbe_out_fR);
|
||||||
|
opts->mbe_out_fR = NULL;
|
||||||
|
opts->mbe_outR = 0;
|
||||||
|
fprintf (stderr, "\nClosing MBE out file 2.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
char ext[5];
|
char ext[5];
|
||||||
|
|
||||||
if ((state->synctype == 0) || (state->synctype == 1) || (state->synctype == 14) || (state->synctype == 15))
|
//phase 1 and provoice
|
||||||
{
|
if ( (state->synctype == 0) || (state->synctype == 1) || (state->synctype == 14) || (state->synctype == 15) )
|
||||||
sprintf (ext, ".imb");
|
{
|
||||||
}
|
sprintf (ext, ".imb");
|
||||||
else
|
}
|
||||||
{
|
//d-star
|
||||||
sprintf (ext, ".amb");
|
else if ( (state->synctype == 6) || (state->synctype == 7) || (state->synctype == 18) || (state->synctype == 19) )
|
||||||
}
|
{
|
||||||
|
sprintf (ext, ".dmb"); //new dstar file extension to make it read in and process properly
|
||||||
|
}
|
||||||
|
//dmr, nxdn, phase 2, x2-tdma
|
||||||
|
else sprintf (ext, ".amb");
|
||||||
|
|
||||||
// reset talkgroup id buffer
|
//reset talkgroup id buffer
|
||||||
for (i = 0; i < 12; i++)
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 25; j++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 25; j++)
|
state->tg[j][i] = 0;
|
||||||
{
|
|
||||||
state->tg[j][i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state->tgcount = 0;
|
state->tgcount = 0;
|
||||||
|
|
||||||
sprintf (opts->mbe_out_file, "%s %s%s", getDateF(), getTimeF(), ext);
|
sprintf (opts->mbe_out_file, "%s %s S1%s", getDateF(), getTimeF(), ext);
|
||||||
|
|
||||||
sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file);
|
sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file);
|
||||||
|
|
||||||
opts->mbe_out_f = fopen (opts->mbe_out_path, "w");
|
opts->mbe_out_f = fopen (opts->mbe_out_path, "w");
|
||||||
if (opts->mbe_out_f == NULL)
|
if (opts->mbe_out_f == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr,"Error, couldn't open %s\n", opts->mbe_out_path);
|
fprintf (stderr,"\nError, couldn't open %s for slot 1\n", opts->mbe_out_path);
|
||||||
}
|
}
|
||||||
else opts->mbe_out = 1;
|
else opts->mbe_out = 1;
|
||||||
|
|
||||||
@@ -411,8 +428,54 @@ openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
|||||||
fflush (opts->mbe_out_f);
|
fflush (opts->mbe_out_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void openMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||||
openWavOutFile (dsd_opts * opts, dsd_state * state)
|
{
|
||||||
|
|
||||||
|
int i, j;
|
||||||
|
char ext[5];
|
||||||
|
|
||||||
|
//phase 1 and provoice
|
||||||
|
if ( (state->synctype == 0) || (state->synctype == 1) || (state->synctype == 14) || (state->synctype == 15) )
|
||||||
|
{
|
||||||
|
sprintf (ext, ".imb");
|
||||||
|
}
|
||||||
|
//d-star
|
||||||
|
else if ( (state->synctype == 6) || (state->synctype == 7) || (state->synctype == 18) || (state->synctype == 19) )
|
||||||
|
{
|
||||||
|
sprintf (ext, ".dmb"); //new dstar file extension to make it read in and process properly
|
||||||
|
}
|
||||||
|
//dmr, nxdn, phase 2, x2-tdma
|
||||||
|
else sprintf (ext, ".amb");
|
||||||
|
|
||||||
|
//reset talkgroup id buffer
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 25; j++)
|
||||||
|
{
|
||||||
|
state->tg[j][i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state->tgcount = 0;
|
||||||
|
|
||||||
|
sprintf (opts->mbe_out_fileR, "%s %s S2%s", getDateF(), getTimeF(), ext);
|
||||||
|
|
||||||
|
sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_fileR);
|
||||||
|
|
||||||
|
opts->mbe_out_fR = fopen (opts->mbe_out_path, "w");
|
||||||
|
if (opts->mbe_out_fR == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr,"\nError, couldn't open %s for slot 2\n", opts->mbe_out_path);
|
||||||
|
}
|
||||||
|
else opts->mbe_outR = 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
fprintf (opts->mbe_out_fR, "%s", ext);
|
||||||
|
|
||||||
|
fflush (opts->mbe_out_fR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void openWavOutFile (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
|
|
||||||
SF_INFO info;
|
SF_INFO info;
|
||||||
|
|||||||
392
src/dsd_frame.c
392
src/dsd_frame.c
@@ -87,8 +87,8 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
//NXDN FSW
|
//NXDN FSW
|
||||||
if ((state->synctype == 28) || (state->synctype == 29))
|
if ((state->synctype == 28) || (state->synctype == 29))
|
||||||
{
|
{
|
||||||
|
//MBEout restored, is not handled internally by nxdn_frame.c
|
||||||
nxdn_frame (opts, state);
|
nxdn_frame (opts, state);
|
||||||
//no MBEout...use symbol capture bin instead!
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((state->synctype == 6) || (state->synctype == 7))
|
else if ((state->synctype == 6) || (state->synctype == 7))
|
||||||
@@ -107,7 +107,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
state->nac = 0;
|
state->nac = 0;
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||||
{
|
{
|
||||||
openMbeOutFile (opts, state);
|
openMbeOutFile (opts, state); //dstar ambe files are read back incorrectly, need to change file extension to differentiate when doing a playback
|
||||||
}
|
}
|
||||||
sprintf (state->fsubtype, " VOICE ");
|
sprintf (state->fsubtype, " VOICE ");
|
||||||
processDSTAR (opts, state);
|
processDSTAR (opts, state);
|
||||||
@@ -128,9 +128,9 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
state->nac = 0;
|
state->nac = 0;
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||||
{
|
{
|
||||||
openMbeOutFile (opts, state);
|
openMbeOutFile (opts, state); //dstar ambe files are read back incorrectly, need to change file extension to differentiate when doing a playback
|
||||||
}
|
}
|
||||||
sprintf (state->fsubtype, " DATA ");
|
sprintf (state->fsubtype, " DATA ");
|
||||||
processDSTAR_HD (opts, state);
|
processDSTAR_HD (opts, state);
|
||||||
return;
|
return;
|
||||||
@@ -141,9 +141,9 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
//print manufacturer strings to branding, disabled 0x10 moto other systems can use that fid set
|
//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?
|
//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");
|
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 == 0x68) sprintf (state->dmr_branding, "%s", " Hytera");
|
||||||
else if (state->dmr_mfid == 0x58) sprintf (state->dmr_branding, "%s", "Tait");
|
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?
|
//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
|
//or, its just a decode error somewhere
|
||||||
@@ -164,70 +164,58 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
//disable so radio id doesn't blink in and out during ncurses and aggressive_framesync
|
//disable so radio id doesn't blink in and out during ncurses and aggressive_framesync
|
||||||
state->nac = 0;
|
state->nac = 0;
|
||||||
//state->lastsrc = 0;
|
|
||||||
//state->lasttg = 0;
|
|
||||||
//state->lastsrcR = 0;
|
|
||||||
//state->lasttgR = 0;
|
|
||||||
if (opts->errorbars == 1)
|
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
|
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) // -T option for DMR (TDMA) stereo
|
||||||
{
|
{
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL) && opts->dmr_stereo == 0)
|
sprintf (state->slot1light, " slot1 ");
|
||||||
{
|
sprintf (state->slot2light, " slot2 ");
|
||||||
openMbeOutFile (opts, state);
|
//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);
|
||||||
sprintf (state->fsubtype, " VOICE ");
|
dmrMSBootstrap (opts, state);
|
||||||
if (opts->dmr_stereo == 0 && state->synctype < 32) // -T option for DMR (TDMA) stereo
|
|
||||||
{
|
|
||||||
sprintf (state->slot1light, " slot1 ");
|
|
||||||
sprintf (state->slot2light, " slot2 ");
|
|
||||||
dmrMSBootstrap (opts, state);
|
|
||||||
}
|
|
||||||
if (opts->dmr_mono == 1 && state->synctype == 32)
|
|
||||||
{
|
|
||||||
// fprintf (stderr, "%s", KRED);
|
|
||||||
// fprintf (stderr, "Please use XDMA or DMR Stereo to decode MS/Simplex \n");
|
|
||||||
// fprintf (stderr, "%s", KNRM);
|
|
||||||
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 )
|
|
||||||
{
|
|
||||||
dmrMSBootstrap (opts, state); //bootstrap into MS Bootstrap (voice only)
|
|
||||||
}
|
|
||||||
else dmrBSBootstrap (opts, state); //bootstrap into BS Bootstrap
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
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
|
else if ( (state->synctype == 33) || (state->synctype == 34) ) //MS Data and RC data
|
||||||
{
|
{
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
dmrMSData (opts, state);
|
dmrMSData (opts, state);
|
||||||
// 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);
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opts->dmr_stereo == 0)
|
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;
|
state->err_str[0] = 0;
|
||||||
sprintf (state->slot1light, " slot1 ");
|
sprintf (state->slot1light, " slot1 ");
|
||||||
sprintf (state->slot2light, " slot2 ");
|
sprintf (state->slot2light, " slot2 ");
|
||||||
@@ -237,6 +225,9 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
//switch dmr_stereo to 0 when handling BS data frame syncs with processDMRdata
|
//switch dmr_stereo to 0 when handling BS data frame syncs with processDMRdata
|
||||||
if (opts->dmr_stereo == 1)
|
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
|
state->dmr_stereo = 0; //set the state to zero for handling pure data frames
|
||||||
sprintf (state->slot1light, " slot1 ");
|
sprintf (state->slot1light, " slot1 ");
|
||||||
sprintf (state->slot2light, " slot2 ");
|
sprintf (state->slot2light, " slot2 ");
|
||||||
@@ -246,7 +237,8 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((state->synctype >= 2) && (state->synctype <= 5))
|
//X2-TDMA
|
||||||
|
else if ((state->synctype >= 2) && (state->synctype <= 5))
|
||||||
{
|
{
|
||||||
state->nac = 0;
|
state->nac = 0;
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
@@ -256,15 +248,15 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
if ((state->synctype == 3) || (state->synctype == 4))
|
if ((state->synctype == 3) || (state->synctype == 4))
|
||||||
{
|
{
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||||
{
|
{
|
||||||
openMbeOutFile (opts, state);
|
openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
sprintf (state->fsubtype, " VOICE ");
|
sprintf (state->fsubtype, " VOICE ");
|
||||||
processX2TDMAvoice (opts, state);
|
processX2TDMAvoice (opts, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
closeMbeOutFile (opts, state);
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
state->err_str[0] = 0;
|
state->err_str[0] = 0;
|
||||||
processX2TDMAdata (opts, state);
|
processX2TDMAdata (opts, state);
|
||||||
}
|
}
|
||||||
@@ -272,21 +264,18 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
else if ((state->synctype == 14) || (state->synctype == 15))
|
else if ((state->synctype == 14) || (state->synctype == 15))
|
||||||
{
|
{
|
||||||
//state->nac = 0;
|
|
||||||
//state->lastsrc = 0;
|
|
||||||
//state->lasttg = 0;
|
|
||||||
if (opts->errorbars == 1)
|
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))
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||||
{
|
{
|
||||||
openMbeOutFile (opts, state);
|
openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
sprintf (state->fsubtype, " VOICE ");
|
sprintf (state->fsubtype, " VOICE ");
|
||||||
processProVoice (opts, state);
|
processProVoice (opts, state);
|
||||||
return;
|
return;
|
||||||
@@ -294,6 +283,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
//edacs
|
//edacs
|
||||||
else if ((state->synctype == 37) || (state->synctype == 38))
|
else if ((state->synctype == 37) || (state->synctype == 38))
|
||||||
{
|
{
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
edacs (opts, state);
|
edacs (opts, state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -313,13 +303,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
//P25 P2
|
//P25 P2
|
||||||
else if ((state->synctype == 35) || (state->synctype == 36))
|
else if ((state->synctype == 35) || (state->synctype == 36))
|
||||||
{
|
{
|
||||||
//Do stuff
|
//relocate MBEout to inside frame handling
|
||||||
//fprintf(stderr, "YSF Sync! \n");
|
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
|
||||||
{
|
|
||||||
//openMbeOutFile (opts, state);
|
|
||||||
}
|
|
||||||
//sprintf(state->fsubtype, " VOICE ");
|
|
||||||
processP2(opts, state);
|
processP2(opts, state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -328,6 +312,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
/* dPMR Frame Sync 1 */
|
/* dPMR Frame Sync 1 */
|
||||||
fprintf(stderr, "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))
|
else if ((state->synctype == 21) || (state->synctype == 25))
|
||||||
{
|
{
|
||||||
@@ -346,12 +331,12 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
state->nac = 0;
|
state->nac = 0;
|
||||||
|
|
||||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||||
{
|
{
|
||||||
openMbeOutFile (opts, state);
|
openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
sprintf(state->fsubtype, " VOICE ");
|
sprintf(state->fsubtype, " VOICE ");
|
||||||
processdPMRvoice (opts, state);
|
processdPMRvoice (opts, state);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -360,11 +345,13 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
/* dPMR Frame Sync 3 */
|
/* dPMR Frame Sync 3 */
|
||||||
fprintf(stderr, "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))
|
else if ((state->synctype == 23) || (state->synctype == 27))
|
||||||
{
|
{
|
||||||
/* dPMR Frame Sync 4 */
|
/* dPMR Frame Sync 4 */
|
||||||
fprintf(stderr, "dPMR Frame Sync 4 ");
|
fprintf(stderr, "dPMR Frame Sync 4 ");
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
//dPMR
|
//dPMR
|
||||||
else //P25
|
else //P25
|
||||||
@@ -463,15 +450,15 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
// Header Data Unit
|
// Header Data Unit
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," HDU\n");
|
fprintf (stderr," HDU\n");
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
if (opts->mbe_out_dir[0] != 0)
|
||||||
{
|
{
|
||||||
closeMbeOutFile (opts, state);
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
openMbeOutFile (opts, state);
|
if (opts->mbe_out_f == NULL) openMbeOutFile (opts, state);
|
||||||
}
|
}
|
||||||
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||||
state->lastp25type = 2;
|
state->lastp25type = 2;
|
||||||
state->dmrburstL = 25;
|
state->dmrburstL = 25;
|
||||||
@@ -483,26 +470,22 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
// Logical Link Data Unit 1
|
// Logical Link Data Unit 1
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," LDU1 ");
|
fprintf (stderr," LDU1 ");
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
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->lastp25type = 1;
|
||||||
state->dmrburstL = 26;
|
state->dmrburstL = 26;
|
||||||
state->currentslot = 0;
|
state->currentslot = 0;
|
||||||
sprintf (state->fsubtype, " LDU1 ");
|
sprintf (state->fsubtype, " LDU1 ");
|
||||||
state->numtdulc = 0;
|
state->numtdulc = 0;
|
||||||
if (state->payload_algid == 0x81)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
processLDU1 (opts, state);
|
processLDU1 (opts, state);
|
||||||
}
|
}
|
||||||
@@ -514,27 +497,27 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->lastp25type != 1)
|
if (state->lastp25type != 1)
|
||||||
{
|
{
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr,"\n Ignoring LDU2 not preceeded by LDU1\n");
|
fprintf (stderr,"\n Ignoring LDU2 not preceeded by LDU1\n");
|
||||||
}
|
}
|
||||||
state->lastp25type = 0;
|
state->lastp25type = 0;
|
||||||
sprintf (state->fsubtype, " ");
|
sprintf (state->fsubtype, " ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," LDU2 ");
|
fprintf (stderr," LDU2 ");
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
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;
|
state->lastp25type = 2;
|
||||||
sprintf (state->fsubtype, " LDU2 ");
|
sprintf (state->fsubtype, " LDU2 ");
|
||||||
state->numtdulc = 0;
|
state->numtdulc = 0;
|
||||||
@@ -546,25 +529,25 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
// Terminator with subsequent Link Control
|
// Terminator with subsequent Link Control
|
||||||
state->dmrburstL = 28;
|
state->dmrburstL = 28;
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," TDULC\n");
|
fprintf (stderr," TDULC\n");
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
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);
|
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||||
state->lasttg = 0;
|
// state->lasttg = 0;
|
||||||
state->lastsrc = 0;
|
// state->lastsrc = 0;
|
||||||
state->lastp25type = 0;
|
state->lastp25type = 0;
|
||||||
state->err_str[0] = 0;
|
state->err_str[0] = 0;
|
||||||
sprintf (state->fsubtype, " TDULC ");
|
sprintf (state->fsubtype, " TDULC ");
|
||||||
state->numtdulc++;
|
state->numtdulc++;
|
||||||
if ((opts->resume > 0) && (state->numtdulc > opts->resume))
|
if ((opts->resume > 0) && (state->numtdulc > opts->resume))
|
||||||
{
|
{
|
||||||
resumeScan (opts, state);
|
resumeScan (opts, state);
|
||||||
}
|
}
|
||||||
processTDULC (opts, state);
|
processTDULC (opts, state);
|
||||||
state->err_str[0] = 0;
|
state->err_str[0] = 0;
|
||||||
}
|
}
|
||||||
@@ -573,14 +556,14 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
// Terminator without subsequent Link Control
|
// Terminator without subsequent Link Control
|
||||||
state->dmrburstL = 28;
|
state->dmrburstL = 28;
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," TDU\n");
|
fprintf (stderr," TDU\n");
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
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);
|
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||||
state->lasttg = 0;
|
state->lasttg = 0;
|
||||||
state->lastsrc = 0;
|
state->lastsrc = 0;
|
||||||
@@ -594,120 +577,59 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
state->dmrburstL = 29;
|
state->dmrburstL = 29;
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," TSBK");
|
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)
|
if (opts->resume > 0)
|
||||||
{
|
{
|
||||||
resumeScan (opts, state);
|
resumeScan (opts, state);
|
||||||
}
|
}
|
||||||
state->lasttg = 0;
|
state->lasttg = 0;
|
||||||
state->lastsrc = 0;
|
state->lastsrc = 0;
|
||||||
state->lastp25type = 3;
|
state->lastp25type = 3;
|
||||||
sprintf (state->fsubtype, " TSBK ");
|
sprintf (state->fsubtype, " TSBK ");
|
||||||
|
|
||||||
// Now processing NID
|
|
||||||
processTSBK(opts, state);
|
processTSBK(opts, state);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (strcmp (duid, "30") == 0)
|
else if (strcmp (duid, "30") == 0)
|
||||||
{
|
{
|
||||||
|
state->dmrburstL = 29;
|
||||||
if (opts->errorbars == 1)
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
printFrameInfo (opts, state);
|
printFrameInfo (opts, state);
|
||||||
fprintf (stderr," PDU\n");
|
fprintf (stderr," MBF\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)
|
if (opts->resume > 0)
|
||||||
{
|
{
|
||||||
resumeScan (opts, state);
|
resumeScan (opts, state);
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_dir[0] != 0)
|
|
||||||
{
|
|
||||||
if (opts->mbe_out_f == NULL)
|
|
||||||
{
|
|
||||||
openMbeOutFile (opts, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state->lastp25type = 4;
|
state->lastp25type = 4;
|
||||||
sprintf (state->fsubtype, " PDU ");
|
sprintf (state->fsubtype, " MBF ");
|
||||||
}
|
|
||||||
// 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) ");
|
|
||||||
|
|
||||||
// Now processing NID
|
processMPDU(opts, state);
|
||||||
skipDibit (opts, state, 328-25);
|
|
||||||
}
|
|
||||||
else if (state->lastp25type == 4)
|
|
||||||
{
|
|
||||||
if (opts->errorbars == 1)
|
|
||||||
{
|
|
||||||
printFrameInfo (opts, state);
|
|
||||||
fprintf (stderr," (PDU)\n");
|
|
||||||
}
|
|
||||||
state->lastp25type = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
state->lastp25type = 0;
|
||||||
|
sprintf (state->fsubtype, " ");
|
||||||
|
if (opts->errorbars == 1)
|
||||||
{
|
{
|
||||||
state->lastp25type = 0;
|
printFrameInfo (opts, state);
|
||||||
sprintf (state->fsubtype, " ");
|
// fprintf (stderr," duid:%s *Unknown DUID*\n", duid);
|
||||||
if (opts->errorbars == 1)
|
fprintf (stderr," duid:%s \n", duid); //DUID ERR
|
||||||
{
|
|
||||||
printFrameInfo (opts, state);
|
|
||||||
fprintf (stderr," duid:%s *Unknown DUID*\n", duid); //prints on dPMR frame 3
|
|
||||||
// fprintf (stderr, "\n"); //prints on dPMR frame 3
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
//start control channel hunting if using trunking, time needs updating on each successful sync
|
//start control channel hunting if using trunking, time needs updating on each successful sync
|
||||||
//will need to assign frequencies to a CC array for P25 since that isn't imported from CSV
|
//will need to assign frequencies to a CC array for P25 since that isn't imported from CSV
|
||||||
if (state->dmr_rest_channel == -1 && opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && ( (time(NULL) - state->last_cc_sync_time) > (opts->trunk_hangtime + 2) ) )
|
if (state->dmr_rest_channel == -1 && opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && ( (time(NULL) - state->last_cc_sync_time) > (opts->trunk_hangtime + 0) ) ) //was 3, go to hangtime value
|
||||||
{
|
{
|
||||||
|
|
||||||
//test to switch back to 10/4 P1 QPSK for P25 FDMA CC
|
//test to switch back to 10/4 P1 QPSK for P25 FDMA CC
|
||||||
@@ -163,10 +163,23 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
//start going through the lcn/frequencies CC/signal hunting
|
//start going through the lcn/frequencies CC/signal hunting
|
||||||
fprintf (stderr, "Control Channel Signal Lost. Searching for Control Channel.\n");
|
fprintf (stderr, "Control Channel Signal Lost. Searching for Control Channel.\n");
|
||||||
//make sure our current roll value doesn't exceed value of frequencies imported
|
//make sure our current roll value doesn't exceed value of frequencies imported
|
||||||
if (state->lcn_freq_roll > state->lcn_freq_count)
|
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
|
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
|
//check that we have a non zero value first, then tune next frequency
|
||||||
if (state->trunk_lcn_freq[state->lcn_freq_roll] != 0)
|
if (state->trunk_lcn_freq[state->lcn_freq_roll] != 0)
|
||||||
{
|
{
|
||||||
@@ -182,7 +195,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
rtl_udp_tune (opts, state, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
rtl_udp_tune (opts, state, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Tuning to Control Channel Frequency: %.06lf MHz\n",
|
fprintf (stderr, "Tuning to Frequency: %.06lf MHz\n",
|
||||||
(double)state->trunk_lcn_freq[state->lcn_freq_roll]/1000000);
|
(double)state->trunk_lcn_freq[state->lcn_freq_roll]/1000000);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -218,10 +231,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
t_max = 12; //based on Frame_Sync_2 pattern
|
t_max = 12; //based on Frame_Sync_2 pattern
|
||||||
}
|
}
|
||||||
//if Phase 2 (or YSF in future), then only 20
|
//if Phase 2 (or YSF in future), then only 19
|
||||||
else if (state->lastsynctype == 35 || state->lastsynctype == 36) //P2
|
else if (state->lastsynctype == 35 || state->lastsynctype == 36) //P2
|
||||||
{
|
{
|
||||||
t_max = 20;
|
t_max = 19; //Phase 2 S-ISCH is only 19
|
||||||
}
|
}
|
||||||
else t_max = 24; //24 for everything else
|
else t_max = 24; //24 for everything else
|
||||||
|
|
||||||
@@ -1264,6 +1277,121 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NXDNTESTSYNC //use experimental sync detection based on multiple factors
|
||||||
|
|
||||||
|
//NXDN FSW sync and handling - testing with more exact syncs patterns
|
||||||
|
else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1))
|
||||||
|
{
|
||||||
|
strncpy (synctest10, (synctest_p - 9), 10); //FSW only
|
||||||
|
strncpy (synctest19, (synctest_p - 18), 19); //Preamble + FSW
|
||||||
|
|
||||||
|
//Using Hard Coded Sync Strings with variations for the areas where the symbol
|
||||||
|
//error will occur due to the demodulation issues internally
|
||||||
|
|
||||||
|
//Preamble plus FSW, proceed right away
|
||||||
|
if (
|
||||||
|
|
||||||
|
(strcmp (synctest19, "3131133313131331131") == 0 )
|
||||||
|
|| (strcmp (synctest19, "3131133313331331131") == 0 )
|
||||||
|
|| (strcmp (synctest19, "3131133313131331111") == 0 )
|
||||||
|
|| (strcmp (synctest19, "3131133313331331111") == 0 )
|
||||||
|
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// state->carrier = 1;
|
||||||
|
state->lastsynctype = 28;
|
||||||
|
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, "\n +PANDF ");
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, " %s \n", synctest19);
|
||||||
|
return (28);
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
|
||||||
|
(strcmp (synctest19, "1313311133131331131") == 0 )
|
||||||
|
|| (strcmp (synctest19, "1313311133331331131") == 0 )
|
||||||
|
|| (strcmp (synctest19, "1313311133131331111") == 0 )
|
||||||
|
|| (strcmp (synctest19, "1313311133331331111") == 0 )
|
||||||
|
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// state->carrier = 1;
|
||||||
|
state->lastsynctype = 29;
|
||||||
|
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, "\n -PANDF ");
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, " %s \n", synctest19);
|
||||||
|
return (29);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (
|
||||||
|
(strcmp (synctest10, "3131331131") == 0 )
|
||||||
|
|| (strcmp (synctest10, "3331331131") == 0 )
|
||||||
|
|| (strcmp (synctest10, "3131331111") == 0 )
|
||||||
|
|| (strcmp (synctest10, "3331331111") == 0 )
|
||||||
|
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// state->carrier = 1;
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
|
||||||
|
if (state->lastsynctype == 28)
|
||||||
|
{
|
||||||
|
state->lastsynctype = 28;
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, "\n +FSW ");
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, " %s \n", synctest10);
|
||||||
|
return (28);
|
||||||
|
}
|
||||||
|
|
||||||
|
state->lastsynctype = 28;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (
|
||||||
|
|
||||||
|
(strcmp (synctest10, "1313113313") == 0 )
|
||||||
|
|| (strcmp (synctest10, "1113113313") == 0 )
|
||||||
|
|| (strcmp (synctest10, "1313113333") == 0 )
|
||||||
|
|| (strcmp (synctest10, "1113113333") == 0 )
|
||||||
|
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// state->carrier = 1;
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
|
||||||
|
if (state->lastsynctype == 29)
|
||||||
|
{
|
||||||
|
state->lastsynctype = 29;
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, "\n -FSW ");
|
||||||
|
// if (opts->payload == 1)
|
||||||
|
// fprintf (stderr, " %s \n", synctest10);
|
||||||
|
return (29);
|
||||||
|
}
|
||||||
|
state->lastsynctype = 29;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else //use current 'more stable' NXDN Sync pattern detection
|
||||||
|
|
||||||
//NXDN FSW sync and handling - moved to very bottom of sync stack for falsing sanity
|
//NXDN FSW sync and handling - moved to very bottom of sync stack for falsing sanity
|
||||||
else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1))
|
else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1))
|
||||||
{
|
{
|
||||||
@@ -1273,30 +1401,33 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
//Preamble plus FSW, proceed right away
|
//Preamble plus FSW, proceed right away
|
||||||
if ( (strncmperr (synctest19, NXDN_PANDFSW, 19, 1) == 0) )
|
if ( (strncmperr (synctest19, NXDN_PANDFSW, 19, 1) == 0) )
|
||||||
{
|
{
|
||||||
state->carrier = 1;
|
// state->carrier = 1;
|
||||||
state->offset = synctest_pos;
|
state->offset = synctest_pos;
|
||||||
state->max = ((state->max) + lmax) / 2;
|
state->max = ((state->max) + lmax) / 2;
|
||||||
state->min = ((state->min) + lmin) / 2;
|
state->min = ((state->min) + lmin) / 2;
|
||||||
state->lastsynctype = 28;
|
state->lastsynctype = 28;
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
//if (opts->payload == 1) fprintf (stderr, "PANDF ");
|
// if (opts->payload == 1) fprintf (stderr, "PANDF ");
|
||||||
|
// fprintf (stderr, " %s ", synctest19);
|
||||||
return (28);
|
return (28);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( (strncmperr (synctest19, INV_NXDN_PANDFSW, 19, 1) == 0) )
|
else if ( (strncmperr (synctest19, INV_NXDN_PANDFSW, 19, 1) == 0) )
|
||||||
{
|
{
|
||||||
state->carrier = 1;
|
// state->carrier = 1;
|
||||||
state->offset = synctest_pos;
|
state->offset = synctest_pos;
|
||||||
state->max = ((state->max) + lmax) / 2;
|
state->max = ((state->max) + lmax) / 2;
|
||||||
state->min = ((state->min) + lmin) / 2;
|
state->min = ((state->min) + lmin) / 2;
|
||||||
state->lastsynctype = 29;
|
state->lastsynctype = 29;
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
//if (opts->payload == 1) fprintf (stderr, "PANDF ");
|
// if (opts->payload == 1) fprintf (stderr, "PANDF ");
|
||||||
|
// fprintf (stderr, " %s ", synctest19);
|
||||||
return (29);
|
return (29);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( (strncmperr (synctest10, NXDN_FSW, 10, 1) == 0) )
|
else if ( (strncmperr (synctest10, NXDN_FSW, 10, 1) == 0) )
|
||||||
{
|
{
|
||||||
state->carrier = 1;
|
// state->carrier = 1;
|
||||||
state->offset = synctest_pos;
|
state->offset = synctest_pos;
|
||||||
state->max = ((state->max) + lmax) / 2;
|
state->max = ((state->max) + lmax) / 2;
|
||||||
state->min = ((state->min) + lmin) / 2;
|
state->min = ((state->min) + lmin) / 2;
|
||||||
@@ -1304,7 +1435,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->lastsynctype == 28)
|
if (state->lastsynctype == 28)
|
||||||
{
|
{
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
//if (opts->payload == 1) fprintf (stderr, "FSW ");
|
// if (opts->payload == 1) fprintf (stderr, "FSW ");
|
||||||
|
// fprintf (stderr, " %s ", synctest10);
|
||||||
return (28);
|
return (28);
|
||||||
}
|
}
|
||||||
state->lastsynctype = 28; //need two consecutive patterns to continue
|
state->lastsynctype = 28; //need two consecutive patterns to continue
|
||||||
@@ -1313,7 +1445,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
else if ( (strncmperr (synctest10, INV_NXDN_FSW, 10, 1) == 0) )
|
else if ( (strncmperr (synctest10, INV_NXDN_FSW, 10, 1) == 0) )
|
||||||
{
|
{
|
||||||
state->carrier = 1;
|
// state->carrier = 1;
|
||||||
state->offset = synctest_pos;
|
state->offset = synctest_pos;
|
||||||
state->max = ((state->max) + lmax) / 2;
|
state->max = ((state->max) + lmax) / 2;
|
||||||
state->min = ((state->min) + lmin) / 2;
|
state->min = ((state->min) + lmin) / 2;
|
||||||
@@ -1321,7 +1453,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->lastsynctype == 29)
|
if (state->lastsynctype == 29)
|
||||||
{
|
{
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
//if (opts->payload == 1) fprintf (stderr, "FSW ");
|
// if (opts->payload == 1) fprintf (stderr, "FSW ");
|
||||||
|
// fprintf (stderr, " %s ", synctest10);
|
||||||
return (29);
|
return (29);
|
||||||
}
|
}
|
||||||
state->lastsynctype = 29; //need two consecutive patterns to continue
|
state->lastsynctype = 29; //need two consecutive patterns to continue
|
||||||
@@ -1329,6 +1462,95 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //NXDN Sync Type Selection
|
||||||
|
|
||||||
|
//Provoice Conventional -- Some False Positives due to shortened frame sync pattern, so use squelch if possible
|
||||||
|
#ifdef PVCONVENTIONAL
|
||||||
|
if (opts->frame_provoice == 1)
|
||||||
|
{
|
||||||
|
memset (synctest32, 0, sizeof(synctest32));
|
||||||
|
strncpy (synctest32, (synctest_p - 31), 16); //short sync grab here on 32
|
||||||
|
char pvc_txs[9]; //string (symbol) value of TX Address
|
||||||
|
char pvc_rxs[9]; //string (symbol) value of RX Address
|
||||||
|
uint8_t pvc_txa = 0; //actual value of TX Address
|
||||||
|
uint8_t pvc_rxa = 0; //actual value of RX Address
|
||||||
|
strncpy (pvc_txs, (synctest_p - 15), 8); //copy string value of TX Address
|
||||||
|
strncpy (pvc_rxs, (synctest_p - 7), 8); //copy string value of RX Address
|
||||||
|
if ((strcmp (synctest32, INV_PROVOICE_CONV_SHORT) == 0))
|
||||||
|
{
|
||||||
|
if (state->lastsynctype == 15) //use this condition, like NXDN, to migitage false positives due to short sync pattern
|
||||||
|
{
|
||||||
|
state->carrier = 1;
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
sprintf (state->ftype, "ProVoice ");
|
||||||
|
// fprintf (stderr, "Sync Pattern = %s ", synctest32);
|
||||||
|
// fprintf (stderr, "TX = %s ", pvc_txs);
|
||||||
|
// fprintf (stderr, "RX = %s ", pvc_rxs);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
pvc_txa = pvc_txa << 1;
|
||||||
|
pvc_rxa = pvc_rxa << 1;
|
||||||
|
//symbol 1 is binary 1 on inverted
|
||||||
|
//I hate working with strings, has to be a better way to evaluate this
|
||||||
|
memset (pvc_txs, 0, sizeof (pvc_txs));
|
||||||
|
memset (pvc_rxs, 0, sizeof (pvc_rxs));
|
||||||
|
strncpy (pvc_txs, (synctest_p - 15+i), 1);
|
||||||
|
strncpy (pvc_rxs, (synctest_p - 7+i), 1);
|
||||||
|
if ((strcmp (pvc_txs, "1") == 0))
|
||||||
|
pvc_txa = pvc_txa + 1;
|
||||||
|
if ((strcmp (pvc_rxs, "1") == 0))
|
||||||
|
pvc_rxa = pvc_rxa + 1;
|
||||||
|
}
|
||||||
|
printFrameSync (opts, state, "-PV_C ", synctest_pos + 1, modulation);
|
||||||
|
fprintf (stderr, "TX: %d ", pvc_txa);
|
||||||
|
fprintf (stderr, "RX: %d ", pvc_rxa);
|
||||||
|
if (pvc_txa == 172) fprintf (stderr, "ALL CALL ");
|
||||||
|
state->lastsynctype = 15;
|
||||||
|
return (15);
|
||||||
|
}
|
||||||
|
state->lastsynctype = 15;
|
||||||
|
}
|
||||||
|
else if ((strcmp (synctest32, PROVOICE_CONV_SHORT) == 0))
|
||||||
|
{
|
||||||
|
if (state->lastsynctype == 14) //use this condition, like NXDN, to migitage false positives due to short sync pattern
|
||||||
|
{
|
||||||
|
state->carrier = 1;
|
||||||
|
state->offset = synctest_pos;
|
||||||
|
state->max = ((state->max) + lmax) / 2;
|
||||||
|
state->min = ((state->min) + lmin) / 2;
|
||||||
|
sprintf (state->ftype, "ProVoice ");
|
||||||
|
// fprintf (stderr, "Sync Pattern = %s ", synctest32);
|
||||||
|
// fprintf (stderr, "TX = %s ", pvc_txs);
|
||||||
|
// fprintf (stderr, "RX = %s ", pvc_rxs);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
pvc_txa = pvc_txa << 1;
|
||||||
|
pvc_rxa = pvc_rxa << 1;
|
||||||
|
//symbol 3 is binary 1 on positive
|
||||||
|
//I hate working with strings, has to be a better way to evaluate this
|
||||||
|
memset (pvc_txs, 0, sizeof (pvc_txs));
|
||||||
|
memset (pvc_rxs, 0, sizeof (pvc_rxs));
|
||||||
|
strncpy (pvc_txs, (synctest_p - 15+i), 1);
|
||||||
|
strncpy (pvc_rxs, (synctest_p - 7+i), 1);
|
||||||
|
if ((strcmp (pvc_txs, "3") == 0))
|
||||||
|
pvc_txa = pvc_txa + 1;
|
||||||
|
if ((strcmp (pvc_rxs, "3") == 0))
|
||||||
|
pvc_rxa = pvc_rxa + 1;
|
||||||
|
}
|
||||||
|
printFrameSync (opts, state, "+PV_C ", synctest_pos + 1, modulation);
|
||||||
|
fprintf (stderr, "TX: %d ", pvc_txa);
|
||||||
|
fprintf (stderr, "RX: %d ", pvc_rxa);
|
||||||
|
if (pvc_txa == 172) fprintf (stderr, "ALL CALL ");
|
||||||
|
state->lastsynctype = 14;
|
||||||
|
return (14);
|
||||||
|
}
|
||||||
|
state->lastsynctype = 14;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //End Provoice Conventional
|
||||||
|
|
||||||
} // t >= 10
|
} // t >= 10
|
||||||
|
|
||||||
if (exitflag == 1)
|
if (exitflag == 1)
|
||||||
|
|||||||
@@ -145,3 +145,68 @@ int csvChanImport(dsd_opts * opts, dsd_state * state) //channel map import
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int csvKeyImport(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;
|
||||||
|
}
|
||||||
|
|||||||
469
src/dsd_main.c
469
src/dsd_main.c
@@ -55,8 +55,7 @@ char * FM_banner[9] = {
|
|||||||
" "
|
" "
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int comp (const void *a, const void *b)
|
||||||
comp (const void *a, const void *b)
|
|
||||||
{
|
{
|
||||||
if (*((const int *) a) == *((const int *) b))
|
if (*((const int *) a) == *((const int *) b))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -69,6 +68,7 @@ comp (const void *a, const void *b)
|
|||||||
//struct for checking existence of directory to write to
|
//struct for checking existence of directory to write to
|
||||||
struct stat st = {0};
|
struct stat st = {0};
|
||||||
char wav_file_directory[1024] = {0};
|
char wav_file_directory[1024] = {0};
|
||||||
|
char dsp_filename[1024] = {0};
|
||||||
unsigned long long int p2vars = 0;
|
unsigned long long int p2vars = 0;
|
||||||
|
|
||||||
char * pEnd; //bugfix
|
char * pEnd; //bugfix
|
||||||
@@ -77,6 +77,37 @@ void
|
|||||||
noCarrier (dsd_opts * opts, dsd_state * state)
|
noCarrier (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//experimental conventional frequency scanner mode
|
||||||
|
if (opts->scanner_mode == 1 && ( (time(NULL) - state->last_cc_sync_time) > opts->trunk_hangtime))
|
||||||
|
{
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
//rtludp
|
||||||
|
if (opts->audio_in_type == 3)
|
||||||
|
{
|
||||||
|
rtl_udp_tune (opts, state, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->lastsynctype != -1) fprintf (stderr, "Resume Scanning Mode\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
state->lcn_freq_roll++;
|
||||||
|
state->last_cc_sync_time = time(NULL);
|
||||||
|
}
|
||||||
|
//end experimental conventional frequency scanner mode
|
||||||
|
|
||||||
//tune back to last known CC when using trunking after x second hangtime
|
//tune back to last known CC when using trunking after x second hangtime
|
||||||
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && ( (time(NULL) - state->last_cc_sync_time) > opts->trunk_hangtime) )
|
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && ( (time(NULL) - state->last_cc_sync_time) > opts->trunk_hangtime) )
|
||||||
{
|
{
|
||||||
@@ -126,6 +157,8 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->p25_vc_freq[0] = 0;
|
state->p25_vc_freq[0] = 0;
|
||||||
state->p25_vc_freq[1] = 0;
|
state->p25_vc_freq[1] = 0;
|
||||||
|
|
||||||
|
memset(state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
|
||||||
state->is_con_plus = 0; //flag off
|
state->is_con_plus = 0; //flag off
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,10 +168,11 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->dmr_payload_p = state->dibit_buf + 200;
|
state->dmr_payload_p = state->dibit_buf + 200;
|
||||||
memset (state->dmr_payload_buf, 0, sizeof (int) * 200);
|
memset (state->dmr_payload_buf, 0, sizeof (int) * 200);
|
||||||
//dmr buffer end
|
//dmr buffer end
|
||||||
if (opts->mbe_out_f != NULL)
|
|
||||||
{
|
//close MBE out files
|
||||||
closeMbeOutFile (opts, state);
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
}
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
|
||||||
state->jitter = -1;
|
state->jitter = -1;
|
||||||
state->lastsynctype = -1;
|
state->lastsynctype = -1;
|
||||||
state->carrier = 0;
|
state->carrier = 0;
|
||||||
@@ -172,6 +206,12 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->nxdn_location_sys_code = 0;
|
state->nxdn_location_sys_code = 0;
|
||||||
sprintf (state->nxdn_location_category, "%s", " ");
|
sprintf (state->nxdn_location_category, "%s", " ");
|
||||||
|
|
||||||
|
//channel access information
|
||||||
|
state->nxdn_rcn = 0;
|
||||||
|
state->nxdn_base_freq = 0;
|
||||||
|
state->nxdn_step = 0;
|
||||||
|
state->nxdn_bw = 0;
|
||||||
|
|
||||||
//dmr mfid branding and site parms
|
//dmr mfid branding and site parms
|
||||||
sprintf(state->dmr_branding_sub, "%s", "");
|
sprintf(state->dmr_branding_sub, "%s", "");
|
||||||
sprintf(state->dmr_branding, "%s", "");
|
sprintf(state->dmr_branding, "%s", "");
|
||||||
@@ -253,12 +293,12 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->data_header_blocks[1] = 1; //when trying to fill the superframe and 0-1 blocks give us an overflow
|
state->data_header_blocks[1] = 1; //when trying to fill the superframe and 0-1 blocks give us an overflow
|
||||||
state->data_header_padding[0] = 0;
|
state->data_header_padding[0] = 0;
|
||||||
state->data_header_padding[1] = 0;
|
state->data_header_padding[1] = 0;
|
||||||
state->data_header_format[0] = 0;
|
state->data_header_format[0] = 7;
|
||||||
state->data_header_format[1] = 0;
|
state->data_header_format[1] = 7;
|
||||||
state->data_header_sap[0] = 0;
|
state->data_header_sap[0] = 0;
|
||||||
state->data_header_sap[1] = 0;
|
state->data_header_sap[1] = 0;
|
||||||
state->data_block_counter[0] = 0;
|
state->data_block_counter[0] = 1;
|
||||||
state->data_block_counter[1] = 0;
|
state->data_block_counter[1] = 1;
|
||||||
state->data_p_head[0] = 0;
|
state->data_p_head[0] = 0;
|
||||||
state->data_p_head[1] = 0;
|
state->data_p_head[1] = 0;
|
||||||
|
|
||||||
@@ -278,8 +318,8 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->fourv_counter[1] = 0;
|
state->fourv_counter[1] = 0;
|
||||||
|
|
||||||
//values displayed in ncurses terminal
|
//values displayed in ncurses terminal
|
||||||
state->p25_vc_freq[0] = 0;
|
// state->p25_vc_freq[0] = 0;
|
||||||
state->p25_vc_freq[1] = 0;
|
// state->p25_vc_freq[1] = 0;
|
||||||
|
|
||||||
//new nxdn stuff
|
//new nxdn stuff
|
||||||
state->nxdn_part_of_frame = 0;
|
state->nxdn_part_of_frame = 0;
|
||||||
@@ -287,11 +327,23 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
state->nxdn_sf = 0;
|
state->nxdn_sf = 0;
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); //init on 1, bad CRC all
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); //init on 1, bad CRC all
|
||||||
state->nxdn_sacch_non_superframe = TRUE;
|
state->nxdn_sacch_non_superframe = TRUE;
|
||||||
memset (state->nxdn_sacch_frame_segment, 0, sizeof(state->nxdn_sacch_frame_segment));
|
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
||||||
state->nxdn_alias_block_number = 0;
|
state->nxdn_alias_block_number = 0;
|
||||||
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
||||||
sprintf (state->nxdn_call_type, "%s", "");
|
sprintf (state->nxdn_call_type, "%s", "");
|
||||||
|
|
||||||
|
//unload keys when using keylaoder
|
||||||
|
if (state->keyloader == 1)
|
||||||
|
{
|
||||||
|
state->R = 0; //NXDN
|
||||||
|
state->K = 0; //BP
|
||||||
|
state->K1 = 0; //tera 10 char BP
|
||||||
|
state->H = 0; //shim for above
|
||||||
|
}
|
||||||
|
|
||||||
|
//forcing key application will re-enable this at the time of voice tx
|
||||||
|
state->nxdn_cipher_type = 0;
|
||||||
|
|
||||||
//dmr overaching manufacturer in use for a particular system or radio
|
//dmr overaching manufacturer in use for a particular system or radio
|
||||||
// state->dmr_mfid = -1;
|
// state->dmr_mfid = -1;
|
||||||
|
|
||||||
@@ -301,6 +353,11 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
//initialize unified dmr pdu 'superframe'
|
//initialize unified dmr pdu 'superframe'
|
||||||
memset (state->dmr_pdu_sf, 0, sizeof (state->dmr_pdu_sf));
|
memset (state->dmr_pdu_sf, 0, sizeof (state->dmr_pdu_sf));
|
||||||
|
memset (state->data_header_valid, 0, sizeof(state->data_header_valid));
|
||||||
|
|
||||||
|
//initialize cap+ bits and block num storage
|
||||||
|
memset (state->cap_plus_csbk_bits, 0, sizeof(state->cap_plus_csbk_bits));
|
||||||
|
memset (state->cap_plus_block_num, 0, sizeof(state->cap_plus_block_num));
|
||||||
|
|
||||||
//init confirmed data individual block crc as invalid
|
//init confirmed data individual block crc as invalid
|
||||||
memset (state->data_block_crc_valid, 0, sizeof(state->data_block_crc_valid));
|
memset (state->data_block_crc_valid, 0, sizeof(state->data_block_crc_valid));
|
||||||
@@ -318,11 +375,13 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
memset(state->dmr_embedded_gps, 0, sizeof(state->dmr_embedded_gps));
|
memset(state->dmr_embedded_gps, 0, sizeof(state->dmr_embedded_gps));
|
||||||
memset(state->dmr_lrrp_gps, 0, sizeof(state->dmr_lrrp_gps));
|
memset(state->dmr_lrrp_gps, 0, sizeof(state->dmr_lrrp_gps));
|
||||||
|
|
||||||
//REMUS! multi-purpose call_string
|
// memset(state->active_channel, 0, sizeof(state->active_channel));
|
||||||
sprintf (state->call_string[0], "%s", " "); //20 spaces
|
|
||||||
sprintf (state->call_string[1], "%s", " "); //20 spaces
|
|
||||||
|
|
||||||
if (time(NULL) - state->last_cc_sync_time > 30) //thirty seconds of no carrier
|
//REMUS! multi-purpose call_string
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
|
||||||
|
if (time(NULL) - state->last_cc_sync_time > 10) //ten seconds of no carrier
|
||||||
{
|
{
|
||||||
state->dmr_rest_channel = -1;
|
state->dmr_rest_channel = -1;
|
||||||
state->p25_vc_freq[0] = 0;
|
state->p25_vc_freq[0] = 0;
|
||||||
@@ -332,8 +391,20 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
|||||||
sprintf(state->dmr_branding, "%s", "");
|
sprintf(state->dmr_branding, "%s", "");
|
||||||
sprintf (state->dmr_site_parms, "%s", "");
|
sprintf (state->dmr_site_parms, "%s", "");
|
||||||
opts->p25_is_tuned = 0;
|
opts->p25_is_tuned = 0;
|
||||||
|
memset(state->active_channel, 0, sizeof(state->active_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts->dPMR_next_part_of_superframe = 0;
|
||||||
|
|
||||||
|
state->dPMRVoiceFS2Frame.CalledIDOk = 0;
|
||||||
|
state->dPMRVoiceFS2Frame.CallingIDOk = 0;
|
||||||
|
memset(state->dPMRVoiceFS2Frame.CalledID, 0, 8);
|
||||||
|
memset(state->dPMRVoiceFS2Frame.CallingID, 0, 8);
|
||||||
|
memset(state->dPMRVoiceFS2Frame.Version, 0, 8);
|
||||||
|
|
||||||
|
sprintf (state->dpmr_caller_id, "%s", " ");
|
||||||
|
sprintf (state->dpmr_target_id, "%s", " ");
|
||||||
|
|
||||||
} //nocarrier
|
} //nocarrier
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -363,8 +434,10 @@ initOpts (dsd_opts * opts)
|
|||||||
opts->playoffsetR = 0;
|
opts->playoffsetR = 0;
|
||||||
opts->mbe_out_dir[0] = 0;
|
opts->mbe_out_dir[0] = 0;
|
||||||
opts->mbe_out_file[0] = 0;
|
opts->mbe_out_file[0] = 0;
|
||||||
|
opts->mbe_out_fileR[0] = 0; //second slot on a TDMA system
|
||||||
opts->mbe_out_path[0] = 0;
|
opts->mbe_out_path[0] = 0;
|
||||||
opts->mbe_out_f = NULL;
|
opts->mbe_out_f = NULL;
|
||||||
|
opts->mbe_out_fR = NULL; //second slot on a TDMA system
|
||||||
opts->audio_gain = 0; //0
|
opts->audio_gain = 0; //0
|
||||||
opts->audio_gainR = 0; //0
|
opts->audio_gainR = 0; //0
|
||||||
opts->audio_out = 1;
|
opts->audio_out = 1;
|
||||||
@@ -377,11 +450,13 @@ initOpts (dsd_opts * opts)
|
|||||||
opts->group_in_file[0] = 0;
|
opts->group_in_file[0] = 0;
|
||||||
opts->lcn_in_file[0] = 0;
|
opts->lcn_in_file[0] = 0;
|
||||||
opts->chan_in_file[0] = 0;
|
opts->chan_in_file[0] = 0;
|
||||||
|
opts->key_in_file[0] = 0;
|
||||||
//end import filenames
|
//end import filenames
|
||||||
opts->szNumbers[0] = 0;
|
opts->szNumbers[0] = 0;
|
||||||
opts->symbol_out_f = NULL;
|
opts->symbol_out_f = NULL;
|
||||||
opts->symbol_out = 0;
|
opts->symbol_out = 0;
|
||||||
opts->mbe_out = 0;
|
opts->mbe_out = 0;
|
||||||
|
opts->mbe_outR = 0; //second slot on a TDMA system
|
||||||
opts->wav_out_f = NULL;
|
opts->wav_out_f = NULL;
|
||||||
opts->wav_out_fR = NULL;
|
opts->wav_out_fR = NULL;
|
||||||
opts->wav_out_raw = NULL;
|
opts->wav_out_raw = NULL;
|
||||||
@@ -464,7 +539,7 @@ initOpts (dsd_opts * opts)
|
|||||||
//rigctl options
|
//rigctl options
|
||||||
opts->use_rigctl = 0;
|
opts->use_rigctl = 0;
|
||||||
opts->rigctl_sockfd = 0;
|
opts->rigctl_sockfd = 0;
|
||||||
opts->rigctlportno = 7356; //TCP Port Number; GQRX - 7356; SDR++ - 4532
|
opts->rigctlportno = 4532; //TCP Port Number; GQRX - 7356; SDR++ - 4532
|
||||||
sprintf (opts->rigctlhostname, "%s", "localhost");
|
sprintf (opts->rigctlhostname, "%s", "localhost");
|
||||||
|
|
||||||
//udp input options
|
//udp input options
|
||||||
@@ -479,7 +554,9 @@ initOpts (dsd_opts * opts)
|
|||||||
|
|
||||||
opts->p25_trunk = 0; //0 disabled, 1 is enabled
|
opts->p25_trunk = 0; //0 disabled, 1 is enabled
|
||||||
opts->p25_is_tuned = 0; //set to 1 if currently on VC, set back to 0 on carrier drop
|
opts->p25_is_tuned = 0; //set to 1 if currently on VC, set back to 0 on carrier drop
|
||||||
opts->trunk_hangtime = 1; //1 second hangtime by default before tuning back to CC
|
opts->trunk_hangtime = 1; //1 second hangtime by default before tuning back to CC, going sub 1 sec causes issues with cc slip
|
||||||
|
|
||||||
|
opts->scanner_mode = 0; //0 disabled, 1 is enabled
|
||||||
|
|
||||||
//reverse mute
|
//reverse mute
|
||||||
opts->reverse_mute = 0;
|
opts->reverse_mute = 0;
|
||||||
@@ -503,6 +580,15 @@ initOpts (dsd_opts * opts)
|
|||||||
//Trunking - Tune Data Calls
|
//Trunking - Tune Data Calls
|
||||||
opts->trunk_tune_data_calls = 0; //disabled by default
|
opts->trunk_tune_data_calls = 0; //disabled by default
|
||||||
|
|
||||||
|
//Trunking - Tune Encrypted Calls (P25 only on applicable grants with svc opts)
|
||||||
|
opts->trunk_tune_enc_calls = 1; //enabled by default
|
||||||
|
|
||||||
|
opts->dPMR_next_part_of_superframe = 0;
|
||||||
|
|
||||||
|
//dsp structured file
|
||||||
|
opts->dsp_out_file[0] = 0;
|
||||||
|
opts->use_dsp_output = 0;
|
||||||
|
|
||||||
} //initopts
|
} //initopts
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -642,8 +728,6 @@ initState (dsd_state * state)
|
|||||||
state->payload_miN = 0;
|
state->payload_miN = 0;
|
||||||
|
|
||||||
state->dpmr_color_code = -1;
|
state->dpmr_color_code = -1;
|
||||||
state->dpmr_caller_id = 0;
|
|
||||||
state->dpmr_target_id = 0;
|
|
||||||
|
|
||||||
state->payload_mi = 0;
|
state->payload_mi = 0;
|
||||||
state->payload_miR = 0;
|
state->payload_miR = 0;
|
||||||
@@ -676,10 +760,12 @@ initState (dsd_state * state)
|
|||||||
state->dmr_stereo = 0; //1, or 0?
|
state->dmr_stereo = 0; //1, or 0?
|
||||||
state->dmrburstL = 17; //initialize at higher value than possible
|
state->dmrburstL = 17; //initialize at higher value than possible
|
||||||
state->dmrburstR = 17; //17 in char array is set for ERR
|
state->dmrburstR = 17; //17 in char array is set for ERR
|
||||||
state->dmr_so = 0;
|
state->dmr_so = 0;
|
||||||
state->dmr_soR = 0;
|
state->dmr_soR = 0;
|
||||||
state->dmr_fid = 0;
|
state->dmr_fid = 0;
|
||||||
state->dmr_fidR = 0;
|
state->dmr_fidR = 0;
|
||||||
|
state->dmr_flco = 0;
|
||||||
|
state->dmr_flcoR = 0;
|
||||||
state->dmr_ms_mode = 0;
|
state->dmr_ms_mode = 0;
|
||||||
|
|
||||||
state->HYTL = 0;
|
state->HYTL = 0;
|
||||||
@@ -705,12 +791,12 @@ initState (dsd_state * state)
|
|||||||
state->data_header_blocks[1] = 1; //when trying to fill the superframe and 0-1 blocks give us an overflow
|
state->data_header_blocks[1] = 1; //when trying to fill the superframe and 0-1 blocks give us an overflow
|
||||||
state->data_header_padding[0] = 0;
|
state->data_header_padding[0] = 0;
|
||||||
state->data_header_padding[1] = 0;
|
state->data_header_padding[1] = 0;
|
||||||
state->data_header_format[0] = 0;
|
state->data_header_format[0] = 7;
|
||||||
state->data_header_format[1] = 0;
|
state->data_header_format[1] = 7;
|
||||||
state->data_header_sap[0] = 0;
|
state->data_header_sap[0] = 0;
|
||||||
state->data_header_sap[1] = 0;
|
state->data_header_sap[1] = 0;
|
||||||
state->data_block_counter[0] = 0;
|
state->data_block_counter[0] = 1;
|
||||||
state->data_block_counter[1] = 0;
|
state->data_block_counter[1] = 1;
|
||||||
state->data_p_head[0] = 0;
|
state->data_p_head[0] = 0;
|
||||||
state->data_p_head[1] = 0;
|
state->data_p_head[1] = 0;
|
||||||
|
|
||||||
@@ -723,6 +809,8 @@ initState (dsd_state * state)
|
|||||||
state->p2_wacn = 0;
|
state->p2_wacn = 0;
|
||||||
state->p2_sysid = 0;
|
state->p2_sysid = 0;
|
||||||
state->p2_cc = 0;
|
state->p2_cc = 0;
|
||||||
|
state->p2_siteid = 0;
|
||||||
|
state->p2_rfssid = 0;
|
||||||
state->p2_hardset = 0;
|
state->p2_hardset = 0;
|
||||||
state->p2_is_lcch = 0;
|
state->p2_is_lcch = 0;
|
||||||
state->p25_cc_is_tdma = 2; //init on 2, TSBK NET_STS will set 0, TDMA NET_STS will set 1. //used to determine if we need to change symbol rate when cc hunting
|
state->p25_cc_is_tdma = 2; //init on 2, TSBK NET_STS will set 0, TDMA NET_STS will set 1. //used to determine if we need to change symbol rate when cc hunting
|
||||||
@@ -738,6 +826,7 @@ initState (dsd_state * state)
|
|||||||
state->p25_chan_iden = 0;
|
state->p25_chan_iden = 0;
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
|
state->p25_chan_tdma[i] = -1; //0, or -1
|
||||||
state->p25_chan_type[i] = 0;
|
state->p25_chan_type[i] = 0;
|
||||||
state->p25_trans_off[i] = 0;
|
state->p25_trans_off[i] = 0;
|
||||||
state->p25_chan_spac[i] = 0;
|
state->p25_chan_spac[i] = 0;
|
||||||
@@ -767,14 +856,12 @@ initState (dsd_state * state)
|
|||||||
state->lcn_freq_roll = 0; //needs reset if sync is found?
|
state->lcn_freq_roll = 0; //needs reset if sync is found?
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
state->is_con_plus = 0;
|
state->is_con_plus = 0;
|
||||||
|
|
||||||
//dmr trunking/ncurses stuff
|
//dmr trunking/ncurses stuff
|
||||||
state->dmr_rest_channel = -1; //init on -1
|
state->dmr_rest_channel = -1; //init on -1
|
||||||
state->dmr_mfid = -1; //
|
state->dmr_mfid = -1; //
|
||||||
state->dmr_tuned_lcn = -1; //logical slot, lcn * ts?
|
|
||||||
state->dmr_vc_lcn = -1; //
|
|
||||||
state->dmr_vc_lsn = -1;
|
|
||||||
|
|
||||||
//new nxdn stuff
|
//new nxdn stuff
|
||||||
state->nxdn_part_of_frame = 0;
|
state->nxdn_part_of_frame = 0;
|
||||||
@@ -782,14 +869,25 @@ initState (dsd_state * state)
|
|||||||
state->nxdn_sf = 0;
|
state->nxdn_sf = 0;
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); //init on 1, bad CRC all
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); //init on 1, bad CRC all
|
||||||
state->nxdn_sacch_non_superframe = TRUE;
|
state->nxdn_sacch_non_superframe = TRUE;
|
||||||
memset (state->nxdn_sacch_frame_segment, 0, sizeof(state->nxdn_sacch_frame_segment));
|
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
||||||
state->nxdn_alias_block_number = 0;
|
state->nxdn_alias_block_number = 0;
|
||||||
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
||||||
|
|
||||||
//site/srv/cch info
|
//site/srv/cch info
|
||||||
state->nxdn_location_site_code = 0;
|
state->nxdn_location_site_code = 0;
|
||||||
state->nxdn_location_sys_code = 0;
|
state->nxdn_location_sys_code = 0;
|
||||||
sprintf (state->nxdn_location_category, "%s", " ");
|
sprintf (state->nxdn_location_category, "%s", " ");
|
||||||
|
|
||||||
|
//channel access information
|
||||||
|
state->nxdn_rcn = 0;
|
||||||
|
state->nxdn_base_freq = 0;
|
||||||
|
state->nxdn_step = 0;
|
||||||
|
state->nxdn_bw = 0;
|
||||||
|
|
||||||
|
//multi-key array
|
||||||
|
memset (state->rkey_array, 0, sizeof(state->rkey_array));
|
||||||
|
state->keyloader = 0; //keyloader off
|
||||||
|
|
||||||
//Remus DMR End Call Alert Beep
|
//Remus DMR End Call Alert Beep
|
||||||
state->dmr_end_alert[0] = 0;
|
state->dmr_end_alert[0] = 0;
|
||||||
state->dmr_end_alert[1] = 0;
|
state->dmr_end_alert[1] = 0;
|
||||||
@@ -800,6 +898,11 @@ initState (dsd_state * state)
|
|||||||
|
|
||||||
//initialize unified dmr pdu 'superframe'
|
//initialize unified dmr pdu 'superframe'
|
||||||
memset (state->dmr_pdu_sf, 0, sizeof (state->dmr_pdu_sf));
|
memset (state->dmr_pdu_sf, 0, sizeof (state->dmr_pdu_sf));
|
||||||
|
memset (state->data_header_valid, 0, sizeof(state->data_header_valid));
|
||||||
|
|
||||||
|
//initialize cap+ bits and block num storage
|
||||||
|
memset (state->cap_plus_csbk_bits, 0, sizeof(state->cap_plus_csbk_bits));
|
||||||
|
memset (state->cap_plus_block_num, 0, sizeof(state->cap_plus_block_num));
|
||||||
|
|
||||||
//init confirmed data individual block crc as invalid
|
//init confirmed data individual block crc as invalid
|
||||||
memset (state->data_block_crc_valid, 0, sizeof(state->data_block_crc_valid));
|
memset (state->data_block_crc_valid, 0, sizeof(state->data_block_crc_valid));
|
||||||
@@ -817,16 +920,26 @@ initState (dsd_state * state)
|
|||||||
memset(state->dmr_alias_block_segment, 0, sizeof(state->dmr_alias_block_segment));
|
memset(state->dmr_alias_block_segment, 0, sizeof(state->dmr_alias_block_segment));
|
||||||
memset(state->dmr_embedded_gps, 0, sizeof(state->dmr_embedded_gps));
|
memset(state->dmr_embedded_gps, 0, sizeof(state->dmr_embedded_gps));
|
||||||
memset(state->dmr_lrrp_gps, 0, sizeof(state->dmr_lrrp_gps));
|
memset(state->dmr_lrrp_gps, 0, sizeof(state->dmr_lrrp_gps));
|
||||||
|
memset(state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
|
||||||
//REMUS! multi-purpose call_string
|
//REMUS! multi-purpose call_string
|
||||||
sprintf (state->call_string[0], "%s", " "); //20 spaces
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
sprintf (state->call_string[1], "%s", " "); //20 spaces
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
|
||||||
//late entry mi fragments
|
//late entry mi fragments
|
||||||
memset (state->late_entry_mi_fragment, 0, sizeof (state->late_entry_mi_fragment));
|
memset (state->late_entry_mi_fragment, 0, sizeof (state->late_entry_mi_fragment));
|
||||||
|
|
||||||
initialize_p25_heuristics(&state->p25_heuristics);
|
initialize_p25_heuristics(&state->p25_heuristics);
|
||||||
|
|
||||||
|
state->dPMRVoiceFS2Frame.CalledIDOk = 0;
|
||||||
|
state->dPMRVoiceFS2Frame.CallingIDOk = 0;
|
||||||
|
memset(state->dPMRVoiceFS2Frame.CalledID, 0, 8);
|
||||||
|
memset(state->dPMRVoiceFS2Frame.CallingID, 0, 8);
|
||||||
|
memset(state->dPMRVoiceFS2Frame.Version, 0, 8);
|
||||||
|
|
||||||
|
sprintf (state->dpmr_caller_id, "%s", " ");
|
||||||
|
sprintf (state->dpmr_target_id, "%s", " ");
|
||||||
|
|
||||||
} //init_state
|
} //init_state
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -855,7 +968,7 @@ usage ()
|
|||||||
printf (" (Use single quotes '/directory/audio file.wav' when directories/spaces are present)\n");
|
printf (" (Use single quotes '/directory/audio file.wav' when directories/spaces are present)\n");
|
||||||
printf (" -s <rate> Sample Rate of wav input files (48000 or 96000) Mono only!\n");
|
printf (" -s <rate> Sample Rate of wav input files (48000 or 96000) Mono only!\n");
|
||||||
printf (" -o <device> Audio output device (default is pulse audio)(null for no audio output)\n");
|
printf (" -o <device> Audio output device (default is pulse audio)(null for no audio output)\n");
|
||||||
printf (" -d <dir> Create mbe data files, use this directory\n");
|
printf (" -d <dir> Create mbe data files, use this directory (TDMA version is experimental)\n");
|
||||||
printf (" -r <files> Read/Play saved mbe data from file(s)\n");
|
printf (" -r <files> Read/Play saved mbe data from file(s)\n");
|
||||||
printf (" -g <num> Audio output gain (default = 0 = auto, disable = -1)\n");
|
printf (" -g <num> Audio output gain (default = 0 = auto, disable = -1)\n");
|
||||||
printf (" -w <file> Output synthesized speech to a .wav file, legacy auto modes only.\n");
|
printf (" -w <file> Output synthesized speech to a .wav file, legacy auto modes only.\n");
|
||||||
@@ -865,6 +978,7 @@ usage ()
|
|||||||
printf (" -a Enable Call Alert Beep (NCurses Terminal Only)\n");
|
printf (" -a Enable Call Alert Beep (NCurses Terminal Only)\n");
|
||||||
printf (" (Warning! Might be annoying.)\n");
|
printf (" (Warning! Might be annoying.)\n");
|
||||||
printf (" -L <file> Specify Filename for LRRP Data Output.\n");
|
printf (" -L <file> Specify Filename for LRRP Data Output.\n");
|
||||||
|
printf (" -Q <file> Specify Filename for DSP Structured File Output. (placed in DSP folder)\n");
|
||||||
printf (" -c <file> Output symbol capture to .bin file\n");
|
printf (" -c <file> Output symbol capture to .bin file\n");
|
||||||
printf (" -q Reverse Mute - Mute Unencrypted Voice and Unmute Encrypted Voice\n");
|
printf (" -q Reverse Mute - Mute Unencrypted Voice and Unmute Encrypted Voice\n");
|
||||||
printf (" -V Enable Audio Smoothing on Upsampled 48k/1 or 24k/2 Audio (Capital V)\n");
|
printf (" -V Enable Audio Smoothing on Upsampled 48k/1 or 24k/2 Audio (Capital V)\n");
|
||||||
@@ -885,7 +999,7 @@ usage ()
|
|||||||
printf ("Decoder options:\n");
|
printf ("Decoder options:\n");
|
||||||
printf (" -fa Legacy Auto Detection 8k/1 (old methods default)\n");
|
printf (" -fa Legacy Auto Detection 8k/1 (old methods default)\n");
|
||||||
printf (" -ft XDMA P25 and DMR BS/MS frame types (new default)\n");
|
printf (" -ft XDMA P25 and DMR BS/MS frame types (new default)\n");
|
||||||
printf (" -fs DMR Stereo BS and MS Simplex only\n");
|
printf (" -fs DMR Stereo BS and MS Simplex\n");
|
||||||
printf (" -f1 Decode only P25 Phase 1\n");
|
printf (" -f1 Decode only P25 Phase 1\n");
|
||||||
printf (" -fd Decode only D-STAR\n");
|
printf (" -fd Decode only D-STAR\n");
|
||||||
printf (" -fr Decode only DMR Mono - Single Slot Voice\n");
|
printf (" -fr Decode only DMR Mono - Single Slot Voice\n");
|
||||||
@@ -894,7 +1008,7 @@ usage ()
|
|||||||
printf (" -fn Decode only NXDN96* (12.5 kHz)\n");
|
printf (" -fn Decode only NXDN96* (12.5 kHz)\n");
|
||||||
printf (" -fp Decode only EDACS/ProVoice*\n");
|
printf (" -fp Decode only EDACS/ProVoice*\n");
|
||||||
printf (" -fm Decode only dPMR*\n");
|
printf (" -fm Decode only dPMR*\n");
|
||||||
printf (" -l Disable DMR and NXDN input filtering\n");
|
printf (" -l Disable DMR, dPMR, and NXDN input filtering\n");
|
||||||
printf (" -u <num> Unvoiced speech quality (default=3)\n");
|
printf (" -u <num> Unvoiced speech quality (default=3)\n");
|
||||||
printf (" -xx Expect non-inverted X2-TDMA signal\n");
|
printf (" -xx Expect non-inverted X2-TDMA signal\n");
|
||||||
printf (" -xr Expect inverted DMR signal\n");
|
printf (" -xr Expect inverted DMR signal\n");
|
||||||
@@ -922,9 +1036,10 @@ usage ()
|
|||||||
//printf (" (4 Level, not 8 Level LSM) (this is honestly unknown since I can't verify what local systems are using)\n");
|
//printf (" (4 Level, not 8 Level LSM) (this is honestly unknown since I can't verify what local systems are using)\n");
|
||||||
printf (" -F Relax P25 Phase 2 MAC_SIGNAL CRC Checksum Pass/Fail\n");
|
printf (" -F Relax P25 Phase 2 MAC_SIGNAL CRC Checksum Pass/Fail\n");
|
||||||
printf (" Use this feature to allow MAC_SIGNAL even if CRC errors.\n");
|
printf (" Use this feature to allow MAC_SIGNAL even if CRC errors.\n");
|
||||||
printf (" -F Relax DMR CACH/Burst FEC Pass/Fail - Passive Frame Sync\n");
|
printf (" -F Relax DMR RAS/CRC CSBK/DATA Pass/Fail\n");
|
||||||
printf (" Use if skipping occurs, but may cause wonky audio due to loss of good sync\n");
|
printf (" Enabling on some systems could lead to bad voice/data decoding if bad or marginal signal\n");
|
||||||
|
printf (" -F Relax NXDN SACCH/FACCH/CAC/F2U CRC Pass/Fail\n");
|
||||||
|
printf (" Not recommended on NXDN, but can be bypassed if desired.\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" -K <dec> Manually Enter Basic Privacy Key (Decimal Value of Key Number)\n");
|
printf (" -K <dec> Manually Enter Basic Privacy Key (Decimal Value of Key Number)\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
@@ -934,9 +1049,12 @@ usage ()
|
|||||||
printf (" -H '736B9A9C5645288B 243AD5CB8701EF8A' \n");
|
printf (" -H '736B9A9C5645288B 243AD5CB8701EF8A' \n");
|
||||||
printf (" -H '20029736A5D91042 C923EB0697484433 005EFC58A1905195 E28E9C7836AA2DB8' \n");
|
printf (" -H '20029736A5D91042 C923EB0697484433 005EFC58A1905195 E28E9C7836AA2DB8' \n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" -R <dec> Manually Enter NXDN 4800/9600 EHR Scrambler Key Value (Decimal Value)\n");
|
printf (" -R <dec> Manually Enter dPMR or NXDN EHR Scrambler Key Value (Decimal Value)\n");
|
||||||
printf (" \n");
|
printf (" \n");
|
||||||
printf (" -4 Force Privacy Key over FID and SVC bits \n");
|
printf (" -k <file> Import Key List from csv file.\n");
|
||||||
|
printf (" Only supports NXDN, DMR Basic Privacy and **tera 10-Char (decimal value) only. \n");
|
||||||
|
printf (" (dPMR and **tera 32/64 char not supported, DMR uses TG value as key id -- EXPERIMENTAL!!). \n");
|
||||||
|
printf (" -4 Force DMR Privacy Key over FID and SVC bits \n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" Trunking Options:\n");
|
printf (" Trunking Options:\n");
|
||||||
printf (" -C <file> Import Channel to Frequency Map (channum, freq) from csv file. (Capital C) \n");
|
printf (" -C <file> Import Channel to Frequency Map (channum, freq) from csv file. (Capital C) \n");
|
||||||
@@ -944,6 +1062,9 @@ usage ()
|
|||||||
printf (" -G <file> Import Group List Allow/Block and Label from csv file.\n");
|
printf (" -G <file> Import Group List Allow/Block and Label from csv file.\n");
|
||||||
printf (" (See group.csv for example)\n");
|
printf (" (See group.csv for example)\n");
|
||||||
printf (" -T Enable Trunking Features (NXDN/P25/EDACS/DMR) with RIGCTL/TCP or RTL Input\n");
|
printf (" -T Enable Trunking Features (NXDN/P25/EDACS/DMR) with RIGCTL/TCP or RTL Input\n");
|
||||||
|
printf (" -Y Enable Fast Scanning Mode with RIGCTL/TCP or RTL Input (Lower z) \n");
|
||||||
|
printf (" Experimental -- Can only scan for sync with enabled decoders, don't mix NXDN and DMR/P25!\n");
|
||||||
|
printf (" This is not a Trunking Feature, just scans through conventional frequencies fast!\n");
|
||||||
printf (" -W Use Imported Group List as a Trunking Allow/White List -- Only Tune with Mode A\n");
|
printf (" -W Use Imported Group List as a Trunking Allow/White List -- Only Tune with Mode A\n");
|
||||||
printf (" -p Disable Tune to Private Calls (DMR TIII and P25)\n");
|
printf (" -p Disable Tune to Private Calls (DMR TIII and P25)\n");
|
||||||
printf (" -E Disable Tune to Group Calls (DMR TIII, Con+, Cap+ and P25)\n");
|
printf (" -E Disable Tune to Group Calls (DMR TIII, Con+, Cap+ and P25)\n");
|
||||||
@@ -954,7 +1075,7 @@ usage ()
|
|||||||
printf (" -B <Hertz> Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF)\n");
|
printf (" -B <Hertz> Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF)\n");
|
||||||
printf (" P25 - 7000-12000; P25 (QPSK) - 12000; NXDN48 - 4000; DMR - 7000; EDACS/PV - 12500;\n");
|
printf (" P25 - 7000-12000; P25 (QPSK) - 12000; NXDN48 - 4000; DMR - 7000; EDACS/PV - 12500;\n");
|
||||||
printf (" May vary based on system stregnth, etc.\n");
|
printf (" May vary based on system stregnth, etc.\n");
|
||||||
printf (" -t <secs> Set Trunking VC/sync loss hangtime in seconds. (default = 1 second)\n");
|
printf (" -t <secs> Set Trunking or Fast Scan VC/sync loss hangtime in seconds. (default = 1 second) (decimal values permitted) \n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" Trunking Example TCP: dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
|
printf (" Trunking Example TCP: dsd-fme -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
|
||||||
printf (" Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
|
printf (" Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
|
||||||
@@ -1085,10 +1206,10 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
closeSymbolOutFile (opts, state);
|
closeSymbolOutFile (opts, state);
|
||||||
}
|
}
|
||||||
if (opts->mbe_out_f != NULL)
|
|
||||||
{
|
//close MBE out files
|
||||||
closeMbeOutFile (opts, state);
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
}
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
|
||||||
fprintf (stderr,"\n");
|
fprintf (stderr,"\n");
|
||||||
fprintf (stderr,"Total audio errors: %i\n", state->debug_audio_errors);
|
fprintf (stderr,"Total audio errors: %i\n", state->debug_audio_errors);
|
||||||
@@ -1098,22 +1219,6 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void
|
|
||||||
// sigfun (int sig) //not convinced this is truly required, maybe some environments require it?
|
|
||||||
// {
|
|
||||||
// exitflag = 1;
|
|
||||||
// #ifdef USE_RTLSDR
|
|
||||||
// // if (opts->audio_in_type == 3)
|
|
||||||
// //rtlsdr_sighandler();
|
|
||||||
// #endif
|
|
||||||
// signal (SIGINT, SIG_DFL);
|
|
||||||
// ncursesClose ();
|
|
||||||
|
|
||||||
// // #ifdef USE_RTLSDR
|
|
||||||
// // if (opts->audio_in_type == 3) rtlsdr_sighandler();
|
|
||||||
// // #endif
|
|
||||||
// }
|
|
||||||
|
|
||||||
double atofs(char *s)
|
double atofs(char *s)
|
||||||
{
|
{
|
||||||
char last;
|
char last;
|
||||||
@@ -1167,9 +1272,8 @@ main (int argc, char **argv)
|
|||||||
InitAllFecFunction();
|
InitAllFecFunction();
|
||||||
|
|
||||||
exitflag = 0;
|
exitflag = 0;
|
||||||
// signal (SIGINT, sigfun);
|
|
||||||
|
|
||||||
while ((c = getopt (argc, argv, "haepPqs:t:v:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:VU:Y:K:H:X:NQWrlZTF01:2:345:6:7:89:E")) != -1)
|
while ((c = getopt (argc, argv, "haepPqs:t:v:zi:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:VU:YK:H:X:NQ:WrlZTF01:2:345:6:7:89:Ek:")) != -1)
|
||||||
{
|
{
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
switch (c)
|
switch (c)
|
||||||
@@ -1181,11 +1285,38 @@ main (int argc, char **argv)
|
|||||||
opts.call_alert = 1;
|
opts.call_alert = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Free'd up switches include Q,Y,z
|
//Free'd up switches include z
|
||||||
//make sure to put a colon : after each if they need an argument
|
//make sure to put a colon : after each if they need an argument
|
||||||
//or remove colon if no argument required
|
//or remove colon if no argument required
|
||||||
|
|
||||||
//Disabled the Serial Port Dev and Baud Rate, etc, If somebody uses that function, sorry...
|
case 'Y': //conventional scanner mode
|
||||||
|
opts.scanner_mode = 1; //enable scanner
|
||||||
|
opts.p25_trunk = 0; //turn off trunking mode if user enabled it
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'k': //multi-key loader
|
||||||
|
strncpy(opts.key_in_file, optarg, 1023);
|
||||||
|
opts.key_in_file[1023] = '\0';
|
||||||
|
csvKeyImport(&opts, &state);
|
||||||
|
state.keyloader = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Q': //'DSP' Structured Output file for OKDMRlib
|
||||||
|
sprintf (wav_file_directory, "./DSP");
|
||||||
|
wav_file_directory[1023] = '\0';
|
||||||
|
if (stat(wav_file_directory, &st) == -1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "-Q %s DSP file directory does not exist\n", wav_file_directory);
|
||||||
|
fprintf (stderr, "Creating directory %s to save DSP Structured files\n", wav_file_directory);
|
||||||
|
mkdir(wav_file_directory, 0700); //user read write execute, needs execute for some reason or segfault
|
||||||
|
}
|
||||||
|
//read in filename
|
||||||
|
//sprintf (opts.wav_out_file, "./WAV/DSD-FME-X1.wav");
|
||||||
|
strncpy(dsp_filename, optarg, 1023);
|
||||||
|
sprintf(opts.dsp_out_file, "%s/%s", wav_file_directory, dsp_filename);
|
||||||
|
fprintf (stderr, "Saving DSP Structured files to %s\n", opts.dsp_out_file);
|
||||||
|
opts.use_dsp_output = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
//Enable Audio Smoothing for Upsampled Audio
|
//Enable Audio Smoothing for Upsampled Audio
|
||||||
case '0':
|
case '0':
|
||||||
@@ -1243,6 +1374,7 @@ main (int argc, char **argv)
|
|||||||
case 'T': //new letter assignment for trunking, flow down to allow temp numbers
|
case 'T': //new letter assignment for trunking, flow down to allow temp numbers
|
||||||
case '3':
|
case '3':
|
||||||
opts.p25_trunk = 1;
|
opts.p25_trunk = 1;
|
||||||
|
opts.scanner_mode = 0; //turn off scanner mode if user enabled it
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U': //New letter assignment for RIGCTL TCP port, flow down to allow temp numbers
|
case 'U': //New letter assignment for RIGCTL TCP port, flow down to allow temp numbers
|
||||||
@@ -1251,9 +1383,14 @@ main (int argc, char **argv)
|
|||||||
if (opts.rigctlportno != 0) opts.use_rigctl = 1;
|
if (opts.rigctlportno != 0) opts.use_rigctl = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//NOTE: I changed trunk_hangtime to a float, BUT! time(NULL) returns in second whole numbers
|
||||||
|
//so using anything but whole numbers won't affect the outcome (rounded up?), in the future though,
|
||||||
|
//may change to a different return on sync times and this will matter!
|
||||||
|
|
||||||
case 't': //New letter assignment for Trunk Hangtime, flow down to allow temp numbers
|
case 't': //New letter assignment for Trunk Hangtime, flow down to allow temp numbers
|
||||||
case '6': //hangtime in seconds, default is 1;
|
case '6': //hangtime in seconds, default is 1;
|
||||||
sscanf (optarg, "%d", &opts.trunk_hangtime);
|
sscanf (optarg, "%f", &opts.trunk_hangtime); //updated for float/decimal values
|
||||||
|
fprintf (stderr, "Trunking or Fast Scanner Hang Time set to: %.02f sec\n", opts.trunk_hangtime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q': //New letter assignment for Reverse Mute, flow down to allow temp numbers
|
case 'q': //New letter assignment for Reverse Mute, flow down to allow temp numbers
|
||||||
@@ -1268,41 +1405,6 @@ main (int argc, char **argv)
|
|||||||
if (opts.setmod_bw > 25000) opts.setmod_bw = 25000; //not too high
|
if (opts.setmod_bw > 25000) opts.setmod_bw = 25000; //not too high
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 'e':
|
|
||||||
// opts.errorbars = 1;
|
|
||||||
// opts.datascope = 0;
|
|
||||||
// break;
|
|
||||||
// case 'p':
|
|
||||||
// if (optarg[0] == 'e')
|
|
||||||
// {
|
|
||||||
// opts.p25enc = 1;
|
|
||||||
// }
|
|
||||||
// else if (optarg[0] == 'l')
|
|
||||||
// {
|
|
||||||
// opts.p25lc = 1;
|
|
||||||
// }
|
|
||||||
// else if (optarg[0] == 's')
|
|
||||||
// {
|
|
||||||
// opts.p25status = 1;
|
|
||||||
// }
|
|
||||||
// else if (optarg[0] == 't')
|
|
||||||
// {
|
|
||||||
// opts.p25tg = 1;
|
|
||||||
// }
|
|
||||||
// else if (optarg[0] == 'u')
|
|
||||||
// {
|
|
||||||
// opts.unmute_encrypted_p25 = 1;
|
|
||||||
// fprintf(stderr, "P25 Encrypted Audio Unmuted\n");
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case 'P':
|
|
||||||
// sscanf (optarg, "%d", &opts.rtlsdr_ppm_error);
|
|
||||||
// break;
|
|
||||||
// case 'q':
|
|
||||||
// opts.errorbars = 0;
|
|
||||||
// opts.verbose = 0;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
sscanf (optarg, "%d", &opts.wav_sample_rate);
|
sscanf (optarg, "%d", &opts.wav_sample_rate);
|
||||||
opts.wav_interpolator = opts.wav_sample_rate / opts.wav_decimator;
|
opts.wav_interpolator = opts.wav_sample_rate / opts.wav_decimator;
|
||||||
@@ -1310,12 +1412,6 @@ main (int argc, char **argv)
|
|||||||
state.symbolCenter = state.symbolCenter * opts.wav_interpolator;
|
state.symbolCenter = state.symbolCenter * opts.wav_interpolator;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 't':
|
|
||||||
// opts.symboltiming = 1;
|
|
||||||
// opts.errorbars = 1;
|
|
||||||
// opts.datascope = 0;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
sscanf (optarg, "%d", &opts.verbose);
|
sscanf (optarg, "%d", &opts.verbose);
|
||||||
break;
|
break;
|
||||||
@@ -1341,17 +1437,9 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
sscanf (optarg, "%lld", &state.R);
|
sscanf (optarg, "%lld", &state.R);
|
||||||
if (state.R > 0x7FFF)
|
if (state.R > 0x7FFF) state.R = 0x7FFF;
|
||||||
{
|
//disable keyloader in case user tries to use this and it at the same time
|
||||||
state.R = 0x7FFF;
|
state.keyloader = 0;
|
||||||
}
|
|
||||||
// opts.dmr_mute_encL = 0;
|
|
||||||
// opts.dmr_mute_encR = 0;
|
|
||||||
if (state.R == 0)
|
|
||||||
{
|
|
||||||
// opts.dmr_mute_encL = 1;
|
|
||||||
// opts.dmr_mute_encR = 1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H':
|
case 'H':
|
||||||
@@ -1394,30 +1482,6 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 'G': //Set rtl device gain
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_gain_value); //multiple value by ten to make it consitent with the way rtl_fm really works
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'L': //Set rtl squelch level
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_squelch_level); //set squelch by user to prevent false positives on NXDN and others
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'V': //Set rtl voltage level
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_volume_multiplier); //set 'volume' multiplier for rtl-sdr samples
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'U': //Set rtl udp remote port
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_udp_port); //set udp port number for RTL remote
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'D': //Set rtl device index number
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_dev_index);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'Y': //Set rtl VFO bandwidth --recommend 6, 12, 24, 36, 48, default 48? or 12?
|
|
||||||
// sscanf (optarg, "%d", &opts.rtl_bandwidth);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
opts.use_ncurses_terminal = 1;
|
opts.use_ncurses_terminal = 1;
|
||||||
fprintf (stderr,"Enabling NCurses Terminal.\n");
|
fprintf (stderr,"Enabling NCurses Terminal.\n");
|
||||||
@@ -1440,7 +1504,7 @@ main (int argc, char **argv)
|
|||||||
wav_file_directory[1023] = '\0';
|
wav_file_directory[1023] = '\0';
|
||||||
if (stat(wav_file_directory, &st) == -1)
|
if (stat(wav_file_directory, &st) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "-T %s WAV file directory does not exist\n", wav_file_directory);
|
fprintf (stderr, "-P %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);
|
fprintf (stderr, "Creating directory %s to save decoded wav files\n", wav_file_directory);
|
||||||
mkdir(wav_file_directory, 0700); //user read write execute, needs execute for some reason or segfault
|
mkdir(wav_file_directory, 0700); //user read write execute, needs execute for some reason or segfault
|
||||||
}
|
}
|
||||||
@@ -1455,24 +1519,12 @@ main (int argc, char **argv)
|
|||||||
case 'F':
|
case 'F':
|
||||||
opts.aggressive_framesync = 0;
|
opts.aggressive_framesync = 0;
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
//fprintf (stderr,"DMR Stereo Aggressive Resync Disabled!\n");
|
fprintf (stderr, "Relax P25 Phase 2 MAC_SIGNAL CRC Pass/Fail\n");
|
||||||
fprintf (stderr, "Relax P25 Phase 2 MAC_SIGNAL CRC Checksum Pass/Fail\n");
|
fprintf (stderr, "Relax DMR RAS/CRC CSBK/DATA Pass/Fail\n");
|
||||||
fprintf (stderr, "Relax DMR CACH/Burst FEC Pass/Fail\n");
|
fprintf (stderr, "Relax NXDN SACCH/FACCH/CAC/F2U CRC Pass/Fail\n");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 'z':
|
|
||||||
// sscanf (optarg, "%d", &opts.scoperate);
|
|
||||||
// opts.errorbars = 0;
|
|
||||||
// opts.p25enc = 0;
|
|
||||||
// opts.p25lc = 0;
|
|
||||||
// opts.p25status = 0;
|
|
||||||
// opts.p25tg = 0;
|
|
||||||
// opts.datascope = 1;
|
|
||||||
// opts.symboltiming = 0;
|
|
||||||
// fprintf (stderr,"Setting datascope frame rate to %i frame per second.\n", opts.scoperate);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
strncpy(opts.audio_in_dev, optarg, 2047);
|
strncpy(opts.audio_in_dev, optarg, 2047);
|
||||||
opts.audio_in_dev[2047] = '\0';
|
opts.audio_in_dev[2047] = '\0';
|
||||||
@@ -1494,11 +1546,6 @@ main (int argc, char **argv)
|
|||||||
// fprintf (stderr,"Writing mbe data temporarily disabled!\n");
|
// fprintf (stderr,"Writing mbe data temporarily disabled!\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 'c':
|
|
||||||
// opts.rtlsdr_center_freq = (uint32_t)atofs(optarg);
|
|
||||||
// fprintf (stderr,"Tuning to frequency: %i Hz\n", opts.rtlsdr_center_freq);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 'c': //now is symbol capture bin output like FME Lite
|
case 'c': //now is symbol capture bin output like FME Lite
|
||||||
strncpy(opts.symbol_out_file, optarg, 1023);
|
strncpy(opts.symbol_out_file, optarg, 1023);
|
||||||
opts.symbol_out_file[1023] = '\0';
|
opts.symbol_out_file[1023] = '\0';
|
||||||
@@ -1537,15 +1584,6 @@ main (int argc, char **argv)
|
|||||||
openWavOutFile (&opts, &state);
|
openWavOutFile (&opts, &state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case 'B':
|
|
||||||
// sscanf (optarg, "%d", &opts.serial_baud);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 'C':
|
|
||||||
// strncpy(opts.serial_dev, optarg, 1023);
|
|
||||||
// opts.serial_dev[1023] = '\0';
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (optarg[0] == 'a')
|
if (optarg[0] == 'a')
|
||||||
{
|
{
|
||||||
@@ -1564,7 +1602,7 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 0;
|
opts.dmr_stereo = 0;
|
||||||
opts.dmr_mono = 1;
|
opts.dmr_mono = 1;
|
||||||
state.dmr_stereo = 0;
|
state.dmr_stereo = 0;
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 7000;
|
||||||
sprintf (opts.output_name, "Legacy Auto");
|
sprintf (opts.output_name, "Legacy Auto");
|
||||||
}
|
}
|
||||||
else if (optarg[0] == 'd')
|
else if (optarg[0] == 'd')
|
||||||
@@ -1631,7 +1669,7 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 0;
|
opts.dmr_stereo = 0;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
state.dmr_stereo = 0;
|
state.dmr_stereo = 0;
|
||||||
opts.setmod_bw = 12500;
|
// opts.setmod_bw = 12500;
|
||||||
sprintf (opts.output_name, "EDACS/PV");
|
sprintf (opts.output_name, "EDACS/PV");
|
||||||
fprintf (stderr,"Setting symbol rate to 9600 / second\n");
|
fprintf (stderr,"Setting symbol rate to 9600 / second\n");
|
||||||
fprintf (stderr,"Decoding only ProVoice frames.\n");
|
fprintf (stderr,"Decoding only ProVoice frames.\n");
|
||||||
@@ -1658,7 +1696,9 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
opts.pulse_digi_rate_out = 48000;
|
opts.pulse_digi_rate_out = 48000;
|
||||||
opts.pulse_digi_out_channels = 1;
|
opts.pulse_digi_out_channels = 1;
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 12000;
|
||||||
|
opts.ssize = 36; //128 current default, fall back to old default on P1 only systems
|
||||||
|
opts.msize = 15; //1024 current default, fall back to old default on P1 only systems
|
||||||
sprintf (opts.output_name, "P25P1");
|
sprintf (opts.output_name, "P25P1");
|
||||||
fprintf (stderr,"Decoding only P25 Phase 1 frames.\n");
|
fprintf (stderr,"Decoding only P25 Phase 1 frames.\n");
|
||||||
}
|
}
|
||||||
@@ -1685,7 +1725,7 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 0;
|
opts.dmr_stereo = 0;
|
||||||
state.dmr_stereo = 0;
|
state.dmr_stereo = 0;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
opts.setmod_bw = 4000;
|
// opts.setmod_bw = 4000; //causing issues
|
||||||
sprintf (opts.output_name, "NXDN48");
|
sprintf (opts.output_name, "NXDN48");
|
||||||
fprintf (stderr,"Setting symbol rate to 2400 / second\n");
|
fprintf (stderr,"Setting symbol rate to 2400 / second\n");
|
||||||
fprintf (stderr,"Decoding only NXDN 4800 baud frames.\n");
|
fprintf (stderr,"Decoding only NXDN 4800 baud frames.\n");
|
||||||
@@ -1739,7 +1779,7 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 1;
|
opts.dmr_stereo = 1;
|
||||||
state.dmr_stereo = 0;
|
state.dmr_stereo = 0;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 12000;
|
||||||
sprintf (opts.output_name, "P25P2");
|
sprintf (opts.output_name, "P25P2");
|
||||||
fprintf (stderr,"Decoding P25-P2 frames C4FM or OP25 Symbol Captures!\n");
|
fprintf (stderr,"Decoding P25-P2 frames C4FM or OP25 Symbol Captures!\n");
|
||||||
}
|
}
|
||||||
@@ -1763,7 +1803,6 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 1;
|
opts.dmr_stereo = 1;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
// opts.setmod_bw = 7000;
|
// opts.setmod_bw = 7000;
|
||||||
opts.setmod_bw = 7000;
|
|
||||||
opts.pulse_digi_rate_out = 24000;
|
opts.pulse_digi_rate_out = 24000;
|
||||||
opts.pulse_digi_out_channels = 2;
|
opts.pulse_digi_out_channels = 2;
|
||||||
sprintf (opts.output_name, "DMR Stereo");
|
sprintf (opts.output_name, "DMR Stereo");
|
||||||
@@ -1790,7 +1829,7 @@ main (int argc, char **argv)
|
|||||||
state.rf_mod = 0;
|
state.rf_mod = 0;
|
||||||
opts.dmr_stereo = 1;
|
opts.dmr_stereo = 1;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 12000; //safe default on both DMR and P25
|
||||||
opts.pulse_digi_rate_out = 24000;
|
opts.pulse_digi_rate_out = 24000;
|
||||||
opts.pulse_digi_out_channels = 2;
|
opts.pulse_digi_out_channels = 2;
|
||||||
sprintf (opts.output_name, "XDMA");
|
sprintf (opts.output_name, "XDMA");
|
||||||
@@ -1817,7 +1856,7 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_stereo = 0;
|
opts.dmr_stereo = 0;
|
||||||
opts.dmr_mono = 0;
|
opts.dmr_mono = 0;
|
||||||
state.dmr_stereo = 0;
|
state.dmr_stereo = 0;
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 7000; //causing issues
|
||||||
sprintf (opts.output_name, "NXDN96");
|
sprintf (opts.output_name, "NXDN96");
|
||||||
fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n");
|
fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n");
|
||||||
}
|
}
|
||||||
@@ -1842,32 +1881,10 @@ main (int argc, char **argv)
|
|||||||
opts.dmr_mono = 1;
|
opts.dmr_mono = 1;
|
||||||
opts.dmr_stereo = 0;
|
opts.dmr_stereo = 0;
|
||||||
state.dmr_stereo = 0; //0
|
state.dmr_stereo = 0; //0
|
||||||
opts.setmod_bw = 7000;
|
// opts.setmod_bw = 7000;
|
||||||
sprintf (opts.output_name, "DMR Mono");
|
sprintf (opts.output_name, "DMR Mono");
|
||||||
//fprintf(stderr, "Notice: DMR cannot autodetect polarity. \n Use -xr option if Inverted Signal expected.\n");
|
fprintf(stderr, "Notice: DMR cannot autodetect polarity. \n Use -xr option if Inverted Signal expected.\n");
|
||||||
fprintf (stderr,"Decoding only DMR Mono. \nUsing DMR Stereo or XDMA is highly encouraged.\n");
|
fprintf (stderr,"Decoding only DMR Mono. \nUsing DMR Stereo or XDMA is highly encouraged.\n");
|
||||||
//dmr stereo below
|
|
||||||
// opts.frame_dstar = 0;
|
|
||||||
// opts.frame_x2tdma = 0;
|
|
||||||
// opts.frame_p25p1 = 0;
|
|
||||||
// opts.frame_p25p2 = 0;
|
|
||||||
// opts.inverted_p2 = 0;
|
|
||||||
// opts.frame_nxdn48 = 0;
|
|
||||||
// opts.frame_nxdn96 = 0;
|
|
||||||
// opts.frame_dmr = 1;
|
|
||||||
// opts.frame_dpmr = 0;
|
|
||||||
// opts.frame_provoice = 0;
|
|
||||||
// opts.frame_ysf = 0;
|
|
||||||
// opts.mod_c4fm = 1;
|
|
||||||
// opts.mod_qpsk = 0;
|
|
||||||
// opts.mod_gfsk = 0;
|
|
||||||
// state.rf_mod = 0;
|
|
||||||
// opts.dmr_stereo = 1;
|
|
||||||
// state.dmr_stereo = 0;
|
|
||||||
// opts.pulse_digi_rate_out = 24000;
|
|
||||||
// opts.pulse_digi_out_channels = 2;
|
|
||||||
// sprintf (opts.output_name, "DMR Stereo");
|
|
||||||
// fprintf (stderr,"Decoding DMR Stereo BS/MS Simplex\n");
|
|
||||||
}
|
}
|
||||||
else if (optarg[0] == 'm')
|
else if (optarg[0] == 'm')
|
||||||
{
|
{
|
||||||
@@ -1897,14 +1914,14 @@ main (int argc, char **argv)
|
|||||||
fprintf(stderr, "Decoding only dPMR frames.\n");
|
fprintf(stderr, "Decoding only dPMR frames.\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//don't mess with the modulations, doesn't really do anything meaningful anyways
|
//don't mess with the modulations unless you really need to
|
||||||
case 'm':
|
case 'm':
|
||||||
if (optarg[0] == 'a')
|
if (optarg[0] == 'a')
|
||||||
{
|
{
|
||||||
// opts.mod_c4fm = 1;
|
opts.mod_c4fm = 1;
|
||||||
// opts.mod_qpsk = 1;
|
opts.mod_qpsk = 1;
|
||||||
// opts.mod_gfsk = 1;
|
opts.mod_gfsk = 1;
|
||||||
// state.rf_mod = 0;
|
state.rf_mod = 0;
|
||||||
fprintf (stderr,"Don't use the -ma switch.\n");
|
fprintf (stderr,"Don't use the -ma switch.\n");
|
||||||
}
|
}
|
||||||
else if (optarg[0] == 'c')
|
else if (optarg[0] == 'c')
|
||||||
@@ -1929,7 +1946,7 @@ main (int argc, char **argv)
|
|||||||
opts.mod_qpsk = 1;
|
opts.mod_qpsk = 1;
|
||||||
opts.mod_gfsk = 0;
|
opts.mod_gfsk = 0;
|
||||||
state.rf_mod = 1;
|
state.rf_mod = 1;
|
||||||
opts.setmod_bw = 12000;
|
// opts.setmod_bw = 12000;
|
||||||
fprintf (stderr,"Enabling only QPSK modulation optimizations.\n");
|
fprintf (stderr,"Enabling only QPSK modulation optimizations.\n");
|
||||||
}
|
}
|
||||||
else if (optarg[0] == '2')
|
else if (optarg[0] == '2')
|
||||||
@@ -1940,9 +1957,32 @@ main (int argc, char **argv)
|
|||||||
state.rf_mod = 1;
|
state.rf_mod = 1;
|
||||||
state.samplesPerSymbol = 8;
|
state.samplesPerSymbol = 8;
|
||||||
state.symbolCenter = 3;
|
state.symbolCenter = 3;
|
||||||
opts.setmod_bw = 12000;
|
// opts.setmod_bw = 12000;
|
||||||
fprintf (stderr,"Enabling 6000 sps P25p2 CQPSK.\n");
|
fprintf (stderr,"Enabling 6000 sps P25p2 CQPSK.\n");
|
||||||
}
|
}
|
||||||
|
//test
|
||||||
|
else if (optarg[0] == '3')
|
||||||
|
{
|
||||||
|
opts.mod_c4fm = 1;
|
||||||
|
opts.mod_qpsk = 0;
|
||||||
|
opts.mod_gfsk = 0;
|
||||||
|
state.rf_mod = 0;
|
||||||
|
state.samplesPerSymbol = 10;
|
||||||
|
state.symbolCenter = 4;
|
||||||
|
// opts.setmod_bw = 12000;
|
||||||
|
fprintf (stderr,"Enabling 6000 sps P25p2 C4FM.\n");
|
||||||
|
}
|
||||||
|
else if (optarg[0] == '4')
|
||||||
|
{
|
||||||
|
opts.mod_c4fm = 1;
|
||||||
|
opts.mod_qpsk = 1;
|
||||||
|
opts.mod_gfsk = 1;
|
||||||
|
state.rf_mod = 0;
|
||||||
|
state.samplesPerSymbol = 8;
|
||||||
|
state.symbolCenter = 3;
|
||||||
|
// opts.setmod_bw = 12000;
|
||||||
|
fprintf (stderr,"Enabling 6000 sps P25p2 all optimizations.\n");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
sscanf (optarg, "%i", &opts.uvquality);
|
sscanf (optarg, "%i", &opts.uvquality);
|
||||||
@@ -2264,6 +2304,7 @@ main (int argc, char **argv)
|
|||||||
opts.pulse_digi_rate_out = 48000;
|
opts.pulse_digi_rate_out = 48000;
|
||||||
opts.pulse_digi_out_channels = 1;
|
opts.pulse_digi_out_channels = 1;
|
||||||
openPulseOutput(&opts); //need to open it up for output
|
openPulseOutput(&opts); //need to open it up for output
|
||||||
|
state.aout_gain = 25; //BUGFIX: No audio output when playing back .amb/.imb files
|
||||||
playMbeFiles (&opts, &state, argc, argv);
|
playMbeFiles (&opts, &state, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
270
src/dsd_mbe.c
270
src/dsd_mbe.c
@@ -17,8 +17,42 @@
|
|||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
|
||||||
void
|
int Pr[256] = {
|
||||||
playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
void playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -26,99 +60,79 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
|
|||||||
char ambe_d[49];
|
char ambe_d[49];
|
||||||
|
|
||||||
for (i = state->optind; i < argc; i++)
|
for (i = state->optind; i < argc; i++)
|
||||||
|
{
|
||||||
|
sprintf (opts->mbe_in_file, "%s", argv[i]);
|
||||||
|
openMbeInFile (opts, state);
|
||||||
|
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||||
|
fprintf (stderr, "playing %s\n", opts->mbe_in_file);
|
||||||
|
while (feof (opts->mbe_in_f) == 0)
|
||||||
{
|
{
|
||||||
sprintf (opts->mbe_in_file, "%s", argv[i]);
|
if (state->mbe_file_type == 0)
|
||||||
openMbeInFile (opts, state);
|
{
|
||||||
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
readImbe4400Data (opts, state, imbe_d);
|
||||||
fprintf (stderr, "playing %s\n", opts->mbe_in_file);
|
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);
|
||||||
while (feof (opts->mbe_in_f) == 0)
|
if (opts->audio_out == 1)
|
||||||
{
|
{
|
||||||
if (state->mbe_file_type == 0)
|
processAudio(opts, state);
|
||||||
{
|
|
||||||
readImbe4400Data (opts, state, 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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (state->mbe_file_type == 1)
|
|
||||||
{
|
|
||||||
readAmbe2450Data (opts, state, ambe_d);
|
|
||||||
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 (opts->audio_out == 1)
|
|
||||||
{
|
|
||||||
processAudio(opts, state);
|
|
||||||
}
|
|
||||||
if (opts->wav_out_f != NULL)
|
|
||||||
{
|
|
||||||
writeSynthesizedVoice (opts, state);
|
|
||||||
}
|
|
||||||
if (opts->audio_out == 1)
|
|
||||||
{
|
|
||||||
playSynthesizedVoice (opts, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (exitflag == 1)
|
|
||||||
{
|
|
||||||
cleanupAndExit (opts, state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (opts->wav_out_f != NULL)
|
||||||
|
{
|
||||||
|
writeSynthesizedVoice (opts, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
playSynthesizedVoice (opts, state);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state->mbe_file_type > 0) //ambe files
|
||||||
|
{
|
||||||
|
readAmbe2450Data (opts, state, ambe_d);
|
||||||
|
int j, x;
|
||||||
|
unsigned long long int k;
|
||||||
|
if (state->K != 0) //apply Pr key
|
||||||
|
{
|
||||||
|
k = Pr[state->K];
|
||||||
|
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
|
||||||
|
for (short int j = 0; j < 48; j++) //49
|
||||||
|
{
|
||||||
|
x = ( ((k << j) & 0x800000000000) >> 47 );
|
||||||
|
ambe_d[j] ^= x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//ambe+2
|
||||||
|
if (state->mbe_file_type == 1) 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);
|
||||||
|
//dstar ambe
|
||||||
|
if (state->mbe_file_type == 2) mbe_processAmbe2400Dataf (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 (opts->audio_out == 1)
|
||||||
|
{
|
||||||
|
processAudio(opts, state);
|
||||||
|
}
|
||||||
|
if (opts->wav_out_f != NULL)
|
||||||
|
{
|
||||||
|
writeSynthesizedVoice (opts, state);
|
||||||
|
}
|
||||||
|
if (opts->audio_out == 1)
|
||||||
|
{
|
||||||
|
playSynthesizedVoice (opts, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exitflag == 1)
|
||||||
|
{
|
||||||
|
cleanupAndExit (opts, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24])
|
processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24])
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
|
||||||
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
|
|
||||||
};
|
|
||||||
//
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char imbe_d[88];
|
char imbe_d[88];
|
||||||
char ambe_d[49];
|
char ambe_d[49];
|
||||||
@@ -126,6 +140,10 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
unsigned long long int k;
|
unsigned long long int k;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
//24-bit TG to 16-bit hash
|
||||||
|
uint32_t hash = 0;
|
||||||
|
uint8_t hash_bits[24];
|
||||||
|
memset (hash_bits, 0, sizeof(hash_bits));
|
||||||
|
|
||||||
for (i = 0; i < 88; i++)
|
for (i = 0; i < 88; i++)
|
||||||
{
|
{
|
||||||
@@ -197,17 +215,16 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
//state->errs2 = state->errs;
|
//state->errs2 = state->errs;
|
||||||
mbe_demodulateImbe7100x4400Data (imbe7100_fr);
|
mbe_demodulateImbe7100x4400Data (imbe7100_fr);
|
||||||
state->errs2 = mbe_eccImbe7100x4400Data (imbe7100_fr, imbe_d);
|
state->errs2 = mbe_eccImbe7100x4400Data (imbe7100_fr, imbe_d);
|
||||||
mbe_convertImbe7100to7200(imbe_d); //needs extra conversion step apparently
|
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
PrintIMBEData (opts, state, imbe_d);
|
||||||
|
}
|
||||||
|
|
||||||
|
mbe_convertImbe7100to7200(imbe_d);
|
||||||
mbe_processImbe4400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str,
|
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);
|
imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||||
|
|
||||||
//below line the old way of doing this
|
|
||||||
// mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
|
||||||
if (opts->payload == 1)
|
|
||||||
{
|
|
||||||
PrintIMBEData (opts, state, imbe_d);
|
|
||||||
}
|
|
||||||
if (opts->mbe_out_f != NULL)
|
if (opts->mbe_out_f != NULL)
|
||||||
{
|
{
|
||||||
saveImbe4400Data (opts, state, imbe_d);
|
saveImbe4400Data (opts, state, imbe_d);
|
||||||
@@ -277,6 +294,34 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
mbe_demodulateAmbe3600x2450Data (ambe_fr);
|
mbe_demodulateAmbe3600x2450Data (ambe_fr);
|
||||||
state->errs2 = mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
|
state->errs2 = mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
|
||||||
|
|
||||||
|
//EXPERIMENTAL!!
|
||||||
|
//load basic privacy key number from array by the tg value (if not forced)
|
||||||
|
//currently only Moto BP and Hytera 10 Char BP (converted to decimal)
|
||||||
|
if (state->M == 0)
|
||||||
|
{
|
||||||
|
//see if we need to hash a value larger than 16-bits
|
||||||
|
hash = state->lasttg & 0xFFFFFF;
|
||||||
|
// fprintf (stderr, "TG: %lld Hash: %ld ", state->lasttg, hash);
|
||||||
|
if (hash > 0xFFFF) //if greater than 16-bits
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
hash_bits[i] = ((hash << i) & 0x800000) >> 23; //load into array for CRC16
|
||||||
|
}
|
||||||
|
hash = ComputeCrcCCITT16d (hash_bits, 24);
|
||||||
|
hash = hash & 0xFFFF; //make sure its no larger than 16-bits
|
||||||
|
// fprintf (stderr, "Hash: %d ", hash);
|
||||||
|
}
|
||||||
|
if (state->rkey_array[hash] != 0)
|
||||||
|
{
|
||||||
|
state->K = state->rkey_array[hash] & 0xFF; //doesn't exceed 255
|
||||||
|
state->K1 = state->H = state->rkey_array[hash] & 0xFFFFFFFFFF; //doesn't exceed 40-bit limit
|
||||||
|
opts->dmr_mute_encL = 0;
|
||||||
|
// fprintf (stderr, "Key: %X ", state->rkey_array[hash]);
|
||||||
|
}
|
||||||
|
// else opts->dmr_mute_encL = 1; //may cause issues for manual key entry (non-csv)
|
||||||
|
}
|
||||||
|
|
||||||
if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) ||
|
if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) ||
|
||||||
(state->K > 0 && state->M == 1) )
|
(state->K > 0 && state->M == 1) )
|
||||||
{
|
{
|
||||||
@@ -362,6 +407,13 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
{
|
{
|
||||||
PrintAMBEData (opts, state, ambe_d);
|
PrintAMBEData (opts, state, ambe_d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//restore MBE file save, slot 1 -- consider saving even if enc
|
||||||
|
if (opts->mbe_out_f != NULL && (state->dmr_encL == 0 || opts->dmr_mute_encL == 0) )
|
||||||
|
{
|
||||||
|
saveAmbe2450Data (opts, state, ambe_d);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//stereo slots and slot 1 (right slot)
|
//stereo slots and slot 1 (right slot)
|
||||||
if (state->currentslot == 1) //&& opts->dmr_stereo == 1
|
if (state->currentslot == 1) //&& opts->dmr_stereo == 1
|
||||||
@@ -372,6 +424,34 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
mbe_demodulateAmbe3600x2450Data (ambe_fr);
|
mbe_demodulateAmbe3600x2450Data (ambe_fr);
|
||||||
state->errs2R = mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
|
state->errs2R = mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
|
||||||
|
|
||||||
|
//EXPERIMENTAL!!
|
||||||
|
//load basic privacy key number from array by the tg value (if not forced)
|
||||||
|
//currently only Moto BP and Hytera 10 Char BP (converted to decimal)
|
||||||
|
if (state->M == 0)
|
||||||
|
{
|
||||||
|
//see if we need to hash a value larger than 16-bits
|
||||||
|
hash = state->lasttgR & 0xFFFFFF;
|
||||||
|
// fprintf (stderr, "TG: %lld Hash: %ld ", state->lasttgR, hash);
|
||||||
|
if (hash > 0xFFFF) //if greater than 16-bits
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
hash_bits[i] = ((hash << i) & 0x800000) >> 23; //load into array for CRC16
|
||||||
|
}
|
||||||
|
hash = ComputeCrcCCITT16d (hash_bits, 24);
|
||||||
|
hash = hash & 0xFFFF; //make sure its no larger than 16-bits
|
||||||
|
// fprintf (stderr, "Hash: %d ", hash);
|
||||||
|
}
|
||||||
|
if (state->rkey_array[hash] != 0)
|
||||||
|
{
|
||||||
|
state->K = state->rkey_array[hash] & 0xFF; //doesn't exceed 255
|
||||||
|
state->K1 = state->H = state->rkey_array[hash] & 0xFFFFFFFFFF; //doesn't exceed 40-bit limit
|
||||||
|
opts->dmr_mute_encR = 0;
|
||||||
|
// fprintf (stderr, "Key: %X ", state->rkey_array[hash]);
|
||||||
|
}
|
||||||
|
// else opts->dmr_mute_encR = 1; //may cause issues for manual key entry (non-csv)
|
||||||
|
}
|
||||||
|
|
||||||
if ( (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ||
|
if ( (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ||
|
||||||
(state->K > 0 && state->M == 1) )
|
(state->K > 0 && state->M == 1) )
|
||||||
{
|
{
|
||||||
@@ -456,6 +536,12 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
|||||||
{
|
{
|
||||||
PrintAMBEData (opts, state, ambe_d);
|
PrintAMBEData (opts, state, ambe_d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//restore MBE file save, slot 2 -- consider saving even if enc
|
||||||
|
if (opts->mbe_out_fR != NULL && (state->dmr_encR == 0 || opts->dmr_mute_encR == 0) )
|
||||||
|
{
|
||||||
|
saveAmbe2450DataR (opts, state, ambe_d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//X2-TDMA? Not sure what still makes it this far to run under Framef
|
//X2-TDMA? Not sure what still makes it this far to run under Framef
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -273,4 +273,9 @@ void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency)
|
|||||||
address.sin_addr.s_addr = inet_addr("127.0.0.1"); //make user configurable later
|
address.sin_addr.s_addr = inet_addr("127.0.0.1"); //make user configurable later
|
||||||
address.sin_port = htons(udp_port);
|
address.sin_port = htons(udp_port);
|
||||||
sendto(handle, data, 5, 0, (const struct sockaddr * ) & address, sizeof(struct sockaddr_in));
|
sendto(handle, data, 5, 0, (const struct sockaddr * ) & address, sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
|
//BUGFIX: This was causing an indefinite number of UDP sockets to stay open on each tune request
|
||||||
|
//we open a new socket with each request, so we need to close the socket after writing to it
|
||||||
|
//this would cause the tuning to stop after x number of tune attempts (few hours? on a busy system)
|
||||||
|
close (handle); //close socket after sending.
|
||||||
}
|
}
|
||||||
@@ -142,16 +142,49 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//tcp socket input from SDR++
|
//tcp socket input from SDR++
|
||||||
else if (opts->audio_in_type == 8)
|
else if (opts->audio_in_type == 8)
|
||||||
{
|
{
|
||||||
result = sf_read_short(opts->tcp_file_in, &sample, 1);
|
result = sf_read_short(opts->tcp_file_in, &sample, 1);
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
sf_close(opts->tcp_file_in);
|
fprintf (stderr, "\nConnection to TCP Server Interrupted. Trying again in 3 seconds.\n");
|
||||||
opts->audio_in_type = 0; //set input type
|
sample = 0;
|
||||||
openPulseInput(opts); //open pulse inpput
|
sf_close(opts->tcp_file_in); //close current connection on this end
|
||||||
sample = 0; //zero sample on bad result, keep the ball rolling
|
sleep (3); //halt all processing and wait 3 seconds
|
||||||
fprintf (stderr, "Connection to TCP Server Disconnected.\n");
|
|
||||||
|
//attempt to reconnect to socket
|
||||||
|
opts->tcp_sockfd = 0;
|
||||||
|
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 Reconnect to TCP with libsndfile: %s\n", sf_strerror(NULL));
|
||||||
|
}
|
||||||
|
else fprintf (stderr, "TCP Socket Reconnected Successfully.\n");
|
||||||
|
}
|
||||||
|
else fprintf (stderr, "TCP Socket Connection Error.\n");
|
||||||
|
|
||||||
|
//now retry reading sample
|
||||||
|
result = sf_read_short(opts->tcp_file_in, &sample, 1);
|
||||||
|
if (result == 0) {
|
||||||
|
sf_close(opts->tcp_file_in);
|
||||||
|
opts->audio_in_type = 0; //set input type
|
||||||
|
opts->tcp_sockfd = 0; //added this line so we will know if it connected when using ncurses terminal keyboard shortcut
|
||||||
|
openPulseInput(opts); //open pulse inpput
|
||||||
|
sample = 0; //zero sample on bad result, keep the ball rolling
|
||||||
|
fprintf (stderr, "Connection to TCP Server Disconnected.\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//UDP Socket input...not working correct. Reads samples, but no sync
|
//UDP Socket input...not working correct. Reads samples, but no sync
|
||||||
|
|||||||
@@ -480,7 +480,8 @@ decode_bch()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long int messagepp = 0x0;
|
//bugfix on 32-bit cygwin, probably overflowed here
|
||||||
|
unsigned long long int messagepp = 0x0;
|
||||||
|
|
||||||
//very simplified version, just to encode, get frame and compare
|
//very simplified version, just to encode, get frame and compare
|
||||||
unsigned long long int edacs_bch (unsigned long long int message)
|
unsigned long long int edacs_bch (unsigned long long int message)
|
||||||
|
|||||||
@@ -47,12 +47,13 @@ char * getTimeE(void) //get pretty hh:mm:ss timestamp
|
|||||||
|
|
||||||
void edacs(dsd_opts * opts, dsd_state * state)
|
void edacs(dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
unsigned long long fr_1 = 0xFFFFFFFFFF; //40-bit frames
|
//changed to ulli here for 32-bit cygwin (not sure if was an issue, but playing it safe)
|
||||||
unsigned long long fr_2 = 0; //each is a 40 bit frame that repeats 3 times
|
unsigned long long int fr_1 = 0xFFFFFFFFFF; //40-bit frames
|
||||||
unsigned long long fr_3 = 0; //two messages per frame
|
unsigned long long int fr_2 = 0; //each is a 40 bit frame that repeats 3 times
|
||||||
unsigned long long fr_4 = 0xFFFFFFFFFF;
|
unsigned long long int fr_3 = 0; //two messages per frame
|
||||||
unsigned long long fr_5 = 0;
|
unsigned long long int fr_4 = 0xFFFFFFFFFF;
|
||||||
unsigned long long fr_6 = 0;
|
unsigned long long int fr_5 = 0;
|
||||||
|
unsigned long long int fr_6 = 0;
|
||||||
|
|
||||||
//BCH stuff
|
//BCH stuff
|
||||||
unsigned long long int fr_1m = 0xFFFFFFF; //28-bit 7X message portion to pass to bch handler
|
unsigned long long int fr_1m = 0xFFFFFFF; //28-bit 7X message portion to pass to bch handler
|
||||||
|
|||||||
@@ -312,11 +312,11 @@ void map_isch()
|
|||||||
isch_map["fb063f092"] = 127;
|
isch_map["fb063f092"] = 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long int isch_lookup (unsigned long long int isch)
|
int isch_lookup (unsigned long long int isch)
|
||||||
{
|
{
|
||||||
map_isch(); //initialize the lookup map
|
map_isch(); //initialize the lookup map
|
||||||
char s[64];
|
char s[64];
|
||||||
unsigned long long int decoded = -2; //initialize lookup to an invalid number
|
int decoded = -2; //initialize lookup to an invalid number
|
||||||
sprintf(s, "%llx", isch);
|
sprintf(s, "%llx", isch);
|
||||||
decoded = isch_map[s];
|
decoded = isch_map[s];
|
||||||
return(decoded);
|
return(decoded);
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ static const unsigned int CNXDNConvolution_NUM_OF_STATES = 16U;
|
|||||||
static const uint32_t CNXDNConvolution_M = 4U;
|
static const uint32_t CNXDNConvolution_M = 4U;
|
||||||
static const unsigned int CNXDNConvolution_K = 5U;
|
static const unsigned int CNXDNConvolution_K = 5U;
|
||||||
|
|
||||||
static uint16_t m_metrics1[16U] = {0};
|
//NOTE:
|
||||||
static uint16_t m_metrics2[16U] = {0};
|
static uint16_t m_metrics1[16U];
|
||||||
static uint64_t m_decisions[300U] = {0};
|
static uint16_t m_metrics2[16U];
|
||||||
|
static uint64_t m_decisions[300U]; //300
|
||||||
static uint16_t * m_oldMetrics = NULL;
|
static uint16_t * m_oldMetrics = NULL;
|
||||||
static uint16_t * m_newMetrics = NULL;
|
static uint16_t * m_newMetrics = NULL;
|
||||||
static uint64_t * m_dp = NULL;
|
static uint64_t * m_dp = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Functions ----------------------------------------------------------------*/
|
/* Functions ----------------------------------------------------------------*/
|
||||||
|
|
||||||
void CNXDNConvolution_decode(uint8_t s0, uint8_t s1)
|
void CNXDNConvolution_decode(uint8_t s0, uint8_t s1)
|
||||||
@@ -158,13 +158,15 @@ void CNXDNConvolution_encode(const unsigned char* in, unsigned char* out, unsign
|
|||||||
|
|
||||||
void CNXDNConvolution_start(void)
|
void CNXDNConvolution_start(void)
|
||||||
{
|
{
|
||||||
memset(m_metrics1, 0x00U, CNXDNConvolution_NUM_OF_STATES * sizeof(uint16_t));
|
|
||||||
memset(m_metrics2, 0x00U, CNXDNConvolution_NUM_OF_STATES * sizeof(uint16_t));
|
|
||||||
|
|
||||||
m_oldMetrics = m_metrics1;
|
m_oldMetrics = m_metrics1;
|
||||||
m_newMetrics = m_metrics2;
|
m_newMetrics = m_metrics2;
|
||||||
m_dp = m_decisions;
|
m_dp = m_decisions;
|
||||||
|
|
||||||
|
memset(m_metrics1, 0x00U, sizeof(m_metrics1));
|
||||||
|
memset(m_metrics2, 0x00U, sizeof(m_metrics2));
|
||||||
|
memset(m_decisions, 0x00U, sizeof(m_decisions));
|
||||||
|
|
||||||
for (int x = 0; x < 4; x++) CNXDNConvolution_decode(0U, 0U);
|
for (int x = 0; x < 4; x++) CNXDNConvolution_decode(0U, 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ static const int PARITY[] = {
|
|||||||
//decoding functions here
|
//decoding functions here
|
||||||
void nxdn_descramble(uint8_t dibits[], int len)
|
void nxdn_descramble(uint8_t dibits[], int len)
|
||||||
{
|
{
|
||||||
for (int i=0; i<sizeof(scramble_t); i++) {
|
for (int i=0; i<len; i++)
|
||||||
|
{
|
||||||
if (scramble_t[i] >= len)
|
if (scramble_t[i] >= len)
|
||||||
break;
|
break;
|
||||||
dibits[scramble_t[i]] ^= 0x2; // invert sign of scrambled dibits
|
dibits[scramble_t[i]] ^= 0x2; // invert sign of scrambled dibits
|
||||||
@@ -51,13 +52,15 @@ void nxdn_descramble(uint8_t dibits[], int len)
|
|||||||
|
|
||||||
void nxdn_deperm_facch(dsd_opts * opts, dsd_state * state, uint8_t bits[144])
|
void nxdn_deperm_facch(dsd_opts * opts, dsd_state * state, uint8_t bits[144])
|
||||||
{
|
{
|
||||||
uint8_t deperm[144];
|
uint8_t deperm[200]; //144
|
||||||
uint8_t depunc[192];
|
uint8_t depunc[200]; //192
|
||||||
uint8_t trellis_buf[96];
|
uint8_t trellis_buf[400]; //96
|
||||||
uint16_t crc = 0; //crc calculated by function
|
uint16_t crc = 0; //crc calculated by function
|
||||||
uint16_t check = 0; //crc from payload for comparison
|
uint16_t check = 0; //crc from payload for comparison
|
||||||
int out;
|
int out;
|
||||||
char buf[128];
|
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
|
||||||
for (int i=0; i<144; i++)
|
for (int i=0; i<144; i++)
|
||||||
deperm[PERM_16_9[i]] = bits[i];
|
deperm[PERM_16_9[i]] = bits[i];
|
||||||
@@ -73,7 +76,7 @@ void nxdn_deperm_facch(dsd_opts * opts, dsd_state * state, uint8_t bits[144])
|
|||||||
uint8_t temp[210];
|
uint8_t temp[210];
|
||||||
uint8_t s0;
|
uint8_t s0;
|
||||||
uint8_t s1;
|
uint8_t s1;
|
||||||
uint8_t m_data[13];
|
uint8_t m_data[20]; //13
|
||||||
memset (temp, 0, sizeof(temp));
|
memset (temp, 0, sizeof(temp));
|
||||||
memset (m_data, 0, sizeof(m_data));
|
memset (m_data, 0, sizeof(m_data));
|
||||||
memset (trellis_buf, 0, sizeof(trellis_buf));
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
@@ -111,17 +114,23 @@ void nxdn_deperm_facch(dsd_opts * opts, dsd_state * state, uint8_t bits[144])
|
|||||||
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load tail 16 bits into check variable to compare vs computed crc value
|
crc = crc12f (trellis_buf, 84); //80
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
check = check << 1;
|
check = check << 1;
|
||||||
check = check + trellis_buf[80+i];
|
check = check | trellis_buf[84+i]; //80
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = crc12f (trellis_buf, 80);
|
if (crc != check)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " FACCH");
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
if (crc == check) NXDN_Elements_Content_decode(opts, state, 1, trellis_buf);
|
if (crc == check) NXDN_Elements_Content_decode(opts, state, 1, trellis_buf);
|
||||||
//else if (opts->payload == 1) NXDN_Elements_Content_decode(opts, state, 0, trellis_buf);
|
else if (opts->aggressive_framesync == 0) NXDN_Elements_Content_decode(opts, state, 0, trellis_buf);
|
||||||
|
|
||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
@@ -131,18 +140,23 @@ void nxdn_deperm_facch(dsd_opts * opts, dsd_state * state, uint8_t bits[144])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "[%02X]", m_data[i]);
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
}
|
}
|
||||||
fprintf (stderr, " - %03X %03X", crc, check);
|
// fprintf (stderr, " - %03X %03X", check, crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//new sacch
|
//sacch
|
||||||
void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
||||||
{
|
{
|
||||||
uint8_t deperm[60];
|
//see about initializing these variables
|
||||||
uint8_t depunc[72];
|
uint8_t deperm[200]; //60
|
||||||
uint8_t trellis_buf[32];
|
uint8_t depunc[200]; //72
|
||||||
uint8_t answer[26];
|
uint8_t trellis_buf[400]; //32
|
||||||
|
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
|
|
||||||
int o = 0;
|
int o = 0;
|
||||||
uint8_t crc = 0; //value computed by crc6 on payload
|
uint8_t crc = 0; //value computed by crc6 on payload
|
||||||
uint8_t check = 0; //value pulled from last 6 bits
|
uint8_t check = 0; //value pulled from last 6 bits
|
||||||
@@ -171,7 +185,7 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
uint8_t temp[90];
|
uint8_t temp[90];
|
||||||
uint8_t s0;
|
uint8_t s0;
|
||||||
uint8_t s1;
|
uint8_t s1;
|
||||||
uint8_t m_data[5];
|
uint8_t m_data[10]; //5
|
||||||
|
|
||||||
memset (temp, 0, sizeof (temp));
|
memset (temp, 0, sizeof (temp));
|
||||||
memset (m_data, 0, sizeof (m_data));
|
memset (m_data, 0, sizeof (m_data));
|
||||||
@@ -188,7 +202,7 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
}
|
}
|
||||||
|
|
||||||
CNXDNConvolution_start();
|
CNXDNConvolution_start();
|
||||||
for (int i = 0U; i < 40U; i++)
|
for (int i = 0U; i < 36U; i++) //40
|
||||||
{
|
{
|
||||||
s0 = temp[(2*i)];
|
s0 = temp[(2*i)];
|
||||||
s1 = temp[(2*i)+1];
|
s1 = temp[(2*i)+1];
|
||||||
@@ -197,7 +211,7 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
}
|
}
|
||||||
|
|
||||||
//stored as 5 bytes, will need to convert to trellis_buf after running
|
//stored as 5 bytes, will need to convert to trellis_buf after running
|
||||||
CNXDNConvolution_chainback(m_data, 36U);
|
CNXDNConvolution_chainback(m_data, 32U); //36
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
@@ -211,11 +225,11 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = crc6(trellis_buf, 32);
|
crc = crc6(trellis_buf, 26); //32
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
check = check << 1;
|
check = check << 1;
|
||||||
check = check + trellis_buf[i+26];
|
check = check | trellis_buf[i+26];
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIRST! If part of a non_superframe, and CRC is good, send directly to NXDN_Elements_Content_decode
|
//FIRST! If part of a non_superframe, and CRC is good, send directly to NXDN_Elements_Content_decode
|
||||||
@@ -224,25 +238,44 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
if (state->nxdn_last_ran != -1) fprintf (stderr, " RAN %02d ", state->nxdn_last_ran);
|
if (state->nxdn_last_ran != -1) fprintf (stderr, " RAN %02d ", state->nxdn_last_ran);
|
||||||
else fprintf (stderr, " ");
|
else fprintf (stderr, " ");
|
||||||
|
|
||||||
uint8_t nsf_sacch[26];
|
uint8_t nsf_sacch[400];
|
||||||
memset (nsf_sacch, 0, sizeof(nsf_sacch));
|
memset (nsf_sacch, 0, sizeof(nsf_sacch));
|
||||||
for (int i = 0; i < 26; i++)
|
for (int i = 0; i < 26; i++)
|
||||||
{
|
{
|
||||||
nsf_sacch[i] = trellis_buf[i+8];
|
nsf_sacch[i] = trellis_buf[i+8];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crc == 0) NXDN_Elements_Content_decode(opts, state, 1, nsf_sacch);
|
if (crc == check)
|
||||||
|
{
|
||||||
|
ran = (trellis_buf[2] << 5) | (trellis_buf[3] << 4) | (trellis_buf[4] << 3) | (trellis_buf[5] << 2) | (trellis_buf[6] << 1) | trellis_buf[7];
|
||||||
|
state->nxdn_last_ran = ran;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crc == check) NXDN_Elements_Content_decode(opts, state, 1, nsf_sacch);
|
||||||
|
else if (opts->aggressive_framesync == 0) NXDN_Elements_Content_decode(opts, state, 0, nsf_sacch);
|
||||||
|
|
||||||
|
if (crc != check)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " SACCH NSF");
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n SACCH NSF ");
|
fprintf (stderr, "\n SACCH NSF ");
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "[%02X]", m_data[i]);
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
}
|
}
|
||||||
if (crc != 0) fprintf (stderr, " CRC ERR - %02X %02X", crc, check);
|
// if (crc != check) fprintf (stderr, " CRC ERR - %02X %02X", check, crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//reset the sacch field -- Github Issue #118
|
||||||
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If part of superframe, collect the fragments and send to NXDN_SACCH_Full_decode instead
|
//If part of superframe, collect the fragments and send to NXDN_SACCH_Full_decode instead
|
||||||
@@ -251,7 +284,7 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
//sf and ran together are denoted as SR in the manual (more confusing acronyms)
|
//sf and ran together are denoted as SR in the manual (more confusing acronyms)
|
||||||
//sf (structure field) and RAN will always exist in first 8 bits of each SACCH, then the next 18 bits are the fragment of the superframe
|
//sf (structure field) and RAN will always exist in first 8 bits of each SACCH, then the next 18 bits are the fragment of the superframe
|
||||||
sf = (trellis_buf[0] << 1) | trellis_buf[1];
|
sf = (trellis_buf[0] << 1) | trellis_buf[1];
|
||||||
ran = (trellis_buf[2] << 5) | (trellis_buf[3] << 4) | (trellis_buf[4] << 3) | (trellis_buf[5] << 2) | (trellis_buf[6] << 1) | trellis_buf[7];
|
|
||||||
if (sf == 3) part_of_frame = 0;
|
if (sf == 3) part_of_frame = 0;
|
||||||
else if (sf == 2) part_of_frame = 1;
|
else if (sf == 2) part_of_frame = 1;
|
||||||
else if (sf == 1) part_of_frame = 2;
|
else if (sf == 1) part_of_frame = 2;
|
||||||
@@ -263,11 +296,20 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
else fprintf (stderr, " ");
|
else fprintf (stderr, " ");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
if (crc != check)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " SACCH SF%d", sf);
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
//reset scrambler seed to key value on new superframe
|
//reset scrambler seed to key value on new superframe
|
||||||
if (part_of_frame == 0 && state->nxdn_cipher_type == 0x1) state->payload_miN = 0;
|
if (part_of_frame == 0 && state->nxdn_cipher_type == 0x1) state->payload_miN = 0;
|
||||||
|
|
||||||
if (crc == 0)
|
if (crc == check)
|
||||||
{
|
{
|
||||||
|
ran = (trellis_buf[2] << 5) | (trellis_buf[3] << 4) | (trellis_buf[4] << 3) | (trellis_buf[5] << 2) | (trellis_buf[6] << 1) | trellis_buf[7];
|
||||||
state->nxdn_ran = state->nxdn_last_ran = ran;
|
state->nxdn_ran = state->nxdn_last_ran = ran;
|
||||||
state->nxdn_sf = sf;
|
state->nxdn_sf = sf;
|
||||||
state->nxdn_part_of_frame = part_of_frame;
|
state->nxdn_part_of_frame = part_of_frame;
|
||||||
@@ -294,24 +336,27 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " SACCH SF Segment #%d ", part_of_frame+1);
|
fprintf (stderr, " SACCH SF Segment #%d ", part_of_frame+1);
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "[%02X]", m_data[i]);
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
}
|
}
|
||||||
if (crc != 0) fprintf (stderr, " CRC ERR - %02X %02X", crc, check);
|
// if (crc != check) fprintf (stderr, " CRC ERR - %02X %02X", crc, check);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[348])
|
void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[348], uint8_t type)
|
||||||
{
|
{
|
||||||
|
uint8_t deperm[500]; //348
|
||||||
uint8_t deperm[348];
|
uint8_t depunc[500]; //406
|
||||||
uint8_t depunc[406];
|
uint8_t trellis_buf[400]; //199
|
||||||
uint8_t trellis_buf[199];
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
uint16_t crc = 0;
|
uint16_t crc = 0;
|
||||||
|
uint16_t check = 0;
|
||||||
|
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
|
||||||
for (int i=0; i<348; i++) {
|
for (int i=0; i<348; i++) {
|
||||||
deperm[PERM_12_29[i]] = bits[i];
|
deperm[PERM_12_29[i]] = bits[i];
|
||||||
@@ -334,10 +379,10 @@ void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[34
|
|||||||
}
|
}
|
||||||
|
|
||||||
//switch to the convolutional decoder
|
//switch to the convolutional decoder
|
||||||
uint8_t temp[220];
|
uint8_t temp[500]; //220, this one was way too small
|
||||||
uint8_t s0;
|
uint8_t s0;
|
||||||
uint8_t s1;
|
uint8_t s1;
|
||||||
uint8_t m_data[26];
|
uint8_t m_data[52]; //26
|
||||||
memset (trellis_buf, 0, sizeof(trellis_buf));
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
memset (temp, 0, sizeof (temp));
|
memset (temp, 0, sizeof (temp));
|
||||||
memset (m_data, 0, sizeof (m_data));
|
memset (m_data, 0, sizeof (m_data));
|
||||||
@@ -377,8 +422,23 @@ void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[34
|
|||||||
}
|
}
|
||||||
|
|
||||||
crc = crc15(trellis_buf, 199);
|
crc = crc15(trellis_buf, 199);
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
check = check << 1;
|
||||||
|
check = check | trellis_buf[i+184];
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t f2u_message_buffer[199];
|
if (crc != check)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
if (type == 0) fprintf (stderr, " UDCH");
|
||||||
|
if (type == 1) fprintf (stderr, " FACCH2");
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t f2u_message_buffer[400]; //199
|
||||||
memset (f2u_message_buffer, 0, sizeof(f2u_message_buffer));
|
memset (f2u_message_buffer, 0, sizeof(f2u_message_buffer));
|
||||||
|
|
||||||
//just going to leave this all here in case its needed, like in cac,
|
//just going to leave this all here in case its needed, like in cac,
|
||||||
@@ -388,36 +448,58 @@ void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[34
|
|||||||
f2u_message_buffer[i] = trellis_buf[i+8];
|
f2u_message_buffer[i] = trellis_buf[i+8];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crc == 0)
|
if (crc == check)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " F2/U ");
|
if (type == 1) NXDN_Elements_Content_decode(opts, state, 1, f2u_message_buffer);
|
||||||
//NXDN_Elements_Content_decode(opts, state, 1, trellis_buf);
|
if (type == 0) ; //need handling for user data (text messages and AVL)
|
||||||
NXDN_Elements_Content_decode(opts, state, 1, f2u_message_buffer);
|
}
|
||||||
|
else if (opts->aggressive_framesync == 0)
|
||||||
|
{
|
||||||
|
if (type == 1) NXDN_Elements_Content_decode(opts, state, 0, f2u_message_buffer);
|
||||||
|
if (type == 0) ; //need handling for user data (text messages and AVL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
fprintf (stderr, " F2/U Payload\n ");
|
if (type == 0) fprintf (stderr, " UDCH");
|
||||||
|
if (type == 1) fprintf (stderr, " FACCH2");
|
||||||
|
fprintf (stderr, " Payload\n ");
|
||||||
for (int i = 0; i < 26; i++)
|
for (int i = 0; i < 26; i++)
|
||||||
{
|
{
|
||||||
|
if (i == 13) fprintf (stderr, "\n ");
|
||||||
fprintf (stderr, "[%02X]", m_data[i]);
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
if (i == 12) fprintf (stderr, "\n ");
|
|
||||||
}
|
}
|
||||||
if (crc != 0) fprintf (stderr, " CRC ERR ");
|
// if (crc != check) fprintf (stderr, " CRC ERR ");
|
||||||
|
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n UDCH Data: ASCII - " );
|
||||||
|
for (int i = 0; i < 24; i++) //remove crc portion
|
||||||
|
{
|
||||||
|
if (m_data[i] <= 0x7E && m_data[i] >=0x20)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%c", m_data[i]);
|
||||||
|
}
|
||||||
|
else fprintf (stderr, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
||||||
{
|
{
|
||||||
|
uint8_t deperm[500]; //300
|
||||||
uint8_t deperm[300];
|
uint8_t depunc[500]; //350
|
||||||
uint8_t depunc[350];
|
uint8_t trellis_buf[400]; //171
|
||||||
uint8_t trellis_buf[171];
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
int ran = 0;
|
||||||
uint16_t crc = 0;
|
uint16_t crc = 0;
|
||||||
|
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
|
||||||
for (int i=0; i<300; i++) {
|
for (int i=0; i<300; i++) {
|
||||||
deperm[PERM_12_25[i]] = bits[i];
|
deperm[PERM_12_25[i]] = bits[i];
|
||||||
}
|
}
|
||||||
@@ -442,7 +524,7 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
|||||||
uint8_t temp[360];
|
uint8_t temp[360];
|
||||||
uint8_t s0;
|
uint8_t s0;
|
||||||
uint8_t s1;
|
uint8_t s1;
|
||||||
uint8_t m_data[26];
|
uint8_t m_data[52]; //26
|
||||||
memset (trellis_buf, 0, sizeof(trellis_buf));
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
memset (temp, 0, sizeof (temp));
|
memset (temp, 0, sizeof (temp));
|
||||||
memset (m_data, 0, sizeof (m_data));
|
memset (m_data, 0, sizeof (m_data));
|
||||||
@@ -452,11 +534,6 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
|||||||
temp[i] = depunc[i] << 1;
|
temp[i] = depunc[i] << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
temp[i+350] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CNXDNConvolution_start();
|
CNXDNConvolution_start();
|
||||||
for (int i = 0U; i < 179U; i++)
|
for (int i = 0U; i < 179U; i++)
|
||||||
{
|
{
|
||||||
@@ -482,30 +559,38 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
|||||||
|
|
||||||
crc = crc16cac(trellis_buf, 171);
|
crc = crc16cac(trellis_buf, 171);
|
||||||
|
|
||||||
//message type will probably be neccesary beforehand on single/dual meessage runs
|
uint8_t cac_message_buffer[400]; //171
|
||||||
//run message, check len, load into a seperate buffer, send to element, do same with other piece?
|
|
||||||
uint8_t MessageType = 0;
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
MessageType = MessageType << 1;
|
|
||||||
MessageType = MessageType + trellis_buf[i+2]; //double check this on CAC
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t cac_message_buffer[171];
|
|
||||||
memset (cac_message_buffer, 0, sizeof(cac_message_buffer));
|
memset (cac_message_buffer, 0, sizeof(cac_message_buffer));
|
||||||
|
|
||||||
//shift the cac_message into the appropriate byte arrangement for element_decoder
|
//shift the cac_message into the appropriate byte arrangement for element_decoder -- skip SR field
|
||||||
for (int i = 0; i < 160; i++) //in future, we can use this to send multiple messages to decoder, if present
|
for (int i = 0; i < 160; i++)
|
||||||
{
|
{
|
||||||
cac_message_buffer[i] = trellis_buf[i+8];
|
cac_message_buffer[i] = trellis_buf[i+8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state->nxdn_last_ran != -1) fprintf (stderr, " RAN %02d ", state->nxdn_last_ran);
|
||||||
|
else fprintf (stderr, " ");
|
||||||
|
|
||||||
if (crc == 0)
|
if (crc == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " CAC ");
|
ran = (trellis_buf[2] << 5) | (trellis_buf[3] << 4) | (trellis_buf[4] << 3) | (trellis_buf[5] << 2) | (trellis_buf[6] << 1) | trellis_buf[7];
|
||||||
NXDN_Elements_Content_decode(opts, state, 1, cac_message_buffer);
|
state->nxdn_last_ran = ran;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
fprintf (stderr, " CAC");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
if (crc != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crc == 0) NXDN_Elements_Content_decode(opts, state, 1, cac_message_buffer);
|
||||||
|
else if (opts->aggressive_framesync == 0) NXDN_Elements_Content_decode(opts, state, 0, cac_message_buffer);
|
||||||
|
|
||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
@@ -515,7 +600,286 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
|||||||
fprintf (stderr, "[%02X]", m_data[i]);
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
if (i == 10) fprintf (stderr, "\n ");
|
if (i == 10) fprintf (stderr, "\n ");
|
||||||
}
|
}
|
||||||
if (crc != 0) fprintf (stderr, " CRC ERR ");
|
// if (crc != 0) fprintf (stderr, " CRC ERR ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Type-D "IDAS"
|
||||||
|
void nxdn_deperm_scch(dsd_opts * opts, dsd_state * state, uint8_t bits[60], uint8_t direction)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
fprintf (stderr, " SCCH");
|
||||||
|
|
||||||
|
//see about initializing these variables
|
||||||
|
uint8_t deperm[200]; //60
|
||||||
|
uint8_t depunc[200]; //72
|
||||||
|
uint8_t trellis_buf[400]; //32
|
||||||
|
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
|
|
||||||
|
int o = 0;
|
||||||
|
uint8_t crc = 0; //value computed by crc7 on payload
|
||||||
|
uint8_t check = 0; //value pulled from last 7 bits
|
||||||
|
int sf = 0;
|
||||||
|
int part_of_frame = 0;
|
||||||
|
|
||||||
|
for (int i=0; i<60; i++)
|
||||||
|
deperm[PERM_12_5[i]] = bits[i];
|
||||||
|
for (int p=0; p<60; p+= 10) {
|
||||||
|
depunc[o++] = deperm[p+0];
|
||||||
|
depunc[o++] = deperm[p+1];
|
||||||
|
depunc[o++] = deperm[p+2];
|
||||||
|
depunc[o++] = deperm[p+3];
|
||||||
|
depunc[o++] = deperm[p+4];
|
||||||
|
depunc[o++] = 0;
|
||||||
|
depunc[o++] = deperm[p+5];
|
||||||
|
depunc[o++] = deperm[p+6];
|
||||||
|
depunc[o++] = deperm[p+7];
|
||||||
|
depunc[o++] = deperm[p+8];
|
||||||
|
depunc[o++] = deperm[p+9];
|
||||||
|
depunc[o++] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//switch to the convolutional decoder
|
||||||
|
uint8_t temp[90];
|
||||||
|
uint8_t s0;
|
||||||
|
uint8_t s1;
|
||||||
|
uint8_t m_data[10]; //5
|
||||||
|
|
||||||
|
memset (temp, 0, sizeof (temp));
|
||||||
|
memset (m_data, 0, sizeof (m_data));
|
||||||
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
|
|
||||||
|
for (int i = 0; i < 72; i++)
|
||||||
|
{
|
||||||
|
temp[i] = depunc[i] << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
temp[i+72] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CNXDNConvolution_start();
|
||||||
|
for (int i = 0U; i < 36U; i++)
|
||||||
|
{
|
||||||
|
s0 = temp[(2*i)];
|
||||||
|
s1 = temp[(2*i)+1];
|
||||||
|
|
||||||
|
CNXDNConvolution_decode(s0, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CNXDNConvolution_chainback(m_data, 32U);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
trellis_buf[(i*8)+0] = (m_data[i] >> 7) & 1;
|
||||||
|
trellis_buf[(i*8)+1] = (m_data[i] >> 6) & 1;
|
||||||
|
trellis_buf[(i*8)+2] = (m_data[i] >> 5) & 1;
|
||||||
|
trellis_buf[(i*8)+3] = (m_data[i] >> 4) & 1;
|
||||||
|
trellis_buf[(i*8)+4] = (m_data[i] >> 3) & 1;
|
||||||
|
trellis_buf[(i*8)+5] = (m_data[i] >> 2) & 1;
|
||||||
|
trellis_buf[(i*8)+6] = (m_data[i] >> 1) & 1;
|
||||||
|
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
crc = crc7_scch(trellis_buf, 25);
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
check = check << 1;
|
||||||
|
check = check | trellis_buf[i+25];
|
||||||
|
}
|
||||||
|
|
||||||
|
//check the sf early for scrambler reset, if required
|
||||||
|
sf = (trellis_buf[0] << 1) | trellis_buf[1];
|
||||||
|
if (sf == 3) part_of_frame = 0;
|
||||||
|
else if (sf == 2) part_of_frame = 1;
|
||||||
|
else if (sf == 1) part_of_frame = 2;
|
||||||
|
else if (sf == 0) part_of_frame = 3;
|
||||||
|
else part_of_frame = 0;
|
||||||
|
|
||||||
|
//reset scrambler seed to key value on new superframe
|
||||||
|
if (part_of_frame == 0 && state->nxdn_cipher_type == 0x1) state->payload_miN = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
4.3.2. Mapping to Functional Channel
|
||||||
|
When Subscriber Unit performs voice communication in RTCH2, SCCH is allocated as
|
||||||
|
described below.
|
||||||
|
|
||||||
|
SCCH has super Frame Structure with 4 frame unit during communication, and has non
|
||||||
|
super Frame Structure with single frame unit at the start time and end time of sending.
|
||||||
|
Allocation of the other channel is not specified particularly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//English Translation: Superframe when voice, Non Superframe when not voice
|
||||||
|
|
||||||
|
//What I've found is that by not using the superframe structure, and decoding each 'unit'
|
||||||
|
//individually instead, we can get more expedient decoding on elements without having to
|
||||||
|
//sacrifice an entire superframe for one bad CRC, also each element cleanly divides into a
|
||||||
|
//single 'unit' except for enc parms IV, which can be stored seperately if needed
|
||||||
|
|
||||||
|
//NOTE: scch has its own message format, and thus, doesn't go to content element decoding
|
||||||
|
//like everything else does
|
||||||
|
if (crc != check)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crc == check) NXDN_decode_scch (opts, state, trellis_buf, direction);
|
||||||
|
else if (opts->aggressive_framesync == 0) NXDN_decode_scch (opts, state, trellis_buf, direction);
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n SCCH Payload ");
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", m_data[i]);
|
||||||
|
}
|
||||||
|
// if (crc != check) fprintf (stderr, " CRC ERR - %02X %02X", check, crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void nxdn_deperm_facch3_udch2(dsd_opts * opts, dsd_state * state, uint8_t bits[288], uint8_t type)
|
||||||
|
{
|
||||||
|
uint8_t deperm[300]; //144
|
||||||
|
uint8_t depunc[300]; //192
|
||||||
|
uint8_t trellis_buf[600]; //96
|
||||||
|
uint8_t f3_udch2[288]; //completed bitstream without crc and tailing bits attached
|
||||||
|
uint8_t f3_udch2_bytes[36]; //completed bytes - with crc and tail
|
||||||
|
uint16_t crc[2]; //crc calculated by function
|
||||||
|
uint16_t check[2]; //crc from payload for comparison
|
||||||
|
int out;
|
||||||
|
|
||||||
|
//switch to the convolutional decoder
|
||||||
|
uint8_t temp[500];
|
||||||
|
uint8_t s0;
|
||||||
|
uint8_t s1;
|
||||||
|
uint8_t m_data[40]; //13
|
||||||
|
memset (temp, 0, sizeof(temp));
|
||||||
|
memset (m_data, 0, sizeof(m_data));
|
||||||
|
memset (trellis_buf, 0, sizeof(trellis_buf));
|
||||||
|
memset (deperm, 0, sizeof(deperm));
|
||||||
|
memset (depunc, 0, sizeof(depunc));
|
||||||
|
memset (crc, 0, sizeof(crc));
|
||||||
|
memset (check, 0, sizeof(check));
|
||||||
|
memset (f3_udch2, 0, sizeof(f3_udch2));
|
||||||
|
memset (f3_udch2_bytes, 0, sizeof(f3_udch2_bytes));
|
||||||
|
|
||||||
|
for (int j=0; j<2; j++)
|
||||||
|
{
|
||||||
|
for (int i=0; i<144; i++)
|
||||||
|
deperm[PERM_16_9[i]] = bits[i+(j*144)];
|
||||||
|
out = 0;
|
||||||
|
for (int i=0; i<144; i+=3) {
|
||||||
|
depunc[out++] = deperm[i+0];
|
||||||
|
depunc[out++] = 0;
|
||||||
|
depunc[out++] = deperm[i+1];
|
||||||
|
depunc[out++] = deperm[i+2];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 192; i++)
|
||||||
|
{
|
||||||
|
temp[i] = depunc[i] << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
temp[i+192] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CNXDNConvolution_start();
|
||||||
|
for (int i = 0U; i < 100U; i++)
|
||||||
|
{
|
||||||
|
s0 = temp[(2*i)];
|
||||||
|
s1 = temp[(2*i)+1];
|
||||||
|
|
||||||
|
CNXDNConvolution_decode(s0, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CNXDNConvolution_chainback(m_data, 96U);
|
||||||
|
|
||||||
|
for(int i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
trellis_buf[(i*8)+0] = (m_data[i] >> 7) & 1;
|
||||||
|
trellis_buf[(i*8)+1] = (m_data[i] >> 6) & 1;
|
||||||
|
trellis_buf[(i*8)+2] = (m_data[i] >> 5) & 1;
|
||||||
|
trellis_buf[(i*8)+3] = (m_data[i] >> 4) & 1;
|
||||||
|
trellis_buf[(i*8)+4] = (m_data[i] >> 3) & 1;
|
||||||
|
trellis_buf[(i*8)+5] = (m_data[i] >> 2) & 1;
|
||||||
|
trellis_buf[(i*8)+6] = (m_data[i] >> 1) & 1;
|
||||||
|
trellis_buf[(i*8)+7] = (m_data[i] >> 0) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
crc[j] = crc12f (trellis_buf, 84); //84
|
||||||
|
for (int i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
check[j] = check[j] << 1;
|
||||||
|
check[j] = check[j] | trellis_buf[84+i]; //84
|
||||||
|
|
||||||
|
}
|
||||||
|
//transfer to storage sans crc and tail bits
|
||||||
|
for (int i = 0; i < 80; i++) f3_udch2[i+(j*80)] = trellis_buf[i];
|
||||||
|
for (int i = 0; i < 12; i++) f3_udch2_bytes[i+(j*12)] = m_data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crc[0] != check[0] || crc[1] != check[1])
|
||||||
|
{
|
||||||
|
if (type == 0) fprintf (stderr, " UDCH2");
|
||||||
|
if (type == 1) fprintf (stderr, " FACCH3");
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crc[0] == check[0] && crc[1] == check[1])
|
||||||
|
{
|
||||||
|
if (type == 1) NXDN_Elements_Content_decode(opts, state, 1, trellis_buf);
|
||||||
|
if (type == 0) ; //need handling for user data (text messages and AVL)
|
||||||
|
}
|
||||||
|
else if (opts->aggressive_framesync == 0)
|
||||||
|
{
|
||||||
|
if (type == 1) NXDN_Elements_Content_decode(opts, state, 0, trellis_buf);
|
||||||
|
if (type == 0) ; //need handling for user data (text messages and AVL)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
if (type == 0) fprintf (stderr, " UDCH2");
|
||||||
|
if (type == 1) fprintf (stderr, " FACCH3");
|
||||||
|
fprintf (stderr, " Payload \n ");
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
if (i == 12) fprintf (stderr, "\n ");
|
||||||
|
fprintf (stderr, "[%02X]", f3_udch2_bytes[i]);
|
||||||
|
}
|
||||||
|
// fprintf (stderr, " - %03X %03X", check[0], crc[0]);
|
||||||
|
// fprintf (stderr, " - %03X %03X", check[1], crc[1]);
|
||||||
|
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n UDCH2 Data: ASCII - " );
|
||||||
|
for (int i = 0; i < 22; i++) //all but last crc portion
|
||||||
|
{
|
||||||
|
if (i == 12) i = 14; //skip first crc portion
|
||||||
|
if (f3_udch2_bytes[i] <= 0x7E && f3_udch2_bytes[i] >=0x20)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%c", f3_udch2_bytes[i]);
|
||||||
|
}
|
||||||
|
else fprintf (stderr, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,23 +888,32 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300])
|
|||||||
void nxdn_message_type (dsd_opts * opts, dsd_state * state, uint8_t MessageType)
|
void nxdn_message_type (dsd_opts * opts, dsd_state * state, uint8_t MessageType)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//NOTE: Most Req/Resp (request and respone) share same message type but differ depending on channel type
|
||||||
|
//RTCH Outbound will take precedent when differences may occur (except CALL_ASSGN)
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
if (MessageType == 0x10) fprintf(stderr, " IDLE");
|
if (MessageType == 0x10) fprintf(stderr, " IDLE");
|
||||||
else if (MessageType == 0x11) fprintf(stderr, " DISC"); //disconnect
|
else if (MessageType == 0x00) fprintf(stderr, " CALL_RESP");
|
||||||
else if (MessageType == 0x01) fprintf(stderr, " VCALL");
|
else if (MessageType == 0x01) fprintf(stderr, " VCALL");
|
||||||
else if (MessageType == 0x03) fprintf(stderr, " VCALL IV");
|
else if (MessageType == 0x02) fprintf(stderr, " VCALL_REC_REQ");
|
||||||
|
else if (MessageType == 0x03) fprintf(stderr, " VCALL_IV");
|
||||||
else if (MessageType == 0x07) fprintf(stderr, " TX_REL_EX");
|
|
||||||
else if (MessageType == 0x08) fprintf(stderr, " TX_REL");
|
|
||||||
|
|
||||||
else if (MessageType == 0x04) fprintf(stderr, " VCALL_ASSGN");
|
else if (MessageType == 0x04) fprintf(stderr, " VCALL_ASSGN");
|
||||||
else if (MessageType == 0x05) fprintf(stderr, " VCALL_ASSGN_DUP");
|
else if (MessageType == 0x05) fprintf(stderr, " VCALL_ASSGN_DUP");
|
||||||
|
else if (MessageType == 0x06) fprintf(stderr, " CALL_CONN_RESP");
|
||||||
|
else if (MessageType == 0x07) fprintf(stderr, " TX_REL_EX");
|
||||||
|
else if (MessageType == 0x08) fprintf(stderr, " TX_REL");
|
||||||
|
else if (MessageType == 0x09) fprintf(stderr, " DCALL_HEADER");
|
||||||
|
else if (MessageType == 0x0A) fprintf(stderr, " DCALL_REC_REQ");
|
||||||
|
else if (MessageType == 0x0B) fprintf(stderr, " DCALL_UDATA");
|
||||||
|
else if (MessageType == 0x0C) fprintf(stderr, " DCALL_ACK");
|
||||||
|
else if (MessageType == 0x0D) fprintf(stderr, " DCALL_ASSGN_DUP");
|
||||||
else if (MessageType == 0x0E) fprintf(stderr, " DCALL_ASSGN");
|
else if (MessageType == 0x0E) fprintf(stderr, " DCALL_ASSGN");
|
||||||
|
else if (MessageType == 0x11) fprintf(stderr, " DISC");
|
||||||
|
else if (MessageType == 0x17) fprintf(stderr, " DST_ID_INFO");
|
||||||
else if (MessageType == 0x18) fprintf(stderr, " SITE_INFO");
|
else if (MessageType == 0x18) fprintf(stderr, " SITE_INFO");
|
||||||
else if (MessageType == 0x19) fprintf(stderr, " SRV_INFO");
|
else if (MessageType == 0x19) fprintf(stderr, " SRV_INFO");
|
||||||
else if (MessageType == 0x1C) fprintf(stderr, " FAIL_STAT_INFO");
|
|
||||||
else if (MessageType == 0x1A) fprintf(stderr, " CCH_INFO");
|
else if (MessageType == 0x1A) fprintf(stderr, " CCH_INFO");
|
||||||
else if (MessageType == 0x1B) fprintf(stderr, " ADJ_SITE_INFO");
|
else if (MessageType == 0x1B) fprintf(stderr, " ADJ_SITE_INFO");
|
||||||
|
else if (MessageType == 0x1C) fprintf(stderr, " FAIL_STAT_INFO");
|
||||||
else if (MessageType == 0x20) fprintf(stderr, " REG_RESP");
|
else if (MessageType == 0x20) fprintf(stderr, " REG_RESP");
|
||||||
else if (MessageType == 0x22) fprintf(stderr, " REG_C_RESP");
|
else if (MessageType == 0x22) fprintf(stderr, " REG_C_RESP");
|
||||||
else if (MessageType == 0x24) fprintf(stderr, " GRP_REG_RESP");
|
else if (MessageType == 0x24) fprintf(stderr, " GRP_REG_RESP");
|
||||||
@@ -549,24 +922,23 @@ void nxdn_message_type (dsd_opts * opts, dsd_state * state, uint8_t MessageType)
|
|||||||
else if (MessageType == 0x38) fprintf(stderr, " SDCALL_REQ_HEADER");
|
else if (MessageType == 0x38) fprintf(stderr, " SDCALL_REQ_HEADER");
|
||||||
else if (MessageType == 0x39) fprintf(stderr, " SDCALL_REQ_USERDATA");
|
else if (MessageType == 0x39) fprintf(stderr, " SDCALL_REQ_USERDATA");
|
||||||
else if (MessageType == 0x3B) fprintf(stderr, " SDCALL_RESP");
|
else if (MessageType == 0x3B) fprintf(stderr, " SDCALL_RESP");
|
||||||
|
|
||||||
else if (MessageType == 0x3F) fprintf(stderr, " ALIAS");
|
else if (MessageType == 0x3F) fprintf(stderr, " ALIAS");
|
||||||
else if (MessageType == 0x0C) fprintf(stderr, " DCALL_ACK");
|
|
||||||
else fprintf(stderr, " Unknown M-%02X", MessageType);
|
else fprintf(stderr, " Unknown M-%02X", MessageType);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
//zero out stale values so they won't persist after a transmit release
|
//Zero out stale values on DISC or TX_REL only (IDLE messaages occur often on NXDN96 VCH, and randomly on Type-C FACCH1 steals for some reason)
|
||||||
//disable if random messages wipe out the alias
|
if (MessageType == 0x08 || MessageType == 0x11)
|
||||||
if (MessageType == 0x08 || MessageType == 0x10) //idle, tx_rel
|
|
||||||
{
|
{
|
||||||
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
|
||||||
state->nxdn_last_rid = 0;
|
state->nxdn_last_rid = 0;
|
||||||
state->nxdn_last_tg = 0;
|
state->nxdn_last_tg = 0;
|
||||||
state->nxdn_cipher_type = 0;
|
state->nxdn_cipher_type = 0; //force will reactivate it if needed during voice tx
|
||||||
|
if (state->keyloader == 1) state->R = 0;
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
||||||
memset (state->nxdn_sacch_frame_segment, 0, sizeof(state->nxdn_sacch_frame_segment));
|
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
||||||
sprintf (state->nxdn_call_type, "%s", "");
|
sprintf (state->nxdn_call_type, "%s", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//voice descrambler
|
//voice descrambler
|
||||||
@@ -669,13 +1041,32 @@ static uint16_t crc15(const uint8_t buf[], int len)
|
|||||||
|
|
||||||
static uint16_t crc16cac(const uint8_t buf[], int len)
|
static uint16_t crc16cac(const uint8_t buf[], int len)
|
||||||
{
|
{
|
||||||
int crc = 0xc3ee;
|
uint32_t crc = 0xc3ee; //not sure why this though
|
||||||
int poly = (1<<12) + (1<<5) + 1;
|
uint32_t poly = (1<<12) + (1<<5) + 1; //poly is fine
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++)
|
||||||
crc = ((crc << 1) | buf[i]) & 0x1ffff;
|
{
|
||||||
if(crc & 0x10000)
|
crc = ((crc << 1) | buf[i]) & 0x1ffff;
|
||||||
crc = (crc & 0xffff) ^ poly;
|
if(crc & 0x10000) crc = (crc & 0xffff) ^ poly;
|
||||||
}
|
}
|
||||||
crc = crc ^ 0xffff;
|
crc = crc ^ 0xffff;
|
||||||
return crc & 0xffff;
|
return crc & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t crc7_scch(uint8_t bits[], int len)
|
||||||
|
{
|
||||||
|
uint8_t s[7];
|
||||||
|
uint8_t a;
|
||||||
|
for (int i=0;i<7;i++)
|
||||||
|
s[i] = 1;
|
||||||
|
for (int i=0;i<len;i++) {
|
||||||
|
a = bits[i] ^ s[0];
|
||||||
|
s[0] = s[1];
|
||||||
|
s[1] = s[2];
|
||||||
|
s[2] = s[3];
|
||||||
|
s[3] = a ^ s[4];
|
||||||
|
s[4] = s[5];
|
||||||
|
s[5] = s[6];
|
||||||
|
s[6] = a;
|
||||||
|
}
|
||||||
|
return load_i(s, 7);
|
||||||
}
|
}
|
||||||
1316
src/nxdn_element.c
1316
src/nxdn_element.c
File diff suppressed because it is too large
Load Diff
363
src/nxdn_frame.c
363
src/nxdn_frame.c
@@ -32,53 +32,74 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
// length is implicitly 192, with frame sync in first 10 dibits
|
// length is implicitly 192, with frame sync in first 10 dibits
|
||||||
uint8_t dbuf[182];
|
uint8_t dbuf[182];
|
||||||
uint8_t lich;
|
uint8_t lich;
|
||||||
int answer_len=0;
|
int answer_len = 0;
|
||||||
uint8_t answer[32];
|
uint8_t answer[32];
|
||||||
uint8_t sacch_answer[32];
|
uint8_t sacch_answer[32];
|
||||||
int lich_parity_received;
|
int lich_parity_received;
|
||||||
int lich_parity_computed;
|
int lich_parity_computed;
|
||||||
int voice=0;
|
int voice = 0;
|
||||||
int facch=0;
|
int facch = 0;
|
||||||
int facch2=0;
|
int facch2 = 0;
|
||||||
int sacch=0;
|
int udch = 0;
|
||||||
int cac=0;
|
int sacch = 0;
|
||||||
|
int cac = 0;
|
||||||
int sr_structure;
|
int sr_structure;
|
||||||
int sr_ran;
|
int sr_ran;
|
||||||
|
|
||||||
uint8_t lich_dibits[8] = {0};
|
//new, and even more confusing NXDN Type-D / "IDAS" acronyms
|
||||||
uint8_t sacch_bits[60] = {0};
|
int idas = 0;
|
||||||
uint8_t facch_bits_a[144] = {0};
|
int scch = 0;
|
||||||
uint8_t facch_bits_b[144] = {0};
|
int facch3 = 0;
|
||||||
uint8_t cac_bits[300] = {0};
|
int udch2 = 0;
|
||||||
uint8_t facch2_bits[348] = {0}; //facch2 or udch, same amount of bits
|
|
||||||
|
|
||||||
//nxdn bit buffer, for easy assignment handling
|
//new breakdown of lich codes
|
||||||
int nxdn_bit_buffer[364] = {0};
|
uint8_t lich_rf = 0; //RF Channel Type
|
||||||
int nxdn_dibit_buffer[182] = {0};
|
uint8_t lich_fc = 0; //Functional Channel Type
|
||||||
|
uint8_t lich_op = 0; //Options
|
||||||
|
uint8_t direction; //inbound or outbound direction
|
||||||
|
|
||||||
|
uint8_t lich_dibits[8];
|
||||||
|
uint8_t sacch_bits[60];
|
||||||
|
uint8_t facch_bits_a[144];
|
||||||
|
uint8_t facch_bits_b[144];
|
||||||
|
uint8_t cac_bits[300];
|
||||||
|
uint8_t facch2_bits[348]; //facch2 or udch, same amount of bits
|
||||||
|
uint8_t facch3_bits[288]; //facch3 or udch2, same amoount of bits
|
||||||
|
|
||||||
|
//nxdn bit buffer, for easy assignment handling
|
||||||
|
int nxdn_bit_buffer[364];
|
||||||
|
int nxdn_dibit_buffer[182];
|
||||||
|
|
||||||
|
//init all arrays
|
||||||
memset (dbuf, 0, sizeof(dbuf));
|
memset (dbuf, 0, sizeof(dbuf));
|
||||||
|
memset (answer, 0, sizeof(answer));
|
||||||
|
memset (sacch_answer, 0, sizeof(sacch_answer));
|
||||||
|
memset (lich_dibits, 0, sizeof(lich_dibits));
|
||||||
|
memset (sacch_bits, 0, sizeof(sacch_bits));
|
||||||
|
memset (facch_bits_b, 0, sizeof(facch_bits_b));
|
||||||
|
memset (facch_bits_a, 0, sizeof(facch_bits_a));
|
||||||
|
memset (cac_bits, 0, sizeof(cac_bits));
|
||||||
|
memset (facch2_bits, 0, sizeof(facch2_bits));
|
||||||
|
|
||||||
|
memset (nxdn_bit_buffer, 0, sizeof(nxdn_bit_buffer));
|
||||||
|
memset (nxdn_dibit_buffer, 0, sizeof(nxdn_dibit_buffer));
|
||||||
|
|
||||||
//collect lich bits first, if they are good, then we can collect the rest of them
|
//collect lich bits first, if they are good, then we can collect the rest of them
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++) lich_dibits[i] = dbuf[i] = getDibit(opts, state);
|
||||||
{
|
|
||||||
lich_dibits[i] = dbuf[i] = getDibit(opts, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
nxdn_descramble (lich_dibits, 8);
|
nxdn_descramble (lich_dibits, 8);
|
||||||
|
|
||||||
lich = 0;
|
lich = 0;
|
||||||
for (int i=0; i<8; i++)
|
for (int i=0; i<8; i++) lich |= (lich_dibits[i] >> 1) << (7-i);
|
||||||
{
|
|
||||||
lich |= (lich_dibits[i] >> 1) << (7-i);
|
|
||||||
}
|
|
||||||
|
|
||||||
lich_parity_received = lich & 1;
|
lich_parity_received = lich & 1;
|
||||||
lich_parity_computed = ((lich >> 7) + (lich >> 6) + (lich >> 5) + (lich >> 4)) & 1;
|
lich_parity_computed = ((lich >> 7) + (lich >> 6) + (lich >> 5) + (lich >> 4)) & 1;
|
||||||
lich = lich >> 1;
|
lich = lich >> 1;
|
||||||
if (lich_parity_received != lich_parity_computed)
|
if (lich_parity_received != lich_parity_computed)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "NXDN lich parity error, ignoring frame \n");
|
if (opts->payload == 1) fprintf(stderr, " Lich Parity Error %02X\n", lich);
|
||||||
return;
|
state->lastsynctype = -1; //set to -1 so we don't jump back here too quickly
|
||||||
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
voice = 0;
|
voice = 0;
|
||||||
@@ -86,6 +107,16 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
facch2 = 0;
|
facch2 = 0;
|
||||||
sacch = 0;
|
sacch = 0;
|
||||||
cac = 0;
|
cac = 0;
|
||||||
|
|
||||||
|
//test for inbound direction lich when trunking (false positive) and skip
|
||||||
|
//all inbound lich are even value (lsb is set to 0 for inbound direction)
|
||||||
|
if (lich % 2 == 0 && opts->p25_trunk == 1)
|
||||||
|
{
|
||||||
|
if (opts->payload == 1) fprintf(stderr, " Simplex/Inbound NXDN lich on trunking system - type 0x%02X\n", lich);
|
||||||
|
state->lastsynctype = -1; //set to -1 so we don't jump back here too quickly
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
switch(lich) { //cases without breaks continue to flow downwards until they hit the break
|
switch(lich) { //cases without breaks continue to flow downwards until they hit the break
|
||||||
case 0x01: // CAC types
|
case 0x01: // CAC types
|
||||||
case 0x05:
|
case 0x05:
|
||||||
@@ -93,21 +124,20 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
break;
|
break;
|
||||||
case 0x28: //facch2 types
|
case 0x28: //facch2 types
|
||||||
case 0x29:
|
case 0x29:
|
||||||
case 0x2e:
|
|
||||||
case 0x2f:
|
|
||||||
case 0x48:
|
case 0x48:
|
||||||
case 0x49:
|
case 0x49:
|
||||||
|
facch2 = 1;
|
||||||
|
break;
|
||||||
|
case 0x2e: //udch types
|
||||||
|
case 0x2f:
|
||||||
case 0x4e:
|
case 0x4e:
|
||||||
case 0x4f:
|
case 0x4f:
|
||||||
case 0x69:
|
udch = 1;
|
||||||
case 0x6f:
|
|
||||||
facch2 = 1;
|
|
||||||
break;
|
break;
|
||||||
case 0x32: //facch in 1, vch in 2
|
case 0x32: //facch in 1, vch in 2
|
||||||
case 0x33:
|
case 0x33:
|
||||||
case 0x52:
|
case 0x52:
|
||||||
case 0x53:
|
case 0x53:
|
||||||
case 0x73:
|
|
||||||
voice = 2;
|
voice = 2;
|
||||||
facch = 1;
|
facch = 1;
|
||||||
sacch = 1;
|
sacch = 1;
|
||||||
@@ -115,8 +145,7 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
case 0x34: //vch in 1, facch in 2
|
case 0x34: //vch in 1, facch in 2
|
||||||
case 0x35:
|
case 0x35:
|
||||||
case 0x54:
|
case 0x54:
|
||||||
case 0x55:
|
case 0x55: //disabled for testing, IDAS system randomly triggers this one, probably due to poor signal
|
||||||
case 0x75:
|
|
||||||
voice = 1;
|
voice = 1;
|
||||||
facch = 2;
|
facch = 2;
|
||||||
sacch = 1;
|
sacch = 1;
|
||||||
@@ -125,7 +154,6 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
case 0x37:
|
case 0x37:
|
||||||
case 0x56:
|
case 0x56:
|
||||||
case 0x57:
|
case 0x57:
|
||||||
case 0x77:
|
|
||||||
voice = 3;
|
voice = 3;
|
||||||
facch = 0;
|
facch = 0;
|
||||||
sacch = 1;
|
sacch = 1;
|
||||||
@@ -138,8 +166,6 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
case 0x41:
|
case 0x41:
|
||||||
case 0x50:
|
case 0x50:
|
||||||
case 0x51:
|
case 0x51:
|
||||||
case 0x61:
|
|
||||||
case 0x71:
|
|
||||||
voice = 0;
|
voice = 0;
|
||||||
facch = 3;
|
facch = 3;
|
||||||
sacch = 1;
|
sacch = 1;
|
||||||
@@ -148,10 +174,63 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
case 0x39:
|
case 0x39:
|
||||||
sacch = 1;
|
sacch = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//NXDN "Type-D" or "IDAS" Specific Lich Codes
|
||||||
|
case 0x76: //normal vch voice (in one and two)
|
||||||
|
case 0x77:
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
voice = 3;
|
||||||
|
break;
|
||||||
|
case 0x74: //vch in 1, facch1 in 2 (facch 2 steal)
|
||||||
|
case 0x75:
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
voice = 1;
|
||||||
|
facch = 2;
|
||||||
|
break;
|
||||||
|
case 0x72: //facch in 1, vch in 2 (facch 1 steal)
|
||||||
|
case 0x73:
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
voice = 2;
|
||||||
|
facch = 1;
|
||||||
|
break;
|
||||||
|
case 0x70: //facch steal in vch 1 and vch 2 (during voice only)
|
||||||
|
case 0x71:
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
facch = 3;
|
||||||
|
break;
|
||||||
|
case 0x6E: //udch2
|
||||||
|
case 0x6F:
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
udch2 = 1;
|
||||||
|
break;
|
||||||
|
case 0x68:
|
||||||
|
case 0x69: //facch3
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
facch3 = 1;
|
||||||
|
break;
|
||||||
|
case 0x62:
|
||||||
|
case 0x63: //facch1 in 1, null data and post field in 2
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
facch = 1;
|
||||||
|
break;
|
||||||
|
case 0x60:
|
||||||
|
case 0x61: //facch1 in both (non vch)
|
||||||
|
idas = 1;
|
||||||
|
scch = 1;
|
||||||
|
facch = 3;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (opts->payload == 1) fprintf(stderr, " false sync or unsupported NXDN lich type 0x%02X\n", lich);
|
if (opts->payload == 1) fprintf(stderr, " false sync or unsupported NXDN lich type 0x%02X\n", lich);
|
||||||
//reset the sacch field, we probably got a false sync and need to wipe or give a bad crc
|
//reset the sacch field, we probably got a false sync and need to wipe or give a bad crc
|
||||||
memset (state->nxdn_sacch_frame_segment, 0, sizeof(state->nxdn_sacch_frame_segment));
|
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->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
||||||
state->lastsynctype = -1; //set to -1 so we don't jump back here too quickly
|
state->lastsynctype = -1; //set to -1 so we don't jump back here too quickly
|
||||||
voice = 0;
|
voice = 0;
|
||||||
@@ -159,17 +238,29 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
break;
|
break;
|
||||||
} // end of switch(lich)
|
} // end of switch(lich)
|
||||||
|
|
||||||
|
//enable these after good lich parity and known lich value
|
||||||
|
state->carrier = 1;
|
||||||
|
state->last_cc_sync_time = time(NULL);
|
||||||
|
|
||||||
//printframesync after determining we have a good lich and it has something in it
|
//printframesync after determining we have a good lich and it has something in it
|
||||||
if (voice || facch || sacch || facch2 || cac)
|
if (idas)
|
||||||
|
{
|
||||||
|
if (opts->frame_nxdn48 == 1)
|
||||||
|
{
|
||||||
|
printFrameSync (opts, state, "IDAS D ", 0, "-");
|
||||||
|
}
|
||||||
|
if (opts->payload == 1)
|
||||||
|
fprintf (stderr, "L%02X - ", lich);
|
||||||
|
}
|
||||||
|
else if (voice || facch || sacch || facch2 || cac)
|
||||||
{
|
{
|
||||||
// if (state->synctype == 28) fprintf (stderr, " +");
|
|
||||||
// else fprintf (stderr, " -");
|
|
||||||
if (opts->frame_nxdn48 == 1)
|
if (opts->frame_nxdn48 == 1)
|
||||||
{
|
{
|
||||||
printFrameSync (opts, state, "NXDN48 ", 0, "-");
|
printFrameSync (opts, state, "NXDN48 ", 0, "-");
|
||||||
}
|
}
|
||||||
else printFrameSync (opts, state, "NXDN96 ", 0, "-");
|
else printFrameSync (opts, state, "NXDN96 ", 0, "-");
|
||||||
if (opts->payload == 1) fprintf (stderr, "L%02X -", lich);
|
if (opts->payload == 1)
|
||||||
|
fprintf (stderr, "L%02X - ", lich);
|
||||||
}
|
}
|
||||||
|
|
||||||
//now that we have a good LICH, we can collect all of our dibits
|
//now that we have a good LICH, we can collect all of our dibits
|
||||||
@@ -188,7 +279,7 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
nxdn_bit_buffer[i*2+1] = dbuf[i] & 1;
|
nxdn_bit_buffer[i*2+1] = dbuf[i] & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sacch
|
//sacch or scch bits
|
||||||
for (int i = 0; i < 60; i++)
|
for (int i = 0; i < 60; i++)
|
||||||
{
|
{
|
||||||
sacch_bits[i] = nxdn_bit_buffer[i+16];
|
sacch_bits[i] = nxdn_bit_buffer[i+16];
|
||||||
@@ -213,23 +304,119 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
facch2_bits[i] = nxdn_bit_buffer[i+16];
|
facch2_bits[i] = nxdn_bit_buffer[i+16];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//udch2 or facch3
|
||||||
|
for (int i = 0; i < 288; i++)
|
||||||
|
{
|
||||||
|
facch3_bits[i] = nxdn_bit_buffer[i+16+60];
|
||||||
|
}
|
||||||
|
|
||||||
//vch frames stay inside dbuf, easier to assign that to ambe_fr frames
|
//vch frames stay inside dbuf, easier to assign that to ambe_fr frames
|
||||||
//sacch needs extra handling depending on superframe or non-superframe variety
|
//sacch needs extra handling depending on superframe or non-superframe variety
|
||||||
|
|
||||||
if (voice)
|
//Add advanced decoding of LICH (RF, FC, OPT, and Direction
|
||||||
|
lich_rf = (lich >> 5) & 0x3;
|
||||||
|
lich_fc = (lich >> 3) & 0x3;
|
||||||
|
lich_op = (lich >> 1) & 0x3;
|
||||||
|
if (lich % 2 == 0) direction = 0;
|
||||||
|
else direction = 1;
|
||||||
|
|
||||||
|
// RF Channel Type
|
||||||
|
if (lich_rf == 0) fprintf (stderr, "RCCH ");
|
||||||
|
else if (lich_rf == 1) fprintf (stderr, "RTCH ");
|
||||||
|
else if (lich_rf == 2) fprintf (stderr, "RDCH ");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lich < 0x60) fprintf (stderr, "RTCH_C ");
|
||||||
|
else fprintf (stderr, "RTCH2 ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functional Channel Type -- things start to get really convoluted here
|
||||||
|
// These will echo when handled, either with the decoded message type, or relevant crc err
|
||||||
|
// if (lich_rf == 0) //CAC Type
|
||||||
|
// {
|
||||||
|
// //Technically, we should be checking direction as well, but the fc never has split meaning on CAC
|
||||||
|
// if (lich_fc == 0) fprintf (stderr, "CAC ");
|
||||||
|
// else if (lich_fc == 1) fprintf (stderr, "Long CAC ");
|
||||||
|
// else if (lich_fc == 3) fprintf (stderr, "Short CAC ");
|
||||||
|
// else fprintf (stderr, "Reserved ");
|
||||||
|
// }
|
||||||
|
// else //USC Type
|
||||||
|
// {
|
||||||
|
// if (lich_fc == 0) fprintf (stderr, "NSF SACCH ");
|
||||||
|
// else if (lich_fc == 1) fprintf (stderr, "UDCH ");
|
||||||
|
// else if (lich_fc == 2) fprintf (stderr, "SF SACCH ");
|
||||||
|
// else if (lich_fc == 3) fprintf (stderr, "SF SACCH/IDLE ");
|
||||||
|
// }
|
||||||
|
|
||||||
|
#ifdef LIMAZULUTWEAKS
|
||||||
|
|
||||||
|
//LimaZulu specific tweak, load keys from frequency value, if avalable -- test before VCALL
|
||||||
|
//needs to be loaded here, if superframe data pair, then we need to run the LFSR on it as well
|
||||||
|
|
||||||
|
if (voice) //can this run TOO frequently?
|
||||||
|
{
|
||||||
|
long int freq = 0;
|
||||||
|
uint8_t hash_bits[24];
|
||||||
|
memset (hash_bits, 0, sizeof(hash_bits));
|
||||||
|
uint16_t limazulu = 0;
|
||||||
|
|
||||||
|
//if not available, then poll rigctl if its available
|
||||||
|
if (opts->use_rigctl == 1)
|
||||||
|
freq = GetCurrentFreq (opts->rigctl_sockfd);
|
||||||
|
|
||||||
|
//if using rtl input, we can ask for the current frequency tuned
|
||||||
|
else if (opts->audio_in_type == 3)
|
||||||
|
freq = (long int)opts->rtlsdr_center_freq;
|
||||||
|
|
||||||
|
// freq = 167831250; //hardset for testing
|
||||||
|
|
||||||
|
//since a frequency value will be larger than the 16-bit max, we need to hash it first
|
||||||
|
//the hash has to be run the same way as the import, so at a 24-bit depth, which hopefully
|
||||||
|
//will not lead to any duplicate key loads due to multiple CRC16 collisions on a larger value?
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
hash_bits[i] = ((freq << i) & 0x800000) >> 23; //load into array for CRC16
|
||||||
|
|
||||||
|
if (freq) limazulu = ComputeCrcCCITT16d (hash_bits, 24);
|
||||||
|
limazulu = limazulu & 0xFFFF; //make sure no larger than 16-bits
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
if (freq) fprintf (stderr, "\n Freq: %ld - Freq Hash: %d", freq, limazulu);
|
||||||
|
if (state->rkey_array[limazulu] != 0) fprintf (stderr, " - Key Loaded: %lld", state->rkey_array[limazulu]);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
if (state->rkey_array[limazulu] != 0)
|
||||||
|
state->R = state->rkey_array[limazulu];
|
||||||
|
|
||||||
|
if (state->R != 0 && state->M == 1) state->nxdn_cipher_type = 0x1;
|
||||||
|
|
||||||
|
//add additional time to last_sync_time for LimaZulu to hold on current frequency
|
||||||
|
//a little longer without affecting normal scan time on trunk_hangtime variable
|
||||||
|
state->last_cc_sync_time = time(NULL) + 2; //ask him for an ideal wait timer
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //end LIMAZULUTWEAKS
|
||||||
|
|
||||||
|
//Option/Steal Flags echoed in Voice, V+F, or Data
|
||||||
|
if (voice && !facch) //voice only, no facch steal
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KGRN);
|
fprintf (stderr, "%s", KGRN);
|
||||||
fprintf (stderr, " Voice ");
|
fprintf (stderr, " Voice ");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
else
|
else if (voice && facch) //voice with facch1 steal
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KGRN);
|
||||||
|
fprintf (stderr, " V%d+F%d ", 3 - facch, facch); //print which position on each
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
else //Covers FACCH1 in both, FACCH2, UDCH, UDCH2, CAC
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KCYN);
|
fprintf (stderr, "%s", KCYN);
|
||||||
fprintf (stderr, " Data ");
|
fprintf (stderr, " Data ");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
//roll the voice scrambler LFSR here if key available to advance seed (usually just needed on NXDN96)
|
//roll the voice scrambler LFSR here if key available to advance seed (usually just needed on NXDN96)
|
||||||
if (state->nxdn_cipher_type == 0x1 && state->R != 0) //!voice, or voice == 0
|
if (state->nxdn_cipher_type == 0x1 && state->R != 0)
|
||||||
{
|
{
|
||||||
char ambe_temp[49] = {0};
|
char ambe_temp[49] = {0};
|
||||||
char ambe_d[49] = {0};
|
char ambe_d[49] = {0};
|
||||||
@@ -241,14 +428,86 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state->nxdn_sacch_non_superframe = (lich == 0x20 || lich == 0x21 || lich == 0x61 || lich == 0x40 || lich == 0x41) ? true : false;
|
if (voice && facch == 1) //facch steal 1 -- before voice
|
||||||
if (sacch)nxdn_deperm_sacch(opts, state, sacch_bits);
|
{
|
||||||
if (cac) nxdn_deperm_cac(opts, state, cac_bits);
|
//force scrambler here, but with unspecified key (just use what's loaded)
|
||||||
if (facch2) nxdn_deperm_facch2_udch(opts, state, facch2_bits);
|
if (state->M == 1 && state->R != 0) state->nxdn_cipher_type = 0x1;
|
||||||
|
//roll the voice scrambler LFSR here if key available to advance seed -- half rotation on a facch steal
|
||||||
|
if (state->nxdn_cipher_type == 0x1 && state->R != 0)
|
||||||
|
{
|
||||||
|
char ambe_temp[49] = {0};
|
||||||
|
char ambe_d[49] = {0};
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
LFSRN(ambe_temp, ambe_d, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lich == 0x20 || lich == 0x21 || lich == 0x61 || lich == 0x40 || lich == 0x41) state->nxdn_sacch_non_superframe = TRUE;
|
||||||
|
else state->nxdn_sacch_non_superframe = FALSE;
|
||||||
|
|
||||||
|
//TODO Later: Add Direction and/or LICH to all decoding functions
|
||||||
|
if (scch) nxdn_deperm_scch (opts, state, sacch_bits, direction);
|
||||||
|
|
||||||
|
if (udch2) nxdn_deperm_facch3_udch2(opts, state, facch3_bits, 0);
|
||||||
|
if (facch3) nxdn_deperm_facch3_udch2(opts, state, facch3_bits, 1);
|
||||||
|
|
||||||
|
if (sacch) nxdn_deperm_sacch(opts, state, sacch_bits);
|
||||||
|
if (cac) nxdn_deperm_cac(opts, state, cac_bits);
|
||||||
|
|
||||||
|
//Seperated UDCH user data from facch2 data
|
||||||
|
if (udch) nxdn_deperm_facch2_udch(opts, state, facch2_bits, 0);
|
||||||
|
if (facch2) nxdn_deperm_facch2_udch(opts, state, facch2_bits, 1);
|
||||||
|
|
||||||
|
//SHOULD be okay to run facch1's again on steal frames, will need testing
|
||||||
if (facch & 1) nxdn_deperm_facch(opts, state, facch_bits_a);
|
if (facch & 1) nxdn_deperm_facch(opts, state, facch_bits_a);
|
||||||
if (facch & 2) nxdn_deperm_facch(opts, state, facch_bits_b);
|
if (facch & 2) nxdn_deperm_facch(opts, state, facch_bits_b);
|
||||||
if (voice) nxdn_voice (opts, state, voice, dbuf);
|
|
||||||
|
|
||||||
fprintf (stderr, "\n");
|
if (voice)
|
||||||
|
{
|
||||||
|
//restore MBE file open here
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
|
||||||
|
//update last voice sync time
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
//turn on scrambler if forced by user option
|
||||||
|
if (state->M == 1 && state->R != 0) state->nxdn_cipher_type = 0x1;
|
||||||
|
//process voice frame
|
||||||
|
nxdn_voice (opts, state, voice, dbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
//close MBE file if no voice and its open
|
||||||
|
if (!voice)
|
||||||
|
{
|
||||||
|
if (opts->mbe_out_f != NULL)
|
||||||
|
{
|
||||||
|
if (opts->frame_nxdn96 == 1) //nxdn96 has pure voice and data frames mixed together, so we will need to do a time check first
|
||||||
|
{
|
||||||
|
if ( (time(NULL) - state->last_vc_sync_time) > 1) //test for optimal time, 1 sec should be okay
|
||||||
|
{
|
||||||
|
closeMbeOutFile (opts, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (opts->frame_nxdn48 == 1) closeMbeOutFile (opts, state); //okay to close right away if nxdn48, no data/voice frames mixing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (voice && facch == 2) //facch steal 2 -- after voice 1
|
||||||
|
{
|
||||||
|
//roll the voice scrambler LFSR here if key available to advance seed -- half rotation on a facch steal
|
||||||
|
if (state->nxdn_cipher_type == 0x1 && state->R != 0)
|
||||||
|
{
|
||||||
|
char ambe_temp[49] = {0};
|
||||||
|
char ambe_d[49] = {0};
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
LFSRN(ambe_temp, ambe_d, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->payload == 1 && !voice) fprintf (stderr, "\n");
|
||||||
|
else if (opts->payload == 0) fprintf (stderr, "\n");
|
||||||
|
|
||||||
END: ; //do nothing
|
END: ; //do nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* p25_frequency.c
|
* p25_frequency.c
|
||||||
* P25 Channel to Frequency Calculator
|
* P25 Channel to Frequency Calculator
|
||||||
*
|
*
|
||||||
* NXDN Channel to Frequency, Courtesy of IcomIcR20 and EricCottrell (base values)
|
* NXDN Channel to Frequency Calculator
|
||||||
*
|
*
|
||||||
* LWVMOBILE
|
* LWVMOBILE
|
||||||
* 2022-11 DSD-FME Florida Man Edition
|
* 2022-11 DSD-FME Florida Man Edition
|
||||||
@@ -59,16 +59,16 @@ long int process_channel_to_freq (dsd_opts * opts, dsd_state * state, int channe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//NXDN Channel to Frequency, Courtesy of IcomIcR20 on RR Forums
|
|
||||||
long int nxdn_channel_to_frequency(dsd_opts * opts, dsd_state * state, uint16_t channel)
|
long int nxdn_channel_to_frequency(dsd_opts * opts, dsd_state * state, uint16_t channel)
|
||||||
{
|
{
|
||||||
long int freq;
|
long int freq;
|
||||||
long int base = 0;
|
long int base = 0;
|
||||||
|
long int step = 0;
|
||||||
|
|
||||||
//the base freq value is per EricCottrell in the Understanding NXDN Trunking Forum Thread
|
//reworked to include Direct Frequency Assignment if available
|
||||||
//will need to do some research or tests to confirm these values are accurate
|
|
||||||
|
|
||||||
//first, check channel map
|
//first, check channel map for imported value, DFA systems most likely won't need an import,
|
||||||
|
//unless it has 'system definable' attributes
|
||||||
if (state->trunk_chan_map[channel] != 0)
|
if (state->trunk_chan_map[channel] != 0)
|
||||||
{
|
{
|
||||||
freq = state->trunk_chan_map[channel];
|
freq = state->trunk_chan_map[channel];
|
||||||
@@ -76,33 +76,41 @@ long int nxdn_channel_to_frequency(dsd_opts * opts, dsd_state * state, uint16_t
|
|||||||
return (freq);
|
return (freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if not found, attempt to find it via calculation
|
//then, let's see if its DFA instead -- 6.5.36
|
||||||
else
|
else if (state->nxdn_rcn == 1)
|
||||||
{
|
{
|
||||||
if ((channel > 0) && (channel <= 400))
|
//determine the base frequency in Hz
|
||||||
{
|
if (state->nxdn_base_freq == 1) base = 100000000; //100 MHz
|
||||||
if (opts->frame_nxdn48 == 1) base = 450000000;
|
else if (state->nxdn_base_freq == 2) base = 330000000; //330 Mhz
|
||||||
else base = 451000000;
|
else if (state->nxdn_base_freq == 3) base = 400000000; //400 Mhz
|
||||||
|
else if (state->nxdn_base_freq == 4) base = 750000000; //750 Mhz
|
||||||
|
else base = 0; //just set to zero, will be system definable most likely and won't be able to calc
|
||||||
|
|
||||||
freq = base + (channel - 1) * 12500;
|
//determine the step value in Hz
|
||||||
fprintf (stderr, "\n Frequency [%.6lf] MHz", (double)freq/1000000);
|
if (state->nxdn_step = 2) step = 1250; //1.25 kHz
|
||||||
return (freq);
|
else if (state->nxdn_step = 3) step = 3125; //3.125 kHz
|
||||||
}
|
else step = 0; //just set to zero, will be system definable most likely and won't be able to calc
|
||||||
else if ((channel >= 401) && (channel <= 800))
|
|
||||||
{
|
|
||||||
if (opts->frame_nxdn48 == 1) base = 460000000;
|
|
||||||
else base = 461000000;
|
|
||||||
|
|
||||||
freq = base + (channel - 401) * 12500;
|
//if we have a valid base and step, then calc frequency
|
||||||
fprintf (stderr, "\n Frequency [%.6lf] MHz", (double)freq/1000000);
|
//6.5.45. Outbound/Inbound Frequency Number (OFN/IFN)
|
||||||
|
if (base && step)
|
||||||
|
{
|
||||||
|
freq = base + (channel * step);
|
||||||
|
fprintf (stderr, "\n DFA Frequency [%.6lf] MHz", (double)freq/1000000);
|
||||||
return (freq);
|
return (freq);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\n Non-standard frequency or channel not found in import file");
|
fprintf(stderr, "\n Custom DFA Settings -- Unknown Freq;");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\n Channel not found in import file");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
470
src/p25_lcw.c
470
src/p25_lcw.c
@@ -1,160 +1,350 @@
|
|||||||
|
/*-------------------------------------------------------------------------------
|
||||||
|
* p25_lcw.c
|
||||||
|
* P25p1 Link Control Word Decoding
|
||||||
|
*
|
||||||
|
* LWVMOBILE
|
||||||
|
* 2023-05 DSD-FME Florida Man Edition
|
||||||
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
|
||||||
void
|
//new p25_lcw function here -- TIA-102.AABF-D LCW Format Messages (if anybody wants to fill the rest out)
|
||||||
processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, char *lcinfo)
|
void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t irrecoverable_errors)
|
||||||
{
|
{
|
||||||
|
uint8_t lc_format = (uint8_t)ConvertBitIntoBytes(&LCW_bits[0], 8); //format
|
||||||
|
uint8_t lc_opcode = (uint8_t)ConvertBitIntoBytes(&LCW_bits[2], 8); //opcode portion of format
|
||||||
|
uint8_t lc_mfid = (uint8_t)ConvertBitIntoBytes(&LCW_bits[8], 8); //mfid
|
||||||
|
uint8_t lc_svcopt = (uint8_t)ConvertBitIntoBytes(&LCW_bits[16], 8); //service options
|
||||||
|
uint8_t lc_pf = LCW_bits[0]; //protect flag
|
||||||
|
uint8_t lc_sf = LCW_bits[1]; //Implicit / Explicit MFID Format
|
||||||
|
|
||||||
char tgid[17], tmpstr[255];
|
if (lc_pf == 1) //check the protect flag -- if set, its an encrypted lcw
|
||||||
long talkgroup, source;
|
{
|
||||||
int i, j;
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " LCW Protected ");
|
||||||
|
fprintf (stderr, "%s",KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
tgid[16] = 0;
|
if (lc_pf == 0) //not protected/encrypted lcw
|
||||||
|
{
|
||||||
|
|
||||||
if (opts->p25lc == 1)
|
if (opts->payload == 1) fprintf (stderr, " LCW");
|
||||||
{
|
|
||||||
fprintf (stderr, "lcformat: %s mfid: %s lcinfo: %s ", lcformat, mfid, lcinfo);
|
|
||||||
if (opts->p25tg == 0)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp (lcformat, "00000100") == 0)
|
//check to see if we need to run these as MFID 0 or 1 only (standard)
|
||||||
|
if (lc_mfid == 0 || lc_mfid == 1) //lc_mfid == 0
|
||||||
{
|
{
|
||||||
|
|
||||||
// first tg is the active channel
|
//check the service options on applicable formats
|
||||||
j = 0;
|
if (lc_format == 0x4A || lc_format == 0x46 || lc_format == 0x45
|
||||||
for (i = 40; i < 52; i++)
|
|| lc_format == 0x44 || lc_format == 0x03 || lc_format == 0x00)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (lc_svcopt & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (lc_svcopt & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
{
|
{
|
||||||
if (state->tgcount < 24)
|
if (lc_svcopt & 0x20) fprintf (stderr, " Duplex");
|
||||||
{
|
if (lc_svcopt & 0x10) fprintf (stderr, " Packet");
|
||||||
state->tg[state->tgcount][j] = lcinfo[i];
|
else fprintf (stderr, " Circuit");
|
||||||
}
|
if (lc_svcopt & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
tmpstr[j] = lcinfo[i];
|
fprintf (stderr, " Priority %d", lc_svcopt & 0x7); //call priority
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
tmpstr[12] = 48;
|
}
|
||||||
tmpstr[13] = 48;
|
|
||||||
tmpstr[14] = 48;
|
if (lc_format == 0x00)
|
||||||
tmpstr[15] = 48;
|
{
|
||||||
tmpstr[16] = 0;
|
fprintf (stderr, " Group Voice Channel User");
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
uint8_t res = (uint8_t)ConvertBitIntoBytes(&LCW_bits[24], 7);
|
||||||
state->lasttg = talkgroup;
|
uint8_t explicit = LCW_bits[24]; //explicit source id required == 1, full SUID on seperate LCW
|
||||||
if (state->tgcount < 24)
|
uint16_t group = (uint16_t)ConvertBitIntoBytes(&LCW_bits[32], 16);
|
||||||
|
uint32_t source = (uint32_t)ConvertBitIntoBytes(&LCW_bits[48], 24);
|
||||||
|
fprintf (stderr, " - Group %d Source %d", group, source);
|
||||||
|
|
||||||
|
//don't set this when zero, annoying blink occurs in ncurses
|
||||||
|
if (group != 0) state->lasttg = group;
|
||||||
|
if (source != 0) state->lastsrc = source;
|
||||||
|
|
||||||
|
sprintf (state->call_string[0], " Group ");
|
||||||
|
if (lc_svcopt & 0x80) strcat (state->call_string[0], " Emergency ");
|
||||||
|
else if (lc_svcopt & 0x40) strcat (state->call_string[0], " Encrypted ");
|
||||||
|
else strcat (state->call_string[0], " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x03)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Unit to Unit Voice Channel User");
|
||||||
|
uint32_t target = (uint32_t)ConvertBitIntoBytes(&LCW_bits[24], 24);
|
||||||
|
uint32_t source = (uint32_t)ConvertBitIntoBytes(&LCW_bits[48], 24);
|
||||||
|
fprintf (stderr, " - Target %d Source %d", target, source);
|
||||||
|
|
||||||
|
//don't set this when zero, annoying blink occurs in ncurses
|
||||||
|
if (target != 0) state->lasttg = target;
|
||||||
|
if (source != 0) state->lastsrc = source;
|
||||||
|
|
||||||
|
sprintf (state->call_string[0], " Private ");
|
||||||
|
if (lc_svcopt & 0x80) strcat (state->call_string[0], " Emergency ");
|
||||||
|
else if (lc_svcopt & 0x40) strcat (state->call_string[0], " Encrypted ");
|
||||||
|
else strcat (state->call_string[0], " ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//uses explicit bit?
|
||||||
|
else if (lc_format == 0x42) //is this group only, or group and private?
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Group Voice Channel Update - ");
|
||||||
|
uint16_t channel1 = (uint16_t)ConvertBitIntoBytes(&LCW_bits[8], 16);
|
||||||
|
uint16_t group1 = (uint16_t)ConvertBitIntoBytes(&LCW_bits[24], 16);
|
||||||
|
uint16_t channel2 = (uint16_t)ConvertBitIntoBytes(&LCW_bits[40], 16);
|
||||||
|
uint16_t group2 = (uint16_t)ConvertBitIntoBytes(&LCW_bits[56], 16);
|
||||||
|
|
||||||
|
if (channel1 && group1)
|
||||||
{
|
{
|
||||||
state->tgcount = state->tgcount + 1;
|
fprintf (stderr, "Ch: %04X TG: %d; ", channel1, group1);
|
||||||
}
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; ", channel1, group1);
|
||||||
if (opts->p25tg == 1)
|
state->last_active_time = time(NULL);
|
||||||
{
|
|
||||||
fprintf (stderr, "tg: %li ", talkgroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->p25tg == 1)
|
if (channel2 && group2 && group1 != group2)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "tg: %li ", talkgroup);
|
fprintf (stderr, "Ch: %04X TG: %d; ", channel2, group2);
|
||||||
|
sprintf (state->active_channel[1], "Active Ch: %04X TG: %d; ", channel2, group2);
|
||||||
// the remaining 3 appear to be other active tg's on the system
|
state->last_active_time = time(NULL);
|
||||||
j = 0;
|
|
||||||
for (i = 28; i < 40; i++)
|
|
||||||
{
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[12] = 48;
|
|
||||||
tmpstr[13] = 48;
|
|
||||||
tmpstr[14] = 48;
|
|
||||||
tmpstr[15] = 48;
|
|
||||||
tmpstr[16] = 0;
|
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
|
||||||
fprintf (stderr, "%li ", talkgroup);
|
|
||||||
j = 0;
|
|
||||||
for (i = 16; i < 28; i++)
|
|
||||||
{
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[12] = 48;
|
|
||||||
tmpstr[13] = 48;
|
|
||||||
tmpstr[14] = 48;
|
|
||||||
tmpstr[15] = 48;
|
|
||||||
tmpstr[16] = 0;
|
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
|
||||||
fprintf (stderr, "%li ", talkgroup);
|
|
||||||
j = 0;
|
|
||||||
for (i = 4; i < 16; i++)
|
|
||||||
{
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[12] = 48;
|
|
||||||
tmpstr[13] = 48;
|
|
||||||
tmpstr[14] = 48;
|
|
||||||
tmpstr[15] = 48;
|
|
||||||
tmpstr[16] = 0;
|
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
|
||||||
fprintf (stderr, "%li\n", talkgroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x44)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Group Voice Channel Update – Explicit");
|
||||||
|
uint16_t group1 = (uint16_t)ConvertBitIntoBytes(&LCW_bits[24], 16);
|
||||||
|
uint16_t channelt = (uint16_t)ConvertBitIntoBytes(&LCW_bits[40], 16);
|
||||||
|
uint16_t channelr = (uint16_t)ConvertBitIntoBytes(&LCW_bits[56], 16);
|
||||||
|
fprintf (stderr, "Ch: %04X TG: %d; ", channelt, group1);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x45)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Unit to Unit Answer Request");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x46)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Telephone Interconnect Voice Channel User");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x47)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Telephone Interconnect Answer Request");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x49)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Souce ID Extension");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x4A)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Unit to Unit Voice Channel User – Extended");
|
||||||
|
uint32_t target = (uint32_t)ConvertBitIntoBytes(&LCW_bits[16], 24);
|
||||||
|
uint32_t suid = (uint32_t)ConvertBitIntoBytes(&LCW_bits[40], 24);
|
||||||
|
fprintf (stderr, "TGT: %04X SUID: %d; ", target, suid);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x50)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Group Affiliation Query");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x51)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Unit Registration Command");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x52) //wonder if anybody uses this if its deleted/obsolete
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Unit Authentication Command - OBSOLETE");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x53)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Status Query");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x54)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Status Update");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x55)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Status Update");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x56)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Call Alert");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x57)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Extended Function Command");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x58)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Channel Identifier Update");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x59)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Channel Identifier Update VU");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x5A)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Status Update – Source ID Extension Required");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x5C)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Extended Function Command – Source ID Extension Required");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x60)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " System Service Broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x61)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Secondary Control Channel Broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x62)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Adjacent Site Status Broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x63)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " RFSS Status Broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x64)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Network Status Broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x65)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Protection Parameter Broadcast - OBSOLETE");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (lc_format == 0x66)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Secondary Control Channel Broadcast – Explicit (LCSCBX)");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x67) //explicit
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Adjacent Site Status (LCASBX)");
|
||||||
|
uint8_t lra = (uint8_t)ConvertBitIntoBytes(&LCW_bits[8], 8);
|
||||||
|
uint16_t channelt = (uint16_t)ConvertBitIntoBytes(&LCW_bits[16], 16);
|
||||||
|
uint8_t rfssid = (uint8_t)ConvertBitIntoBytes(&LCW_bits[32], 8);
|
||||||
|
uint8_t siteid = (uint8_t)ConvertBitIntoBytes(&LCW_bits[40], 8);
|
||||||
|
uint16_t channelr = (uint16_t)ConvertBitIntoBytes(&LCW_bits[48], 16);
|
||||||
|
uint8_t cfva = (uint8_t)ConvertBitIntoBytes(&LCW_bits[64], 4);
|
||||||
|
fprintf (stderr, " - RFSS %d Site %d CH %04X", rfssid, siteid, channelt);
|
||||||
|
|
||||||
|
//debug print only
|
||||||
|
// fprintf (stderr, "\n ");
|
||||||
|
// fprintf (stderr, " LRA [%02X] RFSS [%03d] SITE [%03d] CHAN-T [%04X] CHAN-R [%02X] CFVA [%X]\n ", lra, rfssid, siteid, channelt, channelr, cfva);
|
||||||
|
// if (cfva & 0x8) fprintf (stderr, " Conventional");
|
||||||
|
// if (cfva & 0x4) fprintf (stderr, " Failure Condition");
|
||||||
|
// if (cfva & 0x2) fprintf (stderr, " Up to Date (Correct)");
|
||||||
|
// else fprintf (stderr, " Last Known");
|
||||||
|
if (cfva & 0x1) fprintf (stderr, "- Connection Active");
|
||||||
|
// process_channel_to_freq (opts, state, channelt);
|
||||||
|
//end debug, way too much for a simple link control line
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x68)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " RFSS Status Broadcast – Explicit (LCRSBX)");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x69)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Network Status Broadcast – Explicit (LCNSBX)");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x6A)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Conventional Fallback");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (lc_format == 0x6B)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Message Update – Source ID Extension Required");
|
||||||
|
}
|
||||||
|
|
||||||
|
//tune back to CC here - save about 1-2 seconds
|
||||||
|
else if (lc_format == 0x4F) //# Call Termination/Cancellation
|
||||||
|
{
|
||||||
|
fprintf (stderr, " Call Termination/Cancellation");
|
||||||
|
if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && opts->p25_is_tuned == 1)
|
||||||
|
{
|
||||||
|
//rigctl
|
||||||
|
if (opts->use_rigctl == 1)
|
||||||
|
{
|
||||||
|
state->lasttg = 0;
|
||||||
|
state->lastsrc = 0;
|
||||||
|
state->payload_algid = 0;
|
||||||
|
state->payload_keyid = 0;
|
||||||
|
// state->payload_miP = 0;
|
||||||
|
//reset some strings
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->active_channel[0], "%s", "");
|
||||||
|
sprintf (state->active_channel[1], "%s", "");
|
||||||
|
opts->p25_is_tuned = 0;
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
||||||
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
|
}
|
||||||
|
//rtl_udp
|
||||||
|
else if (opts->audio_in_type == 3)
|
||||||
|
{
|
||||||
|
state->lasttg = 0;
|
||||||
|
state->lastsrc = 0;
|
||||||
|
state->payload_algid = 0;
|
||||||
|
state->payload_keyid = 0;
|
||||||
|
// state->payload_miP = 0;
|
||||||
|
//reset some strings
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->active_channel[0], "%s", "");
|
||||||
|
sprintf (state->active_channel[1], "%s", "");
|
||||||
|
opts->p25_is_tuned = 0;
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
||||||
|
rtl_udp_tune (opts, state, state->p25_cc_freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else fprintf (stderr, " Unknown Format %02X MFID %02X SVC %02X", lc_format, lc_mfid, lc_svcopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp (lcformat, "00000000") == 0)
|
//not a duplicate, this one will print if not MFID 0 or 1
|
||||||
{
|
else fprintf (stderr, " Unknown Format %02X MFID %02X ", lc_format, lc_mfid);
|
||||||
j = 0;
|
}
|
||||||
if (strcmp (mfid, "10010000") == 0)
|
|
||||||
{
|
//ending line break
|
||||||
for (i = 20; i < 32; i++)
|
fprintf (stderr, "\n");
|
||||||
{
|
|
||||||
if (state->tgcount < 24)
|
|
||||||
{
|
|
||||||
state->tg[state->tgcount][j] = lcinfo[i];
|
|
||||||
}
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[12] = 48;
|
|
||||||
tmpstr[13] = 48;
|
|
||||||
tmpstr[14] = 48;
|
|
||||||
tmpstr[15] = 48;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 16; i < 32; i++)
|
|
||||||
{
|
|
||||||
if (state->tgcount < 24)
|
|
||||||
{
|
|
||||||
state->tg[state->tgcount][j] = lcinfo[i];
|
|
||||||
}
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmpstr[16] = 0;
|
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
|
||||||
state->lasttg = talkgroup;
|
|
||||||
if (state->tgcount < 24)
|
|
||||||
{
|
|
||||||
state->tgcount = state->tgcount + 1;
|
|
||||||
}
|
|
||||||
if (opts->p25tg == 1)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "tg: %li ", talkgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
for (i = 32; i < 56; i++)
|
|
||||||
{
|
|
||||||
tmpstr[j] = lcinfo[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[24] = 0;
|
|
||||||
source = strtol (tmpstr, NULL, 2);
|
|
||||||
state->lastsrc = source;
|
|
||||||
if (opts->p25tg == 1)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "src: %li emr: %c\n", source, lcinfo[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((opts->p25tg == 1) && (opts->p25lc == 1))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ static int find_min(uint8_t list[], int len) {
|
|||||||
index = i;
|
index = i;
|
||||||
unique = 1;
|
unique = 1;
|
||||||
} else if (list[i] == min) {
|
} else if (list[i] == min) {
|
||||||
unique = 0;
|
//unique = 0;
|
||||||
|
; //do nothing, still can be correct and pass CRC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* return -1 if a minimum can't be found */
|
/* return -1 if a minimum can't be found */
|
||||||
|
|||||||
107
src/p25p1_hdu.c
107
src/p25p1_hdu.c
@@ -453,93 +453,40 @@ processHDU(dsd_opts* opts, dsd_state* state)
|
|||||||
status = getDibit (opts, state);
|
status = getDibit (opts, state);
|
||||||
//TODO: Do something useful with the status bits...
|
//TODO: Do something useful with the status bits...
|
||||||
|
|
||||||
//if (state->carrier == 1 && state->errs == 0) //only update when carrier is present, and no errors??
|
algidhex = strtol (algid, NULL, 2);
|
||||||
if (state->carrier == 1)
|
kidhex = strtol (kid, NULL, 2);
|
||||||
{
|
mihex1 = (unsigned long long int)ConvertBitIntoBytes(&mi[0], 32);
|
||||||
algidhex = strtol (algid, NULL, 2);
|
mihex2 = (unsigned long long int)ConvertBitIntoBytes(&mi[32], 32);
|
||||||
kidhex = strtol (kid, NULL, 2);
|
mihex3 = (unsigned long long int)ConvertBitIntoBytes(&mi[64], 8);
|
||||||
|
|
||||||
state->payload_algid = algidhex;
|
|
||||||
state->payload_keyid = kidhex;
|
|
||||||
//state->payload_mfid = ConvertBitIntoBytes(&mfid[0], 7);
|
|
||||||
//state->payload_mfid = strtol (mfid, NULL, 2);
|
|
||||||
|
|
||||||
mihex1 = (unsigned long long int)ConvertBitIntoBytes(&mi[0], 32);
|
|
||||||
mihex2 = (unsigned long long int)ConvertBitIntoBytes(&mi[32], 32);
|
|
||||||
mihex3 = (unsigned long long int)ConvertBitIntoBytes(&mi[64], 8);
|
|
||||||
//only use 64 MSB, trailing 8 bits aren't used, so no mihex3
|
|
||||||
state->payload_miP = (mihex1 << 32) | (mihex2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//set vc counter to 0
|
//set vc counter to 0
|
||||||
state->p25vc = 0;
|
state->p25vc = 0;
|
||||||
|
|
||||||
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
if (irrecoverable_errors == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
fprintf (stderr, " HDU ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08llX%08llX%02llX MFID: 0x%02X", algidhex, kidhex, mihex1, mihex2, mihex3, state->payload_mfid);
|
fprintf (stderr, " HDU ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08llX%08llX%02llX", algidhex, kidhex, mihex1, mihex2, mihex3);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
state->payload_algid = algidhex;
|
||||||
|
state->payload_keyid = kidhex;
|
||||||
|
//only use 64 MSB, trailing 8 bits aren't used, so no mihex3
|
||||||
|
state->payload_miP = (mihex1 << 32) | (mihex2);
|
||||||
|
|
||||||
|
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " ENC");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s", KRED);
|
|
||||||
fprintf (stderr, " ENC \n");
|
|
||||||
fprintf (stderr, "%s", KNRM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts->p25enc == 1 && opts->payload == 0)
|
|
||||||
{
|
|
||||||
algidhex = strtol (algid, NULL, 2);
|
|
||||||
kidhex = strtol (kid, NULL, 2);
|
|
||||||
}
|
|
||||||
if (opts->p25lc == 1)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "mfid: %s tgid: %s ", mfid, tgid);
|
|
||||||
if (opts->p25tg == 0)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
if (strcmp (mfid, "10010000") == 0)
|
|
||||||
{
|
|
||||||
for (i = 4; i < 16; i++)
|
|
||||||
{
|
|
||||||
if (state->tgcount < 24)
|
|
||||||
{
|
|
||||||
state->tg[state->tgcount][j] = tgid[i];
|
|
||||||
}
|
|
||||||
tmpstr[j] = tgid[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
tmpstr[12] = '0';
|
|
||||||
tmpstr[13] = '0';
|
|
||||||
tmpstr[14] = '0';
|
|
||||||
tmpstr[15] = '0';
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < 16; i++)
|
fprintf (stderr, "%s", KRED);
|
||||||
{
|
fprintf (stderr, " HDU FEC ERR \n");
|
||||||
if (state->tgcount < 24)
|
fprintf (stderr, "%s", KNRM);
|
||||||
{
|
}
|
||||||
state->tg[state->tgcount][j] = tgid[i];
|
|
||||||
}
|
|
||||||
tmpstr[j] = tgid[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmpstr[16] = 0;
|
|
||||||
talkgroup = strtol (tmpstr, NULL, 2);
|
|
||||||
state->lasttg = talkgroup;
|
|
||||||
if (state->tgcount < 24)
|
|
||||||
{
|
|
||||||
state->tgcount = state->tgcount + 1;
|
|
||||||
}
|
|
||||||
if (opts->p25tg == 1)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "tg: %li\n", talkgroup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,15 +324,53 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
|
|||||||
lcinfo[54] = hex_data[ 0][4] + '0';
|
lcinfo[54] = hex_data[ 0][4] + '0';
|
||||||
lcinfo[55] = hex_data[ 0][5] + '0';
|
lcinfo[55] = hex_data[ 0][5] + '0';
|
||||||
|
|
||||||
unsigned long long int lcinfohex = 0;
|
int j;
|
||||||
if (state->carrier == 1 && state->errs == 0) //only update when carrier is present, otherwise, garbage values may be collected
|
uint8_t LCW_bytes[9];
|
||||||
{
|
uint8_t LCW_bits[72];
|
||||||
state->payload_mfid = strtol (mfid, NULL, 2);
|
memset (LCW_bytes, 0, sizeof(LCW_bytes));
|
||||||
|
memset (LCW_bits, 0, sizeof(LCW_bits));
|
||||||
|
|
||||||
//state->payload_mfid = ConvertBitIntoBytes(&mfid[0], 7);
|
//load array above into byte form first
|
||||||
lcinfohex = ConvertBitIntoBytes(&lcinfo[0], 55);
|
LCW_bytes[0] = (uint8_t) ConvertBitIntoBytes(&lcformat[0], 8);
|
||||||
//fprintf (stderr, " LDU1 LCINFO %16llX \n", lcinfohex);
|
LCW_bytes[1] = (uint8_t) ConvertBitIntoBytes(&mfid[0], 8);
|
||||||
|
for (i = 0; i < 7; i++) LCW_bytes[i+2] = (uint8_t) ConvertBitIntoBytes(&lcinfo[i*8], 8);
|
||||||
|
|
||||||
|
//load as bit array next (easier to process data in bit form)
|
||||||
|
for(i = 0, j = 0; i < 9; i++, j+=8)
|
||||||
|
{
|
||||||
|
LCW_bits[j + 0] = (LCW_bytes[i] >> 7) & 0x01;
|
||||||
|
LCW_bits[j + 1] = (LCW_bytes[i] >> 6) & 0x01;
|
||||||
|
LCW_bits[j + 2] = (LCW_bytes[i] >> 5) & 0x01;
|
||||||
|
LCW_bits[j + 3] = (LCW_bytes[i] >> 4) & 0x01;
|
||||||
|
LCW_bits[j + 4] = (LCW_bytes[i] >> 3) & 0x01;
|
||||||
|
LCW_bits[j + 5] = (LCW_bytes[i] >> 2) & 0x01;
|
||||||
|
LCW_bits[j + 6] = (LCW_bytes[i] >> 1) & 0x01;
|
||||||
|
LCW_bits[j + 7] = (LCW_bytes[i] >> 0) & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
processP25lcw (opts, state, lcformat, mfid, lcinfo);
|
//send to new P25 LCW function
|
||||||
|
if (irrecoverable_errors == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
p25_lcw (opts, state, LCW_bits, 0);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " LCW FEC ERR ");
|
||||||
|
fprintf (stderr, "%s\n", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
fprintf (stderr, " P25 LCW Payload ");
|
||||||
|
for (i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", LCW_bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s\n", KNRM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,37 +357,37 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
|
|||||||
kid[14] = hex_data[ 0][4] + '0';
|
kid[14] = hex_data[ 0][4] + '0';
|
||||||
kid[15] = hex_data[ 0][5] + '0';
|
kid[15] = hex_data[ 0][5] + '0';
|
||||||
|
|
||||||
|
algidhex = strtol (algid, NULL, 2);
|
||||||
|
kidhex = strtol (kid, NULL, 2);
|
||||||
|
mihex1 = (unsigned long long int)ConvertBitIntoBytes(&mi[0], 32);
|
||||||
|
mihex2 = (unsigned long long int)ConvertBitIntoBytes(&mi[32], 32);
|
||||||
|
mihex3 = (unsigned long long int)ConvertBitIntoBytes(&mi[64], 8);
|
||||||
|
|
||||||
//if (state->carrier == 1 && state->errs == 0) //only update when carrier is present, and no errors??
|
if (irrecoverable_errors == 0)
|
||||||
if (state->carrier == 1)
|
|
||||||
{
|
|
||||||
|
|
||||||
algidhex = strtol (algid, NULL, 2);
|
|
||||||
kidhex = strtol (kid, NULL, 2);
|
|
||||||
|
|
||||||
state->payload_algid = algidhex;
|
|
||||||
state->payload_keyid = kidhex;
|
|
||||||
|
|
||||||
mihex1 = (unsigned long long int)ConvertBitIntoBytes(&mi[0], 32);
|
|
||||||
mihex2 = (unsigned long long int)ConvertBitIntoBytes(&mi[32], 32);
|
|
||||||
mihex3 = (unsigned long long int)ConvertBitIntoBytes(&mi[64], 8);
|
|
||||||
//only use 64 MSB, trailing 8 bits aren't used, so no mihex3
|
|
||||||
state->payload_miP = (mihex1 << 32) | (mihex2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
fprintf (stderr, " LDU2 ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08llX%08llX%02llX", algidhex, kidhex, mihex1, mihex2, mihex3);
|
fprintf (stderr, " LDU2 ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08llX%08llX%02llX", algidhex, kidhex, mihex1, mihex2, mihex3);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
|
||||||
|
|
||||||
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
state->payload_algid = algidhex;
|
||||||
|
state->payload_keyid = kidhex;
|
||||||
|
//only use 64 MSB, trailing 8 bits aren't used, so no mihex3
|
||||||
|
state->payload_miP = (mihex1 << 32) | (mihex2);
|
||||||
|
|
||||||
|
if (state->payload_algid != 0x80 && state->payload_algid != 0x0) //print on payload == 1
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KRED);
|
||||||
|
fprintf (stderr, " ENC");
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KRED);
|
fprintf (stderr, "%s", KRED);
|
||||||
fprintf (stderr, " ENC \n");
|
fprintf (stderr, " LDU2 FEC ERR \n");
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
506
src/p25p1_mdpu.c
Normal file
506
src/p25p1_mdpu.c
Normal file
@@ -0,0 +1,506 @@
|
|||||||
|
/*-------------------------------------------------------------------------------
|
||||||
|
* p25p1_mpdu.c
|
||||||
|
* P25p1 Multi Block PDU and Multi Block Trunking
|
||||||
|
*
|
||||||
|
* LWVMOBILE
|
||||||
|
* 2023-03 DSD-FME Florida Man Edition
|
||||||
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "dsd.h"
|
||||||
|
|
||||||
|
static uint32_t crc32mbf(uint8_t buf[], int len)
|
||||||
|
{
|
||||||
|
uint32_t g = 0x04c11db7;
|
||||||
|
uint64_t crc = 0;
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
crc <<= 1;
|
||||||
|
int b = ( buf [i / 8] >> (7 - (i % 8)) ) & 1;
|
||||||
|
if (((crc >> 32) ^ b) & 1) crc ^= g;
|
||||||
|
}
|
||||||
|
crc = (crc & 0xffffffff) ^ 0xffffffff;
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void processMPDU(dsd_opts * opts, dsd_state * state)
|
||||||
|
{
|
||||||
|
|
||||||
|
//reset some strings when returning from a call in case they didn't get zipped already
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
|
||||||
|
//clear stale Active Channel messages here
|
||||||
|
if ( (time(NULL) - state->last_active_time) > 3 )
|
||||||
|
{
|
||||||
|
memset (state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsbkbit[196]; //tsbk bit array, 196 trellis encoded bits
|
||||||
|
int tsbk_dibit[98];
|
||||||
|
|
||||||
|
memset (tsbkbit, 0, sizeof(tsbkbit));
|
||||||
|
memset (tsbk_dibit, 0, sizeof(tsbk_dibit));
|
||||||
|
|
||||||
|
int dibit = 0;
|
||||||
|
|
||||||
|
uint8_t tsbk_byte[12]; //12 byte return from bd_bridge (block_deinterleave)
|
||||||
|
memset (tsbk_byte, 0, sizeof(tsbk_byte));
|
||||||
|
|
||||||
|
unsigned long long int PDU[24];
|
||||||
|
memset (PDU, 0, sizeof(PDU));
|
||||||
|
|
||||||
|
int tsbk_decoded_bits[190]; //decoded bits from tsbk_bytes for sending to crc16_lb_bridge
|
||||||
|
memset (tsbk_decoded_bits, 0, sizeof(tsbk_decoded_bits));
|
||||||
|
|
||||||
|
uint8_t mpdu_decoded_bits[288];
|
||||||
|
memset (mpdu_decoded_bits, 0, sizeof(mpdu_decoded_bits));
|
||||||
|
|
||||||
|
uint8_t mpdu_crc_bits[196];
|
||||||
|
memset (mpdu_crc_bits, 0, sizeof(mpdu_crc_bits));
|
||||||
|
|
||||||
|
uint8_t mpdu_crc_bytes[24];
|
||||||
|
memset (mpdu_crc_bytes, 0, sizeof(mpdu_crc_bytes));
|
||||||
|
|
||||||
|
int flushing_bits[196]; //for flushing the trellis state machine
|
||||||
|
memset (flushing_bits, 0, sizeof(flushing_bits));
|
||||||
|
|
||||||
|
int i, j, k, b, x, y;
|
||||||
|
int ec[3]; //error value returned from (block_deinterleave)
|
||||||
|
int err[2]; //error value returned from ccrc16 or crc32
|
||||||
|
memset (ec, -2, sizeof(ec));
|
||||||
|
memset (err, -2, sizeof(err));
|
||||||
|
|
||||||
|
int skipdibit = 14; //initial status dibit will occur at 14, then add 36 each time it occurs
|
||||||
|
int protectbit = 0;
|
||||||
|
int MFID = 0xFF; //Manufacturer ID
|
||||||
|
|
||||||
|
uint8_t mpdu_byte[36];
|
||||||
|
memset (mpdu_byte, 0, sizeof(mpdu_byte));
|
||||||
|
|
||||||
|
uint8_t io = 0;
|
||||||
|
uint8_t fmt = 0;
|
||||||
|
uint8_t sap = 0;
|
||||||
|
uint8_t blks = 0;
|
||||||
|
uint8_t opcode = 0;
|
||||||
|
|
||||||
|
//CRC32
|
||||||
|
uint32_t CRCComputed = 0;
|
||||||
|
uint32_t CRCExtracted = 0;
|
||||||
|
|
||||||
|
//collect three reps of 101 dibits (98 valid dibits with status dibits interlaced)
|
||||||
|
for (j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
k = 0;
|
||||||
|
for (i = 0; i < 101; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
dibit = getDibit(opts, state);
|
||||||
|
|
||||||
|
if (i+(j*101) != skipdibit) //
|
||||||
|
{
|
||||||
|
tsbk_dibit[k] = dibit;
|
||||||
|
tsbkbit[k*2] = (dibit >> 1) & 1;
|
||||||
|
tsbkbit[k*2+1] = (dibit & 1);
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i+(j*101) == skipdibit)
|
||||||
|
{
|
||||||
|
skipdibit += 36; //was set to 35, this was the bug
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//flushing the trellis state machine
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
bd_bridge(flushing_bits, tsbk_byte);
|
||||||
|
//reset tsbk_byte afterwards
|
||||||
|
memset (tsbk_byte, 0, sizeof(tsbk_byte));
|
||||||
|
}
|
||||||
|
|
||||||
|
//send tsbkbit to block_deinterleave and return tsbk_byte
|
||||||
|
ec[j] = bd_bridge(tsbkbit, tsbk_byte);
|
||||||
|
|
||||||
|
//too many bit manipulations!
|
||||||
|
k = 0;
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
for (x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
tsbk_decoded_bits[k] = ((tsbk_byte[i] << x) & 0x80) >> 7;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CRC16 on the header
|
||||||
|
if (j == 0) err[0] = crc16_lb_bridge(tsbk_decoded_bits, 80);
|
||||||
|
|
||||||
|
//load into bit array for storage (easier decoding for future PDUs)
|
||||||
|
for (i = 0; i < 96; i++) mpdu_decoded_bits[i+(j*96)] = (uint8_t)tsbk_decoded_bits[i];
|
||||||
|
|
||||||
|
//shuffle corrected bits back into tsbk_byte
|
||||||
|
k = 0;
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
int byte = 0;
|
||||||
|
for (x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
byte = byte << 1;
|
||||||
|
byte = byte | tsbk_decoded_bits[k];
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
tsbk_byte[i] = byte;
|
||||||
|
mpdu_byte[i+(j*12)] = byte; //add to completed MBF format bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
io = (mpdu_byte[0] >> 5) & 0x1;
|
||||||
|
fmt = mpdu_byte[0] & 0x1F;
|
||||||
|
sap = mpdu_byte[1] & 0x3F;
|
||||||
|
blks = mpdu_byte[6] & 0x7F;
|
||||||
|
MFID = mpdu_byte[2];
|
||||||
|
|
||||||
|
//group list mode so we can look and see if we need to block tuning any groups, etc
|
||||||
|
char mode[8]; //allow, block, digital, enc, etc
|
||||||
|
|
||||||
|
//if we are using allow/whitelist mode, then write 'B' to mode for block
|
||||||
|
//comparison below will look for an 'A' to write to mode if it is allowed
|
||||||
|
if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B");
|
||||||
|
|
||||||
|
fprintf (stderr, "%s",KGRN);
|
||||||
|
fprintf (stderr, " P25 MBF FMT: %02X SAP: %02X", fmt, sap);
|
||||||
|
fprintf (stderr, " Blocks: %02X MFID: %02X", blks, MFID);
|
||||||
|
|
||||||
|
//trunking blocks
|
||||||
|
if ((sap == 0x3D) && ((fmt == 0x17) || (fmt == 0x15)))
|
||||||
|
{
|
||||||
|
if (fmt == 0x15) fprintf (stderr, " UNC");
|
||||||
|
else fprintf (stderr, " ALT");
|
||||||
|
fprintf (stderr, " MBT"); //find way to convert to vPDU or TSBK format?
|
||||||
|
if (fmt == 0x17) opcode = mpdu_byte[7] & 0x3F; //alt MBT
|
||||||
|
else opcode = mpdu_byte[12] & 0x3F; //unconf MBT
|
||||||
|
fprintf (stderr, " - OP: %02X", opcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//CRC32 is now working!
|
||||||
|
for (i = 0; i < 196; i++) mpdu_crc_bits[i] = mpdu_decoded_bits[i+96];
|
||||||
|
for (i = 0; i < 24; i++) mpdu_crc_bytes[i] = mpdu_byte[i+12];
|
||||||
|
if (blks == 1) //blocks to follow is 1
|
||||||
|
{
|
||||||
|
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&mpdu_crc_bits[96-32], 32);
|
||||||
|
CRCComputed = crc32mbf(mpdu_crc_bytes, 96-32);
|
||||||
|
if (CRCComputed == CRCExtracted) err[1] = 0;
|
||||||
|
}
|
||||||
|
if (blks == 2) //blocks to follow is 2
|
||||||
|
{
|
||||||
|
CRCExtracted = (uint32_t)ConvertBitIntoBytes(&mpdu_crc_bits[192-32], 32);
|
||||||
|
CRCComputed = crc32mbf(mpdu_crc_bytes, 192-32);
|
||||||
|
if (CRCComputed == CRCExtracted) err[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//just going to do a couple for now -- the extended format will not be vPDU compatible :(
|
||||||
|
if (err[0] == 0 && err[1] == 0 && io == 1 && fmt == 0x17) //ALT Format
|
||||||
|
{
|
||||||
|
//NET_STS_BCST -- TIA-102.AABC-D 6.2.11.2
|
||||||
|
if (opcode == 0x3B)
|
||||||
|
{
|
||||||
|
int lra = mpdu_byte[3];
|
||||||
|
int sysid = ((mpdu_byte[4] & 0xF) << 8) | mpdu_byte[5];
|
||||||
|
int res_a = mpdu_byte[8];
|
||||||
|
int res_b = mpdu_byte[9];
|
||||||
|
long int wacn = (mpdu_byte[12] << 12) | (mpdu_byte[13] << 4) | (mpdu_byte[14] >> 4);
|
||||||
|
int channelt = (mpdu_byte[15] << 8) | mpdu_byte[16];
|
||||||
|
int channelr = (mpdu_byte[17] << 8) | mpdu_byte[18];
|
||||||
|
int ssc = mpdu_byte[19];
|
||||||
|
fprintf (stderr, "%s",KYEL);
|
||||||
|
fprintf (stderr, "\n Network Status Broadcast MBT - Extended \n");
|
||||||
|
fprintf (stderr, " LRA [%02X] WACN [%05lX] SYSID [%03X] NAC [%03llX]\n", lra, wacn, sysid, state->p2_cc);
|
||||||
|
fprintf (stderr, " CHAN-T [%04X] CHAN-R [%04X]", channelt, channelr);
|
||||||
|
long int ct_freq = process_channel_to_freq(opts, state, channelt);
|
||||||
|
long int cr_freq = process_channel_to_freq(opts, state, channelr);
|
||||||
|
|
||||||
|
state->p25_cc_freq = ct_freq;
|
||||||
|
state->p25_cc_is_tdma = 0; //flag off for CC tuning purposes when system is qpsk
|
||||||
|
|
||||||
|
//place the cc freq into the list at index 0 if 0 is empty, or not the same,
|
||||||
|
//so we can hunt for rotating CCs without user LCN list
|
||||||
|
if (state->trunk_lcn_freq[0] == 0 || state->trunk_lcn_freq[0] != state->p25_cc_freq)
|
||||||
|
{
|
||||||
|
state->trunk_lcn_freq[0] = state->p25_cc_freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
//only set IF these values aren't already hard set by the user
|
||||||
|
if (state->p2_hardset == 0)
|
||||||
|
{
|
||||||
|
state->p2_wacn = wacn;
|
||||||
|
state->p2_sysid = sysid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//RFSS Status Broadcast - Extended 6.2.15.2
|
||||||
|
else if (opcode == 0x3A)
|
||||||
|
{
|
||||||
|
int lra = mpdu_byte[3];
|
||||||
|
int lsysid = ((mpdu_byte[4] & 0xF) << 8) | mpdu_byte[5];
|
||||||
|
int rfssid = mpdu_byte[12];
|
||||||
|
int siteid = mpdu_byte[13];
|
||||||
|
int channelt = (mpdu_byte[14] << 8) | mpdu_byte[15];
|
||||||
|
int channelr = (mpdu_byte[16] << 8) | mpdu_byte[17];
|
||||||
|
int sysclass = mpdu_byte[18];
|
||||||
|
fprintf (stderr, "%s",KYEL);
|
||||||
|
fprintf (stderr, "\n RFSS Status Broadcast MBF - Extended \n");
|
||||||
|
fprintf (stderr, " LRA [%02X] SYSID [%03X] RFSS ID [%02X] SITE ID [%02X]\n CHAN-T [%04X] CHAN-R [%02X] SSC [%02X] ", lra, lsysid, rfssid, siteid, channelt, channelr, sysclass);
|
||||||
|
process_channel_to_freq (opts, state, channelt);
|
||||||
|
process_channel_to_freq (opts, state, channelr);
|
||||||
|
|
||||||
|
state->p2_siteid = siteid;
|
||||||
|
state->p2_rfssid = rfssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Adjacent Status Broadcast (ADJ_STS_BCST) Extended 6.2.2.2
|
||||||
|
else if (opcode == 0x3C)
|
||||||
|
{
|
||||||
|
int lra = mpdu_byte[3];
|
||||||
|
int cfva = mpdu_byte[4] >> 4;
|
||||||
|
int lsysid = ((mpdu_byte[4] & 0xF) << 8) | mpdu_byte[5];
|
||||||
|
int rfssid = mpdu_byte[8];
|
||||||
|
int siteid = mpdu_byte[9];
|
||||||
|
int channelt = (mpdu_byte[12] << 8) | mpdu_byte[13];
|
||||||
|
int channelr = (mpdu_byte[14] << 8) | mpdu_byte[15];
|
||||||
|
int sysclass = mpdu_byte[16];
|
||||||
|
long int wacn = (mpdu_byte[17] << 12) | (mpdu_byte[18] << 4) | (mpdu_byte[19] >> 4);
|
||||||
|
fprintf (stderr, "%s",KYEL);
|
||||||
|
fprintf (stderr, "\n Adjacent Status Broadcast - Extended\n");
|
||||||
|
fprintf (stderr, " LRA [%02X] CFVA [%X] RFSS[%03d] SYSID [%03X] SITE [%03X]\n CHAN-T [%04X] CHAN-R [%04X] SSC [%02X] WACN [%05lX]\n ", lra, cfva, rfssid, lsysid, siteid, channelt, channelr, sysclass, wacn);
|
||||||
|
if (cfva & 0x8) fprintf (stderr, " Conventional");
|
||||||
|
if (cfva & 0x4) fprintf (stderr, " Failure Condition");
|
||||||
|
if (cfva & 0x2) fprintf (stderr, " Up to Date (Correct)");
|
||||||
|
else fprintf (stderr, " Last Known");
|
||||||
|
if (cfva & 0x1) fprintf (stderr, " Valid RFSS Connection Active");
|
||||||
|
process_channel_to_freq (opts, state, channelt);
|
||||||
|
process_channel_to_freq (opts, state, channelr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Group Voice Channel Grant - Extended
|
||||||
|
else if (opcode == 0x0)
|
||||||
|
{
|
||||||
|
int svc = mpdu_byte[8];
|
||||||
|
int channelt = (mpdu_byte[14] << 8) | mpdu_byte[15];
|
||||||
|
int channelr = (mpdu_byte[16] << 8) | mpdu_byte[17];
|
||||||
|
long int source = (mpdu_byte[3] << 16) |(mpdu_byte[4] << 8) | mpdu_byte[5];
|
||||||
|
int group = (mpdu_byte[18] << 8) | mpdu_byte[19];
|
||||||
|
long int freq1 = 0;
|
||||||
|
long int freq2 = 0;
|
||||||
|
fprintf (stderr, "%s\n ",KYEL);
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
fprintf (stderr, " Group Voice Channel Grant Update - Extended");
|
||||||
|
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc, channelt, channelr, group, group);
|
||||||
|
freq1 = process_channel_to_freq (opts, state, channelt);
|
||||||
|
freq2 = process_channel_to_freq (opts, state, channelr);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d ", channelt, group);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
|
{
|
||||||
|
if (state->group_array[i].groupNumber == group)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " [%s]", state->group_array[i].groupName);
|
||||||
|
strcpy (mode, state->group_array[i].groupMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Skip tuning group calls if group calls are disabled
|
||||||
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (svc & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//tune if tuning available
|
||||||
|
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
||||||
|
{
|
||||||
|
//reworked to set freq once on any call to process_channel_to_freq, and tune on that, independent of slot
|
||||||
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq1 != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
|
{
|
||||||
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
if (opts->mod_qpsk == 1)
|
||||||
|
{
|
||||||
|
int spacing = state->p25_chan_spac[channelt >> 12];
|
||||||
|
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
{
|
||||||
|
state->samplesPerSymbol = 8;
|
||||||
|
state->symbolCenter = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//rigctl
|
||||||
|
if (opts->use_rigctl == 1)
|
||||||
|
{
|
||||||
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
|
SetFreq(opts->rigctl_sockfd, freq1);
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
}
|
||||||
|
//rtl_udp
|
||||||
|
else if (opts->audio_in_type == 3)
|
||||||
|
{
|
||||||
|
rtl_udp_tune (opts, state, freq1);
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unit to Unit Voice Channel Grant - Extended
|
||||||
|
else if (opcode == 0x6)
|
||||||
|
{
|
||||||
|
//I'm not doing EVERY element of this, just enough for tuning!
|
||||||
|
int svc = mpdu_byte[8];
|
||||||
|
int channelt = (mpdu_byte[22] << 8) | mpdu_byte[23];
|
||||||
|
int channelr = (mpdu_byte[24] << 8) | mpdu_byte[25]; //optional!
|
||||||
|
//using source and target address, not source and target id (is this correct?)
|
||||||
|
long int source = (mpdu_byte[3] << 16) |(mpdu_byte[4] << 8) | mpdu_byte[5];
|
||||||
|
long int target = (mpdu_byte[19] << 16) |(mpdu_byte[20] << 8) | mpdu_byte[21];
|
||||||
|
long int freq1 = 0;
|
||||||
|
long int freq2 = 0;
|
||||||
|
fprintf (stderr, "%s\n ",KYEL);
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
fprintf (stderr, " Unit to Unit Voice Channel Grant Update - Extended");
|
||||||
|
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Source [%ld][%04lX] Target [%ld][%04lX]", svc, channelt, channelr, source, source, target, target);
|
||||||
|
freq1 = process_channel_to_freq (opts, state, channelt);
|
||||||
|
freq2 = process_channel_to_freq (opts, state, channelr); //optional!
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TGT: %ld; ", channelt, target);
|
||||||
|
|
||||||
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
|
{
|
||||||
|
if (state->group_array[i].groupNumber == target)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " [%s]", state->group_array[i].groupName);
|
||||||
|
strcpy (mode, state->group_array[i].groupMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Skip tuning private calls if group calls are disabled
|
||||||
|
if (opts->trunk_tune_private_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (svc & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//tune if tuning available
|
||||||
|
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
||||||
|
{
|
||||||
|
//reworked to set freq once on any call to process_channel_to_freq, and tune on that, independent of slot
|
||||||
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq1 != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
|
{
|
||||||
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
if (opts->mod_qpsk == 1)
|
||||||
|
{
|
||||||
|
int spacing = state->p25_chan_spac[channelt >> 12];
|
||||||
|
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
{
|
||||||
|
state->samplesPerSymbol = 8;
|
||||||
|
state->symbolCenter = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//rigctl
|
||||||
|
if (opts->use_rigctl == 1)
|
||||||
|
{
|
||||||
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
|
SetFreq(opts->rigctl_sockfd, freq1);
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
}
|
||||||
|
//rtl_udp
|
||||||
|
else if (opts->audio_in_type == 3)
|
||||||
|
{
|
||||||
|
rtl_udp_tune (opts, state, freq1);
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//convert mpdu_byte to vPDU format and get indication of what the message was
|
||||||
|
PDU[0] = 0x0C; //P25p1 MB Duid 0x0C
|
||||||
|
PDU[1] = opcode;
|
||||||
|
PDU[2] = MFID;
|
||||||
|
PDU[1] = PDU[1] ^ 0xC0; //flip bits to make it compatible with MAC_PDUs explicit format
|
||||||
|
|
||||||
|
//without any extra bytes filled in, we can atleast see what the MBT is supposed to be
|
||||||
|
//Hopefully, no 0 value things will cause issues -- call grants, iden_up, etc!
|
||||||
|
// fprintf (stderr, "%s",KYEL);
|
||||||
|
// process_MAC_VPDU(opts, state, 0, PDU);
|
||||||
|
// fprintf (stderr, "%s",KNRM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SKIPCALL: ; //do nothing
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
fprintf (stderr, "\n P25 MBF Payload \n ");
|
||||||
|
for (i = 0; i < 36; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", mpdu_byte[i]);
|
||||||
|
if (i == 11 || i == 23) fprintf (stderr, "\n ");
|
||||||
|
|
||||||
|
}
|
||||||
|
fprintf (stderr, " CRC EXT %08X CMP %08X", CRCExtracted, CRCComputed);
|
||||||
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
fprintf (stderr, "\n ");
|
||||||
|
|
||||||
|
//Header
|
||||||
|
if (err[0] != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " (HDR CRC16 ERR)");
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
}
|
||||||
|
//Completed MBF
|
||||||
|
if (err[1] != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " (MBF CRC32 ERR)");
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
@@ -33,4 +33,8 @@ processTDU (dsd_opts* opts, dsd_state* state)
|
|||||||
status = getDibit (opts, state) + '0';
|
status = getDibit (opts, state) + '0';
|
||||||
// TODO: do something useful with the status bits...
|
// TODO: do something useful with the status bits...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//reset some strings -- since its a tdu, blank out any call strings, only want during actual call
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,11 +390,60 @@ processTDULC (dsd_opts* opts, dsd_state* state)
|
|||||||
lcinfo[53] = dodeca_data[0][ 9] + '0';
|
lcinfo[53] = dodeca_data[0][ 9] + '0';
|
||||||
lcinfo[54] = dodeca_data[0][10] + '0';
|
lcinfo[54] = dodeca_data[0][10] + '0';
|
||||||
lcinfo[55] = dodeca_data[0][11] + '0';
|
lcinfo[55] = dodeca_data[0][11] + '0';
|
||||||
/*
|
|
||||||
if (state->carrier == 1) //only update when carrier is present, otherwise, garbage values may be collected
|
int j;
|
||||||
|
uint8_t LCW_bytes[9];
|
||||||
|
uint8_t LCW_bits[72];
|
||||||
|
memset (LCW_bytes, 0, sizeof(LCW_bytes));
|
||||||
|
memset (LCW_bits, 0, sizeof(LCW_bits));
|
||||||
|
|
||||||
|
//load array above into byte form first
|
||||||
|
LCW_bytes[0] = (uint8_t) ConvertBitIntoBytes(&lcformat[0], 8);
|
||||||
|
LCW_bytes[1] = (uint8_t) ConvertBitIntoBytes(&mfid[0], 8);
|
||||||
|
for (i = 0; i < 7; i++) LCW_bytes[i+2] = (uint8_t) ConvertBitIntoBytes(&lcinfo[i*8], 8);
|
||||||
|
|
||||||
|
//load as bit array next (easier to process data in bit form)
|
||||||
|
for(i = 0, j = 0; i < 9; i++, j+=8)
|
||||||
{
|
{
|
||||||
state->payload_mfid = strtol (mfid, NULL, 2); //wonder if this is accurate info or not
|
LCW_bits[j + 0] = (LCW_bytes[i] >> 7) & 0x01;
|
||||||
|
LCW_bits[j + 1] = (LCW_bytes[i] >> 6) & 0x01;
|
||||||
|
LCW_bits[j + 2] = (LCW_bytes[i] >> 5) & 0x01;
|
||||||
|
LCW_bits[j + 3] = (LCW_bytes[i] >> 4) & 0x01;
|
||||||
|
LCW_bits[j + 4] = (LCW_bytes[i] >> 3) & 0x01;
|
||||||
|
LCW_bits[j + 5] = (LCW_bytes[i] >> 2) & 0x01;
|
||||||
|
LCW_bits[j + 6] = (LCW_bytes[i] >> 1) & 0x01;
|
||||||
|
LCW_bits[j + 7] = (LCW_bytes[i] >> 0) & 0x01;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
processP25lcw (opts, state, lcformat, mfid, lcinfo);
|
//send to new P25 LCW function
|
||||||
|
if (irrecoverable_errors == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KYEL);
|
||||||
|
p25_lcw (opts, state, LCW_bits, 0);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " LCW FEC ERR ");
|
||||||
|
fprintf (stderr, "%s\n", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
fprintf (stderr, " P25 LCW Payload ");
|
||||||
|
for (i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", LCW_bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fprintf (stderr, "%s\n", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
//reset some strings -- since its a tdu, blank out any call strings, only want during actual call
|
||||||
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,40 @@
|
|||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
|
||||||
void processTSBK(dsd_opts * opts, dsd_state * state)
|
void processTSBK(dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
|
|
||||||
int tsbkbit[196] = {0}; //tsbk bit array, 196 trellis encoded bits
|
//reset some strings when returning from a call in case they didn't get zipped already
|
||||||
int tsbk_dibit[98] = {0};
|
sprintf (state->call_string[0], "%s", " "); //21 spaces
|
||||||
|
sprintf (state->call_string[1], "%s", " "); //21 spaces
|
||||||
|
|
||||||
|
//clear stale Active Channel messages here
|
||||||
|
if ( (time(NULL) - state->last_active_time) > 3 )
|
||||||
|
{
|
||||||
|
memset (state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsbkbit[196]; //tsbk bit array, 196 trellis encoded bits
|
||||||
|
int tsbk_dibit[98];
|
||||||
|
|
||||||
|
memset (tsbkbit, 0, sizeof(tsbkbit));
|
||||||
|
memset (tsbk_dibit, 0, sizeof(tsbk_dibit));
|
||||||
|
|
||||||
int dibit = 0;
|
int dibit = 0;
|
||||||
uint8_t tsbk_byte[12] = {0}; //12 byte return from bd_bridge (block_deinterleave)
|
|
||||||
unsigned long long int PDU[24] = {0}; //24 byte PDU to send to the tsbk_byte vPDU handler, should be same formats (mostly)
|
uint8_t tsbk_byte[12]; //12 byte return from bd_bridge (block_deinterleave)
|
||||||
int tsbk_decoded_bits[190] = {0}; //decoded bits from tsbk_bytes for sending to crc16_lb_bridge
|
memset (tsbk_byte, 0, sizeof(tsbk_byte));
|
||||||
|
|
||||||
|
unsigned long long int PDU[24]; //24 byte PDU to send to the tsbk_byte vPDU handler, should be same formats (mostly)
|
||||||
|
memset (PDU, 0, sizeof(PDU));
|
||||||
|
|
||||||
|
int tsbk_decoded_bits[190]; //decoded bits from tsbk_bytes for sending to crc16_lb_bridge
|
||||||
|
memset (tsbk_decoded_bits, 0, sizeof(tsbk_decoded_bits));
|
||||||
|
|
||||||
|
int flushing_bits[196]; //for flushing the trellis state machine
|
||||||
|
memset (flushing_bits, 0, sizeof(flushing_bits));
|
||||||
|
|
||||||
int i, j, k, b, x, y;
|
int i, j, k, b, x, y;
|
||||||
int ec = -2; //error value returned from (block_deinterleave)
|
int ec = -2; //error value returned from (block_deinterleave)
|
||||||
int err = -2; //error value returned from crc16_lb_bridge
|
int err = -2; //error value returned from crc16_lb_bridge
|
||||||
@@ -24,11 +48,7 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
int protectbit = 0;
|
int protectbit = 0;
|
||||||
int MFID = 0xFF; //Manufacturer ID - Might be beneficial to NOT send anything but standard 0x00 or 0x01 messages
|
int MFID = 0xFF; //Manufacturer ID - Might be beneficial to NOT send anything but standard 0x00 or 0x01 messages
|
||||||
|
|
||||||
//Update: Identified Bug in skipdibit incrememnt causing many block deinterleave/crc failures
|
|
||||||
//with correct values set, now we are decoding many more TSBKs
|
|
||||||
//TODO: Don't Print TSBKs/vPDUs unless verbosity levels set higher
|
//TODO: Don't Print TSBKs/vPDUs unless verbosity levels set higher
|
||||||
//TSBKs are always single block, but up to three can be transmitted in a row,
|
|
||||||
//Multi-Block PDUs are sent on a different DUID - 0xC (not handled currently)
|
|
||||||
|
|
||||||
//collect three reps of 101 dibits (98 valid dibits with status dibits interlaced)
|
//collect three reps of 101 dibits (98 valid dibits with status dibits interlaced)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
@@ -49,11 +69,19 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
if (i+(j*101) == skipdibit)
|
if (i+(j*101) == skipdibit)
|
||||||
{
|
{
|
||||||
skipdibit += 36; //was set to 35, this was the bug
|
skipdibit += 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//flushing the trellis state machine
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
bd_bridge(flushing_bits, tsbk_byte);
|
||||||
|
//reset tsbk_byte afterwards
|
||||||
|
memset (tsbk_byte, 0, sizeof(tsbk_byte));
|
||||||
|
}
|
||||||
|
|
||||||
//send tsbkbit to block_deinterleave and return tsbk_byte
|
//send tsbkbit to block_deinterleave and return tsbk_byte
|
||||||
ec = bd_bridge(tsbkbit, tsbk_byte);
|
ec = bd_bridge(tsbkbit, tsbk_byte);
|
||||||
|
|
||||||
@@ -84,7 +112,7 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
tsbk_byte[i] = byte;
|
tsbk_byte[i] = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
//convert tsbk_byte to PDU and send to vPDU handler
|
//convert tsbk_byte to vPDU and send to vPDU handler
|
||||||
//...may or may not be entirely compatible,
|
//...may or may not be entirely compatible,
|
||||||
MFID = tsbk_byte[1];
|
MFID = tsbk_byte[1];
|
||||||
PDU[0] = 0x07; //P25p1 TSBK Duid 0x07
|
PDU[0] = 0x07; //P25p1 TSBK Duid 0x07
|
||||||
@@ -106,7 +134,10 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
protectbit = (tsbk_byte[0] >> 6) & 0x1;
|
protectbit = (tsbk_byte[0] >> 6) & 0x1;
|
||||||
|
|
||||||
//Don't run NET_STS out of this, or will set wrong NAC/CC //&& PDU[1] != 0x49 && PDU[1] != 0x45
|
//Don't run NET_STS out of this, or will set wrong NAC/CC //&& PDU[1] != 0x49 && PDU[1] != 0x45
|
||||||
//0x49 is telephone grant, 0x46 Unit to Unit Channel Answer Request (seems bogus)
|
//0x49 is telephone grant, 0x46 Unit to Unit Channel Answer Request (seems bogus) (mfid 90)
|
||||||
|
// if (MFID < 0x2 && protectbit == 0 && err == 0 && ec == 0 && PDU[1] != 0x7B )
|
||||||
|
//running with A4 and 90 causing some false positives when sending to vPDU, issuing bad call grants to nowhere!
|
||||||
|
// if ( (MFID < 0x2 || MFID == 0xA4 || MFID == 0x90) && protectbit == 0 && err == 0 && ec == 0 && PDU[1] != 0x7B )
|
||||||
if (MFID < 0x2 && protectbit == 0 && err == 0 && ec == 0 && PDU[1] != 0x7B )
|
if (MFID < 0x2 && protectbit == 0 && err == 0 && ec == 0 && PDU[1] != 0x7B )
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s",KYEL);
|
fprintf (stderr, "%s",KYEL);
|
||||||
@@ -115,9 +146,9 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set our WACN and SYSID here now that we have valid ec and crc/checksum
|
//set our WACN and SYSID here now that we have valid ec and crc/checksum
|
||||||
if (protectbit == 0 && err == 0 && ec == 0 && (tsbk_byte[0] & 0x3F) == 0x3B)
|
else if (protectbit == 0 && err == 0 && ec == 0 && (tsbk_byte[0] & 0x3F) == 0x3B)
|
||||||
{
|
{
|
||||||
long int wacn = (tsbk_byte[3] << 12) | (tsbk_byte[4] << 4) | (tsbk_byte[5] >> 4);;
|
long int wacn = (tsbk_byte[3] << 12) | (tsbk_byte[4] << 4) | (tsbk_byte[5] >> 4);
|
||||||
int sysid = ((tsbk_byte[5] & 0xF) << 8) | tsbk_byte[6];
|
int sysid = ((tsbk_byte[5] & 0xF) << 8) | tsbk_byte[6];
|
||||||
int channel = (tsbk_byte[7] << 8) | tsbk_byte[8];
|
int channel = (tsbk_byte[7] << 8) | tsbk_byte[8];
|
||||||
fprintf (stderr, "%s",KYEL);
|
fprintf (stderr, "%s",KYEL);
|
||||||
@@ -143,16 +174,43 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s",KCYN);
|
fprintf (stderr, "%s",KCYN);
|
||||||
fprintf (stderr, "\n P25 PDU Payload ");
|
fprintf (stderr, "\n P25 PDU Payload #%d ", j);
|
||||||
for (i = 0; i < 12; i++)
|
for (i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "[%02X]", tsbk_byte[i]);
|
fprintf (stderr, "[%02X]", tsbk_byte[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s ", KNRM);
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opts->payload == 1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KCYN);
|
||||||
|
fprintf (stderr, "\n P25 PDU Payload #%d ", j+1);
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", tsbk_byte[i]);
|
||||||
|
}
|
||||||
|
fprintf (stderr, "\n MFID %02X Protected: %d Last Block: %d", MFID, protectbit, (tsbk_byte[0] >> 7) );
|
||||||
|
|
||||||
|
if (ec != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " (FEC ERR)");
|
||||||
|
}
|
||||||
|
else if (err != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s",KRED);
|
||||||
|
fprintf (stderr, " (CRC ERR)");
|
||||||
|
}
|
||||||
|
fprintf (stderr, "%s ", KNRM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//reset for next rep
|
//reset for next rep
|
||||||
ec = -2;
|
ec = -2;
|
||||||
err = -2;
|
err = -2;
|
||||||
@@ -165,5 +223,7 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
|||||||
j = 4; //set j to break the loop early
|
j = 4; //set j to break the loop early
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s ", KNRM);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ int vc_counter = 0;
|
|||||||
int framing_counter = 0;
|
int framing_counter = 0;
|
||||||
|
|
||||||
unsigned long long int isch = 0;
|
unsigned long long int isch = 0;
|
||||||
unsigned long long int isch_decoded = 0;
|
int isch_decoded = -1;
|
||||||
int p2_duid[8] = {0};
|
int p2_duid[8] = {0};
|
||||||
int16_t duid_decoded = 0;
|
int16_t duid_decoded = 0;
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ void process_ISCH (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
isch_decoded = isch_lookup(isch);
|
isch_decoded = isch_lookup(isch);
|
||||||
|
|
||||||
if (isch_decoded > 0)
|
if (isch_decoded > -1)
|
||||||
{
|
{
|
||||||
int uf_count = isch_decoded & 0x3;
|
int uf_count = isch_decoded & 0x3;
|
||||||
int free = (isch_decoded >> 2) & 0x1;
|
int free = (isch_decoded >> 2) & 0x1;
|
||||||
@@ -411,6 +411,7 @@ void process_ISCH (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isch_decoded = -1; //reset to bad value after running
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,19 +686,41 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->currentslot == 0 && duid_decoded != 3 && duid_decoded != 12)
|
if (state->currentslot == 0 && duid_decoded != 3 && duid_decoded != 12)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VCH 0 ");
|
fprintf (stderr, "VCH 0 ");
|
||||||
|
//open MBEout file - slot 1 - USE WITH CAUTION on Phase 2! Consider using a symbol capture bin instead!
|
||||||
|
if (duid_decoded == 0 || duid_decoded == 6) //4V or 2V (voice)
|
||||||
|
{
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (state->currentslot == 1 && duid_decoded != 3 && duid_decoded != 12)
|
else if (state->currentslot == 1 && duid_decoded != 3 && duid_decoded != 12)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VCH 1 ");
|
fprintf (stderr, "VCH 1 ");
|
||||||
|
//open MBEout file - slot 2 - USE WITH CAUTION on Phase 2! Consider using a symbol capture bin instead!
|
||||||
|
if (duid_decoded == 0 || duid_decoded == 6) //4V or 2V (voice)
|
||||||
|
{
|
||||||
|
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_fR == NULL)) openMbeOutFileR (opts, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else fprintf (stderr, "VCH S ");
|
else fprintf (stderr, "VCH S ");
|
||||||
|
|
||||||
|
//check to see when last voice activity occurred in order to allow tuning on phase 2
|
||||||
|
//mac_signal or mac_idle when no more voice activity on current channel
|
||||||
|
//this is primarily a fix for TDMA control channels that carry voice (Duke P25)
|
||||||
|
//but may also allow for chain tuning without returning to the control channel <--may be problematic since we can assign a p25_cc_freq from the pdu
|
||||||
|
if (duid_decoded == 13 && opts->p25_is_tuned == 1 && ((time(NULL) - state->last_vc_sync_time) > opts->trunk_hangtime) ) //version for MAC_SIGNAL only, no idle
|
||||||
|
{
|
||||||
|
opts->p25_is_tuned = 0;
|
||||||
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
||||||
|
memset (state->active_channel, 0, sizeof (state->active_channel)); //zero out here? I think this will be fine
|
||||||
|
}
|
||||||
|
|
||||||
if (duid_decoded == 0)
|
if (duid_decoded == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " 4V %d", state->fourv_counter[state->currentslot]+1);
|
fprintf (stderr, " 4V %d", state->fourv_counter[state->currentslot]+1);
|
||||||
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 &&
|
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 &&
|
||||||
state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
|
state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
|
||||||
{
|
{
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
process_4V (opts, state);
|
process_4V (opts, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,6 +730,7 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
|
|||||||
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 &&
|
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 &&
|
||||||
state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
|
state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
|
||||||
{
|
{
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
process_2V (opts, state);
|
process_2V (opts, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -804,22 +828,21 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
|
|||||||
void processP2 (dsd_opts * opts, dsd_state * state)
|
void processP2 (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
state->dmr_stereo = 1;
|
state->dmr_stereo = 1;
|
||||||
//state->currentslot = 1;
|
|
||||||
|
|
||||||
p2_dibit_buffer (opts, state);
|
p2_dibit_buffer (opts, state);
|
||||||
|
|
||||||
//look at our ISCH values and determine location in superframe before running frame scramble
|
//look at our ISCH values and determine location in superframe before running frame scramble
|
||||||
for (framing_counter = 0; framing_counter < 4; framing_counter++) //12
|
for (framing_counter = 0; framing_counter < 4; framing_counter++)
|
||||||
{
|
{
|
||||||
process_ISCH (opts, state); //run ISCH in here so we know when to start descramble offset
|
//run ISCH in here so we know when to start descramble offset
|
||||||
|
process_ISCH (opts, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set initial current slot depending on offset value
|
//set initial current slot depending on offset value
|
||||||
if (state->p2_scramble_offset % 2)
|
if (state->p2_scramble_offset % 2)
|
||||||
{
|
{
|
||||||
state->currentslot = 0;
|
state->currentslot = 1;
|
||||||
}
|
}
|
||||||
else state->currentslot = 1;
|
else state->currentslot = 0;
|
||||||
|
|
||||||
//frame_scramble runs lfsr and creates an array of unscrambled bits to pull from
|
//frame_scramble runs lfsr and creates an array of unscrambled bits to pull from
|
||||||
process_Frame_Scramble (opts, state);
|
process_Frame_Scramble (opts, state);
|
||||||
|
|||||||
471
src/p25p2_vpdu.c
471
src/p25p2_vpdu.c
@@ -84,7 +84,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//MFID90 Voice Grants, A3, A4, and A5
|
//MFID90 Voice Grants, A3, A4, and A5 <--I bet A4 here was triggering a phantom call when TSBK sent PDUs here
|
||||||
//MFID90 Group Regroup Channel Grant - Implicit
|
//MFID90 Group Regroup Channel Grant - Implicit
|
||||||
if (MAC[1+len_a] == 0xA3 && MAC[2+len_a] == 0x90)
|
if (MAC[1+len_a] == 0xA3 && MAC[2+len_a] == 0x90)
|
||||||
{
|
{
|
||||||
@@ -96,6 +96,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n CHAN [%04X] Group [%d][%04X]", channel, sgroup, sgroup);
|
fprintf (stderr, "\n CHAN [%04X] Group [%d][%04X]", channel, sgroup, sgroup);
|
||||||
freq = process_channel_to_freq (opts, state, channel);
|
freq = process_channel_to_freq (opts, state, channel);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "MFID90 Active Ch: %04X SG: %d; ", channel, sgroup);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
for (int i = 0; i < state->group_tally; i++)
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
{
|
{
|
||||||
if (state->group_array[i].groupNumber == sgroup)
|
if (state->group_array[i].groupNumber == sgroup)
|
||||||
@@ -114,16 +118,27 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//reworked to set freq once on any call to process_channel_to_freq, and tune on that, independent of slot
|
//reworked to set freq once on any call to process_channel_to_freq, and tune on that, independent of slot
|
||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
// //testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[channel >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[channel >> 12];
|
if (state->p25_chan_tdma[channel >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -131,6 +146,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, freq);
|
SetFreq(opts->rigctl_sockfd, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
@@ -138,6 +154,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, freq);
|
rtl_udp_tune (opts, state, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,6 +181,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n CHAN [%04X] Group [%d][%04X]", channel, sgroup, sgroup);
|
fprintf (stderr, "\n CHAN [%04X] Group [%d][%04X]", channel, sgroup, sgroup);
|
||||||
freq = process_channel_to_freq (opts, state, channel);
|
freq = process_channel_to_freq (opts, state, channel);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "MFID90 Active Ch: %04X SG: %d ", channel, sgroup);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
for (int i = 0; i < state->group_tally; i++)
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
{
|
{
|
||||||
if (state->group_array[i].groupNumber == sgroup)
|
if (state->group_array[i].groupNumber == sgroup)
|
||||||
@@ -183,10 +204,20 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[channel >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[channel >> 12];
|
if (state->p25_chan_tdma[channel >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
@@ -199,6 +230,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, freq);
|
SetFreq(opts->rigctl_sockfd, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
@@ -206,6 +238,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, freq);
|
rtl_udp_tune (opts, state, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,6 +272,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
||||||
freq2 = process_channel_to_freq (opts, state, channel2);
|
freq2 = process_channel_to_freq (opts, state, channel2);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "MFID90 Active Ch: %04X SG: %d; Ch: %04X SG: %d; ", channel1, group1, channel2, group2);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
@@ -284,15 +321,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
if (state->p25_chan_tdma[tunable_chan >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -301,6 +349,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -310,6 +359,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_udp_tune (opts, state, tunable_freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,10 +389,27 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
int source = (MAC[7+len_a] << 16) | (MAC[8+len_a] << 8) | MAC[9+len_a];
|
int source = (MAC[7+len_a] << 16) | (MAC[8+len_a] << 8) | MAC[9+len_a];
|
||||||
long int freq = 0;
|
long int freq = 0;
|
||||||
|
|
||||||
fprintf (stderr, "\n Group Voice Channel Grant Update");
|
fprintf (stderr, "\n");
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, " Group Voice Channel Grant Update");
|
||||||
fprintf (stderr, "\n SVC [%02X] CHAN [%04X] Group [%d] Source [%d]", svc, channel, group, source);
|
fprintf (stderr, "\n SVC [%02X] CHAN [%04X] Group [%d] Source [%d]", svc, channel, group, source);
|
||||||
freq = process_channel_to_freq (opts, state, channel);
|
freq = process_channel_to_freq (opts, state, channel);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; ", channel, group);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
for (int i = 0; i < state->group_tally; i++)
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
{
|
{
|
||||||
if (state->group_array[i].groupNumber == group)
|
if (state->group_array[i].groupNumber == group)
|
||||||
@@ -355,6 +422,9 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (svc & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
//tune if tuning available
|
//tune if tuning available
|
||||||
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
||||||
{
|
{
|
||||||
@@ -362,15 +432,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[channel >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[channel >> 12];
|
if (state->p25_chan_tdma[channel >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -378,6 +459,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, freq);
|
SetFreq(opts->rigctl_sockfd, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
@@ -385,6 +467,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, freq);
|
rtl_udp_tune (opts, state, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,7 +486,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Unit-to-Unit Voice Service Channel Grant (UU_V_CH_GRANT), or Grant Update (same format)
|
//Unit-to-Unit Voice Service Channel Grant (UU_V_CH_GRANT), or Grant Update (same format)
|
||||||
if (MAC[1+len_a] == 0x44 || MAC[1+len_a] == 0x46)
|
if (MAC[1+len_a] == 0x44 || MAC[1+len_a] == 0x46) //double check these opcodes
|
||||||
{
|
{
|
||||||
int channel = (MAC[2+len_a] << 8) | MAC[3+len_a];
|
int channel = (MAC[2+len_a] << 8) | MAC[3+len_a];
|
||||||
int target = (MAC[4+len_a] << 16) | (MAC[5+len_a] << 8) | MAC[6+len_a];
|
int target = (MAC[4+len_a] << 16) | (MAC[5+len_a] << 8) | MAC[6+len_a];
|
||||||
@@ -415,9 +498,16 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n CHAN [%04X] Source [%d] Target [%d]", channel, source, target);
|
fprintf (stderr, "\n CHAN [%04X] Source [%d] Target [%d]", channel, source, target);
|
||||||
freq = process_channel_to_freq (opts, state, channel);
|
freq = process_channel_to_freq (opts, state, channel);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TGT: %d; ", channel, target);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
//Skip tuning private calls if private calls is disabled
|
//Skip tuning private calls if private calls is disabled
|
||||||
if (opts->trunk_tune_private_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_private_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled -- abb formats do not carry svc bits :(
|
||||||
|
if (opts->trunk_tune_enc_calls == 0) goto SKIPCALL; //enable, or disable?
|
||||||
|
|
||||||
//unit to unit needs work, may fail under certain conditions (first blocked, second allowed, etc) (labels should still work though)
|
//unit to unit needs work, may fail under certain conditions (first blocked, second allowed, etc) (labels should still work though)
|
||||||
for (int i = 0; i < state->group_tally; i++)
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
{
|
{
|
||||||
@@ -435,15 +525,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[channel >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[channel >> 12];
|
if (state->p25_chan_tdma[channel >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -451,6 +552,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, freq);
|
SetFreq(opts->rigctl_sockfd, freq);
|
||||||
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
@@ -458,6 +560,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, freq);
|
rtl_udp_tune (opts, state, freq);
|
||||||
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,17 +592,46 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
long int freq1r = 0;
|
long int freq1r = 0;
|
||||||
long int freq2t = 0;
|
long int freq2t = 0;
|
||||||
long int freq2r = 0;
|
long int freq2r = 0;
|
||||||
|
|
||||||
fprintf (stderr, "\n Group Voice Channel Grant Update Multiple - Explicit");
|
fprintf (stderr, "\n Group Voice Channel Grant Update Multiple - Explicit");
|
||||||
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc1, channelt1, channelr1, group1, group1);
|
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc1, channelt1, channelr1, group1, group1);
|
||||||
|
if (svc1 & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc1 & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc1 & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc1 & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc1 & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc1 & 0x7); //call priority
|
||||||
|
}
|
||||||
freq1t = process_channel_to_freq (opts, state, channelt1);
|
freq1t = process_channel_to_freq (opts, state, channelt1);
|
||||||
freq1r = process_channel_to_freq (opts, state, channelr1);
|
if (channelr1 != 0 && channelr1 != 0xFFFF) freq1r = process_channel_to_freq (opts, state, channelr1);
|
||||||
|
|
||||||
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc2, channelt2, channelr2, group2, group2);
|
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc2, channelt2, channelr2, group2, group2);
|
||||||
|
if (svc2 & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc2 & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc2 & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc2 & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc2 & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc2 & 0x7); //call priority
|
||||||
|
}
|
||||||
freq1t = process_channel_to_freq (opts, state, channelt2);
|
freq1t = process_channel_to_freq (opts, state, channelt2);
|
||||||
freq1r = process_channel_to_freq (opts, state, channelr2);
|
if (channelr2 != 0 && channelr2 != 0xFFFF) freq1r = process_channel_to_freq (opts, state, channelr2);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; Ch: %04X TG: %d; ", channelt1, group1, channelt2, group2);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (svc1 & 0x40) && (svc2 & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
int loop = 1;
|
int loop = 1;
|
||||||
if (channelt2 == channelt2) loop = 1;
|
if (channelt2 == channelt2) loop = 1;
|
||||||
else loop = 2;
|
else loop = 2;
|
||||||
@@ -510,6 +642,16 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
|
|
||||||
for (int j = 0; j < loop; j++)
|
for (int j = 0; j < loop; j++)
|
||||||
{
|
{
|
||||||
|
//test svc opts for enc to tune or skip
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
if ( (svc1 & 0x40) && opts->trunk_tune_enc_calls == 0) j++; //skip to next
|
||||||
|
}
|
||||||
|
if (j == 1)
|
||||||
|
{
|
||||||
|
if (( svc2 & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL; //skip to end
|
||||||
|
}
|
||||||
|
|
||||||
//assign our internal variables for check down on if to tune one freq/group or not
|
//assign our internal variables for check down on if to tune one freq/group or not
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
{
|
{
|
||||||
@@ -539,10 +681,20 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
if (state->p25_chan_tdma[tunable_chan >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
@@ -555,6 +707,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, tunable_freq);
|
SetFreq(opts->rigctl_sockfd, tunable_freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
@@ -563,6 +716,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_udp_tune (opts, state, tunable_freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,7 +735,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Group Voice Channel Grant Update Multiple - Implicit
|
//Group Voice Channel Grant Update Multiple - Implicit
|
||||||
if (MAC[1+len_a] == 0x05) //wonder if this is MAC_SIGNAL only? Too long for a TSBK
|
if (MAC[1+len_a] == 0x05)
|
||||||
{
|
{
|
||||||
int so1 = MAC[2+len_a];
|
int so1 = MAC[2+len_a];
|
||||||
int channel1 = (MAC[3+len_a] << 8) | MAC[4+len_a];
|
int channel1 = (MAC[3+len_a] << 8) | MAC[4+len_a];
|
||||||
@@ -598,15 +752,54 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
|
|
||||||
fprintf (stderr, "\n Group Voice Channel Grant Update Multiple - Implicit");
|
fprintf (stderr, "\n Group Voice Channel Grant Update Multiple - Implicit");
|
||||||
fprintf (stderr, "\n Channel 1 [%04X] Group 1 [%d][%04X]", channel1, group1, group1);
|
fprintf (stderr, "\n Channel 1 [%04X] Group 1 [%d][%04X]", channel1, group1, group1);
|
||||||
|
if (so1 & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (so1 & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (so1 & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (so1 & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (so1 & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", so1 & 0x7); //call priority
|
||||||
|
}
|
||||||
freq1 = process_channel_to_freq (opts, state, channel1);
|
freq1 = process_channel_to_freq (opts, state, channel1);
|
||||||
|
|
||||||
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
||||||
|
if (so2 & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (so2 & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (so2 & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (so2 & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (so2 & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", so2 & 0x7); //call priority
|
||||||
|
}
|
||||||
freq2 = process_channel_to_freq (opts, state, channel2);
|
freq2 = process_channel_to_freq (opts, state, channel2);
|
||||||
|
|
||||||
fprintf (stderr, "\n Channel 3 [%04X] Group 3 [%d][%04X]", channel3, group3, group3);
|
fprintf (stderr, "\n Channel 3 [%04X] Group 3 [%d][%04X]", channel3, group3, group3);
|
||||||
|
if (so3 & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (so3 & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (so3 & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (so3 & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (so3 & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", so3 & 0x7); //call priority
|
||||||
|
}
|
||||||
freq3 = process_channel_to_freq (opts, state, channel3);
|
freq3 = process_channel_to_freq (opts, state, channel3);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; Ch: %04X TG: %d; Ch: %04X TG: %d; ", channel1, group1, channel2, group2, channel3, group3);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (so1 & 0x40) && (so2 & 0x40) && (so3 & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
int loop = 3;
|
int loop = 3;
|
||||||
|
|
||||||
long int tunable_freq = 0;
|
long int tunable_freq = 0;
|
||||||
@@ -615,6 +808,20 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
|
|
||||||
for (int j = 0; j < loop; j++)
|
for (int j = 0; j < loop; j++)
|
||||||
{
|
{
|
||||||
|
//test svc opts for enc to tune or skip
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
if ( (so1 & 0x40) && opts->trunk_tune_enc_calls == 0) j++; //skip to next
|
||||||
|
}
|
||||||
|
if (j == 1)
|
||||||
|
{
|
||||||
|
if ( (so2 & 0x40) && opts->trunk_tune_enc_calls == 0) j++; //skip to next
|
||||||
|
}
|
||||||
|
if (j == 2)
|
||||||
|
{
|
||||||
|
if ( (so3 & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL; //skip to end
|
||||||
|
}
|
||||||
|
|
||||||
//assign our internal variables for check down on if to tune one freq/group or not
|
//assign our internal variables for check down on if to tune one freq/group or not
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
{
|
{
|
||||||
@@ -651,15 +858,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
if (state->p25_chan_tdma[tunable_chan >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -668,6 +886,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
@@ -677,6 +896,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,9 +930,16 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
fprintf (stderr, "\n Channel 2 [%04X] Group 2 [%d][%04X]", channel2, group2, group2);
|
||||||
freq2 = process_channel_to_freq (opts, state, channel2);
|
freq2 = process_channel_to_freq (opts, state, channel2);
|
||||||
|
|
||||||
|
//add active channel to string for ncurses display
|
||||||
|
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; Ch: %04X TG: %d; ", channel1, group1, channel2, group2);
|
||||||
|
state->last_active_time = time(NULL);
|
||||||
|
|
||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled -- abb formats do not carry svc bits :(
|
||||||
|
if (opts->trunk_tune_enc_calls == 0) goto SKIPCALL; //enable, or disable?
|
||||||
|
|
||||||
int loop = 1;
|
int loop = 1;
|
||||||
if (channel1 == channel2) loop = 1;
|
if (channel1 == channel2) loop = 1;
|
||||||
else loop = 2;
|
else loop = 2;
|
||||||
@@ -753,15 +980,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && tunable_freq != 0) //if we aren't already on a VC and have a valid frequency already
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[tunable_chan >> 12];
|
if (state->p25_chan_tdma[tunable_chan >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -770,6 +1008,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
@@ -779,6 +1018,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -806,15 +1046,30 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
long int freq1 = 0;
|
long int freq1 = 0;
|
||||||
long int freq2 = 0;
|
long int freq2 = 0;
|
||||||
|
|
||||||
fprintf (stderr, "\n Group Voice Channel Grant Update - Explicit");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
fprintf (stderr, " Group Voice Channel Grant Update - Explicit");
|
||||||
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc, channelt, channelr, group, group);
|
fprintf (stderr, "\n SVC [%02X] CHAN-T [%04X] CHAN-R [%04X] Group [%d][%04X]", svc, channelt, channelr, group, group);
|
||||||
freq1 = process_channel_to_freq (opts, state, channelt);
|
freq1 = process_channel_to_freq (opts, state, channelt);
|
||||||
freq2 = process_channel_to_freq (opts, state, channelr);
|
if (channelr != 0 && channelr != 0xFFFF) freq2 = process_channel_to_freq (opts, state, channelr); //one system had this as channel 0xFFFF -- look up any particular meaning for that
|
||||||
if (slot == 0)
|
|
||||||
{
|
//don't set the tg here, one multiple grant updates, will mess up the TG value on current call
|
||||||
state->lasttg = group;
|
// if (slot == 0)
|
||||||
}
|
// {
|
||||||
else state->lasttgR = group;
|
// state->lasttg = group;
|
||||||
|
// }
|
||||||
|
// else state->lasttgR = group;
|
||||||
|
|
||||||
for (int i = 0; i < state->group_tally; i++)
|
for (int i = 0; i < state->group_tally; i++)
|
||||||
{
|
{
|
||||||
@@ -828,6 +1083,9 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
//Skip tuning group calls if group calls are disabled
|
//Skip tuning group calls if group calls are disabled
|
||||||
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
if (opts->trunk_tune_group_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
|
//Skip tuning encrypted calls if enc calls are disabled
|
||||||
|
if ( (svc & 0x40) && opts->trunk_tune_enc_calls == 0) goto SKIPCALL;
|
||||||
|
|
||||||
//tune if tuning available
|
//tune if tuning available
|
||||||
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
if (opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0))
|
||||||
{
|
{
|
||||||
@@ -835,15 +1093,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq1 != 0) //if we aren't already on a VC and have a valid frequency
|
if (state->p25_cc_freq != 0 && opts->p25_is_tuned == 0 && freq1 != 0) //if we aren't already on a VC and have a valid frequency
|
||||||
{
|
{
|
||||||
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
//testing switch to P2 channel symbol rate with qpsk enabled, we need to know if we are going to a TDMA channel or an FDMA channel
|
||||||
|
// if (opts->mod_qpsk == 1)
|
||||||
|
// {
|
||||||
|
// int spacing = state->p25_chan_spac[channelt >> 12];
|
||||||
|
// if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
||||||
|
// {
|
||||||
|
// state->samplesPerSymbol = 8;
|
||||||
|
// state->symbolCenter = 3;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//may be this way independent of whether or not this is QPSK (does C4FM run at 6000 sps?)
|
||||||
if (opts->mod_qpsk == 1)
|
if (opts->mod_qpsk == 1)
|
||||||
{
|
{
|
||||||
int spacing = state->p25_chan_spac[channelt >> 12];
|
if (state->p25_chan_tdma[channelt >> 12] == 1)
|
||||||
if (spacing == 0x64) //tdma should always be 0x64, and fdma should always be 0x32
|
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 8;
|
state->samplesPerSymbol = 8;
|
||||||
state->symbolCenter = 3;
|
state->symbolCenter = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rigctl
|
//rigctl
|
||||||
if (opts->use_rigctl == 1)
|
if (opts->use_rigctl == 1)
|
||||||
{
|
{
|
||||||
@@ -851,6 +1120,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
SetFreq(opts->rigctl_sockfd, freq1);
|
SetFreq(opts->rigctl_sockfd, freq1);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
@@ -858,6 +1128,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
rtl_udp_tune (opts, state, freq1);
|
rtl_udp_tune (opts, state, freq1);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -915,6 +1186,9 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, "\n RFSS Status Broadcast - Implicit \n");
|
fprintf (stderr, "\n RFSS Status Broadcast - Implicit \n");
|
||||||
fprintf (stderr, " LRA [%02X] SYSID [%03X] RFSS ID [%02X] SITE ID [%02X] CHAN [%04X] SSC [%02X] ", lra, lsysid, rfssid, siteid, channel, sysclass);
|
fprintf (stderr, " LRA [%02X] SYSID [%03X] RFSS ID [%02X] SITE ID [%02X] CHAN [%04X] SSC [%02X] ", lra, lsysid, rfssid, siteid, channel, sysclass);
|
||||||
process_channel_to_freq (opts, state, channel);
|
process_channel_to_freq (opts, state, channel);
|
||||||
|
|
||||||
|
state->p2_siteid = siteid;
|
||||||
|
state->p2_rfssid = rfssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//RFSS Status Broadcast - Explicit
|
//RFSS Status Broadcast - Explicit
|
||||||
@@ -931,10 +1205,13 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
fprintf (stderr, " LRA [%02X] SYSID [%03X] RFSS ID [%02X] SITE ID [%02X]\n CHAN-T [%04X] CHAN-R [%02X] SSC [%02X] ", lra, lsysid, rfssid, siteid, channelt, channelr, sysclass);
|
fprintf (stderr, " LRA [%02X] SYSID [%03X] RFSS ID [%02X] SITE ID [%02X]\n CHAN-T [%04X] CHAN-R [%02X] SSC [%02X] ", lra, lsysid, rfssid, siteid, channelt, channelr, sysclass);
|
||||||
process_channel_to_freq (opts, state, channelt);
|
process_channel_to_freq (opts, state, channelt);
|
||||||
process_channel_to_freq (opts, state, channelr);
|
process_channel_to_freq (opts, state, channelr);
|
||||||
|
|
||||||
|
state->p2_siteid = siteid;
|
||||||
|
state->p2_rfssid = rfssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unit-to-Unit Answer Request (UU_ANS_REQ)
|
//Unit-to-Unit Answer Request (UU_ANS_REQ)
|
||||||
if (MAC[1+len_a] == 0x45)
|
if (MAC[1+len_a] == 0x45 && MAC[2+len_a] != 0x90)
|
||||||
{
|
{
|
||||||
int svc = MAC[2+len_a];
|
int svc = MAC[2+len_a];
|
||||||
int answer = MAC[3+len_a];
|
int answer = MAC[3+len_a];
|
||||||
@@ -946,17 +1223,17 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Telephone Interconnect Voice Channel Grant (TELE_INT_CH_GRANT)
|
//Telephone Interconnect Voice Channel Grant (TELE_INT_CH_GRANT) //look at PDU for this, see if this is tunable
|
||||||
if (MAC[1+len_a] == 0x48)
|
// if (MAC[1+len_a] == 0x48 && MAC[2+len_a] != 0x90)
|
||||||
{
|
// {
|
||||||
fprintf (stderr, "\n Telephone Interconnect Voice Channel Grant ");
|
// fprintf (stderr, "\n Telephone Interconnect Voice Channel Grant ");
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Telephone Interconnect Voice Channel Grant Update (TELE_INT_CH_GRANT_UPDT)
|
// //Telephone Interconnect Voice Channel Grant Update (TELE_INT_CH_GRANT_UPDT)
|
||||||
if (MAC[1+len_a] == 0x49)
|
// if (MAC[1+len_a] == 0x49 && MAC[2+len_a] != 0x90)
|
||||||
{
|
// {
|
||||||
fprintf (stderr, "\n Telephone Interconnect Voice Channel Grant Update ");
|
// fprintf (stderr, "\n Telephone Interconnect Voice Channel Grant Update ");
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Synchronization Broadcast (SYNC_BCST)
|
//Synchronization Broadcast (SYNC_BCST)
|
||||||
if (MAC[1+len_a] == 0x70)
|
if (MAC[1+len_a] == 0x70)
|
||||||
@@ -980,12 +1257,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
else offhour = ( (ltoff & 0b11111 ) / 2);
|
else offhour = ( (ltoff & 0b11111 ) / 2);
|
||||||
|
|
||||||
int seconds = slots / 135; //very rough estimation, but may be close enough for grins
|
int seconds = slots / 135; //very rough estimation, but may be close enough for grins
|
||||||
if (seconds > 60) seconds = 60; //sanity check for rounding error
|
if (seconds > 59) seconds = 59; //sanity check for rounding error
|
||||||
fprintf (stderr, " Date: 20%02d.%02d.%02d Time: %02d:%02d:%02d UTC\n",
|
fprintf (stderr, " Date: 20%02d.%02d.%02d Time: %02d:%02d:%02d UTC\n",
|
||||||
year, month, day, hour, min, seconds);
|
year, month, day, hour, min, seconds);
|
||||||
fprintf (stderr, " Local Time Offset: %.01f Hours;", offhour);
|
fprintf (stderr, " Local Time Offset: %.01f Hours;", offhour);
|
||||||
//if ist bit is set, then time on system may be considered invalid (i.e., no external time sync)
|
//if ist bit is set, then time on system may be considered invalid (i.e., no external time sync)
|
||||||
if (ist % 1)
|
if (ist == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " Invalid System Time ");
|
fprintf (stderr, " Invalid System Time ");
|
||||||
}
|
}
|
||||||
@@ -998,13 +1275,26 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
{
|
{
|
||||||
state->p25_chan_iden = MAC[2+len_a] >> 4;
|
state->p25_chan_iden = MAC[2+len_a] >> 4;
|
||||||
int iden = state->p25_chan_iden;
|
int iden = state->p25_chan_iden;
|
||||||
|
|
||||||
state->p25_chan_type[iden] = 1;
|
|
||||||
int bw_vu = (MAC[2+len_a] & 0xF);
|
int bw_vu = (MAC[2+len_a] & 0xF);
|
||||||
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
||||||
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
||||||
state->p25_base_freq[iden] = (MAC[6+len_a] << 24) | (MAC[7+len_a] << 16) | (MAC[8+len_a] << 8) | (MAC[9+len_a] << 0);
|
state->p25_base_freq[iden] = (MAC[6+len_a] << 24) | (MAC[7+len_a] << 16) | (MAC[8+len_a] << 8) | (MAC[9+len_a] << 0);
|
||||||
|
|
||||||
|
//this is causing more issues -- need a different way to check on this
|
||||||
|
// if (state->p25_chan_spac[iden] == 0x64) //tdma
|
||||||
|
// {
|
||||||
|
// state->p25_chan_type[iden] = 4; //
|
||||||
|
// state->p25_chan_tdma[iden] = 1; //
|
||||||
|
// }
|
||||||
|
// else //fdma
|
||||||
|
// {
|
||||||
|
// state->p25_chan_type[iden] = 1; //
|
||||||
|
// state->p25_chan_tdma[iden] = 0; //
|
||||||
|
// }
|
||||||
|
|
||||||
|
state->p25_chan_type[iden] = 1; //set as old values for now
|
||||||
|
state->p25_chan_tdma[iden] = 0; //set as old values for now
|
||||||
|
|
||||||
fprintf (stderr, "\n Identifier Update UHF/VHF\n");
|
fprintf (stderr, "\n Identifier Update UHF/VHF\n");
|
||||||
fprintf (stderr, " Channel Identifier [%01X] BW [%01X] Transmit Offset [%04X]\n Channel Spacing [%03X] Base Frequency [%08lX] [%09ld]",
|
fprintf (stderr, " Channel Identifier [%01X] BW [%01X] Transmit Offset [%04X]\n Channel Spacing [%03X] Base Frequency [%08lX] [%09ld]",
|
||||||
state->p25_chan_iden, bw_vu, state->p25_trans_off[iden], state->p25_chan_spac[iden], state->p25_base_freq[iden], state->p25_base_freq[iden] * 5);
|
state->p25_chan_iden, bw_vu, state->p25_trans_off[iden], state->p25_chan_spac[iden], state->p25_base_freq[iden], state->p25_base_freq[iden] * 5);
|
||||||
@@ -1017,6 +1307,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
int iden = state->p25_chan_iden;
|
int iden = state->p25_chan_iden;
|
||||||
|
|
||||||
state->p25_chan_type[iden] = 1;
|
state->p25_chan_type[iden] = 1;
|
||||||
|
state->p25_chan_tdma[iden] = 0;
|
||||||
int bw = ((MAC[2+len_a] & 0xF) << 5) | ((MAC[3+len_a] & 0xF8) >> 2);
|
int bw = ((MAC[2+len_a] & 0xF) << 5) | ((MAC[3+len_a] & 0xF8) >> 2);
|
||||||
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
||||||
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
||||||
@@ -1032,6 +1323,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
{
|
{
|
||||||
state->p25_chan_iden = MAC[2+len_a] >> 4;
|
state->p25_chan_iden = MAC[2+len_a] >> 4;
|
||||||
int iden = state->p25_chan_iden;
|
int iden = state->p25_chan_iden;
|
||||||
|
state->p25_chan_tdma[iden] = 1;
|
||||||
state->p25_chan_type[iden] = MAC[2+len_a] & 0xF;
|
state->p25_chan_type[iden] = MAC[2+len_a] & 0xF;
|
||||||
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
state->p25_trans_off[iden] = (MAC[3+len_a] << 6) | (MAC[4+len_a] >> 2);
|
||||||
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
state->p25_chan_spac[iden] = ((MAC[4+len_a] & 0x3) << 8) | MAC[5+len_a];
|
||||||
@@ -1047,6 +1339,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
{
|
{
|
||||||
state->p25_chan_iden = MAC[3+len_a] >> 4;
|
state->p25_chan_iden = MAC[3+len_a] >> 4;
|
||||||
int iden = state->p25_chan_iden;
|
int iden = state->p25_chan_iden;
|
||||||
|
state->p25_chan_tdma[iden] = 1;
|
||||||
state->p25_chan_type[iden] = MAC[3+len_a] & 0xF;
|
state->p25_chan_type[iden] = MAC[3+len_a] & 0xF;
|
||||||
state->p25_trans_off[iden] = (MAC[4+len_a] << 6) | (MAC[5+len_a] >> 2);
|
state->p25_trans_off[iden] = (MAC[4+len_a] << 6) | (MAC[5+len_a] >> 2);
|
||||||
state->p25_chan_spac[iden] = ((MAC[5+len_a] & 0x3) << 8) | MAC[6+len_a];
|
state->p25_chan_spac[iden] = ((MAC[5+len_a] & 0x3) << 8) | MAC[6+len_a];
|
||||||
@@ -1073,12 +1366,15 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
{
|
{
|
||||||
|
|
||||||
fprintf (stderr, "\n Secondary Control Channel Broadcast - Explicit\n");
|
fprintf (stderr, "\n Secondary Control Channel Broadcast - Explicit\n");
|
||||||
fprintf (stderr, " RFSS[%03d] SITE ID [%03X] CHAN-T [%04X] CHAN-R [%04X] SSC [%02X]", rfssid, siteid, channelt, channelr, sysclass);
|
fprintf (stderr, " RFSS [%03d] SITE ID [%03X] CHAN-T [%04X] CHAN-R [%04X] SSC [%02X]", rfssid, siteid, channelt, channelr, sysclass);
|
||||||
|
|
||||||
process_channel_to_freq (opts, state, channelt);
|
process_channel_to_freq (opts, state, channelt);
|
||||||
process_channel_to_freq (opts, state, channelr);
|
process_channel_to_freq (opts, state, channelr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->p2_siteid = siteid;
|
||||||
|
state->p2_rfssid = rfssid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Secondary Control Channel Broadcast, Implicit
|
//Secondary Control Channel Broadcast, Implicit
|
||||||
@@ -1110,6 +1406,9 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
state->lcn_freq_count = 3; //increment to three
|
state->lcn_freq_count = 3; //increment to three
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->p2_siteid = siteid;
|
||||||
|
state->p2_rfssid = rfssid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MFID90 Group Regroup Voice Channel User - Abbreviated
|
//MFID90 Group Regroup Voice Channel User - Abbreviated
|
||||||
@@ -1211,7 +1510,25 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
int src = (MAC[5+len_a] << 16) | (MAC[6+len_a] << 8) | MAC[7+len_a];
|
int src = (MAC[5+len_a] << 16) | (MAC[6+len_a] << 8) | MAC[7+len_a];
|
||||||
|
|
||||||
fprintf (stderr, "\n VCH %d - TG %d SRC %d ", slot, gr, src);
|
fprintf (stderr, "\n VCH %d - TG %d SRC %d ", slot, gr, src);
|
||||||
fprintf (stderr, "Group Voice");
|
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, " Group Voice");
|
||||||
|
|
||||||
|
sprintf (state->call_string[slot], " Group ");
|
||||||
|
if (svc & 0x80) strcat (state->call_string[slot], " Emergency ");
|
||||||
|
else if (svc & 0x40) strcat (state->call_string[slot], " Encrypted ");
|
||||||
|
else strcat (state->call_string[slot], " ");
|
||||||
|
|
||||||
if (slot == 0)
|
if (slot == 0)
|
||||||
{
|
{
|
||||||
@@ -1232,7 +1549,25 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
int src = (MAC[6+len_a] << 16) | (MAC[7+len_a] << 8) | MAC[8+len_a];
|
int src = (MAC[6+len_a] << 16) | (MAC[7+len_a] << 8) | MAC[8+len_a];
|
||||||
|
|
||||||
fprintf (stderr, "\n VCH %d - TG %d SRC %d ", slot, gr, src);
|
fprintf (stderr, "\n VCH %d - TG %d SRC %d ", slot, gr, src);
|
||||||
fprintf (stderr, "Unit to Unit Voice");
|
|
||||||
|
if (svc & 0x80) fprintf (stderr, " Emergency");
|
||||||
|
if (svc & 0x40) fprintf (stderr, " Encrypted");
|
||||||
|
|
||||||
|
if (opts->payload == 1) //hide behind payload due to len
|
||||||
|
{
|
||||||
|
if (svc & 0x20) fprintf (stderr, " Duplex");
|
||||||
|
if (svc & 0x10) fprintf (stderr, " Packet");
|
||||||
|
else fprintf (stderr, " Circuit");
|
||||||
|
if (svc & 0x8) fprintf (stderr, " R"); //reserved bit is on
|
||||||
|
fprintf (stderr, " Priority %d", svc & 0x7); //call priority
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, " Unit to Unit Voice");
|
||||||
|
|
||||||
|
sprintf (state->call_string[slot], " Private ");
|
||||||
|
if (svc & 0x80) strcat (state->call_string[slot], " Emergency ");
|
||||||
|
else if (svc & 0x40) strcat (state->call_string[slot], " Encrypted ");
|
||||||
|
else strcat (state->call_string[slot], " ");
|
||||||
|
|
||||||
if (slot == 0)
|
if (slot == 0)
|
||||||
{
|
{
|
||||||
@@ -1304,17 +1639,21 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (MAC[1+len_a] == 0x7C)
|
if (MAC[1+len_a] == 0x7C)
|
||||||
{
|
{
|
||||||
int lra = MAC[2+len_a];
|
int lra = MAC[2+len_a];
|
||||||
|
int cfva = MAC[3+len_a] >> 4;
|
||||||
int lsysid = ((MAC[3+len_a] & 0xF) << 8) | MAC[4+len_a];
|
int lsysid = ((MAC[3+len_a] & 0xF) << 8) | MAC[4+len_a];
|
||||||
int rfssid = MAC[5+len_a];
|
int rfssid = MAC[5+len_a];
|
||||||
int siteid = MAC[6+len_a];
|
int siteid = MAC[6+len_a];
|
||||||
int channelt = (MAC[7+len_a] << 8) | MAC[8+len_a];
|
int channelt = (MAC[7+len_a] << 8) | MAC[8+len_a];
|
||||||
int sysclass = MAC[9+len_a];
|
int sysclass = MAC[9+len_a];
|
||||||
if (1 == 1) //state->p2_is_lcch == 1
|
fprintf (stderr, "\n Adjacent Status Broadcast - Abbreviated\n");
|
||||||
{
|
fprintf (stderr, " LRA [%02X] RFSS[%03d] SYSID [%03X] SITE [%03X] CHAN-T [%04X] SSC [%02X]\n ", lra, rfssid, lsysid, siteid, channelt, sysclass);
|
||||||
fprintf (stderr, "\n Adjacent Status Broadcast - Abbreviated\n");
|
if (cfva & 0x8) fprintf (stderr, " Conventional");
|
||||||
fprintf (stderr, " LRA [%02X] RFSS[%03d] SYSID [%03X] SITE [%03X] CHAN-T [%04X] SSC [%02X]", lra, rfssid, lsysid, siteid, channelt, sysclass);
|
if (cfva & 0x4) fprintf (stderr, " Failure Condition");
|
||||||
process_channel_to_freq (opts, state, channelt);
|
if (cfva & 0x2) fprintf (stderr, " Up to Date (Correct)");
|
||||||
}
|
else fprintf (stderr, " Last Known");
|
||||||
|
if (cfva & 0x1) fprintf (stderr, " Valid RFSS Connection Active");
|
||||||
|
process_channel_to_freq (opts, state, channelt);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1322,19 +1661,23 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
|||||||
if (MAC[1+len_a] == 0xFC)
|
if (MAC[1+len_a] == 0xFC)
|
||||||
{
|
{
|
||||||
int lra = MAC[2+len_a];
|
int lra = MAC[2+len_a];
|
||||||
|
int cfva = MAC[3+len_a] >> 4;
|
||||||
int lsysid = ((MAC[3+len_a] & 0xF) << 8) | MAC[4+len_a];
|
int lsysid = ((MAC[3+len_a] & 0xF) << 8) | MAC[4+len_a];
|
||||||
int rfssid = MAC[5+len_a];
|
int rfssid = MAC[5+len_a];
|
||||||
int siteid = MAC[6+len_a];
|
int siteid = MAC[6+len_a];
|
||||||
int channelt = (MAC[7+len_a] << 8) | MAC[8+len_a];
|
int channelt = (MAC[7+len_a] << 8) | MAC[8+len_a];
|
||||||
int channelr = (MAC[9+len_a] << 8) | MAC[10+len_a];
|
int channelr = (MAC[9+len_a] << 8) | MAC[10+len_a];
|
||||||
int sysclass = MAC[9+len_a];
|
int sysclass = MAC[11+len_a]; //need to re-check this
|
||||||
if (1 == 1) //state->p2_is_lcch == 1
|
fprintf (stderr, "\n Adjacent Status Broadcast - Extended\n");
|
||||||
{
|
fprintf (stderr, " LRA [%02X] RFSS[%03d] SYSID [%03X] SITE [%03X] CHAN-T [%04X] CHAN-R [%04X] SSC [%02X]\n ", lra, rfssid, lsysid, siteid, channelt, channelr, sysclass);
|
||||||
fprintf (stderr, "\n Adjacent Status Broadcast - Extended\n");
|
if (cfva & 0x8) fprintf (stderr, " Conventional");
|
||||||
fprintf (stderr, " LRA [%02X] RFSS[%03d] SYSID [%03X] SITE [%03X] CHAN-T [%04X] CHAN-R [%04X] SSC [%02X]", lra, rfssid, lsysid, siteid, channelt, channelr, sysclass);
|
if (cfva & 0x4) fprintf (stderr, " Failure Condition");
|
||||||
process_channel_to_freq (opts, state, channelt);
|
if (cfva & 0x2) fprintf (stderr, " Up to Date (Correct)");
|
||||||
process_channel_to_freq (opts, state, channelr);
|
else fprintf (stderr, " Last Known");
|
||||||
}
|
if (cfva & 0x1) fprintf (stderr, " Valid RFSS Connection Active");
|
||||||
|
process_channel_to_freq (opts, state, channelt);
|
||||||
|
process_channel_to_freq (opts, state, channelr);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
|
|||||||
//Figure out which PDU we are looking at, see above info on 8.4.1
|
//Figure out which PDU we are looking at, see above info on 8.4.1
|
||||||
//reorganize bits into bytes and process accordingly
|
//reorganize bits into bytes and process accordingly
|
||||||
|
|
||||||
|
//new slot variable with flipped assignment for SACCH
|
||||||
|
uint8_t slot = (state->currentslot ^ 1) & 1;
|
||||||
|
|
||||||
unsigned long long int SMAC[24] = {0}; //22.5 bytes for SACCH MAC PDUs
|
unsigned long long int SMAC[24] = {0}; //22.5 bytes for SACCH MAC PDUs
|
||||||
int byte = 0;
|
int byte = 0;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@@ -202,6 +205,13 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
|
|||||||
//print it and then zero out
|
//print it and then zero out
|
||||||
state->lastsrc = 0;
|
state->lastsrc = 0;
|
||||||
state->lasttg = 0;
|
state->lasttg = 0;
|
||||||
|
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
|
||||||
|
//blank the call string here -- slot variable is already flipped accordingly for sacch
|
||||||
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
||||||
|
|
||||||
}
|
}
|
||||||
if (state->currentslot == 0)
|
if (state->currentslot == 0)
|
||||||
{
|
{
|
||||||
@@ -218,6 +228,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
|
|||||||
//print it and then zero out
|
//print it and then zero out
|
||||||
state->lastsrcR = 0;
|
state->lastsrcR = 0;
|
||||||
state->lasttgR = 0;
|
state->lasttgR = 0;
|
||||||
|
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
@@ -229,6 +242,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
|
|||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
process_MAC_VPDU(opts, state, 1, SMAC);
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
//blank the call string here -- slot variable is already flipped accordingly for sacch
|
||||||
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
||||||
}
|
}
|
||||||
if (opcode == 0x4 && err == 0)
|
if (opcode == 0x4 && err == 0)
|
||||||
{
|
{
|
||||||
@@ -241,8 +257,18 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
|
|||||||
}
|
}
|
||||||
if (opcode == 0x6 && err == 0)
|
if (opcode == 0x6 && err == 0)
|
||||||
{
|
{
|
||||||
if (state->currentslot == 1) state->dmrburstL = 22;
|
if (state->currentslot == 1)
|
||||||
else state->dmrburstR = 22;
|
{
|
||||||
|
state->dmrburstL = 21;
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state->dmrburstR = 21;
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
}
|
||||||
fprintf (stderr, " MAC_HANGTIME ");
|
fprintf (stderr, " MAC_HANGTIME ");
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
process_MAC_VPDU(opts, state, 1, SMAC);
|
process_MAC_VPDU(opts, state, 1, SMAC);
|
||||||
@@ -262,6 +288,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
|
|||||||
//Figure out which PDU we are looking at, see above info on 8.4.1
|
//Figure out which PDU we are looking at, see above info on 8.4.1
|
||||||
//reorganize bits into bytes and process accordingly
|
//reorganize bits into bytes and process accordingly
|
||||||
|
|
||||||
|
//new slot variable
|
||||||
|
uint8_t slot = state->currentslot;
|
||||||
|
|
||||||
unsigned long long int FMAC[24] = {0}; //19.5 bytes for FACCH MAC PDUs, add padding to end
|
unsigned long long int FMAC[24] = {0}; //19.5 bytes for FACCH MAC PDUs, add padding to end
|
||||||
int byte = 0;
|
int byte = 0;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@@ -412,6 +441,13 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
|
|||||||
//print it and then zero out
|
//print it and then zero out
|
||||||
state->lastsrc = 0;
|
state->lastsrc = 0;
|
||||||
state->lasttg = 0;
|
state->lasttg = 0;
|
||||||
|
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
|
||||||
|
//blank the call string here
|
||||||
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
||||||
|
|
||||||
}
|
}
|
||||||
if (state->currentslot == 1)
|
if (state->currentslot == 1)
|
||||||
{
|
{
|
||||||
@@ -428,6 +464,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
|
|||||||
//print it and then zero out
|
//print it and then zero out
|
||||||
state->lastsrcR = 0;
|
state->lastsrcR = 0;
|
||||||
state->lasttgR = 0;
|
state->lasttgR = 0;
|
||||||
|
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
@@ -459,6 +498,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
|
|||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
process_MAC_VPDU(opts, state, 0, FMAC);
|
process_MAC_VPDU(opts, state, 0, FMAC);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
|
||||||
|
//blank the call string here
|
||||||
|
sprintf (state->call_string[slot], "%s", " "); //21 spaces
|
||||||
}
|
}
|
||||||
if (opcode == 0x4 && err == 0)
|
if (opcode == 0x4 && err == 0)
|
||||||
{
|
{
|
||||||
@@ -471,8 +513,18 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
|
|||||||
}
|
}
|
||||||
if (opcode == 0x6 && err == 0)
|
if (opcode == 0x6 && err == 0)
|
||||||
{
|
{
|
||||||
if (state->currentslot == 0) state->dmrburstL = 22;
|
if (state->currentslot == 0)
|
||||||
else state->dmrburstR = 22;
|
{
|
||||||
|
state->dmrburstL = 22;
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state->dmrburstR = 22;
|
||||||
|
//close any open MBEout files
|
||||||
|
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||||
|
}
|
||||||
fprintf (stderr, " MAC_HANGTIME ");
|
fprintf (stderr, " MAC_HANGTIME ");
|
||||||
fprintf (stderr, "%s", KYEL);
|
fprintf (stderr, "%s", KYEL);
|
||||||
process_MAC_VPDU(opts, state, 0, FMAC);
|
process_MAC_VPDU(opts, state, 0, FMAC);
|
||||||
|
|||||||
748
src/provoice.c
748
src/provoice.c
@@ -1,582 +1,432 @@
|
|||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
#include "provoice_const.h"
|
#include "provoice_const.h"
|
||||||
|
|
||||||
void
|
// #define PVDEBUG
|
||||||
processProVoice (dsd_opts * opts, dsd_state * state)
|
|
||||||
|
void processProVoice (dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
int i, j, dibit, k;
|
int i, j, dibit;
|
||||||
uint8_t lid[80];
|
|
||||||
uint8_t lidbyte[10];
|
|
||||||
uint8_t init[64];
|
|
||||||
uint8_t initbyte[8];
|
|
||||||
char imbe7100_fr1[7][24];
|
char imbe7100_fr1[7][24];
|
||||||
char imbe7100_fr2[7][24];
|
char imbe7100_fr2[7][24];
|
||||||
const int *w, *x;
|
const int *w, *x;
|
||||||
|
|
||||||
|
//raw bits storage for analysis
|
||||||
|
uint8_t raw_bits[800];
|
||||||
|
memset (raw_bits, 0, sizeof(raw_bits));
|
||||||
|
//raw bytes storage for analysis
|
||||||
|
uint8_t raw_bytes[100];
|
||||||
|
memset (raw_bytes, 0, sizeof(raw_bytes));
|
||||||
|
|
||||||
|
unsigned long long int initial = 0; //initial 64-bits before the lid
|
||||||
|
uint16_t lid = 0; //lid value 16-bit
|
||||||
|
unsigned long long int secondary = 0; //secondary 64-bits after lid, before voice
|
||||||
|
|
||||||
|
uint8_t spacer_bit[8]; //check this value to see if its a status thing (like P25 P1)
|
||||||
|
memset (spacer_bit, 0, sizeof (spacer_bit));
|
||||||
|
uint8_t spacer = 0;
|
||||||
|
uint16_t bf = 0; //the 16-bit value in-between imbe 2 and imbe 3 that is usually 2175
|
||||||
|
|
||||||
fprintf (stderr," VOICE");
|
fprintf (stderr," VOICE");
|
||||||
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1)
|
|
||||||
|
//print group and source values if EA trunked
|
||||||
|
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && state->ea_mode == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s", KGRN);
|
fprintf (stderr, "%s", KGRN);
|
||||||
fprintf (stderr, " Site [%02llX][%03lld] Group [%05d] Source [%08d] LCN[%02d] ",
|
fprintf (stderr, " Site: %lld Group: %d Source: %d LCN: %d ",
|
||||||
state->edacs_site_id, state->edacs_site_id, state->lasttg, state->lastsrc, state->edacs_tuned_lcn);
|
state->edacs_site_id, state->lasttg, state->lastsrc, state->edacs_tuned_lcn);
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
//print afs value if standard/networked trunked
|
||||||
|
else if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && state->ea_mode == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KGRN);
|
||||||
|
fprintf (stderr, " Site: %lld AFS: %d-%d LCN: %d ",
|
||||||
|
state->edacs_site_id, (state->lasttg >> 7) & 0xF, state->lasttg & 0x7F, state->edacs_tuned_lcn);
|
||||||
fprintf (stderr, "%s", KNRM);
|
fprintf (stderr, "%s", KNRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 64; i++)
|
//load all initial bits before voice into raw_bits array for analysis/handling
|
||||||
{
|
for (i = 0; i < 64+16+64; i++)
|
||||||
dibit = getDibit (opts, state);
|
raw_bits[i] = getDibit (opts, state);
|
||||||
init[i] = dibit;
|
|
||||||
#ifdef PROVOICE_DUMP
|
//Note: the initial 144-bits seem to be provisioned differently depending on system type
|
||||||
fprintf (stderr,"%i", dibit);
|
initial = (unsigned long long int)ConvertBitIntoBytes(&raw_bits[0], 64);
|
||||||
#endif
|
lid = (uint16_t)ConvertBitIntoBytes(&raw_bits[64], 16);
|
||||||
}
|
secondary = (unsigned long long int)ConvertBitIntoBytes(&raw_bits[80], 64);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
//init Bits (64)...MI?
|
|
||||||
if (opts->payload == 1)
|
if (opts->payload == 1)
|
||||||
{
|
{
|
||||||
k = 0;
|
fprintf (stderr, "\n N64: %016llX", initial);
|
||||||
//fprintf (stderr, "\nInit 64 ");
|
fprintf (stderr, "\n LID: %04X", lid);
|
||||||
for(i = 0; i < 8; i++)
|
fprintf (stderr, " %016llX", secondary);
|
||||||
{
|
|
||||||
initbyte[i] = 0;
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
initbyte[i] = initbyte[i] << 1;
|
|
||||||
initbyte[i] = initbyte[i] | init[k];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "%02X", initbyte[i]);
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "\n");
|
|
||||||
}
|
}
|
||||||
// lid
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
lid[i] = dibit;
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < 64; i++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
lid[i+16] = dibit;
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
//load lid (bits) into lidbyte
|
|
||||||
if (opts->payload == 1)
|
|
||||||
{
|
|
||||||
k = 0;
|
|
||||||
//fprintf (stderr, "LID ");
|
|
||||||
for(i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
lidbyte[i] = 0;
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
lidbyte[i] = lidbyte[i] << 1;
|
|
||||||
lidbyte[i] = lidbyte[i] | lid[k];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "%02X", lidbyte[i]);
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// imbe frames 1,2 first half
|
// imbe frames 1,2 first half
|
||||||
w = pW;
|
w = pW;
|
||||||
x = pX;
|
x = pX;
|
||||||
|
|
||||||
for (i = 0; i < 11; i++)
|
for (i = 0; i < 11; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[144+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
w -= 6;
|
||||||
#endif
|
x -= 6;
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[150+j+(i*12)] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+282] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
w -= 6;
|
w -= 6;
|
||||||
x -= 6;
|
x -= 6;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
w++;
|
||||||
#endif
|
x++;
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
raw_bits[j+288] = dibit;
|
||||||
w++;
|
}
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// spacer bits
|
// spacer bits
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[0] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
raw_bits[292] = dibit;
|
||||||
#endif
|
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[1] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
raw_bits[293] = dibit;
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// imbe frames 1,2 second half
|
// imbe frames 1,2 second half
|
||||||
|
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
w++;
|
||||||
#endif
|
x++;
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
raw_bits[j+294] = dibit;
|
||||||
w++;
|
}
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[296+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
w -= 6;
|
||||||
fprintf (stderr,"_");
|
x -= 6;
|
||||||
#endif
|
for (j = 0; j < 6; j++)
|
||||||
w -= 5;
|
|
||||||
x -= 5;
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[302+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
}
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+338] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
|
w -= 5;
|
||||||
|
x -= 5;
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+343] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[348+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
w -= 6;
|
||||||
#endif
|
x -= 6;
|
||||||
w -= 5;
|
for (j = 0; j < 6; j++)
|
||||||
x -= 5;
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[354+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
}
|
||||||
#endif
|
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+438] = dibit;
|
||||||
|
}
|
||||||
|
w -= 5;
|
||||||
|
x -= 5;
|
||||||
|
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+443] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
|
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
|
||||||
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
|
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
|
||||||
|
|
||||||
// spacer bits
|
// spacer bits
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[2] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
raw_bits[448] = dibit;
|
||||||
#endif
|
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[3] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
raw_bits[449] = dibit;
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
//resume raw_bits at +6 current value to round out payload bytes
|
||||||
|
//easier to visualize patterns
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
raw_bits[i+450+6] = getDibit (opts, state);
|
||||||
dibit = getDibit (opts, state); //HERE
|
|
||||||
init[i] = dibit; //recycle
|
bf = (uint16_t)ConvertBitIntoBytes(&raw_bits[456], 16);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
if (opts->payload == 1)
|
||||||
#endif
|
fprintf (stderr, "\n BF: %04X ", bf);
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
if (opts->payload == 1)
|
|
||||||
{
|
|
||||||
k = 0;
|
|
||||||
//fprintf (stderr, "16 bits? ");
|
|
||||||
for(i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
initbyte[i] = 0;
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
initbyte[i] = initbyte[i] << 1;
|
|
||||||
initbyte[i] = initbyte[i] | init[k];
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "%02X", initbyte[i]);
|
|
||||||
}
|
|
||||||
//fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
// imbe frames 3,4 first half
|
// imbe frames 3,4 first half
|
||||||
w = pW;
|
w = pW;
|
||||||
x = pX;
|
x = pX;
|
||||||
for (i = 0; i < 11; i++)
|
for (i = 0; i < 11; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[6+466+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr,"_");
|
w -= 6;
|
||||||
#endif
|
x -= 6;
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[6+472+j+(i*12)] = dibit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+604+6] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
w -= 6;
|
w -= 6;
|
||||||
x -= 6;
|
x -= 6;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
fprintf (stderr,"%i", dibit);
|
w++;
|
||||||
#endif
|
x++;
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
raw_bits[i+610+6] = dibit;
|
||||||
w++;
|
}
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
fprintf (stderr," ");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// spacer bits
|
// spacer bits
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[4];
|
||||||
//fprintf (stderr,"%i", dibit);
|
raw_bits[614+2] = dibit;
|
||||||
#endif
|
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[5];
|
||||||
//fprintf (stderr,"%i", dibit);
|
raw_bits[615+2] = dibit;
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// imbe frames 3,4 second half
|
// imbe frames 3,4 second half
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
//fprintf (stderr,"%i", dibit);
|
w++;
|
||||||
#endif
|
x++;
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
raw_bits[j+616+6] = dibit;
|
||||||
w++;
|
}
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[6+618+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
w -= 6;
|
||||||
//fprintf (stderr,"_");
|
x -= 6;
|
||||||
#endif
|
for (j = 0; j < 6; j++)
|
||||||
w -= 5;
|
|
||||||
x -= 5;
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[6+624+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
}
|
||||||
//fprintf (stderr," ");
|
|
||||||
#endif
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+660+6] = dibit;
|
||||||
|
}
|
||||||
|
w -= 5;
|
||||||
|
x -= 5;
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+665+6] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
w -= 6;
|
|
||||||
x -= 6;
|
|
||||||
for (j = 0; j < 6; j++)
|
|
||||||
{
|
|
||||||
dibit = getDibit (opts, state);
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
|
||||||
w++;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"_");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr1[*w][*x] = dibit;
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[6+670+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
w -= 6;
|
||||||
//fprintf (stderr,"_");
|
x -= 6;
|
||||||
#endif
|
for (j = 0; j < 6; j++)
|
||||||
w -= 5;
|
|
||||||
x -= 5;
|
|
||||||
for (j = 0; j < 5; j++)
|
|
||||||
{
|
{
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
|
||||||
//fprintf (stderr,"%i", dibit);
|
|
||||||
#endif
|
|
||||||
imbe7100_fr2[*w][*x] = dibit;
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
w++;
|
w++;
|
||||||
x++;
|
x++;
|
||||||
|
raw_bits[6+676+j+(i*12)] = dibit;
|
||||||
}
|
}
|
||||||
#ifdef PROVOICE_DUMP
|
}
|
||||||
//fprintf (stderr," ");
|
|
||||||
#endif
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr1[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+760+6] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
|
w -= 5;
|
||||||
|
x -= 5;
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
dibit = getDibit (opts, state);
|
||||||
|
imbe7100_fr2[*w][*x] = dibit;
|
||||||
|
w++;
|
||||||
|
x++;
|
||||||
|
raw_bits[j+765+6] = dibit;
|
||||||
|
}
|
||||||
|
|
||||||
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
|
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
|
||||||
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
|
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
|
||||||
|
|
||||||
// spacer bits
|
// spacer bits
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[6] = dibit;
|
||||||
//fprintf (stderr,"%i", dibit);
|
raw_bits[782] = dibit;
|
||||||
#endif
|
|
||||||
dibit = getDibit (opts, state);
|
dibit = getDibit (opts, state);
|
||||||
#ifdef PROVOICE_DUMP
|
spacer_bit[7] = dibit;
|
||||||
//fprintf (stderr,"%i", dibit);
|
raw_bits[783] = dibit;
|
||||||
//fprintf (stderr," ");
|
|
||||||
|
#ifdef PVDEBUG
|
||||||
|
|
||||||
|
spacer = (uint8_t)ConvertBitIntoBytes(&spacer_bit[0], 8);
|
||||||
|
if (opts->payload == 1)
|
||||||
|
fprintf (stderr, "\n SP: %X", spacer);
|
||||||
|
|
||||||
|
//convert raw bits into raw bytes for payload analysis
|
||||||
|
for (j = 0; j < 98; j++)
|
||||||
|
{
|
||||||
|
raw_bytes[j] = (uint8_t)ConvertBitIntoBytes(&raw_bits[(j*8)], 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
//payload on all raw bytes for analysis...its a lot of 'em
|
||||||
|
if (opts->payload == 1) //find better thingy later or change this
|
||||||
|
// if (opcode != 0x3333)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", KCYN);
|
||||||
|
fprintf (stderr, "\n pV Payload Dump: \n ");
|
||||||
|
for (j = 0; j < 98; j++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "[%02X]", raw_bytes[j]);
|
||||||
|
if (j == 17 || j == 35 || j == 53 || j == 71 || j == 89)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf (stderr, "%s", KNRM);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (opts->errorbars == 1)
|
//line break at end of frame
|
||||||
{
|
fprintf (stderr,"\n");
|
||||||
fprintf (stderr,"\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state)
|
|||||||
{
|
{
|
||||||
if ((eeei == 0) && (aiei == 0))
|
if ((eeei == 0) && (aiei == 0))
|
||||||
{
|
{
|
||||||
processP25lcw (opts, state, lcformat, mfid, lcinfo);
|
// processP25lcw (opts, state, lcformat, mfid, lcinfo);
|
||||||
}
|
}
|
||||||
if (opts->p25enc == 1)
|
if (opts->p25enc == 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pacmd load-module module-null-sink sink_name=virtual_sink sink_properties=device.description=Virtual_Sink
|
pactl 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
|
pactl load-module module-null-sink sink_name=virtual_sink2 sink_properties=device.description=Virtual_Sink2
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user