mirror of https://github.com/kf7eel/hbnet
fix data mirroring
This commit is contained in:
parent
42f27eeac0
commit
665ee6f1a7
|
|
@ -445,9 +445,7 @@ def mirror_traffic(_data):
|
||||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||||
print(CONFIG['SYSTEMS'][system]['OTHER_OPTIONS'])
|
print(CONFIG['SYSTEMS'][system]['OTHER_OPTIONS'])
|
||||||
if 'MIRROR_ALL_TRAFFIC' in CONFIG['SYSTEMS'][system]['OTHER_OPTIONS']:
|
if 'MIRROR_ALL_TRAFFIC' in CONFIG['SYSTEMS'][system]['OTHER_OPTIONS']:
|
||||||
print('mirrored to ' + system)
|
systems[system].send_system(SVRD + b'MDAT' + _data)
|
||||||
print(_data)
|
|
||||||
systems[system].send_system(SVRD + b'DATA' + _data)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1344,12 +1344,14 @@ def aprs_beacon_send():
|
||||||
logger.info(beacon_packet)
|
logger.info(beacon_packet)
|
||||||
|
|
||||||
##### DMR data function ####
|
##### DMR data function ####
|
||||||
def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, mirror = False):
|
||||||
# Capture data headers
|
# Capture data headers
|
||||||
global n_packet_assembly, hdr_type
|
global n_packet_assembly, hdr_type
|
||||||
#logger.info(_dtype_vseq)
|
#logger.info(_dtype_vseq)
|
||||||
#logger.info(_call_type)
|
#logger.info(_call_type)
|
||||||
#logger.info(_frame_type)
|
#logger.info(_frame_type)
|
||||||
|
print(int_id(_stream_id))
|
||||||
|
print((_seq))
|
||||||
logger.info(strftime('%H:%M:%S - %m/%d/%y'))
|
logger.info(strftime('%H:%M:%S - %m/%d/%y'))
|
||||||
#logger.info('Special debug for developement:')
|
#logger.info('Special debug for developement:')
|
||||||
logger.info(ahex(bptc_decode(_data)))
|
logger.info(ahex(bptc_decode(_data)))
|
||||||
|
|
@ -1402,6 +1404,7 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||||
# Form APRS packet
|
# Form APRS packet
|
||||||
#logger.info(aprs_loc_packet)
|
#logger.info(aprs_loc_packet)
|
||||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||||
|
if mirror == False:
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
if int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
|
|
@ -1434,7 +1437,7 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||||
aprslib.parse(aprs_loc_packet)
|
aprslib.parse(aprs_loc_packet)
|
||||||
float(lat_deg) < 91
|
float(lat_deg) < 91
|
||||||
float(lon_deg) < 121
|
float(lon_deg) < 121
|
||||||
## if int_id(_dst_id) == data_id:
|
## if int_id(_dst_id) == data_id:
|
||||||
if int_id(_dst_id) in data_id:
|
if int_id(_dst_id) in data_id:
|
||||||
aprs_send(aprs_loc_packet)
|
aprs_send(aprs_loc_packet)
|
||||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time(), comment, int_id(_rf_src))
|
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time(), comment, int_id(_rf_src))
|
||||||
|
|
@ -1498,6 +1501,7 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||||
nmea_parse = re.sub('.*\$|\n.*|V\*.*', '', final_packet)
|
nmea_parse = re.sub('.*\$|\n.*|V\*.*', '', final_packet)
|
||||||
loc = pynmea2.parse(nmea_parse, check=False)
|
loc = pynmea2.parse(nmea_parse, check=False)
|
||||||
logger.info('Latitude: ' + str(loc.lat) + str(loc.lat_dir) + ' Longitude: ' + str(loc.lon) + str(loc.lon_dir) + ' Direction: ' + str(loc.true_course) + ' Speed: ' + str(loc.spd_over_grnd) + '\n')
|
logger.info('Latitude: ' + str(loc.lat) + str(loc.lat_dir) + ' Longitude: ' + str(loc.lon) + str(loc.lon_dir) + ' Direction: ' + str(loc.true_course) + ' Speed: ' + str(loc.spd_over_grnd) + '\n')
|
||||||
|
if mirror == False:
|
||||||
try:
|
try:
|
||||||
# Begin APRS format and upload
|
# Begin APRS format and upload
|
||||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||||
|
|
@ -1540,7 +1544,7 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||||
# Float values of lat and lon. Anything that is not a number will cause it to fail.
|
# Float values of lat and lon. Anything that is not a number will cause it to fail.
|
||||||
float(loc.lat)
|
float(loc.lat)
|
||||||
float(loc.lon)
|
float(loc.lon)
|
||||||
## if int_id(_dst_id) == data_id:
|
## if int_id(_dst_id) == data_id:
|
||||||
if int_id(_dst_id) in data_id:
|
if int_id(_dst_id) in data_id:
|
||||||
|
|
||||||
aprs_send(aprs_loc_packet)
|
aprs_send(aprs_loc_packet)
|
||||||
|
|
@ -1672,17 +1676,18 @@ class OBP(OPENBRIDGE):
|
||||||
|
|
||||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||||
print(_frame_type)
|
print(_frame_type)
|
||||||
UNIT_MAP[_rf_src] = (self._system, time())
|
## UNIT_MAP[_rf_src] = (self._system, time())
|
||||||
|
UNIT_MAP[_rf_src] = (_seq, time())
|
||||||
if _rf_src not in PACKET_MATCH:
|
if _rf_src not in PACKET_MATCH:
|
||||||
PACKET_MATCH[_rf_src] = [_data, time()]
|
PACKET_MATCH[_rf_src] = [_seq, time()]
|
||||||
|
|
||||||
# Check to see if we have already received this packet
|
# Check to see if we have already received this packet
|
||||||
elif _data == PACKET_MATCH[_rf_src][0] and time() - 1 < PACKET_MATCH[_rf_src][1]:
|
elif _seq == PACKET_MATCH[_rf_src][0] and time() - 1 < PACKET_MATCH[_rf_src][1]:
|
||||||
print('matched, dropping')
|
print('matched, dropping')
|
||||||
pass
|
pass
|
||||||
print(PACKET_MATCH)
|
print(PACKET_MATCH)
|
||||||
else:
|
else:
|
||||||
PACKET_MATCH[_rf_src] = [_data, time()]
|
PACKET_MATCH[_rf_src] = [_seq, time()]
|
||||||
print('OBP RCVD')
|
print('OBP RCVD')
|
||||||
if _dtype_vseq in [3,6,7] and _call_type == 'unit' or _call_type == 'group' and _dtype_vseq == 6 or _call_type == 'vcsbk':
|
if _dtype_vseq in [3,6,7] and _call_type == 'unit' or _call_type == 'group' and _dtype_vseq == 6 or _call_type == 'vcsbk':
|
||||||
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||||
|
|
@ -1697,7 +1702,6 @@ class OBP(OPENBRIDGE):
|
||||||
if _mode == b'DATA' or _mode == b'MDAT':
|
if _mode == b'DATA' or _mode == b'MDAT':
|
||||||
## print(ahex(_data))
|
## print(ahex(_data))
|
||||||
# DMR Data packet, sent via SVRD
|
# DMR Data packet, sent via SVRD
|
||||||
|
|
||||||
_peer_id = _data[11:15]
|
_peer_id = _data[11:15]
|
||||||
_seq = _data[4]
|
_seq = _data[4]
|
||||||
_rf_src = _data[5:8]
|
_rf_src = _data[5:8]
|
||||||
|
|
@ -1721,13 +1725,19 @@ class OBP(OPENBRIDGE):
|
||||||
print((_dtype_vseq))
|
print((_dtype_vseq))
|
||||||
print(ahex(bptc_decode(_data)))
|
print(ahex(bptc_decode(_data)))
|
||||||
|
|
||||||
|
if _mode == b'MDAT' or _mode == b'DATA':
|
||||||
|
print('MDAT')
|
||||||
|
## self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||||
|
if _seq == PACKET_MATCH[_rf_src][0] and time() - 1 < PACKET_MATCH[_rf_src][1]:
|
||||||
|
print('matched, dropping')
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
## # Record last packet to prevent duplicates, think finger printing.
|
print('no match')
|
||||||
## PACKET_MATCH[_rf_src] = [_data, time()]
|
if _mode == b'MDAT':
|
||||||
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, True)
|
||||||
|
if _mode == b'DATA':
|
||||||
self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1824,8 +1834,8 @@ if __name__ == '__main__':
|
||||||
#### use_api = CONFIG['DATA_CONFIG']['USE_API']
|
#### use_api = CONFIG['DATA_CONFIG']['USE_API']
|
||||||
|
|
||||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||||
|
#### if 'DUAL_DASH' in CONFIG['WEB_SERVICE']['']
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
||||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||||
if Path(user_settings_file).is_file():
|
if Path(user_settings_file).is_file():
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
<i class="bi bi-hash"></i> Data
|
<i class="bi bi-window"></i> Data
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" aria-labelledby="aprs_menu">
|
<ul class="dropdown-menu" aria-labelledby="aprs_menu">
|
||||||
<li><a class="dropdown-item" href="{{url}}/aprs"><i class="bi bi-geo"></i> APRS Dashboard </a></li>
|
<li><a class="dropdown-item" href="{{url}}/aprs"><i class="bi bi-geo"></i> APRS Dashboard </a></li>
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
<li><a class="dropdown-item" href="{{url}}/bb"><i class="bi bi-clipboard"></i> Bulletin Board </a></li>
|
<li><a class="dropdown-item" href="{{url}}/bb"><i class="bi bi-clipboard"></i> Bulletin Board </a></li>
|
||||||
<li><a class="dropdown-item" href="{{url}}/ss"><i class="bi bi-people"></i> Social Status </a></li>
|
<li><a class="dropdown-item" href="{{url}}/ss"><i class="bi bi-people"></i> Social Status </a></li>
|
||||||
<li><a class="dropdown-item" href="{{url}}/tp"><i class="bi bi-file-earmark-break"></i> Tiny Pages </a></li>
|
<li><a class="dropdown-item" href="{{url}}/tp"><i class="bi bi-file-earmark-break"></i> Tiny Pages </a></li>
|
||||||
|
<li><a class="dropdown-item" href="{{url}}/tags"><i class="bi bi-hash"></i> Tags </a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
@ -190,7 +191,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
<hr class="no-margins"/>
|
<hr class="no-margins"/>
|
||||||
<div id="footer-div" class="clearfix with-margins">
|
<div id="footer-div" class="clearfix with-margins">
|
||||||
<p style="text-align: center;"><strong>{{ user_manager.USER_APP_NAME }}<br /></strong><a href="https://hbnet.xyz">HBNet Project</a><br />V. <strong>Dev</strong> </p>
|
<p style="text-align: center;"><strong>{{ user_manager.USER_APP_NAME }}<br /></strong><a href="https://hbnet.xyz">HBNet Project</a><br />V. <strong>0.0.1-alpha</strong> </p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue