This is a comprehensive Java-based server implementation for handling Mobile Digital Video Recorder (MDVR) devices using the N9M protocol. The server provides real-time data collection, storage, and a RESTful API for accessing the data.
- N9M Protocol Support: Complete implementation of the N9M protocol for MDVR communication
- Real-time Data Processing: Live GPS tracking, alarm handling, and device monitoring
- RESTful API: Comprehensive API for querying device data and statistics
- WebSocket Support: Real-time data streaming to web clients
- Database Integration: Persistent storage with JPA/Hibernate
- Security: Authentication and authorization with Spring Security
- Monitoring: Health checks, metrics, and Prometheus integration
- Scalable Architecture: NIO-based server for handling multiple concurrent connections
- Java 17 or higher
- Maven 3.6+
- PostgreSQL (for production) or H2 (for development)
mvn clean packagejava -jar target/mdvr-server-1.0.0.jardocker-compose up -dGET /api/mdvr/devices- Get all connected devicesGET /api/mdvr/devices/{deviceId}/status- Get device status
GET /api/mdvr/devices/{deviceId}/gps- Get GPS data within time rangeGET /api/mdvr/devices/{deviceId}/gps/latest- Get latest GPS positionGET /api/mdvr/devices/{deviceId}/track- Get GPS track/route
GET /api/mdvr/devices/{deviceId}/alarms- Get alarm data within time range
POST /api/mdvr/devices/{deviceId}/commands- Send command to device
GET /api/mdvr/devices/{deviceId}/statistics- Get device statistics
GET /api/mdvr/devices/{deviceId}/export- Export data (JSON/CSV)
GET /api/mdvr/devices/{deviceId}/stream- Server-Sent Events streamWS /ws/mdvr- WebSocket connection for real-time updates
mdvr:
server:
port: 8080 # MDVR protocol port
session-timeout-minutes: 5 # Device session timeout
heartbeat-interval-seconds: 30spring:
datasource:
url: jdbc:postgresql://localhost:5432/mdvr_db
username: mdvr_user
password: mdvr_pass+--------+--------+--------+--------+--------+--------+--------+
| Start | Type | Device ID | Seq | Length | Data |
| Flag | | | Num | | |
| 2B | 1B | 4B | 2B | 2B | var |
+--------+--------+--------+--------+--------+--------+--------+
| Checksum | End Flag |
| 2B | 2B |
+--------+--------+--------+--------+
0x01- LOGIN: Device authentication0x02- HEARTBEAT: Keep-alive message0x03- GPS_DATA: GPS location data0x04- ALARM: Alarm/alert message0x05- VIDEO_REQUEST: Video streaming request0x06- HISTORICAL_DATA: Historical data query0x07- ACK: Acknowledgment0x08- LOGOUT: Device logout
curl http://localhost:8081/actuator/healthcurl http://localhost:8081/actuator/metricsAvailable at: http://localhost:8081/actuator/prometheus
Default credentials:
- Username:
mdvr_user - Password:
password123
Admin credentials:
- Username:
admin - Password:
admin123
mvn testmvn spring-boot:run -Dspring-boot.run.profiles=dev- Update database configuration for your production database
- Configure proper authentication credentials
- Set up SSL/TLS certificates
- Configure firewall rules for ports 8080 (MDVR) and 8081 (API)
- Set up monitoring with Prometheus and Grafana
- Configure log aggregation
- Port conflicts: Ensure ports 8080 and 8081 are available
- Database connection: Verify database credentials and connectivity
- Device authentication: Check N9M protocol implementation
- Memory issues: Adjust JVM heap size with
-Xmxparameter
Application logs are available in:
- Console output (development)
./logs/mdvr-server.log(production)
This project is licensed under the MIT License.