Compare commits

...

121 Commits

Author SHA1 Message Date
Shane Daley 3a97ad2d3c Update 'README.md'
Update Readme
2021-10-11 20:41:07 -04:00
Shane Daley c1ebca9919 Update 'README.md'
Update MD
2021-10-11 20:40:32 -04:00
Randy Hall c05d8fed5a
Merge pull request #10 from kf7eel/patch-1
forward CSBK to destination TG
2021-02-28 08:18:34 -08:00
KF7EEL 9d49106a5f forward CSBK to destination TG 2021-02-26 16:16:15 -08:00
Randy Hall 539f8a7fcd
Merge pull request #6 from kf7eel/master
fix typo (CSBK packet types). Does not fundamentally change the script, since CSBK packets aren't processed.
2020-11-23 20:28:14 -08:00
KF7EEL bfff0abacd fix typo 2020-11-21 22:42:05 -08:00
Randy Hall 04e220de86
Merge pull request #2 from K2IE/master
Restored XLXPEER Functionality. Not actually cruft after all.
2020-10-24 21:58:42 -07:00
Dan Srebnick (K2IE) 948a2a7bbc Cosmetics 2020-10-24 21:20:22 -04:00
Dan Srebnick (K2IE) 951f39f3db Re-add needed code removed when diffing to restore XLX 2020-10-24 21:14:06 -04:00
Dan Srebnick (K2IE) 4b9864671e Restore XLXPEER functionality 2020-10-24 20:53:48 -04:00
Cort Buffington d0d496b232 Add necessary pieces for Talker Alias DMRA 2020-10-15 16:23:55 -05:00
n0mjs710 51ecece8dc Add DMRA Framework 2020-10-13 18:59:28 -05:00
n0mjs710 ce494a4a18 Delete hblink-800.cfg 2020-10-12 08:30:42 -05:00
n0mjs710 819c3bae30 remove cruft 2020-10-12 08:29:50 -05:00
n0mjs710 a16e426c55 Merge branch 'master' of https://github.com/n0mjs710/hblink3 2020-10-12 08:27:07 -05:00
n0mjs710 a12b144c7c Options added 2020-10-12 08:27:03 -05:00
Cort Buffington c8e1d88ecc Merge branch 'master' of https://github.com/n0mjs710/hblink3 2020-10-12 06:37:40 -05:00
Cort Buffington 89040e7c14 Remove Cruft 2020-10-12 06:37:21 -05:00
Cort Buffington d68241918b
Merge pull request #18 from n0mjs710/private-call-dev
Private call dev
2020-10-11 07:54:40 -05:00
Cort Buffington ccfd862a0a Fixed Private Call Bridging when BOTH_SLOTS selected
This is the problem where bridge.py is told to send private calls marked with EITHER timeslot over openbridge. Packets weren't assembled correctly when the BOTH_SLOTS option was set True in the hblink configuraiton file.
d:
#	modified:   bridge.py
#	modified:   hblink.py
#
# Changes not staged for commit:
#	modified:   .gitattributes
#	modified:   Dockerfile
#	modified:   voice_lib.py
#
2020-04-27 11:01:54 -05:00
n0mjs710 24dca2e6ad Fixed assignment typos
[_stream_id]['ACTIVE']: False
to
[_stream_id]['ACTIVE'] = False

Thanks, Steve!
2020-03-18 09:32:32 -05:00
Cort Buffington 8c1e9e5185 update coypright years 2020-03-16 14:35:28 +00:00
Cort Buffington a2c0bb54c6 Fixed typo in call state tracking. 2020-03-16 08:38:16 -05:00
Cort Buffington 03f9c81d3a Merge branch 'private-call-dev' of https://github.com/n0mjs710/hblink3 into private-call-dev 2020-03-15 21:23:05 -05:00
Cort Buffington fdbfbf2362 READY FOR TESTING
unit calls should be working on HBP and OBP systems. Also adds the ability to send TS data in OBP for unit calls to preserve timeslot routing for unit calls.
2020-03-15 21:23:03 -05:00
Cort Buffington b48e522f85 Now working version of private call routing, on a per-system basis, with the ability to overload OBP with TS information for unit calls. 2020-03-16 02:20:24 +00:00
Cort Buffington f00d29e8a0 Update to sync dev system
message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch private-call-dev
# Your branch is ahead of 'origin/private-call-dev' by 1 commit.
#   (use "git push" to publish your local commits)
#
2020-03-14 10:56:16 -05:00
Cort Buffington 08f6669bd3
Update README.md 2020-03-11 09:47:39 -05:00
Cort Buffington 8497bb1462
Update README.md 2020-03-11 09:46:54 -05:00
Cort Buffington ac87c44917
Update README.md 2020-03-11 09:46:29 -05:00
Cort Buffington 8f0a3d02a5
Update README.md 2020-03-11 09:46:11 -05:00
Cort Buffington d31c6f7fe7
Update README.md 2020-03-11 09:45:09 -05:00
n0mjs710 e1174e6aba Added IP address logging for denied registration 2020-03-09 13:28:11 -05:00
Cort Buffington e8f838b3d6
Update README.md 2020-03-07 14:08:29 -06:00
Cort Buffington 7f7f8bdf74 Adding Official Logo Images 2020-03-06 07:31:12 -06:00
Cort Buffington 21c6bf9281 save of incremental work 2020-03-03 22:51:50 +00:00
Cort Buffington 4e3a13daaf fixing typos on obp call tracking 2020-02-19 19:27:37 +00:00
Cort Buffington 9e2876dfae update 2020-02-18 18:11:19 +00:00
Cort Buffington c246f3e5db Merge branch 'private-call-dev' of https://github.com/n0mjs710/hblink3 into private-call-dev 2020-02-17 19:20:19 -06:00
Cort Buffington 21f9c680be update sample config 2020-02-17 19:20:10 -06:00
Cort Buffington 50387c2133 update 2020-02-18 01:18:11 +00:00
n0mjs710 41f04dc28b Skeleton App for Data Development 2020-02-11 14:24:29 -06:00
n0mjs710 d44a181c06 create blank app template 2020-02-10 10:11:11 -06:00
n0mjs710 383ba7e0ae Create an "app template"
this should make it easier to build new or test applications.
2020-02-10 10:09:40 -06:00
Cort Buffington 7fc4ce0495 Merge branch 'private-call-dev' of https://github.com/n0mjs710/hblink3 into private-call-dev
As a result of rebasing.
2020-02-09 19:53:31 -06:00
Cort Buffington 4aa5210f5b Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 3d9aa41fcb Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 2fa615dd37 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 35ba251e71 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 30ed93aa30 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 508b9c7197 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington ed2a1ca549 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington e6949e65ec Revert "Update bridge.py"
This reverts commit ab1a536147.
2020-02-09 19:51:58 -06:00
Cort Buffington 9ac426aa2d Revert "Update bridge.py"
This reverts commit 0a2edc09a5.
2020-02-09 19:51:58 -06:00
Cort Buffington 94afc15d7a Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington b5e77e64b1 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 8c2b35ece0 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington bb4356e027 Update bridge.py 2020-02-09 19:51:58 -06:00
Cort Buffington 63604a5b38 inbound OBP Unit calls 2020-02-09 19:51:58 -06:00
Cort Buffington 4643ea47b7 Inbound OBP Unit calls 2020-02-09 19:51:58 -06:00
Cort Buffington 877e1c6c65 Adding inbound OBP Processing 2020-02-09 19:51:58 -06:00
n0mjs710 364ead81ec Working Code - REPORT ERRORS! 2020-02-09 19:51:58 -06:00
Cort Buffington 717e802b9b fixed missing ) on logging line 2020-02-09 19:51:58 -06:00
n0mjs710 857c4d09d0 untested OBP support added
Push is just to sync with a test system.
2020-02-09 19:51:58 -06:00
n0mjs710 2e09350ad2 OBP Support Added -- CURRENTLY UNTESTED
OpenBridge support added, but not yet tested. This push is so that I can pick up my updates on another computer to test.
2020-02-09 19:51:58 -06:00
Cort Buffington 836c655739 add configuration to enable unit routing 2020-02-09 19:51:58 -06:00
Cort Buffington 281860db0b unit to unit calls, with contention working - HBSystems only
This appears to work, but no openbridge support yet.
2020-02-09 19:51:58 -06:00
Cort Buffington 0f38427f2f Works, but no contention handler
Private call forwarding works, with destionation routing cache, but no contention handler yet.
2020-02-09 19:51:58 -06:00
Cort Buffington 112143ec05 incremental update - Not Working
the program runs at ths point, logging is updated for group calls, no errors in unit sectinon, but no contention handler and send routines not yet built.
2020-02-09 19:51:58 -06:00
Cort Buffington 887657aa16 Track subscribers
this is not yet really useable, just getting the mechanics started
2020-02-09 19:51:58 -06:00
Cort Buffington 7bf0a77e16 Separate UNIT from GROUP Calls
Initial framework for processing UNIT calls
2020-02-09 19:51:58 -06:00
Cort Buffington 28f006b493 Update bridge.py 2020-02-09 17:08:32 -06:00
Cort Buffington 99c76b44de Update bridge.py 2020-02-09 16:33:46 -06:00
Cort Buffington b9dc33dae5
Update README.md 2020-02-06 15:30:53 -06:00
Cort Buffington 58c84cf43a Changed initial state values for some reporting variables. Cosmetic, but avoids unecessary tracabacks. 2020-01-13 14:45:17 +00:00
Cort Buffington ef4514b8e0 updated commented debugging message at line #355 to remove unnecessary type conversion for _seq 2019-12-15 16:55:19 +00:00
Cort Buffington 96514de5cc Fixed unecessary type conversion in commended debug logging at line #355 2019-12-15 16:52:14 +00:00
Cort Buffington cdae79e0ee
Merge pull request #11 from kc1awv/patch-1
fix typo
2019-12-13 10:00:16 -06:00
Steve Miller 429287452a
fix typo
missing bracket on line 89
2019-12-13 10:54:04 -05:00
Cort Buffington 3cb00bc5bd Update bridge.py 2019-12-04 19:13:13 -06:00
Cort Buffington d68d3582da Update bridge.py 2019-12-04 19:07:58 -06:00
Cort Buffington 3d5437e9a0 Update bridge.py 2019-12-04 19:06:57 -06:00
Cort Buffington e00a98f7d2 Update bridge.py 2019-12-04 19:05:48 -06:00
Cort Buffington 053914a68b Update bridge.py 2019-12-04 19:02:24 -06:00
Cort Buffington 76143f718c Revert "Update bridge.py"
This reverts commit ab1a536147.
2019-12-04 19:00:13 -06:00
Cort Buffington 83d120c101 Revert "Update bridge.py"
This reverts commit 0a2edc09a5.
2019-12-04 18:59:55 -06:00
Cort Buffington 0a2edc09a5 Update bridge.py 2019-12-04 18:57:44 -06:00
Cort Buffington ab1a536147 Update bridge.py 2019-12-04 18:51:42 -06:00
Cort Buffington e6d25534b5 Update bridge.py 2019-12-04 18:48:51 -06:00
Cort Buffington 9219b4b2ee Update bridge.py 2019-12-04 18:45:22 -06:00
Cort Buffington da607cd542 inbound OBP Unit calls 2019-12-04 17:25:50 -06:00
Cort Buffington 83299312cc Inbound OBP Unit calls 2019-12-04 17:23:04 -06:00
Cort Buffington 8bbd9ee850 Adding inbound OBP Processing 2019-12-04 17:12:26 -06:00
n0mjs710 999bbbf5f7 Working Code - REPORT ERRORS! 2019-12-03 13:11:01 -06:00
Cort Buffington 76bb7f1140 fixed missing ) on logging line 2019-12-02 19:56:41 -06:00
Cort Buffington ece48f3a50 Merge branch 'private-call-dev' of https://github.com/n0mjs710/hblink3 into private-call-dev 2019-12-02 19:49:47 -06:00
Cort Buffington 1bc57b5ea4 add configuration to enable unit routing 2019-12-02 19:49:37 -06:00
n0mjs710 9e2d2315da untested OBP support added
Push is just to sync with a test system.
2019-12-02 08:30:25 -06:00
n0mjs710 3893e12fca OBP Support Added -- CURRENTLY UNTESTED
OpenBridge support added, but not yet tested. This push is so that I can pick up my updates on another computer to test.
2019-12-02 08:29:52 -06:00
Cort Buffington 8a45e927ae unit to unit calls, with contention working - HBSystems only
This appears to work, but no openbridge support yet.
2019-12-01 13:27:07 -06:00
Cort Buffington f98c12096c Works, but no contention handler
Private call forwarding works, with destionation routing cache, but no contention handler yet.
2019-12-01 11:20:14 -06:00
Cort Buffington e5eafeec3e incremental update - Not Working
the program runs at ths point, logging is updated for group calls, no errors in unit sectinon, but no contention handler and send routines not yet built.
2019-12-01 10:06:08 -06:00
Cort Buffington d8bfdc7068 Track subscribers
this is not yet really useable, just getting the mechanics started
2019-11-29 10:35:27 -06:00
Cort Buffington d689a876aa Separate UNIT from GROUP Calls
Initial framework for processing UNIT calls
2019-11-28 10:49:32 -06:00
Cort Buffington 31c23ae7a0 Fixed unecessary bytes to int conversion of sequence field -- used for loss reporting 2019-11-20 14:52:24 +00:00
n0mjs710 3878c82513 Add ability to specify a rules file on the CLI 2019-10-07 09:52:33 -05:00
n0mjs710 96b029a927 Cleaned up Processing and logging 2019-09-30 14:10:40 -05:00
n0mjs710 2ef0dfcd74 Fix ACL logging - SLOT specifig logging had quietly been broken 2019-09-25 14:36:20 -05:00
n0mjs710 1b265d8368 Initial Upload -- seems to work. 2019-09-25 09:56:03 -05:00
Cort Buffington 84800d690a
Merge pull request #8 from millaguie/docker
Add support for configuration from directory instead a git repo
2019-09-22 11:29:05 -05:00
Millaguie 9ba975bfff Add support for configuration from directory instead a git repo 2019-09-22 18:17:10 +02:00
Cort Buffington e570adbef0 Remove print() used for debugging 2019-09-18 23:45:32 +00:00
Cort Buffington 99d0b49559 convert seq from bytes to int so we can actually use it 2019-09-11 09:24:54 -05:00
Cort Buffington d3a5ee2221 Fixed reference to STRING_TO to be const.STRING_TO 2019-09-07 13:31:37 +00:00
n0mjs710 557b21c022 Remove unnecessary state variables 2019-09-06 13:43:24 -05:00
n0mjs710 553bcba3a2 Contention Handler logging error fixed (lots of them) 2019-09-06 13:02:39 -05:00
n0mjs710 101a6e4a11 Fix typo in contention handler logging 2019-09-06 12:49:13 -05:00
n0mjs710 55a546a239 Added Contention Handler & Target Iteration to continue not return 2019-09-06 10:18:24 -05:00
n0mjs710 64a685cd80 1st Working Version
May still have issues, definitley needs improvement.
2019-09-06 09:06:37 -05:00
n0mjs710 aefedca6ee 1st attempt at an operational upload 2019-09-05 12:51:29 -05:00
n0mjs710 be13083729 Create bridge_all.py
NO GUARANTEES. It still has some python2 code that needs updated, but it's here while I work on it.
2019-09-05 08:46:28 -05:00
17 changed files with 1586 additions and 625 deletions

