diff --git a/docs/资料/物联网中心/设备接入/飞比/zlltest.zip b/docs/资料/物联网中心/设备接入/飞比/zlltest.zip deleted file mode 100644 index edfe9abb..00000000 Binary files a/docs/资料/物联网中心/设备接入/飞比/zlltest.zip and /dev/null differ diff --git a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs index c278dc08..ac619c09 100644 --- a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs +++ b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs @@ -54,5 +54,6 @@ namespace Application.Domain.Entities public int Hue { get; set; } public int Saturation { get; set; } public int ColorTemperature { get; set; } + public string IRVersion { get; set; } } } \ No newline at end of file diff --git a/projects/IoT/IoTServices/FBeeService/Controllers/HomeController.cs b/projects/IoT/IoTServices/FBeeService/Controllers/HomeController.cs index 22fc23de..fbfe3fbb 100644 --- a/projects/IoT/IoTServices/FBeeService/Controllers/HomeController.cs +++ b/projects/IoT/IoTServices/FBeeService/Controllers/HomeController.cs @@ -308,6 +308,27 @@ namespace FBeeService.Controllers #endregion colorlight + #region IR + + [SwaggerOperation("版本")] + [HttpGet] + [Route("/ir/version")] + public ApiResponse Version([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id) + { + try + { + this._deviceService.XA70080(sn, id); + } + catch (Exception ex) + { + ex.PrintStack(); + return ApiResponse.Error(ex.Message); + } + return ApiResponse.AsyncSuccess(); + } + + #endregion IR + #region tools private string GetApiJson(string prefix) diff --git a/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs b/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs index 004ef0ea..9ca97b21 100644 --- a/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs +++ b/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs @@ -93,7 +93,7 @@ namespace FBeeService } /// - /// 接收当前连接的设备信息 + /// 接收当前连接的设备信息返回值 /// /// /// @@ -187,7 +187,7 @@ namespace FBeeService var list = new List(); list.AddRange(ieee.HexToBytes()); list.Add(0x01); - this.Write(sn, RequestType.x95, ieee, list, false); + this.Write(sn, RequestType.x95, ieee, list); } //0x94更改指定设备名 @@ -467,6 +467,20 @@ namespace FBeeService } } + public void XA70080(string sn, string ieee) + { + var list = new List(); + list.Add(0x03); + list.Add(0xff); + list.Add(0x00); + list.AddRange(new byte[] { 0x55, 0x55 }); + list.Add(0x02); + list.AddRange(new byte[] { 0x80, 0x00 }); + list.Add(0x82); + list[1] = (byte)(list.Count() - 3); + this.Write(sn, RequestType.xa7, ieee, list, 1); + } + //0xa9 //0xab ///// @@ -609,8 +623,12 @@ namespace FBeeService //device.PM10 = BitConverter.ToInt16(props[0x003e]); device.Voltage = props[0x21][0] / 2f; } - if (device.DeviceId == 0x0220) + if (device.DeviceId == 0x0163) { + if (props.ContainsKey(0x400a)) + { + device.IRVersion = BitConverter.ToString((props[0x400a].Skip(3).Take(6).ToArray())).Replace("-", "").ToLower(); + } } deviceRepo.SaveChanges(); } @@ -835,30 +853,40 @@ namespace FBeeService } } - private void Write(string sn, byte commandType, string ieee = null, List command = null, bool needEndPoint = true, byte addressType = 0x02) + private void Write(string sn, byte commandType, string ieee = null, List command = null, int format = 0, byte addressType = 0x02) { this.Clients.TryGetValue(sn, out TcpClientWrapper client); var data = new List(); - data.AddRange(sn.HexToBytes().Reverse()); - data.Add(RequestType.xfe); - data.Add(commandType); + data.AddRange(sn.HexToBytes().Reverse());//sn号 + data.Add(RequestType.xfe);//控制标志 + data.Add(commandType);//控制类型 if (command != null && command.Count > 0) { - data.Add((byte)(command.Count() + 13)); - data.Add(addressType); using (var scope = _applicationServices.CreateScope()) { var repo = scope.ServiceProvider.GetService>(); var device = repo.ReadOnlyTable().FirstOrDefault(o => o.Sn == sn && o.IEEE == ieee); - data.AddRange(device.Address.HexToBytes().Reverse()); - data.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); - data.Add((byte)device.Endpoint); - data.AddRange(new byte[] { 0x00, 0x00 }); + if (format == 0) + { + data.Add((byte)(command.Count() + 1 + 2 + 6 + 1 + 2));//数据总长 + data.Add(addressType);//地址模式 + data.AddRange(device.Address.HexToBytes().Reverse()); + data.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); + data.Add((byte)device.Endpoint); + data.AddRange(new byte[] { 0x00, 0x00 }); + data.AddRange(command); + } + else if (format == 1) + { + data.Add((byte)(command.Count() + 2 + 1));//数据总长 + data.AddRange(device.Address.HexToBytes().Reverse()); + data.Add((byte)device.Endpoint); + data.AddRange(command); + } } - data.AddRange(command); } - var head = BitConverter.GetBytes(data.Count() + 2).ToList(); + var head = BitConverter.GetBytes(data.Count() + 2).ToList();//消息总长 if (BitConverter.IsLittleEndian) { head.Reverse(); diff --git a/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml b/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml index 13725bb1..f8dde36f 100644 --- a/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml +++ b/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml @@ -66,6 +66,13 @@ 饱和度:@item.Saturation 色温:@item.ColorTemperature } + else if (item.DeviceId == 0x0163) + { + if (!string.IsNullOrEmpty(item.IRVersion)) + { + 版本:@item.IRVersion + } + } @if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(item.DeviceId)) @@ -79,7 +86,7 @@ } @if (item.DeviceId == 0x0163) { - 查询 + 版本 } @if (item.DeviceId == 0x0220) { @@ -99,7 +106,6 @@ - } 删除设备