# YKCProtocol **Repository Path**: debuggerSun/ykcprotocol ## Basic Information - **Project Name**: YKCProtocol - **Description**: 云快充1.5 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 4 - **Created**: 2024-12-06 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Cloud Charging Pile Communication Protocol Service An IoT charging pile communication protocol service implementation based on Netty. ## Project Overview This project implements a TCP communication protocol for charging pile devices, supporting functionalities such as device registration, heartbeat detection, real-time data retrieval, charging control, and fee management. Built using the Netty framework to deliver a high-performance asynchronous communication service. ## Technology Stack - Java 8+ - Netty 4.x - Spring Boot 2.x - Lombok ## Core Components ### 1. Communication Encoder/Decoder - `ChargingYunDecoder` - Charging protocol data decoder, supporting custom binary protocol parsing - `ChargingYunEncoder` - Charging protocol data encoder - `MessageDecoder` - Length-field-based frame decoder ### 2. Server Core - `NettyServer` - Netty server startup class managing boss and worker event loop groups - `NettyServerChannelInitializer` - Channel initialization configuration - `NettyServerHandler` - Channel handler processing client connections and messages ### 3. Data Models | Class Name | Description | |------------|-------------| | `NettyMessage` | Protocol message encapsulation class | | `ChargingOrder` | Charging order information | | `Operator` | Operator information | | `UserOrderDto` | User order data transfer object | ### 4. Protocol Constants - `FrameTypeConstant` - Frame type definitions (login, heartbeat, charging control, fee inquiry, etc.) - `DataMapKeyConstant` - Data Map key constants - `NettyConstant` - General Netty constants ### 5. Enumerations - `FrameTypeEnum` - Frame type enumeration - `PileStatusEnum` - Charging pile status enumeration - `StartChargingErrorEnum` - Charging start error enumeration - `DeviceErrorEnum` - Device error enumeration ## Supported Protocol Features - Device login and authentication - Heartbeat keep-alive - Real-time data retrieval - Charging start/stop - Fee model distribution - Offline data synchronization - OTA remote upgrade - Scheduled task configuration - Remote device reboot control ## Configuration Configure the server port in `application.yml`: ```yaml netty: port: 9000 ``` FTP upgrade configuration: ```yaml ftp-server: downloadTimeout: 30000 ``` ## Quick Start 1. Clone the project 2. Configure the database connection in `application-dev.yml` 3. Build with `mvn package` 4. Run the Application class ```bash mvn clean package java -jar target/*.jar ``` ## Directory Structure ``` src/main/java/com/zhitan/netty/ ├── Application.java # Spring Boot startup class ├── ChannelRepository.java # Channel repository management ├── constant/ # Constant definitions ├── decoder/ # Encoder/decoder ├── enums/ # Enumerations ├── server/ # Netty server ├── service/ # Business processing services └── util/ # Utility classes ``` ## Notes - Device ID length defaults to 10 digits - Transaction ID length defaults to 20 digits - CRC16Modbus checksum is used - Supports packet fragmentation; maximum packet index is configurable