0
.gitattributes vendored Normal file → Executable file
View File

View File

@ -1,32 +0,0 @@
FROM python:3.7-slim-stretch
RUN apt update && \
apt install -y git && \
cd /usr/src/ && \
git clone https://github.com/n0mjs710/dmr_utils3 && \
cd /usr/src/dmr_utils3 && \
./install.sh && \
rm -rf /var/lib/apt/lists/* && \
cd /opt && \
rm -rf /usr/src/dmr_utils3 && \
git clone https://github.com/n0mjs710/hblink3
RUN cd /opt/hblink3/ && \
sed -i s/.*python.*//g requirements.txt && \
pip install --no-cache-dir -r requirements.txt
ADD entrypoint /entrypoint
RUN adduser -u 54000 radio && \
adduser radio radio && \
chmod 755 /entrypoint && \
chown radio:radio /entrypoint && \
chown radio /opt/hblink3
RUN chmod 755 /entrypoint
USER radio
EXPOSE 54000
ENTRYPOINT [ "/entrypoint" ]

BIN
HBlink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

245
HBlink.svg Normal file
View File

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0beta1 (d565813, 2019-09-28)"
sodipodi:docname="HBlink.svg"
id="svg877"
height="411.17413"
width="1042.9242"
viewBox="49.656 217.125 1042.9242 411.17414"
version="1.1">
<sodipodi:namedview
inkscape:current-layer="svg877"
inkscape:window-maximized="0"
inkscape:window-y="23"
inkscape:window-x="583"
inkscape:cy="48.366866"
inkscape:cx="574.39926"
inkscape:zoom="1"
fit-margin-left="5"
fit-margin-bottom="5"
fit-margin-right="5"
fit-margin-top="5"
units="px"
inkscape:pagecheckerboard="true"
showgrid="false"
id="namedview879"
inkscape:window-height="1348"
inkscape:window-width="1943"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
inkscape:document-rotation="0"
bordercolor="#666666"
pagecolor="#ffffff" />
<defs
id="defs837">
<font-face
overline-thickness="0"
overline-position="0"
strikethrough-thickness="0"
strikethrough-position="0"
v-hanging="0"
v-mathematical="0"
v-alphabetic="0"
v-ideographic="0"
hanging="0"
mathematical="0"
alphabetic="0"
ideographic="0"
accent-height="0"
stemh="0"
stemv="0"
id="font-face833"
font-weight="400"
descent="-255.00488"
ascent="945.0073"
cap-height="669"
x-height="669"
slope="0"
underline-thickness="20"
underline-position="-133"
units-per-em="1000"
panose-1="2 0 6 0 0 0 0 0 0 0"
font-size="96"
font-family="Ethnocentric">
<font-face-src>
<font-face-name
name="EthnocentricRg-Regular" />
</font-face-src>
</font-face>
<font-face
overline-thickness="0"
overline-position="0"
strikethrough-thickness="0"
strikethrough-position="0"
v-hanging="0"
v-mathematical="0"
v-alphabetic="0"
v-ideographic="0"
hanging="0"
mathematical="0"
alphabetic="0"
ideographic="0"
accent-height="0"
stemh="0"
stemv="0"
id="font-face835"
font-weight="400"
descent="-255.00488"
ascent="945.0073"
cap-height="669"
x-height="669"
slope="0"
underline-thickness="20"
underline-position="-133"
units-per-em="1000"
panose-1="2 0 6 0 0 0 0 0 0 0"
font-size="48"
font-family="Ethnocentric">
<font-face-src>
<font-face-name
name="EthnocentricRg-Regular" />
</font-face-src>
</font-face>
</defs>
<metadata
id="metadata839"> Produced by OmniGraffle 7.12.1
<dc:date>2018-03-14 13:37:44 +0000</dc:date>
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="matrix(3.5262508,0,0,3.5262508,-159.40153,-655.56235)"
stroke-opacity="1"
stroke="none"
stroke-dasharray="none"
fill-opacity="1"
fill="none"
id="Canvas_2">
<title
id="title841">Canvas 2</title>
<g
id="Canvas_2: Layer 1">
<title
id="title843">Layer 1</title>
<g
id="Group_40">
<g
id="Graphic_39">
<title
id="title845">path6007</title>
<path
inkscape:connector-curvature="0"
id="path847"
stroke-width="3"
stroke-linejoin="round"
stroke-linecap="round"
stroke="#009051"
d="m 72.52062,328.5 h 225.5218 c 6.17355,0 11.1782,5.00465 11.1782,11.1782 v 0 c 0,6.17355 -5.00465,11.1782 -11.1782,11.1782 H 72.52062 c -6.17355,0 -11.1782,-5.00465 -11.1782,-11.1782 v 0 c 0,-6.17355 5.00465,-11.1782 11.1782,-11.1782 z" />
</g>
<g
id="Graphic_38">
<g
style="fill:#009051"
id="text852"
transform="translate(54.656,222.125)"
aria-label="HB">
<path
inkscape:connector-curvature="0"
id="path881"
style="font-weight:400;font-size:96px;font-family:Ethnocentric;fill:#009051"
d="M 84,91 H 64.224 V 66.232 H 26.016 V 91 H 6.048 V 26.776 H 26.016 V 49.528 H 64.224 V 26.776 H 84 Z" />
<path
inkscape:connector-curvature="0"
id="path883"
style="font-weight:400;font-size:96px;font-family:Ethnocentric;fill:#009051"
d="m 168.7155,57.976 q 4.224,1.248 7.104,4.896 2.976,3.648 2.976,9.408 0,4.032 -1.248,7.488 -1.248,3.36 -4.224,5.856 -2.976,2.496 -8.064,3.936 -4.992,1.44 -12.576,1.44 H 96.2355 V 51.928 h 56.832 q 2.208,0 3.84,-0.864 1.728,-0.96 1.728,-3.456 0,-2.4 -1.728,-3.264 -1.728,-0.864 -3.84,-0.864 h -56.832 l 13.44,-16.704 h 42.528 q 5.76,0 10.368,1.152 4.704,1.056 7.968,3.36 3.36,2.208 5.088,5.568 1.824,3.264 1.824,7.68 0,2.88 -0.768,5.088 -0.768,2.208 -2.016,3.936 -1.152,1.632 -2.784,2.784 -1.536,1.056 -3.168,1.632 z m -52.512,7.68 v 8.832 h 36.576 q 3.264,0 4.704,-1.152 1.44,-1.152 1.44,-3.36 0,-2.112 -1.44,-3.168 -1.44,-1.152 -4.704,-1.152 z" />
</g>
</g>
<g
id="Graphic_37">
<g
style="fill:#ff9300"
id="text857"
transform="translate(209.109,275)"
aria-label="link">
<path
inkscape:connector-curvature="0"
id="path886"
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
d="M 3.024,45 Z M 37.824,36.744 31.392,45 H 3.024 V 12.888 h 9.936 v 23.856 z" />
<path
inkscape:connector-curvature="0"
id="path888"
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
d="m 41.32425,45 z m 9.936,0 h -9.936 V 12.888 h 9.936 z" />
<path
inkscape:connector-curvature="0"
id="path890"
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
d="m 57.34875,45 z m 32.688,0.528 q -0.96,0 -1.92,-0.336 -0.912,-0.288 -2.064,-1.392 l -19.68,-17.664 V 45 h -9.024 V 18.36 q 0,-1.584 0.432,-2.736 0.48,-1.152 1.2,-1.872 0.768,-0.72 1.728,-1.056 1.008,-0.336 2.064,-0.336 0.912,0 1.824,0.336 0.96,0.288 2.16,1.392 l 19.68,17.664 V 12.888 h 9.072 V 39.48 q 0,1.584 -0.48,2.736 -0.432,1.152 -1.2,1.92 -0.72,0.72 -1.728,1.056 -1.008,0.336 -2.064,0.336 z" />
<path
inkscape:connector-curvature="0"
id="path892"
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
d="m 101.36775,45 z m 40.512,0 h -15.024 l -9.696,-8.448 q -2.496,-2.16 -3.84,-3.36 -1.296,-1.2 -2.112,-2.016 0.048,1.104 0.096,2.304 0.048,1.152 0.048,2.304 V 45 h -9.984 V 12.888 h 9.984 v 7.44 q 0,1.488 -0.048,2.928 -0.048,1.44 -0.144,2.688 0.96,-0.864 2.304,-2.112 1.392,-1.296 3.6,-3.12 l 9.264,-7.824 h 14.4 l -12.288,9.216 q -1.584,1.2 -2.832,2.112 -1.2,0.912 -2.16,1.584 -0.96,0.672 -1.776,1.2 -0.768,0.528 -1.536,1.008 1.392,0.96 3.36,2.4 1.968,1.44 5.088,3.984 z" />
</g>
</g>
<g
id="Graphic_36">
<path
inkscape:connector-curvature="0"
d="m 302.0625,336.9375 h 14.5771 v 6.1875 h -14.5771 z"
style="fill:#ffffff"
id="rect860" />
</g>
<g
id="Graphic_35">
<title
id="title863">path6381</title>
<path
inkscape:connector-curvature="0"
id="path865"
stroke-width="3"
stroke-linejoin="round"
stroke-linecap="round"
stroke="#ff9300"
d="M 116.9282,340.3125 H 342.45 c 6.17355,0 11.1782,5.00465 11.1782,11.1782 v 0 c 0,6.17355 -5.00465,11.1782 -11.1782,11.1782 H 116.9282 c -6.17355,0 -11.1782,-5.00465 -11.1782,-11.1782 v 0 c 0,-6.17355 5.00465,-11.1782 11.1782,-11.1782 z" />
</g>
<g
id="Graphic_34">
<path
inkscape:connector-curvature="0"
d="m 99,347.625 h 14.5771 v 6.1875 H 99 Z"
style="fill:#ffffff"
id="rect868" />
</g>
<g
id="Line_33">
<path
inkscape:connector-curvature="0"
d="M 93.9375,350.85641 H 120.375"
style="stroke:#009051;stroke-width:3;stroke-linecap:round;stroke-linejoin:round"
id="line871" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -1,10 +1,18 @@
# OBP-Master #
---
### Forked from the HBLink project ###
### FOR SUPPORT, DISCUSSION, GETTING INVOLVED ###
Please join the DVSwitch group at groups.io for online forum support, discussion, and to become part of the development team.
DVSwitch@groups.io
A voluntary registrty for HBlink systems with public access has been created at http://hblink-register.com.es Please consider listing your system if you allow open access.
---
## PROJECT: Open Source HomeBrew Repeater Proctol Client/Master. ##
@ -13,7 +21,7 @@ DVSwitch@groups.io
**PURPOSE:** Thanks to the work of Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT we have an open protocol for internetworking DMR repeaters. Unfortunately, there's no generic client and/or master stacks. This project is to build an open-source, python-based implementation. You are free to use this software however you want, however we ask that you provide attribution in some public venue (such as project, club, organization web site). This helps us see where the software is in use and track how it is used.
For those who will ask: This is a piece of software that implements an open-source, amateur radio networking protocol. It is not a network. It is not indended to be a network. It is not intended to replace or circumvent a network. People do those things, code doesn't.
For those who will ask: This is a piece of software that implements an open-source, amateur radio networking protocol. It is not a network. It is not intended to be a network. It is not intended to replace or circumvent a network. People do those things, code doesn't.
**PROPERTY:**
This work represents the author's interpretation of the HomeBrew Repeater Protocol, based on the 2015-07-26 documents from DMRplus, "IPSC Protocol Specs for homebrew DMR repeater" as written by Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT, also licenced under Creative Commons BY-NC-SA license.
@ -54,7 +62,7 @@ chown 65000 /var/log/hblink.log
***0x49 DE N0MJS***
Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS n0mjs@me.com
Copyright (C) 2016-2020 Cortney T. Buffington, N0MJS n0mjs@me.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

