Compare commits
121 Commits
voice_tele
...
master
Author | SHA1 | Date |
---|---|---|
Shane Daley | 3a97ad2d3c | |
Shane Daley | c1ebca9919 | |
Randy Hall | c05d8fed5a | |
KF7EEL | 9d49106a5f | |
Randy Hall | 539f8a7fcd | |
KF7EEL | bfff0abacd | |
Randy Hall | 04e220de86 | |
Dan Srebnick (K2IE) | 948a2a7bbc | |
Dan Srebnick (K2IE) | 951f39f3db | |
Dan Srebnick (K2IE) | 4b9864671e | |
Cort Buffington | d0d496b232 | |
n0mjs710 | 51ecece8dc | |
n0mjs710 | ce494a4a18 | |
n0mjs710 | 819c3bae30 | |
n0mjs710 | a16e426c55 | |
n0mjs710 | a12b144c7c | |
Cort Buffington | c8e1d88ecc | |
Cort Buffington | 89040e7c14 | |
Cort Buffington | d68241918b | |
Cort Buffington | ccfd862a0a | |
n0mjs710 | 24dca2e6ad | |
Cort Buffington | 8c1e9e5185 | |
Cort Buffington | a2c0bb54c6 | |
Cort Buffington | 03f9c81d3a | |
Cort Buffington | fdbfbf2362 | |
Cort Buffington | b48e522f85 | |
Cort Buffington | f00d29e8a0 | |
Cort Buffington | 08f6669bd3 | |
Cort Buffington | 8497bb1462 | |
Cort Buffington | ac87c44917 | |
Cort Buffington | 8f0a3d02a5 | |
Cort Buffington | d31c6f7fe7 | |
n0mjs710 | e1174e6aba | |
Cort Buffington | e8f838b3d6 | |
Cort Buffington | 7f7f8bdf74 | |
Cort Buffington | 21c6bf9281 | |
Cort Buffington | 4e3a13daaf | |
Cort Buffington | 9e2876dfae | |
Cort Buffington | c246f3e5db | |
Cort Buffington | 21f9c680be | |
Cort Buffington | 50387c2133 | |
n0mjs710 | 41f04dc28b | |
n0mjs710 | d44a181c06 | |
n0mjs710 | 383ba7e0ae | |
Cort Buffington | 7fc4ce0495 | |
Cort Buffington | 4aa5210f5b | |
Cort Buffington | 3d9aa41fcb | |
Cort Buffington | 2fa615dd37 | |
Cort Buffington | 35ba251e71 | |
Cort Buffington | 30ed93aa30 | |
Cort Buffington | 508b9c7197 | |
Cort Buffington | ed2a1ca549 | |
Cort Buffington | e6949e65ec | |
Cort Buffington | 9ac426aa2d | |
Cort Buffington | 94afc15d7a | |
Cort Buffington | b5e77e64b1 | |
Cort Buffington | 8c2b35ece0 | |
Cort Buffington | bb4356e027 | |
Cort Buffington | 63604a5b38 | |
Cort Buffington | 4643ea47b7 | |
Cort Buffington | 877e1c6c65 | |
n0mjs710 | 364ead81ec | |
Cort Buffington | 717e802b9b | |
n0mjs710 | 857c4d09d0 | |
n0mjs710 | 2e09350ad2 | |
Cort Buffington | 836c655739 | |
Cort Buffington | 281860db0b | |
Cort Buffington | 0f38427f2f | |
Cort Buffington | 112143ec05 | |
Cort Buffington | 887657aa16 | |
Cort Buffington | 7bf0a77e16 | |
Cort Buffington | 28f006b493 | |
Cort Buffington | 99c76b44de | |
Cort Buffington | b9dc33dae5 | |
Cort Buffington | 58c84cf43a | |
Cort Buffington | ef4514b8e0 | |
Cort Buffington | 96514de5cc | |
Cort Buffington | cdae79e0ee | |
Steve Miller | 429287452a | |
Cort Buffington | 3cb00bc5bd | |
Cort Buffington | d68d3582da | |
Cort Buffington | 3d5437e9a0 | |
Cort Buffington | e00a98f7d2 | |
Cort Buffington | 053914a68b | |
Cort Buffington | 76143f718c | |
Cort Buffington | 83d120c101 | |
Cort Buffington | 0a2edc09a5 | |
Cort Buffington | ab1a536147 | |
Cort Buffington | e6d25534b5 | |
Cort Buffington | 9219b4b2ee | |
Cort Buffington | da607cd542 | |
Cort Buffington | 83299312cc | |
Cort Buffington | 8bbd9ee850 | |
n0mjs710 | 999bbbf5f7 | |
Cort Buffington | 76bb7f1140 | |
Cort Buffington | ece48f3a50 | |
Cort Buffington | 1bc57b5ea4 | |
n0mjs710 | 9e2d2315da | |
n0mjs710 | 3893e12fca | |
Cort Buffington | 8a45e927ae | |
Cort Buffington | f98c12096c | |
Cort Buffington | e5eafeec3e | |
Cort Buffington | d8bfdc7068 | |
Cort Buffington | d689a876aa | |
Cort Buffington | 31c23ae7a0 | |
n0mjs710 | 3878c82513 | |
n0mjs710 | 96b029a927 | |
n0mjs710 | 2ef0dfcd74 | |
n0mjs710 | 1b265d8368 | |
Cort Buffington | 84800d690a | |
Millaguie | 9ba975bfff | |
Cort Buffington | e570adbef0 | |
Cort Buffington | 99d0b49559 | |
Cort Buffington | d3a5ee2221 | |
n0mjs710 | 557b21c022 | |
n0mjs710 | 553bcba3a2 | |
n0mjs710 | 101a6e4a11 | |
n0mjs710 | 55a546a239 | |
n0mjs710 | 64a685cd80 | |
n0mjs710 | aefedca6ee | |
n0mjs710 | be13083729 |
32
Dockerfile
32
Dockerfile
|
@ -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" ]
|
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -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 |
12
README.md
12
README.md
|
@ -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.
|
||||
|
||||
|
|
150
app_template.py
150
app_template.py
|
@ -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()
|
|
@ -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()
|
|
@ -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'),
|
||||
|
|
1
const.py
1
const.py
|
@ -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'
|
||||
|
|
10
entrypoint
10
entrypoint
|
@ -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
|
|
@ -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
|
||||
|
|
98
hblink.py
98
hblink.py
|
@ -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
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Install the required support programs
|
||||
apt-get install python3 python3-pip -y
|
||||
pip3 install -r requirements.txt
|
||||
|
|
@ -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()
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue