diff --git a/projects/Infrastructure/Web/BaseStartup.cs b/projects/Infrastructure/Web/BaseStartup.cs index be2740c4..b1b8e703 100644 --- a/projects/Infrastructure/Web/BaseStartup.cs +++ b/projects/Infrastructure/Web/BaseStartup.cs @@ -293,7 +293,7 @@ namespace Infrastructure.Web { if (!context.Request.IsStatic()) { - Debug.WriteLine(context.Request.Path); + //Debug.WriteLine(context.Request.Path); if (context.Request.Query.ContainsKey("access_token")) { context.Token = context.Request.Query["access_token"]; diff --git a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs index bba556a2..6c2dc490 100644 --- a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs +++ b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs @@ -193,6 +193,7 @@ namespace IoTNode.DeviceServices.FBee Clients.TryGetValue(gateway.Number, out TcpClientWrapper client); if (client.Ip != gateway.Ip) { + client.Ip = gateway.Ip; this.Connect(client); } else @@ -687,7 +688,7 @@ namespace IoTNode.DeviceServices.FBee } else if (deviceId == 0x0051) { - //this.X8D07020000(sn, ieee); + this.X8D07020000(sn, ieee); } } catch (Exception ex) @@ -950,8 +951,8 @@ namespace IoTNode.DeviceServices.FBee /// public void X8D07020000(string sn, string ieee) { - var list = new List() { 0x02, 0x07, 0x00, 0x00, 0x00 }; - this.Write(sn, RequestType.xa7, ieee, list, 2); + this.Write(sn, RequestType.xa7, ieee, new List() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 2); + this.Write(sn, RequestType.xa7, ieee, new List() { 0x02, 0x07, 0x0b, 0x05, 0x00 }, 2); } // @@ -1364,6 +1365,26 @@ namespace IoTNode.DeviceServices.FBee } else if (deviceId == 0x0051) { + foreach (var item in props) + { + if (item.Key == 0x0000) + { + var tempBytes = new List(); + tempBytes.AddRange(item.Value); + tempBytes.Add(0x00); + tempBytes.Add(0x00); + var electricity = BitConverter.ToUInt64(tempBytes.ToArray()) / 10000f; + System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~electricity:{electricity}"); + this.UpdateData(deviceRepo, device, device.CreateData(Keys.Electricity, electricity.ToString("f2"), DeviceDataType.Float, "电量", "kWh", timestamp: timestamp)); + } + else if (item.Key == 0x050b) + { + var power = BitConverter.ToUInt16(item.Value.ToArray()); + System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~power:{power}"); + this.UpdateData(deviceRepo, device, device.CreateData(Keys.Power, power, DeviceDataType.Float, "功率", "W", timestamp: timestamp)); + } + System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~{item.Key.ToString("X")}:{System.BitConverter.ToString(item.Value)}"); + } if (clusterId == ClusterId.SummationDivisor) { this.X8D07020000(sn, device.Number); diff --git a/projects/IoTNode/DeviceServices/FBee/Keys.cs b/projects/IoTNode/DeviceServices/FBee/Keys.cs index 85fb91fd..1243bf40 100644 --- a/projects/IoTNode/DeviceServices/FBee/Keys.cs +++ b/projects/IoTNode/DeviceServices/FBee/Keys.cs @@ -7,6 +7,7 @@ public const string EndPoint = "EndPoint"; public const string Version = "Version"; public const string Electricity = "Electricity"; + public const string Power = "Power"; public const string KeyPress = "KeyPress"; public const string State = "State"; public const string L1State = "L1State"; diff --git a/projects/IoTNode/IoTNode.csproj b/projects/IoTNode/IoTNode.csproj index 3e12a44f..7931462d 100644 --- a/projects/IoTNode/IoTNode.csproj +++ b/projects/IoTNode/IoTNode.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 true - 1.0.0-beta.402 + 1.0.0-beta.403.1