Hướng dẫn thiết lập hệ thống thu thập và phân tích dữ liệu WiFi CSI xuyên tường. Hệ thống tích hợp xử lý tín hiệu thời gian thực và phát hiện xâm nhập thông minh.
Cài đặt các công cụ cần thiết để nạp firmware và xử lý dữ liệu:
pip install esptool pyserial esp-idf-nvs-partition-gen numpy matplotlib pytest- Nạp Firmware:
python -m esptool --chip esp32s3 --port COM5 --baud 460800 write_flash 0x0 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/esp32-csi-node.bin
- Cấu hình (Wifi, IP đích, ID):
python provision.py --port COM5 --ssid "VIET HUY" --password "12345678" --target-ip 192.168.1.3 --node-id 1
- Kiểm tra:
python -m serial.tools.miniterm COM5 115200(Phải thấy log "CSI streaming active").
Thực hiện tương tự Node 1, thay đổi --port COM6 và --node-id 2.
Hệ thống tích hợp bộ xử lý tín hiệu CsiProcessor để lọc nhiễu và trích xuất đặc trưng (motion, breathing) trong thời gian thực.
# Chạy với log thông thường
python -m aggregator --port 5005
# Xem chi tiết quá trình xử lý (Debug)
python -m aggregator --port 5005 --log-level INFOĐây là tính năng mới giúp hệ thống tự động nhận diện có người trong phòng dựa trên thuật toán Adaptive Baseline.
python -m aggregator --port 5005 --log-level INFO --processor-config "{\"window_size\":30,\"step_size\":15}" --detector-config "{\"enter_threshold_sigma\":2.5,\"exit_threshold_sigma\":1.5,\"enter_frames\":2,\"exit_frames\":5,\"baseline_alpha\":0.15}"- Adaptive Baseline (Tự học): Hệ thống dành 10-20 giây đầu để học "độ tĩnh" của căn phòng và tự điều chỉnh khi môi trường thay đổi.
- Hysteresis Detection: Ngăn chặn báo động giả khi tín hiệu dao động nhẹ ở ngưỡng biên.
- Multi-node Fusion: Hợp nhất dữ liệu từ nhiều Node (Logic OR) để mở rộng vùng bao phủ.
- Alert Persistence: Cảnh báo được lưu tại
data/alerts/alerts_YYYY-MM-DD.jsonl.
Bạn có thể điều chỉnh độ nhạy (Sigma) qua tham số:
python -m aggregator --detector-config "{\"enter_threshold_sigma\": 3.0, \"cooldown_seconds\": 10.0}"Chạy bộ xử lý trên dữ liệu đã ghi lại:
python -m processor --input data/raw/node_1_record.npyĐảm bảo toán học và logic hệ thống hoạt động chính xác:
$env:PYTHONPATH="."; pytest tests/python -m aggregator --port 5005 --dashboard --dashboard-port 8024 --log-level INFO --classifier-config "{\"model_path\":\"models/activity/model.pth\",\"scaler_path\":\"models/activity/activity_scaler.json\",\"confidence_threshold\":0.6}"
Dùng script để xem bản đồ nhiệt (Heatmap):
python scripts/view_csi.py <tên_session_trong_data_raw>