diff --git a/bridge_gps_data.py b/bridge_gps_data.py index 1bd30aa..e248afe 100644 --- a/bridge_gps_data.py +++ b/bridge_gps_data.py @@ -160,12 +160,12 @@ def aprs_send(packet): AIS.close() logger.info('Packet sent to APRS-IS.') -def dashboard_loc_write(call, lat, lon, time): +def dashboard_loc_write(call, lat, lon, time, comment): #try: dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) # except: # dash_entries = [] - dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time}) + dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment':comment}) with open("/tmp/gps_data_user_loc.txt", 'w') as user_loc_file: user_loc_file.write(str(dash_entries[:200])) user_loc_file.close() @@ -362,7 +362,7 @@ def process_sms(_rf_src, sms): 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()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time(), comment) #logger.info('Sent manual position to APRS') except Exception as error_exception: logger.info('Exception. Not uploaded') @@ -1546,7 +1546,7 @@ class routerHBP(HBSYSTEM): float(lat_deg) < 91 float(lon_deg) < 121 aprs_send(aprs_loc_packet) - dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time(), comment) #logger.info('Sent APRS packet') except Exception as error_exception: logger.info('Error. Failed to send packet. Packet may be malformed.') @@ -1648,7 +1648,7 @@ class routerHBP(HBSYSTEM): float(loc.lat) float(loc.lon) aprs_send(aprs_loc_packet) - dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time(), comment) except Exception as error_exception: logger.info('Failed to parse packet. Packet may be deformed. Not uploaded.') logger.info(error_exception) diff --git a/gps_data.py b/gps_data.py index cdac809..165c8a2 100644 --- a/gps_data.py +++ b/gps_data.py @@ -153,12 +153,12 @@ def aprs_send(packet): AIS.close() logger.info('Packet sent to APRS-IS.') -def dashboard_loc_write(call, lat, lon, time): +def dashboard_loc_write(call, lat, lon, time, comment): #try: dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) # except: # dash_entries = [] - dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time}) + dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment': comment}) with open("/tmp/gps_data_user_loc.txt", 'w') as user_loc_file: user_loc_file.write(str(dash_entries[:200])) user_loc_file.close() @@ -357,7 +357,7 @@ def process_sms(_rf_src, sms): 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.time()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment) #logger.info('Sent manual position to APRS') except Exception as error_exception: logger.info('Exception. Not uploaded') @@ -496,7 +496,7 @@ class DATA_SYSTEM(HBSYSTEM): float(lat_deg) < 91 float(lon_deg) < 121 aprs_send(aprs_loc_packet) - dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment) #logger.info('Sent APRS packet') except Exception as error_exception: logger.info('Error. Failed to send packet. Packet may be malformed.') @@ -598,7 +598,7 @@ class DATA_SYSTEM(HBSYSTEM): float(loc.lat) float(loc.lon) aprs_send(aprs_loc_packet) - dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time.time()) + dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time.time(), comment) except Exception as error_exception: logger.info('Failed to parse packet. Packet may be deformed. Not uploaded.') logger.info(error_exception) diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index 384f654..2bdaca4 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -217,6 +217,15 @@ def view_map(): user_lat = -user_lat if 'W' in user_coord['lon']: user_lon = -user_lon + loc_comment = '' + if 'comment' in user_coord: + loc_comment = """ + + Comment: + + + """+ str(user_coord['comment']) +""" + """ if user_coord['call'] not in last_known_list and user_coord['call'] == track_call: folium_map = folium.Map(location=[user_lat, user_lon], tiles=map_theme, zoom_start=15) marker_cluster = MarkerCluster().add_to(folium_map) @@ -231,6 +240,7 @@ def view_map(): """+ loc_time +""" + """ + loc_comment + """ @@ -285,10 +295,10 @@ def view_map():

""" + map_view return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) - except: + except Exception as e: content = """

Station not found.

-

-

""" + #

+ #

""" return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) if not track_call: @@ -305,6 +315,15 @@ def view_map(): user_lat = -user_lat if 'W' in user_coord['lon']: user_lon = -user_lon + loc_comment = '' + if 'comment' in user_coord: + loc_comment = """ + + Comment: + + + """+ str(user_coord['comment']) +""" + """ if user_coord['call'] not in last_known_list: folium.Marker([user_lat, user_lon], popup=""" @@ -318,6 +337,7 @@ def view_map(): + """ + loc_comment + """
""" + loc_time + """
Track Station