mirror of
https://github.com/ruvnet/RuView
synced 2026-06-18 11:43:19 +00:00
Compare commits
6 Commits
v0.4.0-desktop
...
v0.4.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 21aba2df8d | |||
| a28a875594 | |||
| e12749bf68 | |||
| 3b37aaf460 | |||
| d3c683cc7e | |||
| 56de77c0ad |
@@ -7,9 +7,13 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to release (e.g., 0.3.0)'
|
||||
description: 'Version to release (e.g., 0.4.0)'
|
||||
required: true
|
||||
default: '0.3.0'
|
||||
default: '0.4.0'
|
||||
attach_to_existing:
|
||||
description: 'Attach to existing release tag (leave empty to create new)'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
@@ -65,7 +69,7 @@ jobs:
|
||||
- name: Package macOS app
|
||||
run: |
|
||||
cd rust-port/wifi-densepose-rs/target/${{ matrix.target }}/release/bundle/macos
|
||||
zip -r "RuView-Desktop-${{ github.event.inputs.version || '0.3.0' }}-macos-${{ steps.arch.outputs.arch }}.zip" "RuView Desktop.app"
|
||||
zip -r "RuView-Desktop-${{ github.event.inputs.version || '0.4.0' }}-macos-${{ steps.arch.outputs.arch }}.zip" "RuView Desktop.app"
|
||||
|
||||
- name: Upload macOS artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -136,21 +140,21 @@ jobs:
|
||||
- name: List artifacts
|
||||
run: find artifacts -type f
|
||||
|
||||
- name: Create Release
|
||||
- name: Create or Update Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
name: RuView Desktop v${{ github.event.inputs.version || '0.3.0' }}
|
||||
tag_name: desktop-v${{ github.event.inputs.version || '0.3.0' }}
|
||||
name: RuView Desktop v${{ github.event.inputs.version || '0.4.0' }}
|
||||
tag_name: ${{ github.event.inputs.attach_to_existing || format('desktop-v{0}', github.event.inputs.version || '0.4.0') }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
generate_release_notes: ${{ github.event.inputs.attach_to_existing == '' }}
|
||||
files: |
|
||||
artifacts/**/*.zip
|
||||
artifacts/**/*.msi
|
||||
artifacts/**/*.exe
|
||||
artifacts/**/*.dmg
|
||||
body: |
|
||||
## RuView Desktop v${{ github.event.inputs.version || '0.3.0' }}
|
||||
## RuView Desktop v${{ github.event.inputs.version || '0.4.0' }}
|
||||
|
||||
WiFi-based human pose estimation desktop application.
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# ADR-055: Integrated Sensing Server in Desktop App
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
The RuView Desktop application (ADR-054) requires the WiFi sensing server to provide real-time CSI data, activity detection, and vital signs monitoring. Currently, the sensing server is a separate binary (`wifi-densepose-sensing-server`) that must be installed separately and found in the system PATH.
|
||||
|
||||
This creates several problems:
|
||||
1. **Distribution complexity**: Users must install two binaries
|
||||
2. **Path issues**: Binary may not be in PATH, causing "No such file or directory" errors
|
||||
3. **Version mismatch**: Server and desktop app versions may diverge
|
||||
4. **Poor UX**: Error messages about missing binaries confuse users
|
||||
|
||||
## Decision
|
||||
Bundle the sensing server binary inside the desktop application and provide intelligent binary discovery with clear fallback paths.
|
||||
|
||||
### Binary Discovery Order
|
||||
The desktop app searches for the sensing server in this order:
|
||||
1. **Custom path** from user settings (`server_path`)
|
||||
2. **Bundled resources** (`Contents/Resources/bin/` on macOS)
|
||||
3. **Next to executable** (same directory as the app binary)
|
||||
4. **System PATH** (legacy fallback)
|
||||
|
||||
### Implementation
|
||||
```rust
|
||||
fn find_server_binary(app: &AppHandle, custom_path: Option<&str>) -> Result<String, String> {
|
||||
// 1. Custom path from settings
|
||||
if let Some(path) = custom_path {
|
||||
if std::path::Path::new(path).exists() {
|
||||
return Ok(path.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Bundled in resources
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
let bundled = resource_dir.join("bin").join(DEFAULT_SERVER_BIN);
|
||||
if bundled.exists() {
|
||||
return Ok(bundled.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Next to executable
|
||||
if let Ok(exe_path) = std::env::current_exe() {
|
||||
if let Some(exe_dir) = exe_path.parent() {
|
||||
let sibling = exe_dir.join(DEFAULT_SERVER_BIN);
|
||||
if sibling.exists() {
|
||||
return Ok(sibling.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. System PATH
|
||||
// ... which lookup ...
|
||||
|
||||
Err("Sensing server binary not found")
|
||||
}
|
||||
```
|
||||
|
||||
### Bundle Configuration
|
||||
In `tauri.conf.json`:
|
||||
```json
|
||||
{
|
||||
"bundle": {
|
||||
"resources": [
|
||||
{
|
||||
"src": "../../target/release/wifi-densepose-sensing-server",
|
||||
"target": "bin/wifi-densepose-sensing-server"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
- **Single package distribution**: Users download one DMG/MSI/EXE
|
||||
- **Version alignment**: Server and UI always match
|
||||
- **Better UX**: No PATH configuration required
|
||||
- **Offline capable**: Works without network access to download server
|
||||
|
||||
### Negative
|
||||
- **Larger bundle size**: ~10-15MB additional for server binary
|
||||
- **Build complexity**: Must build server before bundling desktop
|
||||
- **Platform-specific**: Need separate server binaries per platform
|
||||
|
||||
### Neutral
|
||||
- CI/CD workflow updated to build server before desktop
|
||||
- GitHub Actions builds all platforms (macOS arm64/x64, Windows x64)
|
||||
|
||||
## WebSocket Integration
|
||||
The Sensing page connects to the bundled server's WebSocket endpoint:
|
||||
- `ws://127.0.0.1:{ws_port}/ws/sensing` - Real-time CSI data stream
|
||||
- `ws://127.0.0.1:{ws_port}/ws/pose` - Pose estimation stream
|
||||
|
||||
Message format:
|
||||
```typescript
|
||||
interface WsSensingUpdate {
|
||||
type: string;
|
||||
timestamp: number;
|
||||
source: string;
|
||||
tick: number;
|
||||
nodes: WsNodeInfo[];
|
||||
classification: { motion_level: string; presence: boolean; confidence: number };
|
||||
vital_signs?: { breathing_rate_hz?: number; heart_rate_bpm?: number };
|
||||
}
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
- Server binary signed with same certificate as desktop app
|
||||
- Communication over localhost only (127.0.0.1)
|
||||
- No external network access by default
|
||||
- Process spawned as child of desktop app (inherits permissions)
|
||||
|
||||
## Related ADRs
|
||||
- ADR-054: Desktop Full Implementation
|
||||
- ADR-053: UI Design System
|
||||
- ADR-052: Tauri Desktop Frontend
|
||||
@@ -0,0 +1,251 @@
|
||||
# ADR-056: RuView Desktop Complete Capabilities Reference
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
RuView Desktop is a comprehensive WiFi-based sensing platform that combines hardware management, real-time signal processing, neural network inference, and intelligent monitoring. This ADR documents all integrated capabilities across the desktop application and underlying crates.
|
||||
|
||||
## Decision
|
||||
The RuView Desktop application consolidates all WiFi-DensePose functionality into a single, unified interface with the following capabilities.
|
||||
|
||||
---
|
||||
|
||||
## 1. Hardware Management
|
||||
|
||||
### 1.1 Node Discovery
|
||||
- **mDNS discovery**: Automatic detection of ESP32 nodes via Bonjour/Avahi
|
||||
- **UDP probe**: Direct UDP broadcast discovery on port 5005
|
||||
- **HTTP sweep**: Sequential IP scanning with health checks
|
||||
- **Manual registration**: User-defined node configuration
|
||||
|
||||
### 1.2 Firmware Flashing
|
||||
- **Serial flashing**: Direct USB flash via espflash integration
|
||||
- **Chip detection**: Automatic ESP32/S2/S3/C3/C6 identification
|
||||
- **Progress monitoring**: Real-time progress with speed metrics
|
||||
- **Verification**: Post-flash integrity verification
|
||||
|
||||
### 1.3 OTA Updates
|
||||
- **Single-node OTA**: HTTP-based firmware push to individual nodes
|
||||
- **Batch OTA**: Coordinated multi-node updates with strategies:
|
||||
- `sequential`: One node at a time
|
||||
- `tdm_safe`: Respects TDM slot timing
|
||||
- `parallel`: Concurrent updates with throttling
|
||||
- **Rollback support**: Automatic rollback on verification failure
|
||||
- **Version tracking**: Pre/post version comparison
|
||||
|
||||
### 1.4 Node Configuration
|
||||
- **NVS provisioning**: WiFi credentials, node ID, TDM slot assignment
|
||||
- **Mesh configuration**: Coordinator/node/aggregator role assignment
|
||||
- **TDM scheduling**: Time-division multiplexing slot allocation
|
||||
|
||||
---
|
||||
|
||||
## 2. Sensing Server
|
||||
|
||||
### 2.1 Data Sources
|
||||
- **ESP32 CSI**: Real UDP frames from ESP32 hardware (port 5005)
|
||||
- **Windows WiFi**: Native Windows RSSI monitoring via netsh
|
||||
- **Simulation**: Synthetic data generation for demo/testing
|
||||
- **Auto**: Automatic source detection based on available hardware
|
||||
|
||||
### 2.2 Real-Time Processing
|
||||
- **CSI pipeline**: 56-subcarrier amplitude/phase extraction
|
||||
- **FFT analysis**: Spectral decomposition for motion detection
|
||||
- **Vital signs**: Breathing rate (0.1-0.5 Hz), heart rate (0.8-2.0 Hz)
|
||||
- **Motion classification**: still/walking/running/exercising
|
||||
- **Presence detection**: Binary presence with confidence score
|
||||
|
||||
### 2.3 WebSocket Streaming
|
||||
- **Sensing endpoint**: `ws://localhost:8765/ws/sensing`
|
||||
- **Pose endpoint**: `ws://localhost:8765/ws/pose`
|
||||
- **Real-time broadcast**: 10-100 Hz update rate
|
||||
- **Multi-client support**: Concurrent WebSocket connections
|
||||
|
||||
### 2.4 REST API
|
||||
- **Health check**: `GET /health`
|
||||
- **Status**: `GET /api/status`
|
||||
- **Recording control**: `POST /api/recording/start|stop`
|
||||
- **Model management**: `GET/POST /api/models`
|
||||
|
||||
---
|
||||
|
||||
## 3. Neural Network Inference
|
||||
|
||||
### 3.1 Model Formats
|
||||
- **RVF (RuVector Format)**: Proprietary binary container with:
|
||||
- Model weights (quantized f32/f16/i8)
|
||||
- Vital sign configuration
|
||||
- SONA environment profiles
|
||||
- Training provenance
|
||||
- Cryptographic attestation
|
||||
|
||||
### 3.2 Inference Capabilities
|
||||
- **Pose estimation**: 17 COCO keypoints from WiFi CSI
|
||||
- **Activity recognition**: Multi-class classification
|
||||
- **Vital signs**: Breathing and heart rate extraction
|
||||
- **Multi-person detection**: Up to 3 simultaneous subjects
|
||||
|
||||
### 3.3 Self-Learning (SONA)
|
||||
- **Environment adaptation**: LoRA-based fine-tuning to room geometry
|
||||
- **Profile switching**: Multiple learned environment profiles
|
||||
- **Online learning**: Continuous adaptation during runtime
|
||||
- **Transfer learning**: Profile export/import between deployments
|
||||
|
||||
---
|
||||
|
||||
## 4. WASM Edge Modules
|
||||
|
||||
### 4.1 Module Management
|
||||
- **Upload**: Deploy WASM modules to ESP32 nodes
|
||||
- **Start/Stop**: Runtime control of edge processing
|
||||
- **Status monitoring**: CPU, memory, execution count
|
||||
- **Hot reload**: Update modules without node reboot
|
||||
|
||||
### 4.2 Supported Operations
|
||||
- **Local filtering**: On-device noise reduction
|
||||
- **Feature extraction**: Pre-compute features at edge
|
||||
- **Compression**: Reduce data before transmission
|
||||
- **Custom logic**: User-defined processing pipelines
|
||||
|
||||
---
|
||||
|
||||
## 5. Mesh Visualization
|
||||
|
||||
### 5.1 Network Topology
|
||||
- **Live mesh view**: Real-time node connectivity graph
|
||||
- **Signal quality**: RSSI/SNR visualization per link
|
||||
- **Latency monitoring**: Round-trip time measurement
|
||||
- **Packet loss**: Delivery success rate tracking
|
||||
|
||||
### 5.2 CSI Visualization
|
||||
- **Amplitude heatmap**: Per-subcarrier amplitude display
|
||||
- **Phase unwrapping**: Continuous phase visualization
|
||||
- **Spectrogram**: Time-frequency representation
|
||||
- **Signal field**: 3D voxel grid of RF perturbations
|
||||
|
||||
---
|
||||
|
||||
## 6. Training & Export
|
||||
|
||||
### 6.1 Dataset Management
|
||||
- **Recording**: Capture CSI frames with annotations
|
||||
- **Labeling**: Activity and pose ground truth
|
||||
- **Augmentation**: Synthetic data generation
|
||||
- **Export**: Standard formats (JSON, CSV, NumPy)
|
||||
|
||||
### 6.2 Training Pipeline (ADR-023)
|
||||
- **Contrastive pretraining**: Self-supervised feature learning
|
||||
- **Supervised fine-tuning**: Labeled pose estimation
|
||||
- **SONA adaptation**: Environment-specific tuning
|
||||
- **Validation**: Cross-environment testing
|
||||
|
||||
### 6.3 Export Formats
|
||||
- **RVF container**: Production deployment format
|
||||
- **ONNX**: Interoperability with external tools
|
||||
- **PyTorch**: Research and experimentation
|
||||
- **Candle**: Rust-native inference
|
||||
|
||||
---
|
||||
|
||||
## 7. Security Features
|
||||
|
||||
### 7.1 Network Security
|
||||
- **OTA PSK**: Pre-shared key for firmware updates
|
||||
- **Node authentication**: MAC-based node verification
|
||||
- **Encrypted transport**: Optional TLS for API endpoints
|
||||
|
||||
### 7.2 Code Signing
|
||||
- **Firmware verification**: Hash-based integrity checks
|
||||
- **WASM attestation**: Module signature validation
|
||||
- **Model provenance**: Training lineage tracking
|
||||
|
||||
---
|
||||
|
||||
## 8. Configuration & Settings
|
||||
|
||||
### 8.1 Server Configuration
|
||||
- **Ports**: HTTP (8080), WebSocket (8765), UDP (5005)
|
||||
- **Bind address**: Localhost or network-wide
|
||||
- **Data source**: auto/wifi/esp32/simulate
|
||||
- **Log level**: debug/info/warn/error
|
||||
|
||||
### 8.2 Application Settings
|
||||
- **Theme**: Dark/light mode
|
||||
- **Auto-discovery**: Periodic node scanning
|
||||
- **Discovery interval**: Configurable scan frequency
|
||||
- **UI customization**: Responsive layout options
|
||||
|
||||
---
|
||||
|
||||
## 9. Crate Architecture
|
||||
|
||||
| Crate | Capabilities |
|
||||
|-------|-------------|
|
||||
| `wifi-densepose-core` | CSI frame primitives, traits, error types |
|
||||
| `wifi-densepose-signal` | FFT, phase unwrapping, vital signs, RuvSense |
|
||||
| `wifi-densepose-nn` | ONNX/PyTorch/Candle inference backends |
|
||||
| `wifi-densepose-train` | Training pipeline, dataset, metrics |
|
||||
| `wifi-densepose-mat` | Mass casualty assessment tool |
|
||||
| `wifi-densepose-hardware` | ESP32 protocol, TDM, channel hopping |
|
||||
| `wifi-densepose-ruvector` | Cross-viewpoint fusion, attention |
|
||||
| `wifi-densepose-api` | REST API (Axum) |
|
||||
| `wifi-densepose-db` | Postgres/SQLite/Redis persistence |
|
||||
| `wifi-densepose-config` | Configuration management |
|
||||
| `wifi-densepose-wasm` | Browser WASM bindings |
|
||||
| `wifi-densepose-cli` | Command-line interface |
|
||||
| `wifi-densepose-sensing-server` | Real-time sensing server |
|
||||
| `wifi-densepose-wifiscan` | Multi-BSSID scanning |
|
||||
| `wifi-densepose-vitals` | Vital sign extraction |
|
||||
| `wifi-densepose-desktop` | Tauri desktop application |
|
||||
|
||||
---
|
||||
|
||||
## 10. UI Design System (ADR-053)
|
||||
|
||||
### 10.1 Pages
|
||||
- **Dashboard**: Overview, node status, quick actions
|
||||
- **Discovery**: Network scanning interface
|
||||
- **Nodes**: Node management and configuration
|
||||
- **Flash**: Serial firmware flashing
|
||||
- **OTA**: Over-the-air update management
|
||||
- **Edge Modules**: WASM deployment
|
||||
- **Sensing**: Real-time monitoring with server control
|
||||
- **Mesh View**: Network topology visualization
|
||||
- **Settings**: Application configuration
|
||||
|
||||
### 10.2 Components
|
||||
- **StatusBadge**: Health indicator
|
||||
- **NodeCard**: Node information display
|
||||
- **LogViewer**: Real-time log streaming
|
||||
- **ActivityFeed**: Sensing data visualization
|
||||
- **ProgressBar**: Operation progress
|
||||
- **ConfigForm**: Settings input
|
||||
|
||||
---
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
- **Unified interface**: All capabilities in one application
|
||||
- **Bundled deployment**: Single package with server included
|
||||
- **Real-time feedback**: WebSocket-based live updates
|
||||
- **Cross-platform**: macOS, Windows, Linux support
|
||||
- **Extensible**: WASM modules, custom models, API access
|
||||
|
||||
### Negative
|
||||
- **Larger bundle**: ~6MB app + ~2.6MB server
|
||||
- **Complexity**: Many features require learning curve
|
||||
- **Hardware dependency**: Full functionality requires ESP32 nodes
|
||||
|
||||
### Neutral
|
||||
- Documentation required for all features
|
||||
- Training materials needed for advanced capabilities
|
||||
- Community contributions welcome
|
||||
|
||||
## Related ADRs
|
||||
- ADR-053: UI Design System
|
||||
- ADR-054: Desktop Full Implementation
|
||||
- ADR-055: Integrated Sensing Server
|
||||
- ADR-023: 8-Phase Training Pipeline
|
||||
- ADR-016: RuVector Integration
|
||||
@@ -76,7 +76,16 @@ def generate_nvs_binary(csv_content, size):
|
||||
bin_path = csv_path.replace(".csv", ".bin")
|
||||
|
||||
try:
|
||||
# Try the pip-installed version first
|
||||
# Try the pip-installed version first (esp_idf_nvs_partition_gen package)
|
||||
try:
|
||||
from esp_idf_nvs_partition_gen import nvs_partition_gen
|
||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
||||
with open(bin_path, "rb") as f:
|
||||
return f.read()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Try legacy import name (older versions)
|
||||
try:
|
||||
import nvs_partition_gen
|
||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# ESP32-S3 CSI Node — Default SDK Configuration
|
||||
# This file is applied automatically by idf.py when no sdkconfig exists.
|
||||
|
||||
# Target: ESP32-S3
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
|
||||
# Use custom partition table (8MB flash with OTA — ADR-045)
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_display.csv"
|
||||
|
||||
# Flash configuration: 8MB (Quad SPI)
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
|
||||
|
||||
# Compiler optimization: optimize for size to reduce binary
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
# Enable CSI (Channel State Information) in WiFi driver
|
||||
CONFIG_ESP_WIFI_CSI_ENABLED=y
|
||||
|
||||
# Enable NVS encryption for secure credential storage
|
||||
CONFIG_NVS_ENCRYPTION=y
|
||||
|
||||
# Disable unused features to reduce binary size
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
|
||||
# LWIP: enable extended socket options for UDP multicast
|
||||
CONFIG_LWIP_SO_RCVBUF=y
|
||||
|
||||
# FreeRTOS: increase task stack for CSI processing
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
||||
Generated
+14
-26
@@ -2357,20 +2357,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.27.7"
|
||||
name = "hyper-tls"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
|
||||
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
||||
dependencies = [
|
||||
"http",
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"rustls 0.23.37",
|
||||
"rustls-pki-types",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tokio-native-tls",
|
||||
"tower-service",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4758,22 +4757,21 @@ dependencies = [
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-tls",
|
||||
"hyper-util",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime_guess",
|
||||
"native-tls",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"quinn",
|
||||
"rustls 0.23.37",
|
||||
"rustls-pki-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tokio-native-tls",
|
||||
"tower",
|
||||
"tower-http 0.6.8",
|
||||
"tower-service",
|
||||
@@ -4781,7 +4779,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6569,12 +6566,12 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.26.4"
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61"
|
||||
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
||||
dependencies = [
|
||||
"rustls 0.23.37",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -7523,15 +7520,6 @@ dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com"
|
||||
version = "0.38.2"
|
||||
|
||||
@@ -23,3 +23,39 @@ serde_json = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
||||
# Discovery (mDNS + UDP)
|
||||
mdns-sd = "0.11"
|
||||
flume = "0.11"
|
||||
|
||||
# Serial port (cross-platform)
|
||||
tokio-serial = "5.4"
|
||||
|
||||
# HTTP client for OTA/WASM (native-tls for Windows compatibility)
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "native-tls"] }
|
||||
|
||||
# Crypto for OTA PSK
|
||||
sha2 = "0.10"
|
||||
hmac = "0.12"
|
||||
|
||||
# System info for server management
|
||||
sysinfo = "0.32"
|
||||
|
||||
# Async utilities
|
||||
futures = "0.3"
|
||||
|
||||
# Logging
|
||||
tracing = "0.1"
|
||||
|
||||
# UUID for session IDs
|
||||
uuid = { version = "1.0", features = ["v4", "serde"] }
|
||||
|
||||
# Hex encoding for hashes
|
||||
hex = "0.4"
|
||||
|
||||
# Regex for parsing espflash output
|
||||
regex = "1.10"
|
||||
|
||||
# Unix signals for graceful process termination
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
+80
-3
@@ -276,11 +276,24 @@ fn parse_beacon_response(data: &[u8], addr: SocketAddr) -> Option<DiscoveredNode
|
||||
/// Filters for known ESP32 USB-to-serial chips (CP2102, CH340, FTDI).
|
||||
#[tauri::command]
|
||||
pub async fn list_serial_ports() -> Result<Vec<SerialPortInfo>, String> {
|
||||
let ports = available_ports().map_err(|e| format!("Failed to enumerate ports: {}", e))?;
|
||||
tracing::info!("list_serial_ports called");
|
||||
|
||||
let ports = match available_ports() {
|
||||
Ok(p) => {
|
||||
tracing::info!("Found {} ports from tokio_serial", p.len());
|
||||
p
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to enumerate ports: {}", e);
|
||||
// Fallback: try to list /dev/cu.usb* manually on macOS
|
||||
return list_serial_ports_fallback();
|
||||
}
|
||||
};
|
||||
|
||||
let mut result = Vec::new();
|
||||
|
||||
for port in ports {
|
||||
tracing::debug!("Processing port: {}", port.port_name);
|
||||
let info = match port.port_type {
|
||||
tokio_serial::SerialPortType::UsbPort(usb_info) => {
|
||||
SerialPortInfo {
|
||||
@@ -294,12 +307,13 @@ pub async fn list_serial_ports() -> Result<Vec<SerialPortInfo>, String> {
|
||||
}
|
||||
_ => {
|
||||
SerialPortInfo {
|
||||
name: port.port_name,
|
||||
name: port.port_name.clone(),
|
||||
vid: None,
|
||||
pid: None,
|
||||
manufacturer: None,
|
||||
serial_number: None,
|
||||
is_esp32_compatible: false,
|
||||
// Mark /dev/cu.usb* ports as potentially compatible
|
||||
is_esp32_compatible: port.port_name.contains("usb"),
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -307,9 +321,72 @@ pub async fn list_serial_ports() -> Result<Vec<SerialPortInfo>, String> {
|
||||
result.push(info);
|
||||
}
|
||||
|
||||
// If no ports found via tokio_serial, try fallback
|
||||
if result.is_empty() {
|
||||
tracing::warn!("No ports from tokio_serial, trying fallback");
|
||||
return list_serial_ports_fallback();
|
||||
}
|
||||
|
||||
// Sort ESP32-compatible ports first
|
||||
result.sort_by(|a, b| b.is_esp32_compatible.cmp(&a.is_esp32_compatible));
|
||||
|
||||
tracing::info!("Returning {} serial ports", result.len());
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Fallback serial port listing for macOS when tokio_serial fails
|
||||
fn list_serial_ports_fallback() -> Result<Vec<SerialPortInfo>, String> {
|
||||
tracing::info!("Using fallback serial port listing");
|
||||
|
||||
let mut result = Vec::new();
|
||||
|
||||
// List /dev/cu.usb* devices on macOS
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use std::fs;
|
||||
if let Ok(entries) = fs::read_dir("/dev") {
|
||||
for entry in entries.flatten() {
|
||||
let name = entry.file_name().to_string_lossy().to_string();
|
||||
if name.starts_with("cu.usb") {
|
||||
let path = format!("/dev/{}", name);
|
||||
tracing::info!("Fallback found port: {}", path);
|
||||
result.push(SerialPortInfo {
|
||||
name: path,
|
||||
vid: None,
|
||||
pid: None,
|
||||
manufacturer: Some("USB Serial".to_string()),
|
||||
serial_number: None,
|
||||
is_esp32_compatible: true, // Assume USB serial is ESP32
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Linux fallback
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
use std::fs;
|
||||
if let Ok(entries) = fs::read_dir("/dev") {
|
||||
for entry in entries.flatten() {
|
||||
let name = entry.file_name().to_string_lossy().to_string();
|
||||
if name.starts_with("ttyUSB") || name.starts_with("ttyACM") {
|
||||
let path = format!("/dev/{}", name);
|
||||
tracing::info!("Fallback found port: {}", path);
|
||||
result.push(SerialPortInfo {
|
||||
name: path,
|
||||
vid: None,
|
||||
pid: None,
|
||||
manufacturer: Some("USB Serial".to_string()),
|
||||
serial_number: None,
|
||||
is_esp32_compatible: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracing::info!("Fallback found {} ports", result.len());
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,77 @@ use std::process::{Command, Stdio};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sysinfo::{Pid, ProcessesToUpdate, System};
|
||||
use tauri::State;
|
||||
use tauri::{AppHandle, Manager, State};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
/// Default path to the sensing server binary (relative to resources).
|
||||
const DEFAULT_SERVER_BIN: &str = "wifi-densepose-sensing-server";
|
||||
/// Default binary name for the sensing server.
|
||||
const DEFAULT_SERVER_BIN: &str = "sensing-server";
|
||||
|
||||
/// Find the sensing server binary path.
|
||||
///
|
||||
/// Search order:
|
||||
/// 1. Custom path from config.server_path
|
||||
/// 2. Bundled in app resources (macOS: Contents/Resources/bin/)
|
||||
/// 3. Next to the app executable
|
||||
/// 4. System PATH
|
||||
fn find_server_binary(app: &AppHandle, custom_path: Option<&str>) -> Result<String, String> {
|
||||
// 1. Custom path from settings
|
||||
if let Some(path) = custom_path {
|
||||
if std::path::Path::new(path).exists() {
|
||||
return Ok(path.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Bundled in resources (Tauri bundles to Contents/Resources/)
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
let bundled = resource_dir.join("bin").join(DEFAULT_SERVER_BIN);
|
||||
if bundled.exists() {
|
||||
return Ok(bundled.to_string_lossy().to_string());
|
||||
}
|
||||
// Also check directly in resources
|
||||
let direct = resource_dir.join(DEFAULT_SERVER_BIN);
|
||||
if direct.exists() {
|
||||
return Ok(direct.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Next to the executable
|
||||
if let Ok(exe_path) = std::env::current_exe() {
|
||||
if let Some(exe_dir) = exe_path.parent() {
|
||||
let sibling = exe_dir.join(DEFAULT_SERVER_BIN);
|
||||
if sibling.exists() {
|
||||
return Ok(sibling.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Check if it's in PATH
|
||||
if let Ok(output) = Command::new("which").arg(DEFAULT_SERVER_BIN).output() {
|
||||
if output.status.success() {
|
||||
let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !path.is_empty() {
|
||||
return Ok(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(format!(
|
||||
"Sensing server binary '{}' not found. Please build it with: cargo build --release -p wifi-densepose-sensing-server",
|
||||
DEFAULT_SERVER_BIN
|
||||
))
|
||||
}
|
||||
|
||||
/// Start the sensing server as a managed child process.
|
||||
///
|
||||
/// The server binary is looked up in the following order:
|
||||
/// 1. Settings `server_path` if set
|
||||
/// 2. Bundled resource path
|
||||
/// 3. System PATH
|
||||
/// 3. Next to executable
|
||||
/// 4. System PATH
|
||||
#[tauri::command]
|
||||
pub async fn start_server(
|
||||
app: AppHandle,
|
||||
config: ServerConfig,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<ServerStartResult, String> {
|
||||
@@ -28,10 +84,10 @@ pub async fn start_server(
|
||||
}
|
||||
}
|
||||
|
||||
// Determine server binary path
|
||||
let server_path = config.server_path
|
||||
.clone()
|
||||
.unwrap_or_else(|| DEFAULT_SERVER_BIN.to_string());
|
||||
// Find server binary
|
||||
let server_path = find_server_binary(&app, config.server_path.as_deref())?;
|
||||
|
||||
tracing::info!("Starting sensing server from: {}", server_path);
|
||||
|
||||
// Build command with configuration
|
||||
let mut cmd = Command::new(&server_path);
|
||||
@@ -52,6 +108,10 @@ pub async fn start_server(
|
||||
cmd.args(["--log-level", log_level]);
|
||||
}
|
||||
|
||||
// Set data source (default to "simulate" if not specified for demo mode)
|
||||
let source = config.source.as_deref().unwrap_or("simulate");
|
||||
cmd.args(["--source", source]);
|
||||
|
||||
// Redirect stdout/stderr to pipes for monitoring
|
||||
cmd.stdout(Stdio::piped());
|
||||
cmd.stderr(Stdio::piped());
|
||||
@@ -88,14 +148,15 @@ pub async fn start_server(
|
||||
/// First attempts graceful termination (SIGTERM), then SIGKILL after timeout.
|
||||
#[tauri::command]
|
||||
pub async fn stop_server(state: State<'_, AppState>) -> Result<(), String> {
|
||||
// Extract child process ID and take ownership of child for killing
|
||||
// This releases the lock before any await points
|
||||
let child_id = {
|
||||
let srv = state.server.lock().map_err(|e| e.to_string())?;
|
||||
// Extract child process and take ownership for killing
|
||||
let (child_id, mut child_process) = {
|
||||
let mut srv = state.server.lock().map_err(|e| e.to_string())?;
|
||||
if !srv.running {
|
||||
return Err("Server is not running".into());
|
||||
}
|
||||
srv.pid
|
||||
let pid = srv.pid;
|
||||
let child = srv.child.take(); // Take ownership of child
|
||||
(pid, child)
|
||||
};
|
||||
|
||||
let child_id = match child_id {
|
||||
@@ -103,46 +164,60 @@ pub async fn stop_server(state: State<'_, AppState>) -> Result<(), String> {
|
||||
None => return Err("No server process found".into()),
|
||||
};
|
||||
|
||||
// First try graceful termination
|
||||
tracing::info!("Stopping sensing server with PID {}", child_id);
|
||||
|
||||
// First try graceful termination via SIGTERM
|
||||
#[cfg(unix)]
|
||||
{
|
||||
unsafe {
|
||||
libc::kill(child_id as i32, libc::SIGTERM);
|
||||
// Kill the process group (negative PID) to kill all children too
|
||||
let _ = libc::kill(-(child_id as i32), libc::SIGTERM);
|
||||
// Also kill the main process directly
|
||||
let _ = libc::kill(child_id as i32, libc::SIGTERM);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait briefly for graceful shutdown (async operation - no lock held)
|
||||
let wait_result: Result<Result<bool, _>, _> = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(5),
|
||||
tokio::task::spawn_blocking({
|
||||
move || {
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
// Check if process is still alive
|
||||
let mut sys = System::new();
|
||||
let pid = Pid::from_u32(child_id);
|
||||
sys.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);
|
||||
sys.process(pid).is_some()
|
||||
}
|
||||
})
|
||||
).await;
|
||||
// Wait briefly for graceful shutdown
|
||||
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
|
||||
|
||||
// Force kill if still running - re-acquire lock
|
||||
let still_running = match wait_result {
|
||||
Ok(Ok(running)) => running,
|
||||
_ => true,
|
||||
// Check if still running
|
||||
let still_running = {
|
||||
let mut sys = System::new();
|
||||
let pid = Pid::from_u32(child_id);
|
||||
sys.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);
|
||||
sys.process(pid).is_some()
|
||||
};
|
||||
|
||||
{
|
||||
let mut srv = state.server.lock().map_err(|e| e.to_string())?;
|
||||
// Force kill if still running
|
||||
if still_running {
|
||||
tracing::warn!("Server still running after SIGTERM, sending SIGKILL");
|
||||
|
||||
if still_running {
|
||||
if let Some(ref mut child) = srv.child {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
#[cfg(unix)]
|
||||
{
|
||||
unsafe {
|
||||
// SIGKILL the process group and main process
|
||||
let _ = libc::kill(-(child_id as i32), libc::SIGKILL);
|
||||
let _ = libc::kill(child_id as i32, libc::SIGKILL);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear state
|
||||
// Also use the child handle if available
|
||||
if let Some(ref mut child) = child_process {
|
||||
let _ = child.kill();
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for process to actually terminate
|
||||
if let Some(ref mut child) = child_process {
|
||||
let _ = child.wait();
|
||||
}
|
||||
|
||||
// Final verification and cleanup
|
||||
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
||||
|
||||
// Clear state
|
||||
{
|
||||
let mut srv = state.server.lock().map_err(|e| e.to_string())?;
|
||||
srv.running = false;
|
||||
srv.pid = None;
|
||||
srv.http_port = None;
|
||||
@@ -151,6 +226,19 @@ pub async fn stop_server(state: State<'_, AppState>) -> Result<(), String> {
|
||||
srv.child = None;
|
||||
}
|
||||
|
||||
// Verify process is dead
|
||||
let still_alive = {
|
||||
let mut sys = System::new();
|
||||
let pid = Pid::from_u32(child_id);
|
||||
sys.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);
|
||||
sys.process(pid).is_some()
|
||||
};
|
||||
|
||||
if still_alive {
|
||||
tracing::error!("Failed to kill server process {}", child_id);
|
||||
return Err(format!("Failed to stop server process {}", child_id));
|
||||
}
|
||||
|
||||
tracing::info!("Stopped sensing server");
|
||||
|
||||
Ok(())
|
||||
@@ -207,6 +295,7 @@ pub async fn server_status(state: State<'_, AppState>) -> Result<ServerStatusRes
|
||||
/// Restart the sensing server with the same or new configuration.
|
||||
#[tauri::command]
|
||||
pub async fn restart_server(
|
||||
app: AppHandle,
|
||||
config: Option<ServerConfig>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<ServerStartResult, String> {
|
||||
@@ -222,6 +311,7 @@ pub async fn restart_server(
|
||||
log_level: None,
|
||||
bind_address: None,
|
||||
server_path: None,
|
||||
source: None, // Use default (simulate)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,7 +322,7 @@ pub async fn restart_server(
|
||||
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
|
||||
|
||||
// Start with new config
|
||||
start_server(restart_config, state).await
|
||||
start_server(app, restart_config, state).await
|
||||
}
|
||||
|
||||
/// Get server logs (last N lines from stdout/stderr).
|
||||
@@ -260,6 +350,8 @@ pub struct ServerConfig {
|
||||
pub log_level: Option<String>,
|
||||
pub bind_address: Option<String>,
|
||||
pub server_path: Option<String>,
|
||||
/// Data source: "auto", "wifi", "esp32", "simulate"
|
||||
pub source: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@@ -302,6 +394,7 @@ mod tests {
|
||||
log_level: None,
|
||||
bind_address: None,
|
||||
server_path: None,
|
||||
source: Some("simulate".to_string()),
|
||||
};
|
||||
|
||||
assert_eq!(config.http_port, Some(8080));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-config-schema/schema.json",
|
||||
"productName": "RuView Desktop",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.3",
|
||||
"identifier": "net.ruv.ruview",
|
||||
"build": {
|
||||
"frontendDist": "ui/dist",
|
||||
@@ -30,6 +30,9 @@
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
],
|
||||
"resources": {
|
||||
"../../target/release/sensing-server": "bin/sensing-server"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ruview-desktop-ui",
|
||||
"private": true,
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { APP_VERSION } from "./version";
|
||||
import Dashboard from "./pages/Dashboard";
|
||||
import { Nodes } from "./pages/Nodes";
|
||||
import NetworkDiscovery from "./pages/NetworkDiscovery";
|
||||
@@ -90,8 +91,8 @@ const App: React.FC = () => {
|
||||
|
||||
const renderPage = () => {
|
||||
switch (activePage) {
|
||||
case "dashboard": return <Dashboard />;
|
||||
case "discovery": return <NetworkDiscovery />;
|
||||
case "dashboard": return <Dashboard onNavigate={navigateTo} />;
|
||||
case "discovery": return <NetworkDiscovery onNavigate={navigateTo} />;
|
||||
case "nodes": return <Nodes />;
|
||||
case "flash": return <FlashFirmware />;
|
||||
case "ota": return <OtaUpdate />;
|
||||
@@ -167,7 +168,7 @@ const App: React.FC = () => {
|
||||
letterSpacing: "0.02em",
|
||||
}}
|
||||
>
|
||||
v0.4.0
|
||||
v{APP_VERSION}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@ const DEFAULT_CONFIG: ServerConfig = {
|
||||
static_dir: null,
|
||||
model_dir: null,
|
||||
log_level: "info",
|
||||
source: "simulate",
|
||||
};
|
||||
|
||||
interface UseServerOptions {
|
||||
|
||||
+36
-7
@@ -19,19 +19,31 @@ interface ServerStatus {
|
||||
ws_port: number | null;
|
||||
}
|
||||
|
||||
const Dashboard: React.FC = () => {
|
||||
type Page = "dashboard" | "discovery" | "nodes" | "flash" | "ota" | "wasm" | "sensing" | "mesh" | "settings";
|
||||
|
||||
interface DashboardProps {
|
||||
onNavigate?: (page: Page) => void;
|
||||
}
|
||||
|
||||
const Dashboard: React.FC<DashboardProps> = ({ onNavigate }) => {
|
||||
const [nodes, setNodes] = useState<DiscoveredNode[]>([]);
|
||||
const [serverStatus, setServerStatus] = useState<ServerStatus | null>(null);
|
||||
const [scanning, setScanning] = useState(false);
|
||||
const [scanError, setScanError] = useState<string | null>(null);
|
||||
|
||||
const handleScan = async () => {
|
||||
setScanning(true);
|
||||
setScanError(null);
|
||||
try {
|
||||
const { invoke } = await import("@tauri-apps/api/core");
|
||||
const found = await invoke<DiscoveredNode[]>("discover_nodes", { timeoutMs: 3000 });
|
||||
setNodes(found);
|
||||
if (found.length === 0) {
|
||||
setScanError("No nodes found. Ensure ESP32 devices are powered on and connected to the network.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Discovery failed:", err);
|
||||
setScanError(`Scan failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
} finally {
|
||||
setScanning(false);
|
||||
}
|
||||
@@ -133,9 +145,9 @@ const Dashboard: React.FC = () => {
|
||||
<div className="card">
|
||||
<h3 className="heading-sm" style={{ marginBottom: "var(--space-3)" }}>Quick Actions</h3>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "var(--space-2)" }}>
|
||||
<QuickAction label="Flash Firmware" desc="Flash via serial port" />
|
||||
<QuickAction label="Push OTA Update" desc="Over-the-air to nodes" />
|
||||
<QuickAction label="Upload WASM" desc="Deploy edge modules" />
|
||||
<QuickAction label="Flash Firmware" desc="Flash via serial port" onClick={() => onNavigate?.("flash")} />
|
||||
<QuickAction label="Push OTA Update" desc="Over-the-air to nodes" onClick={() => onNavigate?.("ota")} />
|
||||
<QuickAction label="Upload WASM" desc="Deploy edge modules" onClick={() => onNavigate?.("wasm")} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -145,7 +157,23 @@ const Dashboard: React.FC = () => {
|
||||
<h3 className="heading-sm">Discovered Nodes ({nodes.length})</h3>
|
||||
</div>
|
||||
|
||||
{nodes.length === 0 ? (
|
||||
{scanError && (
|
||||
<div
|
||||
style={{
|
||||
padding: "var(--space-3) var(--space-4)",
|
||||
background: "rgba(248, 81, 73, 0.1)",
|
||||
border: "1px solid rgba(248, 81, 73, 0.3)",
|
||||
borderRadius: "var(--radius-md)",
|
||||
marginBottom: "var(--space-4)",
|
||||
fontSize: 13,
|
||||
color: "var(--status-error)",
|
||||
}}
|
||||
>
|
||||
{scanError}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{nodes.length === 0 && !scanError ? (
|
||||
<div className="card empty-state">
|
||||
<div className="empty-state-icon">{"\u25C9"}</div>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, color: "var(--text-secondary)" }}>
|
||||
@@ -155,7 +183,7 @@ const Dashboard: React.FC = () => {
|
||||
Click "Scan Network" to discover ESP32 devices on your local network.
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
) : nodes.length === 0 ? null : (
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
@@ -258,9 +286,10 @@ function PortTag({ label, port }: { label: string; port: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
function QuickAction({ label, desc }: { label: string; desc: string }) {
|
||||
function QuickAction({ label, desc, onClick }: { label: string; desc: string; onClick?: () => void }) {
|
||||
return (
|
||||
<div
|
||||
onClick={onClick}
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
|
||||
+76
-4
@@ -3,6 +3,12 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
import { StatusBadge } from "../components/StatusBadge";
|
||||
import type { HealthStatus, Chip, MeshRole, DiscoveryMethod } from "../types";
|
||||
|
||||
type Page = "dashboard" | "discovery" | "nodes" | "flash" | "ota" | "wasm" | "sensing" | "mesh" | "settings";
|
||||
|
||||
interface NetworkDiscoveryProps {
|
||||
onNavigate?: (page: Page) => void;
|
||||
}
|
||||
|
||||
interface DiscoveredNode {
|
||||
ip: string;
|
||||
mac: string | null;
|
||||
@@ -34,7 +40,7 @@ interface SerialPortInfo {
|
||||
|
||||
type DiscoveryTab = "network" | "serial" | "manual";
|
||||
|
||||
const NetworkDiscovery: React.FC = () => {
|
||||
const NetworkDiscovery: React.FC<NetworkDiscoveryProps> = ({ onNavigate }) => {
|
||||
const [activeTab, setActiveTab] = useState<DiscoveryTab>("network");
|
||||
const [nodes, setNodes] = useState<DiscoveredNode[]>([]);
|
||||
const [serialPorts, setSerialPorts] = useState<SerialPortInfo[]>([]);
|
||||
@@ -112,16 +118,22 @@ const NetworkDiscovery: React.FC = () => {
|
||||
}
|
||||
}, [manualIp, manualMac]);
|
||||
|
||||
// Scan both network and serial ports on mount
|
||||
useEffect(() => {
|
||||
scanNetwork();
|
||||
scanSerialPorts();
|
||||
}, []);
|
||||
|
||||
// Also refresh serial ports when switching to that tab
|
||||
useEffect(() => {
|
||||
if (activeTab === "serial") {
|
||||
scanSerialPorts();
|
||||
}
|
||||
}, [activeTab, scanSerialPorts]);
|
||||
|
||||
// Count ESP32-compatible serial ports
|
||||
const esp32SerialCount = serialPorts.filter((p) => p.is_esp32_compatible).length;
|
||||
|
||||
const filteredNodes = nodes.filter((node) => {
|
||||
if (filterOnline && node.health !== "online") return false;
|
||||
if (searchQuery) {
|
||||
@@ -302,21 +314,61 @@ const NetworkDiscovery: React.FC = () => {
|
||||
<div className="card empty-state">
|
||||
<div className="empty-state-icon">{"◉"}</div>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, color: "var(--text-secondary)" }}>
|
||||
{isScanning ? "Scanning for nodes..." : "No nodes discovered"}
|
||||
{isScanning ? "Scanning for nodes..." : "No network nodes found"}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 13,
|
||||
color: "var(--text-muted)",
|
||||
maxWidth: 300,
|
||||
maxWidth: 340,
|
||||
textAlign: "center",
|
||||
lineHeight: 1.5,
|
||||
}}
|
||||
>
|
||||
{isScanning
|
||||
? "Please wait while we search for ESP32 devices on your network."
|
||||
: "Click 'Scan Network' to discover ESP32 devices using mDNS and UDP broadcast."}
|
||||
: "Network discovery uses mDNS/UDP to find ESP32 devices running firmware on WiFi."}
|
||||
</div>
|
||||
|
||||
{/* USB device hint */}
|
||||
{!isScanning && esp32SerialCount > 0 && (
|
||||
<div
|
||||
style={{
|
||||
marginTop: "var(--space-4)",
|
||||
padding: "var(--space-3) var(--space-4)",
|
||||
background: "rgba(56, 139, 253, 0.1)",
|
||||
border: "1px solid rgba(56, 139, 253, 0.3)",
|
||||
borderRadius: 8,
|
||||
maxWidth: 340,
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 6 }}>
|
||||
<span style={{ fontSize: 16 }}>🔌</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 600, color: "var(--accent)" }}>
|
||||
{esp32SerialCount} USB device{esp32SerialCount > 1 ? "s" : ""} detected!
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: "var(--text-secondary)", lineHeight: 1.5, marginBottom: 10 }}>
|
||||
Your ESP32 is connected via USB. To flash firmware or configure it:
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setActiveTab("serial")}
|
||||
style={{
|
||||
padding: "8px 16px",
|
||||
background: "var(--accent)",
|
||||
border: "none",
|
||||
borderRadius: 6,
|
||||
color: "#fff",
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
cursor: "pointer",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
View Serial Ports →
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
@@ -384,6 +436,7 @@ const NetworkDiscovery: React.FC = () => {
|
||||
<Th>Manufacturer</Th>
|
||||
<Th>VID:PID</Th>
|
||||
<Th>Compatible</Th>
|
||||
<Th>Actions</Th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -417,6 +470,25 @@ const NetworkDiscovery: React.FC = () => {
|
||||
<span style={{ color: "var(--text-muted)" }}>--</span>
|
||||
)}
|
||||
</Td>
|
||||
<Td>
|
||||
{port.is_esp32_compatible && onNavigate && (
|
||||
<button
|
||||
onClick={() => onNavigate("flash")}
|
||||
style={{
|
||||
padding: "4px 12px",
|
||||
background: "var(--accent)",
|
||||
border: "none",
|
||||
borderRadius: 4,
|
||||
color: "#fff",
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
Flash →
|
||||
</button>
|
||||
)}
|
||||
</Td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
+298
-86
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState, useRef, useCallback } from "react";
|
||||
import { useServer } from "../hooks/useServer";
|
||||
import type { SensingUpdate } from "../types";
|
||||
import type { SensingUpdate, DataSource } from "../types";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Log entry model
|
||||
@@ -17,34 +17,58 @@ interface LogEntry {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mock data generators
|
||||
// WebSocket message types from sensing server
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const MOCK_LOG_TEMPLATES: { level: LogLevel; source: string; message: string }[] = [
|
||||
{ level: "INFO", source: "sensing-server", message: "HTTP listening on 127.0.0.1:8080" },
|
||||
{ level: "INFO", source: "udp_receiver", message: "CSI frame from 192.168.1.42" },
|
||||
{ level: "WARN", source: "vital_signs", message: "Low signal quality on node 2" },
|
||||
{ level: "INFO", source: "pose_engine", message: "Activity: walking (confidence: 0.87)" },
|
||||
{ level: "ERROR", source: "ws_session", message: "Client disconnected unexpectedly" },
|
||||
{ level: "INFO", source: "udp_receiver", message: "CSI frame from 192.168.1.15" },
|
||||
{ level: "INFO", source: "pose_engine", message: "Activity: sitting (confidence: 0.93)" },
|
||||
{ level: "INFO", source: "sensing-server", message: "WebSocket client connected from 127.0.0.1" },
|
||||
{ level: "WARN", source: "mesh_sync", message: "Node 4 heartbeat delayed by 1200ms" },
|
||||
{ level: "INFO", source: "pose_engine", message: "Activity: standing (confidence: 0.91)" },
|
||||
{ level: "INFO", source: "udp_receiver", message: "CSI frame from 192.168.1.78" },
|
||||
{ level: "ERROR", source: "udp_receiver", message: "Malformed CSI payload (len=0)" },
|
||||
{ level: "INFO", source: "csi_pipeline", message: "Subcarrier FFT complete (52 bins)" },
|
||||
{ level: "WARN", source: "vital_signs", message: "Breathing rate out of range on node 5" },
|
||||
{ level: "INFO", source: "pose_engine", message: "Activity: sleeping (confidence: 0.78)" },
|
||||
];
|
||||
interface WsNodeInfo {
|
||||
node_id: number;
|
||||
rssi_dbm: number;
|
||||
position: [number, number, number];
|
||||
amplitude: number[];
|
||||
subcarrier_count: number;
|
||||
}
|
||||
|
||||
const MOCK_ACTIVITIES = [
|
||||
{ activity: "walking", confidence: 0.87 },
|
||||
{ activity: "sitting", confidence: 0.93 },
|
||||
{ activity: "standing", confidence: 0.91 },
|
||||
{ activity: "sleeping", confidence: 0.78 },
|
||||
{ activity: "exercising", confidence: 0.65 },
|
||||
];
|
||||
interface WsClassification {
|
||||
motion_level: string;
|
||||
presence: boolean;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
interface WsFeatures {
|
||||
mean_rssi: number;
|
||||
variance: number;
|
||||
motion_band_power: number;
|
||||
breathing_band_power: number;
|
||||
dominant_freq_hz: number;
|
||||
change_points: number;
|
||||
spectral_power: number;
|
||||
}
|
||||
|
||||
interface WsVitalSigns {
|
||||
breathing_rate_hz?: number;
|
||||
heart_rate_bpm?: number;
|
||||
confidence?: number;
|
||||
}
|
||||
|
||||
interface WsSensingUpdate {
|
||||
type: string;
|
||||
timestamp: number;
|
||||
source: string;
|
||||
tick: number;
|
||||
nodes: WsNodeInfo[];
|
||||
features: WsFeatures;
|
||||
classification: WsClassification;
|
||||
vital_signs?: WsVitalSigns;
|
||||
posture?: string;
|
||||
signal_quality_score?: number;
|
||||
quality_verdict?: string;
|
||||
bssid_count?: number;
|
||||
estimated_persons?: number;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function formatTimestamp(d: Date): string {
|
||||
const hh = String(d.getHours()).padStart(2, "0");
|
||||
@@ -56,26 +80,71 @@ function formatTimestamp(d: Date): string {
|
||||
|
||||
let nextLogId = 1;
|
||||
|
||||
function createMockLogEntry(): LogEntry {
|
||||
const template = MOCK_LOG_TEMPLATES[Math.floor(Math.random() * MOCK_LOG_TEMPLATES.length)];
|
||||
return {
|
||||
id: nextLogId++,
|
||||
timestamp: formatTimestamp(new Date()),
|
||||
level: template.level,
|
||||
source: template.source,
|
||||
message: template.message,
|
||||
};
|
||||
function createLogFromWsUpdate(update: WsSensingUpdate): LogEntry[] {
|
||||
const entries: LogEntry[] = [];
|
||||
const ts = formatTimestamp(new Date(update.timestamp * 1000));
|
||||
|
||||
// Log each node's CSI data
|
||||
for (const node of update.nodes) {
|
||||
entries.push({
|
||||
id: nextLogId++,
|
||||
timestamp: ts,
|
||||
level: "INFO",
|
||||
source: "csi_receiver",
|
||||
message: `Node ${node.node_id}: RSSI ${node.rssi_dbm.toFixed(1)} dBm, ${node.subcarrier_count} subcarriers`,
|
||||
});
|
||||
}
|
||||
|
||||
// Log classification
|
||||
if (update.classification) {
|
||||
const level: LogLevel = update.classification.confidence < 0.5 ? "WARN" : "INFO";
|
||||
entries.push({
|
||||
id: nextLogId++,
|
||||
timestamp: ts,
|
||||
level,
|
||||
source: "classifier",
|
||||
message: `Motion: ${update.classification.motion_level} (presence=${update.classification.presence}, conf=${(update.classification.confidence * 100).toFixed(0)}%)`,
|
||||
});
|
||||
}
|
||||
|
||||
// Log vital signs if present
|
||||
if (update.vital_signs) {
|
||||
const vs = update.vital_signs;
|
||||
const level: LogLevel = (vs.confidence ?? 0) < 0.5 ? "WARN" : "INFO";
|
||||
entries.push({
|
||||
id: nextLogId++,
|
||||
timestamp: ts,
|
||||
level,
|
||||
source: "vital_signs",
|
||||
message: `Breathing: ${vs.breathing_rate_hz?.toFixed(2) ?? "--"} Hz, HR: ${vs.heart_rate_bpm?.toFixed(0) ?? "--"} bpm`,
|
||||
});
|
||||
}
|
||||
|
||||
// Log quality verdict if present
|
||||
if (update.quality_verdict && update.quality_verdict !== "Permit") {
|
||||
entries.push({
|
||||
id: nextLogId++,
|
||||
timestamp: ts,
|
||||
level: update.quality_verdict === "Deny" ? "ERROR" : "WARN",
|
||||
source: "quality_gate",
|
||||
message: `Signal quality: ${update.quality_verdict} (score=${(update.signal_quality_score ?? 0).toFixed(2)})`,
|
||||
});
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
function createMockSensingUpdate(): SensingUpdate {
|
||||
const act = MOCK_ACTIVITIES[Math.floor(Math.random() * MOCK_ACTIVITIES.length)];
|
||||
function createActivityFromWsUpdate(update: WsSensingUpdate): SensingUpdate | null {
|
||||
if (!update.classification) return null;
|
||||
|
||||
const node = update.nodes[0];
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
node_id: Math.floor(Math.random() * 6) + 1,
|
||||
subcarrier_count: 52,
|
||||
rssi: -(Math.floor(Math.random() * 40) + 30),
|
||||
activity: act.activity,
|
||||
confidence: parseFloat((act.confidence + (Math.random() * 0.1 - 0.05)).toFixed(2)),
|
||||
timestamp: new Date(update.timestamp * 1000).toISOString(),
|
||||
node_id: node?.node_id ?? 1,
|
||||
subcarrier_count: node?.subcarrier_count ?? 52,
|
||||
rssi: node?.rssi_dbm ?? -50,
|
||||
activity: update.posture ?? update.classification.motion_level,
|
||||
confidence: update.classification.confidence,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,7 +153,7 @@ function createMockSensingUpdate(): SensingUpdate {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const MAX_LOG_ENTRIES = 200;
|
||||
const LOG_INTERVAL_MS = 2000;
|
||||
const WS_RECONNECT_DELAY_MS = 3000;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// LogViewer component (ADR-053)
|
||||
@@ -107,11 +176,12 @@ function LogViewer({
|
||||
paused: boolean;
|
||||
onTogglePause: () => void;
|
||||
}) {
|
||||
const bottomRef = useRef<HTMLDivElement>(null);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!paused && bottomRef.current) {
|
||||
bottomRef.current.scrollIntoView({ behavior: "smooth" });
|
||||
// Scroll to bottom within the container only (not the page)
|
||||
if (!paused && containerRef.current) {
|
||||
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
||||
}
|
||||
}, [entries, paused]);
|
||||
|
||||
@@ -185,6 +255,7 @@ function LogViewer({
|
||||
|
||||
{/* Log entries */}
|
||||
<div
|
||||
ref={containerRef}
|
||||
style={{
|
||||
height: 320,
|
||||
overflowY: "auto",
|
||||
@@ -217,7 +288,6 @@ function LogViewer({
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -232,6 +302,9 @@ export const Sensing: React.FC = () => {
|
||||
const [starting, setStarting] = useState(false);
|
||||
const [stopping, setStopping] = useState(false);
|
||||
|
||||
// Data source selection
|
||||
const [dataSource, setDataSource] = useState<DataSource>("simulate");
|
||||
|
||||
// Log viewer state
|
||||
const [logEntries, setLogEntries] = useState<LogEntry[]>([]);
|
||||
const [paused, setPaused] = useState(false);
|
||||
@@ -241,28 +314,119 @@ export const Sensing: React.FC = () => {
|
||||
// Activity feed state
|
||||
const [activities, setActivities] = useState<SensingUpdate[]>([]);
|
||||
|
||||
// Simulated log feed
|
||||
// WebSocket connection state
|
||||
const [wsConnected, setWsConnected] = useState(false);
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const reconnectTimeoutRef = useRef<number | null>(null);
|
||||
|
||||
// Connect to real WebSocket when server is running
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
if (pausedRef.current) return;
|
||||
const entry = createMockLogEntry();
|
||||
setLogEntries((prev) => {
|
||||
const next = [...prev, entry];
|
||||
return next.length > MAX_LOG_ENTRIES ? next.slice(next.length - MAX_LOG_ENTRIES) : next;
|
||||
});
|
||||
|
||||
// Also push an activity update every ~3rd tick
|
||||
if (Math.random() < 0.35) {
|
||||
setActivities((prev) => {
|
||||
const update = createMockSensingUpdate();
|
||||
const next = [update, ...prev];
|
||||
return next.slice(0, 5);
|
||||
});
|
||||
if (!isRunning || !status?.ws_port) {
|
||||
// Server not running, disconnect if connected
|
||||
if (wsRef.current) {
|
||||
wsRef.current.close();
|
||||
wsRef.current = null;
|
||||
setWsConnected(false);
|
||||
}
|
||||
}, LOG_INTERVAL_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
const connect = () => {
|
||||
const wsUrl = `ws://127.0.0.1:${status.ws_port}/ws/sensing`;
|
||||
const ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = () => {
|
||||
setWsConnected(true);
|
||||
setLogEntries((prev) => [
|
||||
...prev,
|
||||
{
|
||||
id: nextLogId++,
|
||||
timestamp: formatTimestamp(new Date()),
|
||||
level: "INFO",
|
||||
source: "desktop",
|
||||
message: `WebSocket connected to ${wsUrl}`,
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
if (pausedRef.current) return;
|
||||
|
||||
try {
|
||||
const update = JSON.parse(event.data) as WsSensingUpdate;
|
||||
|
||||
// Create log entries from the update
|
||||
const entries = createLogFromWsUpdate(update);
|
||||
if (entries.length > 0) {
|
||||
setLogEntries((prev) => {
|
||||
const next = [...prev, ...entries];
|
||||
return next.length > MAX_LOG_ENTRIES ? next.slice(next.length - MAX_LOG_ENTRIES) : next;
|
||||
});
|
||||
}
|
||||
|
||||
// Create activity update
|
||||
const activity = createActivityFromWsUpdate(update);
|
||||
if (activity) {
|
||||
setActivities((prev) => {
|
||||
const next = [activity, ...prev];
|
||||
return next.slice(0, 5);
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to parse WebSocket message:", err);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
setWsConnected(false);
|
||||
wsRef.current = null;
|
||||
|
||||
// Only add disconnect log if server is still supposed to be running
|
||||
if (isRunning) {
|
||||
setLogEntries((prev) => [
|
||||
...prev,
|
||||
{
|
||||
id: nextLogId++,
|
||||
timestamp: formatTimestamp(new Date()),
|
||||
level: "WARN",
|
||||
source: "desktop",
|
||||
message: "WebSocket disconnected, reconnecting...",
|
||||
},
|
||||
]);
|
||||
|
||||
// Attempt reconnect
|
||||
reconnectTimeoutRef.current = window.setTimeout(connect, WS_RECONNECT_DELAY_MS);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = () => {
|
||||
setLogEntries((prev) => [
|
||||
...prev,
|
||||
{
|
||||
id: nextLogId++,
|
||||
timestamp: formatTimestamp(new Date()),
|
||||
level: "ERROR",
|
||||
source: "desktop",
|
||||
message: "WebSocket connection error",
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
wsRef.current = ws;
|
||||
};
|
||||
|
||||
connect();
|
||||
|
||||
return () => {
|
||||
if (reconnectTimeoutRef.current) {
|
||||
clearTimeout(reconnectTimeoutRef.current);
|
||||
}
|
||||
if (wsRef.current) {
|
||||
wsRef.current.close();
|
||||
wsRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [isRunning, status?.ws_port]);
|
||||
|
||||
const handleClearLog = useCallback(() => setLogEntries([]), []);
|
||||
const handleTogglePause = useCallback(() => setPaused((p) => !p), []);
|
||||
@@ -270,7 +434,7 @@ export const Sensing: React.FC = () => {
|
||||
const handleStart = async () => {
|
||||
setStarting(true);
|
||||
try {
|
||||
await start();
|
||||
await start({ source: dataSource });
|
||||
} finally {
|
||||
setStarting(false);
|
||||
}
|
||||
@@ -349,28 +513,76 @@ export const Sensing: React.FC = () => {
|
||||
{status.pid != null && <span>PID {status.pid}</span>}
|
||||
{status.http_port != null && <span>HTTP :{status.http_port}</span>}
|
||||
{status.ws_port != null && <span>WS :{status.ws_port}</span>}
|
||||
<span style={{ display: "flex", alignItems: "center", gap: 4 }}>
|
||||
<span
|
||||
style={{
|
||||
width: 6,
|
||||
height: 6,
|
||||
borderRadius: "50%",
|
||||
background: wsConnected ? "var(--status-online)" : "var(--status-warning)",
|
||||
}}
|
||||
/>
|
||||
{wsConnected ? "Live" : "Connecting..."}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right: action button */}
|
||||
<button
|
||||
onClick={isRunning ? handleStop : handleStart}
|
||||
disabled={starting || stopping}
|
||||
style={{
|
||||
padding: "var(--space-2) var(--space-4)",
|
||||
borderRadius: 6,
|
||||
fontSize: 13,
|
||||
fontWeight: 600,
|
||||
cursor: starting || stopping ? "not-allowed" : "pointer",
|
||||
border: "none",
|
||||
background: isRunning ? "var(--status-error)" : "var(--accent)",
|
||||
color: "#fff",
|
||||
opacity: starting || stopping ? 0.6 : 1,
|
||||
}}
|
||||
>
|
||||
{starting ? "Starting..." : stopping ? "Stopping..." : isRunning ? "Stop Server" : "Start Server"}
|
||||
</button>
|
||||
{/* Right: data source + action button */}
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "var(--space-3)" }}>
|
||||
{/* Data source selector */}
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "var(--space-2)" }}>
|
||||
<label
|
||||
style={{
|
||||
fontSize: 12,
|
||||
color: "var(--text-muted)",
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
Source:
|
||||
</label>
|
||||
<select
|
||||
value={dataSource}
|
||||
onChange={(e) => setDataSource(e.target.value as DataSource)}
|
||||
disabled={isRunning}
|
||||
style={{
|
||||
padding: "var(--space-1) var(--space-2)",
|
||||
borderRadius: 4,
|
||||
fontSize: 12,
|
||||
fontWeight: 500,
|
||||
border: "1px solid var(--border)",
|
||||
background: isRunning ? "var(--bg-hover)" : "var(--bg-surface)",
|
||||
color: "var(--text-primary)",
|
||||
cursor: isRunning ? "not-allowed" : "pointer",
|
||||
opacity: isRunning ? 0.6 : 1,
|
||||
}}
|
||||
>
|
||||
<option value="simulate">Simulate</option>
|
||||
<option value="esp32">ESP32 (Real)</option>
|
||||
<option value="wifi">WiFi (RSSI)</option>
|
||||
<option value="auto">Auto Detect</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Action button */}
|
||||
<button
|
||||
onClick={isRunning ? handleStop : handleStart}
|
||||
disabled={starting || stopping}
|
||||
style={{
|
||||
padding: "var(--space-2) var(--space-4)",
|
||||
borderRadius: 6,
|
||||
fontSize: 13,
|
||||
fontWeight: 600,
|
||||
cursor: starting || stopping ? "not-allowed" : "pointer",
|
||||
border: "none",
|
||||
background: isRunning ? "var(--status-error)" : "var(--accent)",
|
||||
color: "#fff",
|
||||
opacity: starting || stopping ? 0.6 : 1,
|
||||
}}
|
||||
>
|
||||
{starting ? "Starting..." : stopping ? "Stopping..." : isRunning ? "Stop Server" : "Start Server"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Error display */}
|
||||
|
||||
@@ -170,6 +170,8 @@ export interface WasmModule {
|
||||
// Sensing Server
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type DataSource = "auto" | "wifi" | "esp32" | "simulate";
|
||||
|
||||
export interface ServerConfig {
|
||||
http_port: number;
|
||||
ws_port: number;
|
||||
@@ -177,6 +179,7 @@ export interface ServerConfig {
|
||||
static_dir: string | null;
|
||||
model_dir: string | null;
|
||||
log_level: string;
|
||||
source: DataSource;
|
||||
}
|
||||
|
||||
export interface ServerStatus {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Application version - single source of truth
|
||||
export const APP_VERSION = "0.4.3";
|
||||
+10
-1
@@ -80,7 +80,16 @@ def generate_nvs_binary(csv_content, size):
|
||||
bin_path = csv_path.replace(".csv", ".bin")
|
||||
|
||||
try:
|
||||
# Try the pip-installed version first
|
||||
# Try the pip-installed version first (esp_idf_nvs_partition_gen package)
|
||||
try:
|
||||
from esp_idf_nvs_partition_gen import nvs_partition_gen
|
||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
||||
with open(bin_path, "rb") as f:
|
||||
return f.read()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Try legacy import name (older versions)
|
||||
try:
|
||||
import nvs_partition_gen
|
||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
||||
|
||||
Reference in New Issue
Block a user