View File

@ -1,150 +0,0 @@
#!/usr/bin/env python
#
###############################################################################
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
# Python modules we need
import sys
from bitarray import bitarray
from time import time
from importlib import import_module
# Twisted is pretty important, so I keep it separate
from twisted.internet.protocol import Factory, Protocol
from twisted.protocols.basic import NetstringReceiver
from twisted.internet import reactor, task
# Things we import from the main hblink module
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
from dmr_utils3.utils import bytes_3, int_id, get_alias
from dmr_utils3 import decode, bptc, const
import config
import log
from const import *
# Stuff for socket reporting
import pickle
# REMOVE LATER from datetime import datetime
# The module needs logging, but handlers, etc. are controlled by the parent
import logging
logger = logging.getLogger(__name__)
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
__author__ = 'Cortney T. Buffington, N0MJS'
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
__license__ = 'GNU GPLv3'
__maintainer__ = 'Cort Buffington, N0MJS'
__email__ = 'n0mjs@me.com'
# Module gobal varaibles
class OBP(OPENBRIDGE):
def __init__(self, _name, _config, _report):
OPENBRIDGE.__init__(self, _name, _config, _report)
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
pass
class HBP(HBSYSTEM):
def __init__(self, _name, _config, _report):
HBSYSTEM.__init__(self, _name, _config, _report)
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
pass
#************************************************
# MAIN PROGRAM LOOP STARTS HERE
#************************************************
if __name__ == '__main__':
import argparse
import sys
import os
import signal
# Change the current directory to the location of the application
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
# Call the external routine to build the configuration dictionary
CONFIG = config.build_config(cli_args.CONFIG_FILE)
# Start the system logger
if cli_args.LOG_LEVEL:
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
logger = log.config_logging(CONFIG['LOGGER'])
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018\n\tThe Regents of the K0USY Group. All rights reserved.\n')
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
# Set up the signal handler
def sig_handler(_signal, _frame):
logger.info('(GLOBAL) SHUTDOWN: CONFBRIDGE IS TERMINATING WITH SIGNAL %s', str(_signal))
hblink_handler(_signal, _frame)
logger.info('(GLOBAL) SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
reactor.stop()
# Set signal handers so that we can gracefully exit if need be
for sig in [signal.SIGINT, signal.SIGTERM]:
signal.signal(sig, sig_handler)
# Create the name-number mapping dictionaries
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
# INITIALIZE THE REPORTING LOOP
if CONFIG['REPORTS']['REPORT']:
report_server = config_reports(CONFIG, bridgeReportFactory)
else:
report_server = None
logger.info('(REPORT) TCP Socket reporting not configured')
# HBlink instance creation
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
for system in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
systems[system] = OBP(system, CONFIG, report_server)
else:
systems[system] = HBP(system, CONFIG, report_server)
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
def loopingErrHandle(failure):
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
reactor.stop()
reactor.run()

1111
bridge.py

File diff suppressed because it is too large Load Diff

295
bridge_all.py Executable file
View File

@ -0,0 +1,295 @@
#!/usr/bin/env python
#
###############################################################################
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
'''
This is a very simple call/packet router for Homebrew Repeater Protocol. It
will forward traffic from any system to all other systems configured in the
hblink.py configuration file. It does not check for call contentions or
filter TS/TGID combinations. It should really only be used as a proxy to
hide multiple Homebrew repater protocol systems behind what appears as a single
repeater, hotspot, etc.
As is, this program only works with group voice packets. It could work for all
of them by removing a few things.
IT ONLY WORKS FOR HBP SYSTEMS!!! Using it with OpenBridge or XLX wouldn't make
a lot of sense, and has the potential to do bad things.
'''
# Python modules we need
import sys
from bitarray import bitarray
from time import time
from importlib import import_module
from types import ModuleType
# Twisted is pretty important, so I keep it separate
from twisted.internet.protocol import Factory, Protocol
from twisted.protocols.basic import NetstringReceiver
from twisted.internet import reactor, task
# Things we import from the main hblink module
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases, acl_check
from dmr_utils3.utils import bytes_3, int_id, get_alias
from dmr_utils3 import decode, bptc, const
import config
import log
import const
# The module needs logging logging, but handlers, etc. are controlled by the parent
import logging
logger = logging.getLogger(__name__)
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
__author__ = 'Cortney T. Buffington, N0MJS'
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
__license__ = 'GNU GPLv3'
__maintainer__ = 'Cort Buffington, N0MJS'
__email__ = 'n0mjs@me.com'
__status__ = 'pre-alpha'
# Module gobal varaibles
class bridgeallSYSTEM(HBSYSTEM):
def __init__(self, _name, _config, _report):
HBSYSTEM.__init__(self, _name, _config, _report)
self._laststrid = ''
# Status information for the system, TS1 & TS2
# 1 & 2 are "timeslot"
self.STATUS = {
1: {
'RX_START': time(),
'RX_LOSS': 0,
'RX_SEQ': 0,
'RX_RFS': b'\x00',
'TX_RFS': b'\x00',
'RX_STREAM_ID': b'\x00',
'TX_STREAM_ID': b'\x00',
'RX_TGID': b'\x00\x00\x00',
'TX_TGID': b'\x00\x00\x00',
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
},
2: {
'RX_START': time(),
'RX:LOSS': 0,
'RX_SEQ': 0,
'RX_RFS': b'\x00',
'TX_RFS': b'\x00',
'RX_STREAM_ID': b'\x00',
'TX_STREAM_ID': b'\x00',
'RX_TGID': b'\x00\x00\x00',
'TX_TGID': b'\x00\x00\x00',
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
}
}
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
pkt_time = time()
dmrpkt = _data[20:53]
_bits = _data[15]
if _call_type == 'group':
# Is this is a new call stream?
new_stream = (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'])
if new_stream:
self.STATUS[_slot]['RX_START'] = pkt_time
self.STATUS[_slot]['RX_LOSS'] = 0
self.STATUS[_slot]['RX_SEQ'] = _seq
logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot)
else:
# This could be much better, it will have errors during roll-over
if _seq > (self.STATUS[_slot]['RX_SEQ'] + 1):
#print(_seq, self.STATUS[_slot]['RX_SEQ'])
self.STATUS[_slot]['RX_LOSS'] += _seq - (self.STATUS[_slot]['RX_SEQ'] + 1)
# Final actions - Is this a voice terminator?
if (_frame_type == const.HBPF_DATA_SYNC) and (_dtype_vseq == const.HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != const.HBPF_SLT_VTERM):
call_duration = pkt_time - self.STATUS[_slot]['RX_START']
logger.info('(%s) *CALL END* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s, Loss: %s, Duration: %s', \
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, self.STATUS[_slot]['RX_LOSS'], call_duration)
for _target in self._CONFIG['SYSTEMS']:
if _target != self._system:
_target_status = systems[_target].STATUS
_target_system = self._CONFIG['SYSTEMS'][_target]
# BEGIN STANDARD CONTENTION HANDLING
#
# The rules for each of the 4 "ifs" below are listed here for readability. The Frame To Send is:
# From a different group than last RX from this HBSystem, but it has been less than Group Hangtime
# From a different group than last TX to this HBSystem, but it has been less than Group Hangtime
# From the same group as the last RX from this HBSystem, but from a different subscriber, and it has been less than stream timeout
# From the same group as the last TX to this HBSystem, but from a different subscriber, and it has been less than stream timeout
# The "continue" at the end of each means the next iteration of the for loop that tests for matching rules
#
if ((_dst_id != _target_status[_slot]['RX_TGID']) and ((pkt_time - _target_status[_slot]['RX_TIME']) < _target_system['GROUP_HANGTIME'])):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
logger.info('(%s) Call not routed to TGID %s, target active or in group hangtime: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['RX_TGID']))
continue
if ((_dst_id != _target_status[_slot]['TX_TGID']) and ((pkt_time - _target_status[_slot]['TX_TIME']) < _target_system['GROUP_HANGTIME'])):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
logger.info('(%s) Call not routed to TGID%s, target in group hangtime: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['TX_TGID']))
continue
if (_dst_id == _target_status[_slot]['RX_TGID']) and ((pkt_time - _target_status[_slot]['RX_TIME']) < const.STREAM_TO):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
logger.info('(%s) Call not routed to TGID%s, matching call already active on target: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['RX_TGID']))
continue
if (_dst_id == _target_status[_slot]['TX_TGID']) and (_rf_src != _target_status[_slot]['TX_RFS']) and ((pkt_time - _target_status[_slot]['TX_TIME']) < const.STREAM_TO):
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
logger.info('(%s) Call not routed for subscriber %s, call route in progress on target: HBSystem: %s, TS: %s, TGID: %s, SUB: %s', self._system, int_id(_rf_src), _target, _slot, int_id(_target_status[_slot]['TX_TGID']), int_id(_target_status[_slot]['TX_RFS']))
continue
# ACL Processing
if self._CONFIG['GLOBAL']['USE_ACL']:
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', _target, int_id(_stream_id), int_id(_rf_src))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', _target, int_id(_stream_id), int_id(_dst_id))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', _target, int_id(_stream_id), int_id(_dst_id))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
if _target_system['USE_ACL']:
if not acl_check(_rf_src, _target_system['SUB_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', _target, int_id(_stream_id), int_id(_rf_src))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
if _slot == 1 and not acl_check(_dst_id, _target_system['TG1_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', _target, int_id(_stream_id), int_id(_dst_id))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
if _slot == 2 and not acl_check(_dst_id, _target_system['TG2_ACL']):
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', _target, int_id(_stream_id), int_id(_dst_id))
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
continue
# Record this stuff for later
# Is this a new call stream?
if new_stream:
# Record the DST TGID and Stream ID
_target_status[_slot]['TX_START'] = pkt_time
_target_status[_slot]['TX_TGID'] = _dst_id
_target_status[_slot]['TX_RFS'] = _rf_src
_target_status[_slot]['TX_PEER'] = _peer_id
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
_target_status[_slot]['TX_TIME'] = pkt_time
systems[_target].send_system(_data)
#logger.debug('(%s) Packet routed to system: %s', self._system, _target)
# Mark status variables for use later
self.STATUS[_slot]['RX_RFS'] = _rf_src
self.STATUS[_slot]['RX_SEQ'] = _seq
self.STATUS[_slot]['RX_TYPE'] = _dtype_vseq
self.STATUS[_slot]['RX_TGID'] = _dst_id
self.STATUS[_slot]['RX_TIME'] = pkt_time
self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id
#************************************************
# MAIN PROGRAM LOOP STARTS HERE
#************************************************
if __name__ == '__main__':
import argparse
import sys
import os
import signal
from dmr_utils3.utils import try_download, mk_id_dict
# Change the current directory to the location of the application
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
# Call the external routine to build the configuration dictionary
CONFIG = config.build_config(cli_args.CONFIG_FILE)
# Start the system logger
if cli_args.LOG_LEVEL:
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
logger = log.config_logging(CONFIG['LOGGER'])
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n')
logger.debug('Logging system started, anything from here on gets logged')
# Set up the signal handler
def sig_handler(_signal, _frame):
logger.info('SHUTDOWN: BRIDGE_ALL IS TERMINATING WITH SIGNAL %s', str(_signal))
hblink_handler(_signal, _frame)
logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
reactor.stop()
# Set signal handers so that we can gracefully exit if need be
for sig in [signal.SIGTERM, signal.SIGINT]:
signal.signal(sig, sig_handler)
# Create the name-number mapping dictionaries
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
# INITIALIZE THE REPORTING LOOP
report_server = config_reports(CONFIG, reportFactory)
# HBlink instance creation
logger.info('HBlink \'bridge_all.py\' -- SYSTEM STARTING...')
for system in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
logger.critical('%s FATAL: Instance is mode \'OPENBRIDGE\', \n\t\t...Which would be tragic for Bridge All, since it carries multiple call\n\t\tstreams simultaneously. bridge_all.py onlyl works with MMDVM-based systems', system)
sys.exit('bridge_all.py cannot function with systems that are not MMDVM devices. System {} is configured as an OPENBRIDGE'.format(system))
else:
systems[system] = bridgeallSYSTEM(system, CONFIG, report_server)
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
reactor.run()

View File

@ -86,7 +86,7 @@ def acl_build(_acl, _max):
if (const.ID_MIN <= start <= _max) or (const.ID_MIN <= end <= _max):
acl.append((start, end))
else:
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE (} - {})IN RANGE-BASED ENTRY: {}'.format(const.ID_MIN, _max, entry))
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE ({} - {})IN RANGE-BASED ENTRY: {}'.format(const.ID_MIN, _max, entry))
else:
id = int(entry)
if (const.ID_MIN <= id <= _max):
@ -182,7 +182,7 @@ def build_config(_config_file):
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
'OPTIONS': bytes(config.get(section, 'OPTIONS'), 'utf-8'),
'OPTIONS': b''.join([b'Type=HBlink;', bytes(config.get(section, 'OPTIONS'), 'utf-8')]),
'USE_ACL': config.getboolean(section, 'USE_ACL'),
'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
@ -274,6 +274,7 @@ def build_config(_config_file):
'TARGET_SOCK': (gethostbyname(config.get(section, 'TARGET_IP')), config.getint(section, 'TARGET_PORT')),
'TARGET_IP': gethostbyname(config.get(section, 'TARGET_IP')),
'TARGET_PORT': config.getint(section, 'TARGET_PORT'),
'BOTH_SLOTS': config.getboolean(section, 'BOTH_SLOTS'),
'USE_ACL': config.getboolean(section, 'USE_ACL'),
'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_ACL'),

View File

@ -50,6 +50,7 @@ HBPF_SLT_VHEAD = 0x1
HBPF_SLT_VTERM = 0x2
# HomeBrew Protocol Commands
DMRA = b'DMRA'
DMRD = b'DMRD'
MSTCL = b'MSTCL'
MSTNAK = b'MSTNAK'

View File

@ -1,10 +0,0 @@
#!/bin/sh
mkdir -p /var/tmp/config
cd /var/tmp/config
git clone https://${GIT_USER}:${GIT_PASSWORD}@${GIT_REPO}
DIR=$(echo ${GIT_REPO}| sed s/.git$//g | sed s#^.*/##g)
cp -a /var/tmp/config/${DIR}/*cfg /opt/hblink3/
python /opt/hblink3/hblink.py

View File

@ -120,7 +120,9 @@ STALE_DAYS: 7
#
# ACLs:
# OpenBridge does not 'register', so registration ACL is meaningless.
# OpenBridge passes all traffic on TS1, so there is only 1 TGID ACL.
# Proper OpenBridge passes all traffic on TS1.
# HBlink can extend OPB to use both slots for unit calls only.
# Setting "BOTH_SLOTS" True ONLY affects unit traffic!
# Otherwise ACLs work as described in the global stanza
[OBP-1]
MODE: OPENBRIDGE
@ -131,6 +133,7 @@ NETWORK_ID: 3129100
PASSPHRASE: password
TARGET_IP: 1.2.3.4
TARGET_PORT: 62035
BOTH_SLOTS: True
USE_ACL: True
SUB_ACL: DENY:1
TGID_ACL: PERMIT:ALL

View File

@ -160,8 +160,8 @@ class OPENBRIDGE(DatagramProtocol):
_stream_id = _data[16:20]
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
# Sanity check for OpenBridge -- all calls must be on Slot 1
if _slot != 1:
# Sanity check for OpenBridge -- all calls must be on Slot 1 for Brandmeister or DMR+. Other HBlinks can process timeslot on OPB if the flag is set
if _slot != 1 and not self._config['BOTH_SLOTS'] and not _call_type == 'unit':
logger.error('(%s) OpenBridge packet discarded because it was not received on slot 1. SID: %s, TGID %s', self._system, int_id(_rf_src), int_id(_dst_id))
return
@ -206,8 +206,7 @@ class HBSYSTEM(DatagramProtocol):
self._system = _name
self._report = _report
self._config = self._CONFIG['SYSTEMS'][self._system]
self._laststrid1 = ''
self._laststrid2 = ''
self._laststrid = {1: b'', 2: b''}
# Define shortcuts and generic function names based on the type of system we are
if self._config['MODE'] == 'MASTER':
@ -353,45 +352,39 @@ class HBSYSTEM(DatagramProtocol):
_frame_type = (_bits & 0x30) >> 4
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
_stream_id = _data[16:20]
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, _seq, int_id(_rf_src), int_id(_dst_id))
# ACL Processing
if self._CONFIG['GLOBAL']['USE_ACL']:
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
if self._laststrid != _stream_id:
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
if _slot == 1:
self._laststrid1 = _stream_id
else:
self._laststrid2 = _stream_id
self._laststrid[_slot] = _stream_id
return
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
if self._laststrid1 != _stream_id:
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid1 = _stream_id
self._laststrid[_slot] = _stream_id
return
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
if self._laststrid2 != _stream_id:
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid2 = _stream_id
self._laststrid[_slot] = _stream_id
return
if self._config['USE_ACL']:
if not acl_check(_rf_src, self._config['SUB_ACL']):
if self._laststrid != _stream_id:
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
if _slot == 1:
self._laststrid1 = _stream_id
else:
self._laststrid2 = _stream_id
self._laststrid[_slot] = _stream_id
return
if _slot == 1 and not acl_check(_dst_id, self._config['TG1_ACL']):
if self._laststrid1 != _stream_id:
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid1 = _stream_id
self._laststrid[_slot] = _stream_id
return
if _slot == 2 and not acl_check(_dst_id, self._config['TG2_ACL']):
if self._laststrid2 != _stream_id:
if self._laststrid[_slot]!= _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid2 = _stream_id
self._laststrid[_slot] = _stream_id
return
# The basic purpose of a master is to repeat to the peers
@ -446,7 +439,7 @@ class HBSYSTEM(DatagramProtocol):
logger.info('(%s) Sent Challenge Response to %s for login: %s', self._system, int_id(_peer_id), self._peers[_peer_id]['SALT'])
else:
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
logger.warning('(%s) Invalid Login from Radio ID: %s Denied by Registation ACL', self._system, int_id(_peer_id))
logger.warning('(%s) Invalid Login from %s Radio ID: %s Denied by Registation ACL', self._system, _sockaddr[0], int_id(_peer_id))
else:
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
logger.warning('(%s) Registration denied from Radio ID: %s Maximum number of peers exceeded', self._system, int_id(_peer_id))
@ -526,6 +519,18 @@ class HBSYSTEM(DatagramProtocol):
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
logger.warning('(%s) Ping from Radio ID that is not logged in: %s', self._system, int_id(_peer_id))
elif _command == RPTO:
_peer_id = _data[4:8]
if _peer_id in self._peers \
and self._peers[_peer_id]['CONNECTION'] == 'YES' \
and self._peers[_peer_id]['SOCKADDR'] == _sockaddr:
logger.info('(%s) Peer %s (%s) has send options: %s', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_peer_id), _data[8:])
self.transport.write(b''.join([RPTACK, _peer_id]), _sockaddr)
elif _command == DMRA:
_peer_id = _data[4:8]
logger.info('(%s) Recieved DMR Talker Alias from peer %s, subscriber %s', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_rf_src))
else:
logger.error('(%s) Unrecognized command. Raw HBP PDU: %s', self._system, ahex(_data))
@ -562,41 +567,35 @@ class HBSYSTEM(DatagramProtocol):
# ACL Processing
if self._CONFIG['GLOBAL']['USE_ACL']:
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
if self._laststrid != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
if _slot == 1:
self._laststrid1 = _stream_id
else:
self._laststrid2 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
self._laststrid[_slot] = _stream_id
return
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
if self._laststrid1 != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid1 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid[_slot] = _stream_id
return
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
if self._laststrid2 != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid2 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid[_slot] = _stream_id
return
if self._config['USE_ACL']:
if not acl_check(_rf_src, self._config['SUB_ACL']):
if self._laststrid != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
if _slot == 1:
self._laststrid1 = _stream_id
else:
self._laststrid2 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
self._laststrid[_slot] = _stream_id
return
if _slot == 1 and not acl_check(_dst_id, self._config['TG1_ACL']):
if self._laststrid1 != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid1 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid[_slot] = _stream_id
return
if _slot == 2 and not acl_check(_dst_id, self._config['TG2_ACL']):
if self._laststrid2 != _stream_id:
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid2 = _stream_id
if self._laststrid[_slot] != _stream_id:
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
self._laststrid[_slot] = _stream_id
return
@ -661,6 +660,7 @@ class HBSYSTEM(DatagramProtocol):
self._stats['CONNECTION'] = 'YES'
self._stats['CONNECTED'] = time()
logger.info('(%s) Connection to Master Completed', self._system)
# If we are an XLX, send the XLX module request here.
if self._config['MODE'] == 'XLXPEER':
self.send_xlxmaster(self._config['RADIO_ID'], int(4000), self._config['MASTER_SOCKADDR'])
@ -802,7 +802,7 @@ if __name__ == '__main__':
if cli_args.LOG_LEVEL:
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
logger = log.config_logging(CONFIG['LOGGER'])
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n')
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019, 2020\n\tThe Regents of the K0USY Group. All rights reserved.\n')
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
# Set up the signal handler

View File

@ -1,6 +0,0 @@
#! /bin/bash
# Install the required support programs
apt-get install python3 python3-pip -y
pip3 install -r requirements.txt

229
playback.py Executable file
View File

@ -0,0 +1,229 @@
#!/usr/bin/env python
#
###############################################################################
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com> (and Mike Zingman N4IRR)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
# Python modules we need
import sys
from bitarray import bitarray
from time import time, sleep
from importlib import import_module
# Twisted is pretty important, so I keep it separate
from twisted.internet.protocol import Factory, Protocol
from twisted.protocols.basic import NetstringReceiver
from twisted.internet import reactor, task
# Things we import from the main hblink module
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases
from dmr_utils3.utils import bytes_3, int_id, get_alias
from dmr_utils3 import decode, bptc, const
import config
import log
import const
# The module needs logging logging, but handlers, etc. are controlled by the parent
import logging
logger = logging.getLogger(__name__)
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
__author__ = 'Cortney T. Buffington, N0MJS and Mike Zingman, N4IRR'
__copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group'
__license__ = 'GNU GPLv3'
__maintainer__ = 'Cort Buffington, N0MJS'
__email__ = 'n0mjs@me.com'
__status__ = 'pre-alpha'
# Module gobal varaibles
class playback(HBSYSTEM):
def __init__(self, _name, _config, _report):
HBSYSTEM.__init__(self, _name, _config, _report)
# Status information for the system, TS1 & TS2
# 1 & 2 are "timeslot"
# In TX_EMB_LC, 2-5 are burst B-E
self.STATUS = {
1: {
'RX_START': time(),
'RX_SEQ': '\x00',
'RX_RFS': '\x00',
'TX_RFS': '\x00',
'RX_STREAM_ID': '\x00',
'TX_STREAM_ID': '\x00',
'RX_TGID': '\x00\x00\x00',
'TX_TGID': '\x00\x00\x00',
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
'RX_LC': '\x00',
'TX_H_LC': '\x00',
'TX_T_LC': '\x00',
'TX_EMB_LC': {
1: '\x00',
2: '\x00',
3: '\x00',
4: '\x00',
}
},
2: {
'RX_START': time(),
'RX_SEQ': '\x00',
'RX_RFS': '\x00',
'TX_RFS': '\x00',
'RX_STREAM_ID': '\x00',
'TX_STREAM_ID': '\x00',
'RX_TGID': '\x00\x00\x00',
'TX_TGID': '\x00\x00\x00',
'RX_TIME': time(),
'TX_TIME': time(),
'RX_TYPE': const.HBPF_SLT_VTERM,
'RX_LC': '\x00',
'TX_H_LC': '\x00',
'TX_T_LC': '\x00',
'TX_EMB_LC': {
1: '\x00',
2: '\x00',
3: '\x00',
4: '\x00',
}
}
}
self.CALL_DATA = []
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
pkt_time = time()
dmrpkt = _data[20:53]
_bits = _data[15]
if _call_type == 'group':
# Is this is a new call stream?
if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']):
self.STATUS['RX_START'] = pkt_time
logger.info('(%s) *START RECORDING* STREAM ID: %s SUB: %s (%s) REPEATER: %s (%s) TGID %s (%s), TS %s', \
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot)
self.CALL_DATA.append(_data)
self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id
return
# Final actions - Is this a voice terminator?
if (_frame_type == const.HBPF_DATA_SYNC) and (_dtype_vseq == const.HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != const.HBPF_SLT_VTERM) and (self.CALL_DATA):
call_duration = pkt_time - self.STATUS['RX_START']
self.CALL_DATA.append(_data)
logger.info('(%s) *END RECORDING* STREAM ID: %s', self._system, int_id(_stream_id))
sleep(2)
logger.info('(%s) *START PLAYBACK* STREAM ID: %s SUB: %s (%s) REPEATER: %s (%s) TGID %s (%s), TS %s, Duration: %s', \
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, call_duration)
for i in self.CALL_DATA:
self.send_system(i)
#print(i)
sleep(0.06)
self.CALL_DATA = []
logger.info('(%s) *END PLAYBACK* STREAM ID: %s', self._system, int_id(_stream_id))
else:
if self.CALL_DATA:
self.CALL_DATA.append(_data)
# Mark status variables for use later
self.STATUS[_slot]['RX_RFS'] = _rf_src
self.STATUS[_slot]['RX_TYPE'] = _dtype_vseq
self.STATUS[_slot]['RX_TGID'] = _dst_id
self.STATUS[_slot]['RX_TIME'] = pkt_time
self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id
#************************************************
# MAIN PROGRAM LOOP STARTS HERE
#************************************************
if __name__ == '__main__':
import argparse
import sys
import os
import signal
from dmr_utils3.utils import try_download, mk_id_dict
# Change the current directory to the location of the application
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
# Call the external routine to build the configuration dictionary
CONFIG = config.build_config(cli_args.CONFIG_FILE)
# Start the system logger
if cli_args.LOG_LEVEL:
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
logger = log.config_logging(CONFIG['LOGGER'])
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Founding Members of the K0USY Group. All rights reserved.\n')
logger.debug('Logging system started, anything from here on gets logged')
# Set up the signal handler
def sig_handler(_signal, _frame):
logger.info('SHUTDOWN: HBROUTER IS TERMINATING WITH SIGNAL %s', str(_signal))
hblink_handler(_signal, _frame)
logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
reactor.stop()
# Set signal handers so that we can gracefully exit if need be
for sig in [signal.SIGTERM, signal.SIGINT]:
signal.signal(sig, sig_handler)
# ID ALIAS CREATION
# Download
if CONFIG['ALIASES']['TRY_DOWNLOAD'] == True:
# Try updating peer aliases file
result = try_download(CONFIG['ALIASES']['PATH'], CONFIG['ALIASES']['PEER_FILE'], CONFIG['ALIASES']['PEER_URL'], CONFIG['ALIASES']['STALE_TIME'])
logger.info(result)
# Try updating subscriber aliases file
result = try_download(CONFIG['ALIASES']['PATH'], CONFIG['ALIASES']['SUBSCRIBER_FILE'], CONFIG['ALIASES']['SUBSCRIBER_URL'], CONFIG['ALIASES']['STALE_TIME'])
logger.info(result)
# Create the name-number mapping dictionaries
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
# INITIALIZE THE REPORTING LOOP
report_server = config_reports(CONFIG, reportFactory)
# HBlink instance creation
logger.info('HBlink \'playback.py\' (c) 2017-2019 Cort Buffington, N0MJS & Mike Zingman, N4IRR -- SYSTEM STARTING...')
for system in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
logger.critical('%s FATAL: Instance is mode \'OPENBRIDGE\', \n\t\t...Which would be tragic for playback, since it carries multiple call\n\t\tstreams simultaneously. playback.py onlyl works with MMDVM-based systems', system)
sys.exit('playback.py cannot function with systems that are not MMDVM devices. System {} is configured as an OPENBRIDGE'.format(system))
else:
systems[system] = playback(system, CONFIG, report_server)
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
reactor.run()

View File

@ -47,6 +47,18 @@ BRIDGES = {
]
}
'''
list the names of each system that should bridge unit to unit (individual) calls.
'''
UNIT = ['ONE', 'TWO']
'''
This is for testing the syntax of the file. It won't eliminate all errors, but running this file
like it were a Python program itself will tell you if the syntax is correct!
'''
if __name__ == '__main__':
from pprint import pprint
pprint(BRIDGES)
print(UNIT)

0
voice_lib.py Normal file → Executable file
View File