From f4593c5fdd8e347f1e372905987c1b76a93261ca Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Tue, 9 Jan 2024 16:03:05 -0700 Subject: [PATCH 1/3] Feat: Storing decoded values --- app.py | 68 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/app.py b/app.py index fd1f373..0bbd8e1 100644 --- a/app.py +++ b/app.py @@ -23,52 +23,60 @@ frequency = lambda port: {'port1': 433, 'port2': 868,'port3': 915}.get(port, Non surveydata = {} +import re +import time + +import re +import time + def read_serial_data(port, ser, buffer): global surveydata rssi_pattern = r"RSSI: (-?\d+)" - rssi = '' - + decoded_value_pattern = r"Decoded Value: (.+)" + rssi = None + decoded_value = None + while True: try: if ser.in_waiting > 0: data = ser.readline().decode('utf-8').strip() - match = re.search(rssi_pattern, data) - # Check if a RSSI was found - if match: - if port =='port1': - rssi = int(match.group(1)) - surveydata['Raw LoRa Device 443 MHz'] = [433,rssi,''] - elif port =='port2': - rssi = int(match.group(1)) - surveydata['Raw LoRa Device 868 MHz'] = [868,rssi,''] - elif port =='port3': - rssi = int(match.group(1)) - surveydata['Raw LoRa Device 915 MHz'] = [915,rssi,''] + # Match RSSI + rssi_match = re.search(rssi_pattern, data) + if rssi_match: + rssi = int(rssi_match.group(1)) + + # Match Decoded Value + decoded_match = re.search(decoded_value_pattern, data) + if decoded_match: + decoded_value = decoded_match.group(1) + + # Update dictionary only if both RSSI and Decoded Value are found + if rssi is not None and decoded_value is not None: + key = f'Raw LoRa Device {frequency(port)} MHz' + surveydata[key] = [frequency(port), rssi, decoded_value] + # Reset rssi and decoded_value for next packet + rssi = None + decoded_value = None buffer.append(data) - socketio.emit(f'serial_data_{port}', {'data': data}) - if frequency(port) == 433 and surveydata.get('Raw LoRa Device 443 MHz') is None: - surveydata['Raw LoRa Device 443 MHz'] = [433,0,rssi] + socketio.emit(f'serial_data_{port}', {'data': data}) - elif frequency(port) == 868 and surveydata.get('Raw LoRa Device 868 MHz') is None: - surveydata['Raw LoRa Device 868 MHz'] = [868,0,rssi] - - elif frequency(port) == 915 and surveydata.get('Raw LoRa Device 915 MHz') is None: - surveydata['Raw LoRa Device 915 MHz'] = [915,0,rssi] - - - if (port == 'port1' and port1_status == False): - return - if (port == 'port2' and port2_status == False): - return - if (port == 'port3' and port3_status == False): + # Check port status + if (port == 'port1' and not port1_status) or \ + (port == 'port2' and not port2_status) or \ + (port == 'port3' and not port3_status): return + time.sleep(0.1) - except: + + except Exception as e: + print(f"Error: {e}") pass + + def connect_serial(port,frequency): global ser1 global ser2 From f370754d178f99c85975615a09eaaaa7a3b48a60 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Tue, 9 Jan 2024 18:04:36 -0700 Subject: [PATCH 2/3] Feat: Parsing decoded values for survey mode --- app.py | 20 +++++----- static/css/styles.css | 21 +++++++++-- templates/survey.html | 73 ++++++++++++++++++++++++++++-------- templates/tracking.html | 83 ++++++++++++++++++++--------------------- 4 files changed, 126 insertions(+), 71 deletions(-) diff --git a/app.py b/app.py index 0bbd8e1..7a54506 100644 --- a/app.py +++ b/app.py @@ -22,13 +22,6 @@ global_dataframe = pd.DataFrame(columns=['Device Name', 'Frequency', 'Signal Str frequency = lambda port: {'port1': 433, 'port2': 868,'port3': 915}.get(port, None) surveydata = {} - -import re -import time - -import re -import time - def read_serial_data(port, ser, buffer): global surveydata rssi_pattern = r"RSSI: (-?\d+)" @@ -53,8 +46,16 @@ def read_serial_data(port, ser, buffer): # Update dictionary only if both RSSI and Decoded Value are found if rssi is not None and decoded_value is not None: - key = f'Raw LoRa Device {frequency(port)} MHz' - surveydata[key] = [frequency(port), rssi, decoded_value] + freq = frequency(port) + key = f'Raw LoRa Device {freq} MHz' + + # Initialize the list for the frequency if not already done + if key not in surveydata: + surveydata[key] = [] + + # Append the new values to the list for this frequency + surveydata[key].append([freq, rssi, decoded_value]) + # Reset rssi and decoded_value for next packet rssi = None decoded_value = None @@ -77,6 +78,7 @@ def read_serial_data(port, ser, buffer): + def connect_serial(port,frequency): global ser1 global ser2 diff --git a/static/css/styles.css b/static/css/styles.css index 41da4c6..d01bdbc 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -11066,10 +11066,25 @@ section.resume-section .resume-section-content { /* Styling for the table */ .scrollable-table { - max-height: 300px; - overflow-y: auto; - display: block; + width: 100%; + overflow-y: auto; /* Enable vertical scrolling */ + max-height: 500px; /* Adjust the height as needed */ } +#data-table { + width: 100%; + font-size: 1.1em; + border-collapse: collapse; /* Optional: for border styling */ +} +#data-table thead th { + position: sticky; + top: 0; + background-color: #fff; /* Or any other background color */ +} +#data-table th, #data-table td { + padding: 10px; + border: 1px solid #ddd; /* Optional: for border styling */ +} + table { width: 100%; border-collapse: collapse; diff --git a/templates/survey.html b/templates/survey.html index 9fdf426..84ddffb 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -56,16 +56,17 @@ Device Name Frequency Signal Strength - Recovered Plaintext + Decoded Values - + diff --git a/templates/tracking.html b/templates/tracking.html index ecf0e5c..ed48ffe 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -71,9 +71,7 @@
- -
-
+
From d08da7f5870129cab2a0f8a63a4633f61cc23a9d Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Tue, 9 Jan 2024 18:25:02 -0700 Subject: [PATCH 3/3] Chore: Updating the syle of the clear filter button --- templates/tracking.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/tracking.html b/templates/tracking.html index ed48ffe..c099d5b 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -69,8 +69,10 @@
- - + + + +