diff --git a/projects/Demo/Demo.iOS/Controls/SampleBufferDelegate.cs b/projects/Demo/Demo.iOS/Controls/SampleBufferDelegate.cs index a9b64f94..f25d4df0 100644 --- a/projects/Demo/Demo.iOS/Controls/SampleBufferDelegate.cs +++ b/projects/Demo/Demo.iOS/Controls/SampleBufferDelegate.cs @@ -2,7 +2,6 @@ using CoreGraphics; using CoreMedia; using CoreVideo; -using Foundation; using SkiaSharp.Views.iOS; using System; using System.IO; diff --git a/projects/Demo/Demo.iOS/Controls/UICameraPreview.cs b/projects/Demo/Demo.iOS/Controls/UICameraPreview.cs index 1b297849..3a2e1431 100644 --- a/projects/Demo/Demo.iOS/Controls/UICameraPreview.cs +++ b/projects/Demo/Demo.iOS/Controls/UICameraPreview.cs @@ -4,7 +4,6 @@ using CoreGraphics; using CoreVideo; using Demo.Controls; using Foundation; -using System; using System.Linq; using UIKit; @@ -49,8 +48,7 @@ namespace Demo.iOS.Controls { return; } - NSError error; - var input = new AVCaptureDeviceInput(device, out error); + var input = new AVCaptureDeviceInput(device, out NSError error); CaptureSession.AddInput(input); // @@ -59,7 +57,6 @@ namespace Demo.iOS.Controls output.SetSampleBufferDelegateQueue(new SampleBufferDelegate(), new DispatchQueue("myQueue")); CaptureSession.AddOutput(output); // - Layer.AddSublayer(previewLayer); CaptureSession.StartRunning(); IsPreviewing = true; diff --git a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/DeviceId.cs b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/DeviceId.cs index 1bdbec03..87214267 100644 --- a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/DeviceId.cs +++ b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/DeviceId.cs @@ -9,7 +9,13 @@ namespace Application.Domain.Entities static DeviceId() { - List.Add(new DeviceId { Name = "外挂式插座", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Smart plug", RawDeviceId = 0x0051 }); + List.Add(new DeviceId { RawDeviceId = 0x0002, Name = "0x0002", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "On/Off Output" }); + List.Add(new DeviceId { RawDeviceId = 0x0009, Name = "0x0009", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Mains Power Outlet" }); + List.Add(new DeviceId { RawDeviceId = 0x0051, Name = "0x0051", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Smart plug" }); + List.Add(new DeviceId { RawDeviceId = 0x0106, Name = "0x0106", Category = "传感器", Icon = "socket", RawCategory = "Lighting", EName = "Light Sensor" }); + List.Add(new DeviceId { RawDeviceId = 0x0202, Name = "0x0202", Category = "电器", Icon = "socket", RawCategory = "Closures", EName = "Window Covering Device" }); + List.Add(new DeviceId { RawDeviceId = 0x0309, Name = "0x0309", Category = "传感器", Icon = "socket", RawCategory = "HVAC", EName = "PM2.5 Sensor" }); + List.Add(new DeviceId { RawDeviceId = 0x0402, Name = "0x0402", Category = "传感器", Icon = "socket", RawCategory = "Intruder Alarm Systems", EName = "IAS Zone" }); } public string Name { get; set; } diff --git a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs index 93514c3b..208c2b49 100644 --- a/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs +++ b/projects/IoT/IoTServices/FBeeService/Application/Domain/Entities/FBeeDevice.cs @@ -13,15 +13,17 @@ namespace Application.Domain.Entities public int Endpoint { get; set; } public int ProfileId { get; set; } public int DeviceId { get; set; } - public int Status { get; set; } + public int SwitchState { get; set; } public int NameLength { get; set; } public string CName { get; set; } - public int Online { get; set; } + public int IsOnline { get; set; } public string IEEE { get; set; } public int SNLength { get; set; } public string RawSN { get; set; } public int ZoneType { get; set; } - public int Power { get; set; } + public int Battery { get; set; } + public int EpCount { get; set; } + public string Data { get; set; } public string Safe { get; set; } public string RawValue { get; set; } diff --git a/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs b/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs index cf1ec0ce..c68803ec 100644 --- a/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs +++ b/projects/IoT/IoTServices/FBeeService/Infrastructure/DeviceService.cs @@ -135,17 +135,20 @@ namespace FBeeService device.Endpoint = endpoint; device.ProfileId = profileId; device.DeviceId = deviceId; - device.Status = ms.ReadByte(); + device.SwitchState = ms.ReadByte(); device.NameLength = ms.ReadByte(); - device.CName = ms.ReadASIIString(device.NameLength); - device.Online = ms.ReadByte(); + if (device.NameLength > 0) + { + device.CName = ms.ReadASIIString(device.NameLength); + } + device.IsOnline = ms.ReadByte(); device.IEEE = ms.ReadHexString(8); device.SNLength = ms.ReadByte(); device.RawSN = ms.ReadHexString(device.SNLength); - device.ZoneType = ms.ReadByte(); - device.Power = ms.ReadByte(); + device.ZoneType = ms.ReadInt(); + device.Battery = ms.ReadByte(); + device.EpCount = ms.ReadByte(); device.Data = ms.ReadHexString(4); - device.Safe = ms.ReadHexString(2); device.RawValue = BitConverter.ToString(data); deviceRepo.SaveChanges(); } @@ -164,7 +167,7 @@ namespace FBeeService using (var scope = _applicationServices.CreateScope()) { var repo = scope.ServiceProvider.GetService>(); - var device = repo.ReadOnlyTable().FirstOrDefault(o => o.Online != 0 && o.IEEE == ieee); + var device = repo.ReadOnlyTable().FirstOrDefault(o => o.IsOnline != 0 && o.IEEE == ieee); var address = device.Address; var list = new List(); list.Add(0x0c); @@ -197,7 +200,7 @@ namespace FBeeService list.Add(0x02); list.AddRange(address.HexToBytes()); list.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); - list.Add(0x01); + list.Add((byte)device.Endpoint); list.AddRange(new byte[] { 0x00, 0x00 }); list.Add(status); this.Write(sn, RequestType.x82, list); @@ -224,7 +227,7 @@ namespace FBeeService var device = deviceRepo.Table().FirstOrDefault(o => o.Sn == sn && o.Address == address); if (device != null) { - device.Power = ms.ReadInt(); + device.SwitchState = ms.ReadInt(); deviceRepo.SaveChanges(); } else @@ -412,7 +415,15 @@ namespace FBeeService } else { - propDataLength = Convert.ToInt32(Regex.Match(propDataType.GetName(), @"\d+").Groups[1].Value); + try + { + propDataLength = Convert.ToInt32(Regex.Match(propDataType.GetName(), @"(\d+)$").Groups[1].Value); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + propDataLength = 1; + } } } else diff --git a/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml b/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml index df8eded6..d1b332a3 100644 --- a/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml +++ b/projects/IoT/IoTServices/FBeeService/Views/Home/Gateway.cshtml @@ -1,17 +1,21 @@ @model List @{ this.HtmlTitle = "设备列表"; + var index = 0; }
+ + + - + @@ -19,14 +23,18 @@ @foreach (var item in Model) { + + + - - + + +
Sn编号 IEEE地址 地址EP 名称英文名称 分类 分类编号电源开关电量 在线 开关 删除
@(++index) @item.Sn @item.IEEE @item.Address@item.Endpoint @item.Name@item.EName @item.CategoryName @item.CategoryNumber@item.Battery @item.SwitchState diff --git a/projects/IoT/IoTServices/FBeeService/appsettings.Development.json b/projects/IoT/IoTServices/FBeeService/appsettings.Development.json index e203e940..bb0aceca 100644 --- a/projects/IoT/IoTServices/FBeeService/appsettings.Development.json +++ b/projects/IoT/IoTServices/FBeeService/appsettings.Development.json @@ -5,5 +5,6 @@ "System": "Information", "Microsoft": "Information" } - } -} + }, + "UseMiniProfiler": false +}. \ No newline at end of file