Skip to content

Commit 8293aba

Browse files
Merge remote-tracking branch 'origin/dev-frontend-can-processing' into dev-base-frontend
2 parents a812ee5 + 1da584b commit 8293aba

5 files changed

Lines changed: 875465 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ downloads/
1515
eggs/
1616
.eggs/
1717
lib/
18+
!pecan/Frontend/pecan-live-dashboard/src/lib/
1819
lib64/
1920
parts/
2021
sdist/
@@ -218,5 +219,7 @@ ENV/
218219
# Conda artifacts
219220
*.conda
220221
*.tar.bz2
222+
221223
.idea/workspace.xml
222224
/.idea
225+
node_modules/

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,56 @@ daq-radio/
4949
- Transmits data to base station
5050
- Supports both real CAN hardware and CSV simulation
5151

52+
### WebSocket Service Architecture
53+
54+
The frontend uses a **centralized WebSocket service** that runs independently of any component, ensuring continuous data flow across all pages.
55+
56+
#### Location
57+
```
58+
pecan/Frontend/pecan-live-dashboard/src/
59+
├── services/
60+
│ └── WebSocketService.ts # WebSocket connection manager
61+
├── App.tsx # Service initialization
62+
└── pages/
63+
└── Dashboard.tsx # Displays data from DataStore
64+
```
65+
66+
#### How It Works
67+
68+
**1. Service Initialization (App.tsx)**
69+
- WebSocketService starts when the app mounts
70+
- Connects to ESP32 WebSocket server
71+
- Initializes CAN processor with DBC file
72+
- Stays active during entire app session
73+
74+
**2. Message Processing (WebSocketService.ts)**
75+
```
76+
WebSocket Message → CAN Processor → DataStore → React Components
77+
```
78+
79+
**3. Automatic Reconnection**
80+
- Up to 5 reconnection attempts on disconnect
81+
- Linear backoff delay (2s, 4s, 6s, 8s, 10s) TODO: maybe change to exponential
82+
- Seamless recovery from network issues
83+
84+
**4. Component Updates**
85+
- Components use DataStore hooks to access data
86+
- No WebSocket logic in display components
87+
- Clean separation of concerns
88+
89+
#### Benefits
90+
- **Persistent Connection**: WebSocket stays alive across page navigation
91+
- **Centralized Management**: Single point of control for all telemetry data
92+
- **Automatic Recovery**: Handles disconnections gracefully
93+
- **Simpler Components**: Pages focus on display, not data fetching
94+
- **Scalability**: Multiple pages can show live data without multiple connections
95+
96+
#### Development URL
97+
```
98+
Development: ws://localhost:8080/ws
99+
Production: ws://192.168.4.1:8080/ws (ESP32 Access Point)
100+
```
101+
52102
### SavvyCAN Integration
53103
- Real-time CAN monitoring and analysis
54104
- UDP forwarding on port 12347

0 commit comments

Comments
 (0)