Browse Source

增加809加密参数解析

pull/3/head
SmallChi(Koike) 5 years ago
parent
commit
3c4967c058
2 changed files with 37 additions and 2 deletions
  1. +23
    -2
      src/JTTools/Controllers/JTToolsController.cs
  2. +14
    -0
      src/JTTools/Dtos/JT809RequestDto.cs

+ 23
- 2
src/JTTools/Controllers/JTToolsController.cs View File

@@ -61,13 +61,24 @@ namespace JTTools.Controllers

[Route("Parse809")]
[HttpPost]
public ActionResult<JTResultDto> Parse809([FromBody]JTRequestDto parameter)
public ActionResult<JTResultDto> Parse809([FromBody]JT809RequestDto parameter)
{
JTResultDto jTResultDto = new JTResultDto();
try
{
if (parameter.IsEncrypt)
{
IJT809Config jt809ConfigInternal = new JT809Config(Guid.NewGuid().ToString());
jt809ConfigInternal.EncryptOptions = parameter.EncryptOptions;
JT809Serializer jT809SerializerInternal = new JT809Serializer(jt809ConfigInternal);
jTResultDto.Data = jT809SerializerInternal.Deserialize(parameter.HexData.ToHexBytes());
}
else
{
jTResultDto.Data = jT809Serializer.Deserialize(parameter.HexData.ToHexBytes());
}
jTResultDto.Code = 200;
jTResultDto.Data = jT809Serializer.Deserialize(parameter.HexData.ToHexBytes());
}
catch (JT809Exception ex)
{
@@ -100,4 +111,14 @@ namespace JTTools.Controllers
return jTResultDto;
}
}

class JT809Config : JT809.Protocol.Interfaces.GlobalConfigBase
{
public JT809Config(string configId)
{
ConfigId = configId;
}

public override string ConfigId { get; }
}
}

+ 14
- 0
src/JTTools/Dtos/JT809RequestDto.cs View File

@@ -0,0 +1,14 @@
using JT809.Protocol.Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JTTools.Dtos
{
public class JT809RequestDto: JTRequestDto
{
public bool IsEncrypt { get; set; } = false;
public JT809EncryptOptions EncryptOptions { get; set; }
}
}

Loading…
Cancel
Save