SHEapDeviceSDK 5.2.2

dotnet add package SHEapDeviceSDK --version 5.2.2
                    
NuGet\Install-Package SHEapDeviceSDK -Version 5.2.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SHEapDeviceSDK" Version="5.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SHEapDeviceSDK" Version="5.2.2" />
                    
Directory.Packages.props
<PackageReference Include="SHEapDeviceSDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SHEapDeviceSDK --version 5.2.2
                    
#r "nuget: SHEapDeviceSDK, 5.2.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SHEapDeviceSDK@5.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SHEapDeviceSDK&version=5.2.2
                    
Install as a Cake Addin
#tool nuget:?package=SHEapDeviceSDK&version=5.2.2
                    
Install as a Cake Tool

SHEapDeviceSDK

EAP TCP 设备端 C# SDK,用于快速集成 EAP TCP 通讯协议 v5.2。

特性

  • 支持 .NET 8.0.NET Framework 4.8 双目标框架
  • 设备作为 TCP Server,EAP 系统作为客户端连接
  • 支持 7 大类 70+ 种消息类型
  • 完整的序列化/反序列化支持
  • 心跳监控和连接管理
  • 状态管理和配方管理
  • 结构化日志(Serilog)

安装

dotnet add package SHEapDeviceSDK

快速开始

1. 创建设备服务端

using EAP.Device.SDK.Server;
using EAP.Device.SDK.Serialization;
using Microsoft.Extensions.Logging;

// 创建消息序列化器
var serializer = new MessageSerializer(logger);

// 创建设备服务端
var server = new TcpDeviceServer(serializer, logger);

// 订阅消息事件
server.MessageReceived += (sender, e) =>
{
    Console.WriteLine($"收到消息: {e.Message.MessageType}");
};

// 启动服务端
await server.StartAsync(8080);

2. 处理消息

server.MessageReceived += async (sender, e) =>
{
    // 处理读取请求
    if (e.Message is ReadRequestMessage request)
    {
        var response = new ReadResponseMessage
        {
            Data = new ReadResponseData
            {
                RequestId = request.Data.RequestId,
                Success = true,
                Value = "25.5"
            }
        };
        await server.SendMessageAsync(e.ClientId, response);
    }
};

消息类型

类别 描述 消息数量
连接管理 握手、心跳 4
数据读写 变量读取/写入 8
订阅管理 变量订阅/取消 8
事件推送 事件/报警推送 6
远程命令 命令执行 4
配方管理 配方上传/下载 8
状态管理 状态查询/变更 6

文档

许可证

MIT License

更新日志

v5.2.2

  • 安全修复:升级 System.Text.Json 到 6.0.10(修复 CVE-2024-43485)

v5.2.1

  • 新增 .NET Framework 4.8 支持

v5.2.0

  • 升级到 EAP TCP 协议 v5.2
  • 新增状态管理功能
  • 扩展到 70+ 种消息类型
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.2.2 96 1/14/2026
5.2.0 411 11/19/2025
1.0.0 409 11/19/2025

v5.2.2:
     - 🔒 安全修复:升级 System.Text.Json 从 6.0.0 到 6.0.10(修复 CVE-2024-43485 DoS 漏洞)
     - 确保 .NET Framework 4.8 目标框架使用安全的依赖版本

     v5.2.1:
     - 新增 .NET Framework 4.8 支持(多目标框架:net8.0 和 net48)
     - 为 .NET Framework 4.8 实现自定义 CRC32 算法(替代 System.IO.Hashing)
     - 添加网络 API 兼容性扩展方法(TcpClient、Stream、TcpListener)
     - 优化 BitConverter 调用以兼容不同框架

     v5.2.0:
     - 升级到 EAP TCP 协议 v5.2
     - 新增状态管理功能(StateChangeRequest/Response, StateQueryRequest/Response, StatePush)
     - 优化配方管理(RecipeUpload/Download,编码更新为 0x60-0x63)
     - 扩展到 70+ 种消息类型
     - 改进序列化性能和错误处理
     - 完善心跳监控和连接管理
     - 增强调试支持(SourceLink 和符号包)

     v1.0.0:
     - 首次发布
     - 支持 EAP TCP 协议 v4.1
     - 基础消息类型支持