diff --git a/app.py b/app.py index fd1f373..7a54506 100644 --- a/app.py +++ b/app.py @@ -22,53 +22,63 @@ global_dataframe = pd.DataFrame(columns=['Device Name', 'Frequency', 'Signal Str frequency = lambda port: {'port1': 433, 'port2': 868,'port3': 915}.get(port, None) surveydata = {} - 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: + 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 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 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..c099d5b 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -69,11 +69,11 @@
- - + + + -
-
+