Skip to content

subhromoitrafreelancer/mdvr-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MDVR N9M Protocol Server

Overview

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.

Features

  • 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

Quick Start

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • PostgreSQL (for production) or H2 (for development)

Building the Application

mvn clean package

Running the Application

java -jar target/mdvr-server-1.0.0.jar

Using Docker

docker-compose up -d

API Endpoints

Device Management

  • GET /api/mdvr/devices - Get all connected devices
  • GET /api/mdvr/devices/{deviceId}/status - Get device status

GPS Data

  • GET /api/mdvr/devices/{deviceId}/gps - Get GPS data within time range
  • GET /api/mdvr/devices/{deviceId}/gps/latest - Get latest GPS position
  • GET /api/mdvr/devices/{deviceId}/track - Get GPS track/route

Alarms

  • GET /api/mdvr/devices/{deviceId}/alarms - Get alarm data within time range

Commands

  • POST /api/mdvr/devices/{deviceId}/commands - Send command to device

Statistics

  • GET /api/mdvr/devices/{deviceId}/statistics - Get device statistics

Data Export

  • GET /api/mdvr/devices/{deviceId}/export - Export data (JSON/CSV)

Real-time Streaming

  • GET /api/mdvr/devices/{deviceId}/stream - Server-Sent Events stream
  • WS /ws/mdvr - WebSocket connection for real-time updates

Configuration

Application Properties

mdvr:
  server:
    port: 8080                    # MDVR protocol port
    session-timeout-minutes: 5   # Device session timeout
    heartbeat-interval-seconds: 30

Database Configuration

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/mdvr_db
    username: mdvr_user
    password: mdvr_pass

N9M Protocol Details

Message Structure

+--------+--------+--------+--------+--------+--------+--------+
| Start  | Type   | Device ID      | Seq    | Length | Data   |
| Flag   |        |                | Num    |        |        |
| 2B     | 1B     | 4B             | 2B     | 2B     | var    |
+--------+--------+--------+--------+--------+--------+--------+
| Checksum       | End Flag        |
| 2B             | 2B              |
+--------+--------+--------+--------+

Message Types

  • 0x01 - LOGIN: Device authentication
  • 0x02 - HEARTBEAT: Keep-alive message
  • 0x03 - GPS_DATA: GPS location data
  • 0x04 - ALARM: Alarm/alert message
  • 0x05 - VIDEO_REQUEST: Video streaming request
  • 0x06 - HISTORICAL_DATA: Historical data query
  • 0x07 - ACK: Acknowledgment
  • 0x08 - LOGOUT: Device logout

Monitoring and Health

Health Check

curl http://localhost:8081/actuator/health

Metrics

curl http://localhost:8081/actuator/metrics

Prometheus Metrics

Available at: http://localhost:8081/actuator/prometheus

Security

Default credentials:

  • Username: mdvr_user
  • Password: password123

Admin credentials:

  • Username: admin
  • Password: admin123

Development

Running Tests

mvn test

Local Development

mvn spring-boot:run -Dspring-boot.run.profiles=dev

Production Deployment

  1. Update database configuration for your production database
  2. Configure proper authentication credentials
  3. Set up SSL/TLS certificates
  4. Configure firewall rules for ports 8080 (MDVR) and 8081 (API)
  5. Set up monitoring with Prometheus and Grafana
  6. Configure log aggregation

Troubleshooting

Common Issues

  1. Port conflicts: Ensure ports 8080 and 8081 are available
  2. Database connection: Verify database credentials and connectivity
  3. Device authentication: Check N9M protocol implementation
  4. Memory issues: Adjust JVM heap size with -Xmx parameter

Logs

Application logs are available in:

  • Console output (development)
  • ./logs/mdvr-server.log (production)

License

This project is licensed under the MIT License.

About

MDVR, N9M, Streamax device server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors