From 0273e05c6e993804e49e9444635fb23ce7c0c0cd Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 15 Apr 2021 16:14:39 +0800 Subject: [PATCH] 2.0 Former-commit-id: 878de8933a17ec1901a6b6a4533d4711dcf09d37 Former-commit-id: 05e6cc47ab6cf1ce5a68e223630348d8730a47c7 --- .../DeviceServices/FBee/FBeeService.cs | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs index e6f65101..51a2a08d 100644 --- a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs +++ b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs @@ -561,7 +561,7 @@ namespace IoTNode.DeviceServices.FBee { if (props.ContainsKey(0x0021)) { - this.UpdateIoTData(device.Id, DataKeys.Battery,Convert.ToInt32(props[0x21][0])/100f); + this.UpdateIoTData(device.Id, DataKeys.Battery, Convert.ToInt32(props[0x21][0]) / 100f); } else if (props.ContainsKey(0x003e)) { @@ -593,6 +593,9 @@ namespace IoTNode.DeviceServices.FBee this._logger.LogError($"data length must be 8 but now is {tempBytes.Count}"); } } + else if (props.TryGetValue(0x0300, out item))//单位 + { + } else if (props.TryGetValue(0x0301, out item))//总量乘数 { var value = BitConverter.ToUInt16(item); @@ -603,6 +606,11 @@ namespace IoTNode.DeviceServices.FBee var value = BitConverter.ToUInt16(item); this.UpdateIoTData(device.Id, DataKeys.ElectricityDivisor, value); } + else if (props.TryGetValue(0x0400, out item))//查询 + { + var ieee = device.Number; + this.X8D0702ReadValue(sn, ieee); + } } else if (clusterId == ClusterId.doorlock) { @@ -753,7 +761,7 @@ namespace IoTNode.DeviceServices.FBee //var FbeeDeviceId = fbeeDeviceId.ToString("x2"); Console.WriteLine(deviceName); byte[] item; - + if (props.TryGetValue(0x0505, out item))//电压 { var value = BitConverter.ToUInt16(item); @@ -992,7 +1000,7 @@ namespace IoTNode.DeviceServices.FBee //插座 this.UpdateIoTData(device.Id, DataKeys.PowerState, switchState); } - else if(endpoint==0x0b) + else if (endpoint == 0x0b) { //调色灯 this.UpdateIoTData(device.Id, DataKeys.PowerState, switchState); @@ -1005,7 +1013,7 @@ namespace IoTNode.DeviceServices.FBee else if (endpoint == 0x10) { //开关 - if (device.Name.Contains("二路") || device.Name.Contains("三路")) + if (device.Name.Contains("二路") || device.Name.Contains("三路")) { this.UpdateIoTData(device.Id, DataKeys.L1State, switchState); } @@ -1177,15 +1185,23 @@ namespace IoTNode.DeviceServices.FBee /// 0x8d-0x70发送zcl指令,读取簇id为0702的电量、电功率 /// public void X8D0702(string sn, string ieee) + { + this.X8D0702ReadParameter(sn, ieee); + this.X8D0702ReadValue(sn, ieee); + } + + private void X8D0702ReadParameter(string sn, string ieee) { this.Write(sn, RequestType.x8d, ieee, new List() { 0x02, 0x07, 0x01, 0x03, 0x00 }, 3);//0301电量乘数 this.Write(sn, RequestType.x8d, ieee, new List() { 0x02, 0x07, 0x02, 0x03, 0x00 }, 3);//0302电量除数 this.Write(sn, RequestType.x8d, ieee, new List() { 0x04, 0x0b, 0x04, 0x06, 0x00 }, 3);//0604功率乘数 this.Write(sn, RequestType.x8d, ieee, new List() { 0x04, 0x0b, 0x05, 0x06, 0x00 }, 3);//0605功率除数 - this.Write(sn, RequestType.xa7, ieee, new List() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 2);//0000电量 - this.Write(sn, RequestType.xa7, ieee, new List() { 0x02, 0x07, 0x0b, 0x05, 0x00 }, 2);//050b功率 } - + private void X8D0702ReadValue(string sn, string ieee) + { + this.Write(sn, RequestType.x8d, ieee, new List() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 3);//0000电量 + this.Write(sn, RequestType.x8d, ieee, new List() { 0x04, 0x0b, 0x0b, 0x05, 0x00 }, 3);//050b功率 + } // //0x96 //0x8e