mirror of https://github.com/kf7eel/hbnet.git
fix PEER folder creation, adjust CSBK to 1 block, add error for *MH
This commit is contained in:
parent
1c60c525fe
commit
0872ca716e
|
|
@ -172,7 +172,7 @@ def sms_format_retrieve(sub):
|
||||||
def mqtt_main(mqtt_user, mqtt_pass, mqtt_user2, mqtt_pass2, broker_url = 'localhost', broker_port = 1883, broker_url2 = 'localhost', broker_port2 = 1883):
|
def mqtt_main(mqtt_user, mqtt_pass, mqtt_user2, mqtt_pass2, broker_url = 'localhost', broker_port = 1883, broker_url2 = 'localhost', broker_port2 = 1883):
|
||||||
global mqtt_client, mqtt_client2
|
global mqtt_client, mqtt_client2
|
||||||
if broker_url2 != '':
|
if broker_url2 != '':
|
||||||
logger.info('Enabling MQTT Server 22')
|
logger.info('Enabling MQTT Server 2')
|
||||||
mqtt_client2 = mqtt.Client(client_id = mqtt_shortcut_gen + '-' + str(random.randint(1,99)))
|
mqtt_client2 = mqtt.Client(client_id = mqtt_shortcut_gen + '-' + str(random.randint(1,99)))
|
||||||
elif broker_url2 == '':
|
elif broker_url2 == '':
|
||||||
mqtt_client2 = ''
|
mqtt_client2 = ''
|
||||||
|
|
@ -913,8 +913,8 @@ def process_sms(_rf_src, sms, call_type, system_name):
|
||||||
elif '*MH' in parse_sms[0]:
|
elif '*MH' in parse_sms[0]:
|
||||||
grid_square = parse_sms[1]
|
grid_square = parse_sms[1]
|
||||||
if len(grid_square) < 6:
|
if len(grid_square) < 6:
|
||||||
pass
|
send_sms(False, int_id(_rf_src), data_id[0], data_id[0], 'unit', 'Grid square needs to be 6 characters.')
|
||||||
else:
|
elif len(grid_square) > 5:
|
||||||
lat = decdeg2dms(mh.to_location(grid_square)[0])
|
lat = decdeg2dms(mh.to_location(grid_square)[0])
|
||||||
lon = decdeg2dms(mh.to_location(grid_square)[1])
|
lon = decdeg2dms(mh.to_location(grid_square)[1])
|
||||||
|
|
||||||
|
|
@ -930,44 +930,44 @@ def process_sms(_rf_src, sms, call_type, system_name):
|
||||||
#logger.info(lat_dir)
|
#logger.info(lat_dir)
|
||||||
aprs_lat = str(str(re.sub('\..*|-', '', str(lat[0]))).zfill(2) + str(re.sub('\..*', '', str(lat[1])).zfill(2) + '.')) + ' ' + lat_dir
|
aprs_lat = str(str(re.sub('\..*|-', '', str(lat[0]))).zfill(2) + str(re.sub('\..*', '', str(lat[1])).zfill(2) + '.')) + ' ' + lat_dir
|
||||||
aprs_lon = str(str(re.sub('\..*|-', '', str(lon[0]))).zfill(3) + str(re.sub('\..*', '', str(lon[1])).zfill(2) + '.')) + ' ' + lon_dir
|
aprs_lon = str(str(re.sub('\..*|-', '', str(lon[0]))).zfill(3) + str(re.sub('\..*', '', str(lon[1])).zfill(2) + '.')) + ' ' + lon_dir
|
||||||
logger.debug('Latitude: ' + str(aprs_lat))
|
logger.debug('Latitude: ' + str(aprs_lat))
|
||||||
logger.debug('Longitude: ' + str(aprs_lon))
|
logger.debug('Longitude: ' + str(aprs_lon))
|
||||||
# 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:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
|
||||||
icon_icon = '['
|
|
||||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
|
||||||
else:
|
|
||||||
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
|
|
||||||
ssid = user_ssid
|
|
||||||
if user_settings[int_id(_rf_src)][3]['comment'] == '':
|
|
||||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
|
||||||
if user_settings[int_id(_rf_src)][2]['icon'] == '':
|
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
icon_icon = '['
|
icon_icon = '['
|
||||||
if user_settings[int_id(_rf_src)][2]['icon'] != '':
|
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||||
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
|
else:
|
||||||
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
|
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
|
||||||
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
ssid = user_ssid
|
||||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
if user_settings[int_id(_rf_src)][3]['comment'] == '':
|
||||||
if user_settings[int_id(_rf_src)][3]['comment'] != '':
|
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||||
comment = user_settings[int_id(_rf_src)][3]['comment']
|
if user_settings[int_id(_rf_src)][2]['icon'] == '':
|
||||||
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
|
icon_table = '/'
|
||||||
logger.info(aprs_loc_packet)
|
icon_icon = '['
|
||||||
logger.debug('User comment: ' + comment)
|
if user_settings[int_id(_rf_src)][2]['icon'] != '':
|
||||||
logger.debug('User SSID: ' + ssid)
|
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
|
||||||
logger.debug('User icon: ' + icon_table + icon_icon)
|
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
|
||||||
try:
|
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||||
aprslib.parse(aprs_loc_packet)
|
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||||
aprs_send(aprs_loc_packet)
|
if user_settings[int_id(_rf_src)][3]['comment'] != '':
|
||||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time(), comment, int_id(_rf_src))
|
comment = user_settings[int_id(_rf_src)][3]['comment']
|
||||||
logger.info('Sent maidenhed position to APRS')
|
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
|
||||||
except Exception as error_exception:
|
logger.info(aprs_loc_packet)
|
||||||
logger.error('Exception. Not uploaded')
|
logger.debug('User comment: ' + comment)
|
||||||
logger.error(error_exception)
|
logger.debug('User SSID: ' + ssid)
|
||||||
logger.error(str(traceback.extract_tb(error_exception.__traceback__)))
|
logger.debug('User icon: ' + icon_table + icon_icon)
|
||||||
|
try:
|
||||||
|
aprslib.parse(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))
|
||||||
|
logger.info('Sent maidenhed position to APRS')
|
||||||
|
except Exception as error_exception:
|
||||||
|
logger.error('Exception. Not uploaded')
|
||||||
|
logger.error(error_exception)
|
||||||
|
logger.error(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||||
## packet_assembly = ''
|
## packet_assembly = ''
|
||||||
|
|
||||||
elif '.' == parse_sms[0][0:1]:
|
elif '.' == parse_sms[0][0:1]:
|
||||||
|
|
@ -1134,7 +1134,7 @@ def csbk_gen2(to_id, from_id, tot_block):
|
||||||
csbk_lst = []
|
csbk_lst = []
|
||||||
csbk_pk = 'BD0080'
|
csbk_pk = 'BD0080'
|
||||||
csbk_n = 0
|
csbk_n = 0
|
||||||
csbk_tot = 2
|
csbk_tot = 1
|
||||||
while csbk_n < csbk_tot:
|
while csbk_n < csbk_tot:
|
||||||
csbk_lst.append(csbk_pk)
|
csbk_lst.append(csbk_pk)
|
||||||
csbk_n = csbk_n + 1
|
csbk_n = csbk_n + 1
|
||||||
|
|
@ -2258,6 +2258,11 @@ if __name__ == '__main__':
|
||||||
aprs_thread = threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,))
|
aprs_thread = threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,))
|
||||||
aprs_thread.daemon = True
|
aprs_thread.daemon = True
|
||||||
aprs_thread.start()
|
aprs_thread.start()
|
||||||
|
# Create folder so hbnet.py can access list PEER connections
|
||||||
|
if Path('/tmp/' + (CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/')).exists():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
Path('/tmp/' + (CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/')).mkdir()
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
# John 3:16 - For God so loved the world, that he gave his only Son,
|
# John 3:16 - For God so loved the world, that he gave his only Son,
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,12 @@ def decrypt_packet(key, message):
|
||||||
|
|
||||||
def write_peer_file(master, peer_dict, CONFIG):
|
def write_peer_file(master, peer_dict, CONFIG):
|
||||||
# Pull stuff for aprs out
|
# Pull stuff for aprs out
|
||||||
print(peer_dict)
|
if Path('/tmp/' + CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/' + master).is_file():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
Path('/tmp/' + CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/' + master).touch()
|
||||||
new_peers = {}
|
new_peers = {}
|
||||||
for d in peer_dict.items():
|
for d in peer_dict.items():
|
||||||
print(d[1])
|
|
||||||
new_peers[int_id(d[0])] = {'call': str(d[1]['CALLSIGN'].decode('utf-8')).strip(' '), 'lat':str(d[1]['LATITUDE'].decode('utf-8')), 'lon':str(d[1]['LONGITUDE'].decode('utf-8')), 'description':str(d[1]['DESCRIPTION'].decode('utf-8'))}
|
new_peers[int_id(d[0])] = {'call': str(d[1]['CALLSIGN'].decode('utf-8')).strip(' '), 'lat':str(d[1]['LATITUDE'].decode('utf-8')), 'lon':str(d[1]['LONGITUDE'].decode('utf-8')), 'description':str(d[1]['DESCRIPTION'].decode('utf-8'))}
|
||||||
with open('/tmp/' + CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/' + master, 'w') as peer_file:
|
with open('/tmp/' + CONFIG['LOGGER']['LOG_NAME'] + '_PEERS/' + master, 'w') as peer_file:
|
||||||
peer_file.write(str(new_peers))
|
peer_file.write(str(new_peers))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue