SNS_updated
SNS_updated
def classify_signal(frequency):
signal_types = [
(2.412e9, 2.8e9, "Wi-Fi EMI ", "Internet connectivity"),
(2.8e9, 5e9 , "Wi-Fi" , "Internet connectivity"),
(2.410e9, 2.4835e9, "Bluetooth EMI", "Short-range wireless communication"),
(2.4845e9, 2.993e9, "Bluetooth ", "Short-range wireless communication"),
(2.7e9, 3.4e9, "Weather Radar EMI", "Precipitation monitoring"),
(2.51e9,2.6e9, "Fixed wireless access system EMI"),
(3.5e9, 3.5e9, "5G EMI", "Mobile networks"),
#(2.9e9, 3.9e9, "Military Radar", "Defense and security"),
(2.9e9, 3.5e9, "Satellite Communication", "Telemetry, control, and
communication"),
]
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", f"Error running hackrf_sweep: {e}")
print(f"Command failed with error: {e}")
print(f"STDOUT: {e.stdout}")
print(f"STDERR: {e.stderr}")
return False
except FileNotFoundError:
messagebox.showerror("Error", "HackRF tools are not installed or not found
in system PATH.")
return False
def visualize_spectrum(output_file):
try:
freq_bins = []
power_levels = []
except Exception as e:
messagebox.showerror("Error", f"Failed to visualize spectrum: {e}")
print(f"Detailed error: {traceback.format_exc()}")
if not signal_data:
raise ValueError("No valid data found in the CSV file.")
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, txt="EMI Measurement Report", ln=True, align='C')
pdf.ln(10)
pdf.output(report_file)
messagebox.showinfo("Success", f"Report generated and saved to
{report_file}.")
except Exception as e:
messagebox.showerror("Error", f"Error generating report: {e}")
def notification():
topic_arn = 'arn:aws:sns:ap-south-1:515966519193:EMC'
sns_client = boto3.client(
'sns',
aws_access_key_id='AKIAXQIQAI6MTLUHUJP6',
aws_secret_access_key='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',
region_name='ap-south-1'
)
print(response)
def start_sweep():
output_file = filedialog.asksaveasfilename(
defaultextension=".csv",
filetypes=[("CSV files", ".csv"), ("All files", ".*")]
)
if not output_file:
return
try:
freq_min = int(freq_min_entry.get())
freq_max = int(freq_max_entry.get())
bin_width = int(bin_width_entry.get())
vga_gain = int(vga_gain_entry.get())
lna_gain = int(lna_gain_entry.get())
amp_enable = amp_enable_var.get()
antenna_enable = antenna_enable_var.get()
num_sweeps = int(num_sweeps_entry.get())
except ValueError:
messagebox.showerror("Error", "Please enter valid numeric values for all
fields.")
return
# Frequency range
ttk.Label(root, text="Frequency Range (MHz)").pack(pady=5)
freq_min_entry = ttk.Entry(root, width=10)
freq_min_entry.pack(pady=5)
freq_min_entry.insert(0, "0")
freq_max_entry = ttk.Entry(root, width=10)
freq_max_entry.pack(pady=5)
freq_max_entry.insert(0, "6000")
# Bin width
ttk.Label(root, text="Bin Width (Hz)").pack(pady=5)
bin_width_entry = ttk.Entry(root, width=10)
bin_width_entry.pack(pady=5)
bin_width_entry.insert(0, "1000000")
# Gains
ttk.Label(root, text="VGA Gain (dB)").pack(pady=5)
vga_gain_entry = ttk.Entry(root, width=10)
vga_gain_entry.pack(pady=5)
vga_gain_entry.insert(0, "20")
antenna_enable_var = tk.IntVar(value=1)
ttk.Checkbutton(root, text="Enable Antenna",
variable=antenna_enable_var).pack(pady=5)
# Number of sweeps
ttk.Label(root, text="Number of Sweeps").pack(pady=5)
num_sweeps_entry = ttk.Entry(root, width=10)
num_sweeps_entry.pack(pady=5)
num_sweeps_entry.insert(0, "100")
# Start button
ttk.Button(root, text="Start Sweep", command=start_sweep).pack(pady=20)
root.mainloop()
# import tkinter as tk
# from tkinter import messagebox
# import numpy as np
# import matplotlib.pyplot as plt
# from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
# import subprocess
# Input fields
# tk.Label(root, text="Center Frequency (Hz):").grid(row=0, column=0, sticky="w")
# center_freq_entry = tk.Entry(root)
# center_freq_entry.grid(row=0, column=1)
# Start button
# start_button = tk.Button(root, text="Start", command=start_measurement)
# start_button.grid(row=3, column=0, columnspan=2)
# Spectrum display
# fig, ax = plt.subplots(figsize=(5, 3))
# canvas = FigureCanvasTkAgg(fig, master=root)
# canvas_widget = canvas.get_tk_widget()
# canvas_widget.grid(row=4, column=0, columnspan=2)
# Log area
# tk.Label(root, text="Detected Sources:").grid(row=5, column=0, sticky="w")
# log_text = tk.Text(root, height=10, width=50)
# log_text.grid(row=6, column=0, columnspan=2)