From 2adea59472abb2e93fe51a7571746ee078994403 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Wed, 13 Dec 2023 15:47:55 -0700 Subject: [PATCH 1/6] Adding a table for survey mode --- app.py | 36 +++++++++++-------- static/css/styles.css | 19 ++++++++++ templates/survey.html | 84 ++++++++++++++++++++----------------------- 3 files changed, 79 insertions(+), 60 deletions(-) diff --git a/app.py b/app.py index 3788b30..bee1766 100644 --- a/app.py +++ b/app.py @@ -19,25 +19,27 @@ 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 = {'Test Device': [915, -20, 'Some Plaintext information'],} def read_serial_data(port, ser, buffer): - global global_dataframe + global surveydata while True: try: if ser.in_waiting > 0: data = ser.readline().decode('utf-8').strip() buffer.append(data) - socketio.emit(f'serial_data_{port}', {'data': 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())''' - + if frequency(port) == 433 and surveydata.get('Raw LoRa Device 443 MHz') is None: + surveydata['Raw LoRa Device 443 MHz'] = [433,0,''] + + elif frequency(port) == 868 and surveydata.get('Raw LoRa Device 868 MHz') is None: + surveydata['Raw LoRa Device 868 MHz'] = [868,0,''] + + elif frequency(port) == 915 and surveydata.get('Raw LoRa Device 915 MHz') is None: + surveydata['Raw LoRa Device 915 MHz'] = [915,0,''] + + if (port == 'port1' and port1_status == False): return if (port == 'port2' and port2_status == False): @@ -47,7 +49,7 @@ def read_serial_data(port, ser, buffer): time.sleep(0.1) except: pass - + def connect_serial(port,frequency): global ser1 @@ -114,7 +116,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 +223,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/static/css/styles.css b/static/css/styles.css index 8a0e4c2..0076e38 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -11062,4 +11062,23 @@ 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; } \ No newline at end of file diff --git a/templates/survey.html b/templates/survey.html index 0ef37a5..4ff4db2 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -20,7 +20,7 @@ - + @@ -45,52 +45,46 @@
-

+

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
+
+ +

From 9526cbefa016dc275c94a7d8fc6d9e25be8cc340 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Mon, 8 Jan 2024 14:55:13 -0700 Subject: [PATCH 2/6] Feat: Making analysis sections collapsable --- templates/analysis.html | 88 +++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 42 deletions(-) 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 @@ }); } - +
+
+ + +
+
+ + From 3ca487dc5ec83849db4d7e6947e078a4e0d37c50 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Mon, 8 Jan 2024 14:57:56 -0700 Subject: [PATCH 3/6] Chore: Adding requirements.txt --- requirements.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 requirements.txt 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 From e713b628046fbe28f5a1de4ee48cbf3986890334 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Mon, 8 Jan 2024 15:35:16 -0700 Subject: [PATCH 4/6] Feat: Adding the most recent RSSI to survey mode data --- app.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index bee1766..091078b 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) @@ -21,23 +22,40 @@ global_dataframe = pd.DataFrame(columns=['Device Name', 'Frequency', 'Signal Str frequency = lambda port: {'port1': 433, 'port2': 868,'port3': 915}.get(port, None) surveydata = {'Test Device': [915, -20, 'Some Plaintext information'],} + def read_serial_data(port, ser, buffer): 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 frequency(port) == 433 and surveydata.get('Raw LoRa Device 443 MHz') is None: - surveydata['Raw LoRa Device 443 MHz'] = [433,0,''] + 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,''] + 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,''] + surveydata['Raw LoRa Device 915 MHz'] = [915,0,rssi] if (port == 'port1' and port1_status == False): From 862ee809a7e73ce90e8623b8b8e01c68e964d95b Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Mon, 8 Jan 2024 17:40:26 -0700 Subject: [PATCH 5/6] Feat: Adding RSSI to tracking functionality --- templates/survey.html | 45 ++++++++++++++++++++-------------- templates/tracking.html | 53 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 74 insertions(+), 24 deletions(-) diff --git a/templates/survey.html b/templates/survey.html index 4ff4db2..9fdf426 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -66,25 +66,34 @@ +
diff --git a/templates/tracking.html b/templates/tracking.html index 2b8001a..c5295c0 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -20,7 +20,7 @@ - + @@ -35,8 +35,8 @@ @@ -45,11 +45,52 @@
-

+

Tracking Mode

-

Skinny Research and Development

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

From 107be33687526c70e4e398f9bd49e645ad0b8437 Mon Sep 17 00:00:00 2001 From: Halcy0nic Date: Mon, 8 Jan 2024 18:28:00 -0700 Subject: [PATCH 6/6] Feat: Adding a filter button to tracking mode --- app.py | 2 +- static/css/styles.css | 15 +++++++ templates/index.html | 2 +- templates/tracking.html | 96 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 109 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 091078b..fd1f373 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,7 @@ 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 = {'Test Device': [915, -20, 'Some Plaintext information'],} +surveydata = {} def read_serial_data(port, ser, buffer): diff --git a/static/css/styles.css b/static/css/styles.css index 0076e38..41da4c6 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -11081,4 +11081,19 @@ th, td { } 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/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/tracking.html b/templates/tracking.html index c5295c0..98df0d2 100644 --- a/templates/tracking.html +++ b/templates/tracking.html @@ -21,7 +21,6 @@ - @@ -35,8 +34,8 @@ @@ -49,6 +48,8 @@ Tracking Mode
+

Select A Device You Would Like To Track

+
@@ -63,16 +64,61 @@
- + +
+ + + + + + + +
+