diff --git a/app.py b/app.py index 3788b30..fd1f373 100644 --- a/app.py +++ b/app.py @@ -6,6 +6,7 @@ import threading import time from collections import deque import pandas as pd +import re app = Flask(__name__) socketio = SocketIO(app) @@ -19,25 +20,44 @@ global ser2 global ser3 global_dataframe = pd.DataFrame(columns=['Device Name', 'Frequency', 'Signal Strength', 'Plaintext']) frequency = lambda port: {'port1': 433, 'port2': 868,'port3': 915}.get(port, None) +surveydata = {} def read_serial_data(port, ser, buffer): - global global_dataframe + global surveydata + rssi_pattern = r"RSSI: (-?\d+)" + rssi = '' + 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,''] + buffer.append(data) - socketio.emit(f'serial_data_{port}', {'data': data}) - - - if (global_dataframe['Device Name'] == 'Unknown Raw LoRa Devices').any(): - pass - else: - pandasdata = {'Device Name': 'Unknown Raw LoRa Devices', 'Frequency': frequency(port)} - global_dataframe = global_dataframe.append(pandasdata, ignore_index=True) - '''print(global_dataframe.head())''' - + 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] + + 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): @@ -47,7 +67,7 @@ def read_serial_data(port, ser, buffer): time.sleep(0.1) except: pass - + def connect_serial(port,frequency): global ser1 @@ -114,7 +134,7 @@ def analysis(): @app.route('/survey') def survey(): - return render_template('survey.html', initial_data={port: list(buffer) for port, buffer in serial_buffers.items()}) + return render_template('survey.html', data=global_dataframe) @app.route('/tracking') def tracking(): @@ -221,8 +241,12 @@ def checkSer(): except: pass return jsonify(result="False") - - + +@app.route('/get_table_data') +def get_table_data(): + global surveydata + print(surveydata) + return jsonify(surveydata) if __name__ == '__main__': socketio.run(app, debug=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..04a159c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +Flask==2.3.2 +Flask_SocketIO==5.3.6 +MarkupSafe==2.1.3 +pandas==2.0.3 +pyserial==3.5 diff --git a/static/css/styles.css b/static/css/styles.css index 8a0e4c2..41da4c6 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -11062,4 +11062,38 @@ section.resume-section .resume-section-content { .red { background-color: red; +} + +/* Styling for the table */ +.scrollable-table { + max-height: 300px; + overflow-y: auto; + display: block; +} +table { + width: 100%; + border-collapse: collapse; +} +th, td { + border: 1px solid black; + padding: 8px; + text-align: left; +} +th { + background-color: #f2f2f2; +} + +.selected-row { + background-color: #FFFF99; /* Highlight color */ + font-weight: bold; /* Enlarge the font */ +} + +.hidden-row { + display: none; /* Hide the non-selected rows */ +} + +.center-button { + display: block; + margin: 0 auto; + text-align: center; } \ No newline at end of file diff --git a/templates/analysis.html b/templates/analysis.html index 9a2a041..dff10fd 100644 --- a/templates/analysis.html +++ b/templates/analysis.html @@ -52,25 +52,18 @@

Analyze LoRa traffic received at 433, 868, or 915 MHz. Click the desired frequency below to get started. Once you are on the appropriate page, click the 'Connect Serial Port' button to connect to a serial port on your computer. Once connected to your LoRa receiver, traffic will automatically be streamed to the web page for analysis. To disconnect a receiver, click the 'Disconnect Serial Port' button.

-

- 433 MHz -
- 868 MHz -
- 915 MHz -

- - -
+
+

-
-

433 MHz

+ +
-

LoRa Transceiver


+

433 MHz LoRa Transceiver


+
@@ -235,18 +228,20 @@ }); } - - - -
-
- -
+ + + + + + +

-

868 MHz

+
-

LoRa Transceiver


+

868 MHz LoRa Transceiver


@@ -296,22 +291,17 @@ -
-
- -
+ + + + + +

+
-

915 MHz


+
-

LoRa Transceiver


+

915 MHZ LoRa Transceiver


@@ -606,8 +601,17 @@ }); } - +
+
+ + +
+
+ + diff --git a/templates/index.html b/templates/index.html index 0473d80..a75498f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -36,7 +36,7 @@ - + diff --git a/templates/survey.html b/templates/survey.html index 0ef37a5..9fdf426 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -20,7 +20,7 @@ - + @@ -45,52 +45,55 @@
-

+

Survey Mode

-

Skinny Research and Development

-
- - - - DataFrame Table - - - - - - - - - - - - {% for index, row in data.iterrows() %} - - - - - - - {% endfor %} - -
Device NameFrequencySignal StrengthPlaintext
{{ row['Device Name'] }}{{ row['Frequency'] }}{{ row['Signal Strength'] }}{{ row['Plaintext'] }}
- - +
+
+ + + + + + + + + + + + +
Device NameFrequencySignal StrengthRecovered Plaintext
+
+ + +

diff --git a/templates/tracking.html b/templates/tracking.html index 2b8001a..98df0d2 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -20,8 +20,7 @@ - - + @@ -45,11 +44,141 @@
-

+

Tracking Mode

-

Skinny Research and Development

-
+
+

Select A Device You Would Like To Track

+
+
+ + + + + + + + + + + +
Device NameFrequencySignal Strength
+
+ +
+ + + + + + + + + +
+