Development guide
Development workflow and setup instructions for contributors and developers working on the Veetr project.
For ESP32 implementation details and the BLE protocol, see the firmware README.
Quick Development Setup ⚡
1. Setup Development Environment
git clone https://github.com/veetrlabs/veetr.gitcd veetrcode veetr.code-workspace2. Use VS Code Tasks
The workspace is configured with tasks for development. Access via:
- Ctrl+Shift+P → “Tasks: Run Task” → Select task
- Terminal → “Run Task…” menu
Available tasks:
- Web: Dev Server - Start React development server
- Firmware: Build - Build ESP32 firmware
- Firmware: Upload - Upload firmware to ESP32
- Firmware: Monitor - Open serial monitor
3. Manual Commands
# Web developmentcd app && npm install && npm run dev
# Firmware developmentpio run # Buildpio run --target upload # Upload to ESP32pio device monitor # Serial monitorDevelopment Workflow
Daily Development Process:
- 🌐 Start App Dev Server - Run “App: Dev Server” task or
cd app && npm run dev - ⚡ Build Firmware - Run “Firmware: Build” task or
pio run - 📤 Upload to ESP32 - Run “Firmware: Upload” task or
pio run --target upload - 📺 Monitor Serial - Run “Firmware: Monitor” task or
pio device monitor - 🔘 Activate Discovery - Press and hold BOOT button (GPIO0) for 1+ seconds
- 🔗 Test BLE Connection - Open dashboard and connect to ESP32
Code Organization
Web Application (`/app`)
- React 18 + TypeScript + Vite
- Tailwind CSS for styling
- Web Bluetooth API for BLE communication
- PWA capabilities for mobile installation
ESP32 Firmware (/firmware)
- Arduino Framework via PlatformIO
- NimBLE for Bluetooth Low Energy
- Sensor Integration: GPS, IMU, Wind sensors (hardware specs)
- Communication: UART/I2C/RS485 protocols
PWA Health Monitoring System
The web application includes an advanced health monitoring system designed for long sailing sessions, especially on Android tablets:
Automatic Monitoring Features:
- Memory Management: Monitors JavaScript heap usage and triggers garbage collection when >80%
- BLE Connection Watchdog: Detects disconnected devices and attempts automatic reconnection
- Long Session Tracking: Special monitoring for sessions >1 hour with detailed logging
- Service Worker Health: Monitors PWA service worker status and cache integrity
- Background Cleanup: Handles stale connections and prevents memory leaks
Recovery Systems:
- Automatic Recovery: Proactive garbage collection and connection cleanup
- Manual Recovery Tools: User-accessible PWA refresh and diagnostics
- Progressive Escalation: Failure count tracking with escalating recovery options
- Connection Diagnostics: Detailed BLE and PWA status logging for troubleshooting
Implementation Details:
- Health checks run every 60 seconds when in PWA standalone mode
- Only activates on installed PWAs to avoid overhead in browser mode
- Comprehensive error handling prevents monitoring system from causing issues
- Detailed console logging for debugging Android tablet stability issues
Development Tasks
Web Development
# Start development servernpm run dev
# Build for productionnpm run build
# Preview production buildnpm run preview
# Run lintingnpm run lint
# Format codenpm run formatFirmware Development
# Build firmwarepio run
# Upload to ESP32pio run --target upload
# Monitor serial outputpio device monitor
# Clean build filespio run --target clean
# Upload filesystem (if needed)pio run --target uploadfsTesting Workflow
Hardware Testing:
- Build and upload firmware to ESP32
- Activate BLE discovery mode (BOOT button)
- Connect via web dashboard
- Verify sensor data streams
- Test configuration commands
Web Testing:
- Start development server
- Test in Chrome/Edge (Web Bluetooth supported)
- Verify PWA installation
- Test responsive design on mobile devices
- Validate BLE connectivity
Code Quality
Pre-commit Checklist:
- Code passes TypeScript compilation
- Firmware builds without errors
- No console errors in web browser
- BLE communication works
- Responsive design validated
- Documentation updated if needed
Standards:
- TypeScript: Strict mode enabled
- ESLint: Configured for React/TypeScript
- Prettier: Code formatting
- Git: Conventional commit messages
Debugging Tips
Web Dashboard:
- Use Chrome DevTools for Web Bluetooth debugging
- Check Network tab for PWA service worker issues
- Console shows BLE connection status and errors
ESP32 Firmware:
- Serial monitor shows sensor readings and BLE status
- Built-in LED indicates discovery mode status
- Watchdog timer prevents system hangs
Common Issues:
- BLE not found: Activate discovery mode on ESP32
- Build errors: Check PlatformIO installation
- Web not connecting: Ensure HTTPS or localhost
- Sensor errors: Check wiring and power supply
Contributing
Pull Request Process:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Make changes and test thoroughly
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Code Review:
- All code changes require review
- Tests must pass
- Documentation must be updated
- Hardware changes need validation
Development Environment
Recommended VS Code Extensions:
- PlatformIO IDE - ESP32 development
- TypeScript and JavaScript Language Features
- Tailwind CSS IntelliSense
- Prettier - Code formatting
- GitLens - Git integration
- Auto Rename Tag - HTML/JSX editing
- Bracket Pair Colorizer - Code readability
System Requirements:
- Node.js v16+ (for app development)
- Python 3.7+ (for PlatformIO)
- Git (version control)
- USB drivers for ESP32 (platform specific)
This development guide provides everything needed for productive Veetr development!