1.0.0.20101901

Former-commit-id: 8ad24cfb5d53aa6319fe638e183f948262e192c2
Former-commit-id: 14b1af628645dd3e0a3b84ad0f67b75f22c617c2
TSXN
wanggang 5 years ago
parent a15166e652
commit c6b5d2ec69

@ -58,6 +58,7 @@ namespace IoTCenter.Controllers
#if DEBUG
[Route("/license")]
[AllowAnonymous]
public IActionResult License(string mac)
{
return Content(Helper.Instance.MacEncrypt(mac));

@ -215,7 +215,7 @@ namespace IoTDameon
this.Log(command.Bash());
this.Log($"修改权限:{updateScript}");
this.Log(updateScript.Bash());
this.Log($"执行更脚本:{updateScript}");
this.Log($"执行更脚本:{updateScript}");
}
//启动更新程序
proxy.startProcess(processName);

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.20092701")]
[assembly: AssemblyInformationalVersion("1.0.0.20101601")]

@ -1,6 +1,7 @@
using Application.Domain.Entities;
using Application.Domain.Entities;
using Infrastructure.Application.Services.Settings;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web;
using IoT.Shared.Services;
using Microsoft.AspNetCore.Authorization;
@ -60,5 +61,15 @@ namespace IoTNode.Controllers
{
return Content(this._settingService.GetSetting("notify:host").Value?.Trim());
}
#if DEBUG
[AllowAnonymous]
public IActionResult Test(string id)
{
return Content(Helper.Instance.MacEncrypt(id));
}
#endif
}
}

@ -45,13 +45,13 @@ namespace IoTNode.Controllers
});
}
//[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("删除指定设备")]
//public ApiResponse X95([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
//{
// return this.AsyncAction(() =>
// {
// this._deviceService.X95(gateway, number);
// });
//}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X95([SwaggerParameter("网关编号")] string gateway, [SwaggerParameter("设备编号")] string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X95(gateway, number);
});
}
}
}

@ -335,6 +335,10 @@ namespace IoTNode.DeviceServices.FBee
{
this.X27(sn, data);
}
else if (responseType == ResponseType.x50)
{
this.X50(sn, data);
}
else if (responseType == ResponseType.x70)
{
this.X70(sn, data);
@ -398,6 +402,14 @@ namespace IoTNode.DeviceServices.FBee
payload.Add(ep ?? (byte)endPoint);
payload.AddRange(command);
}
else if (format == 3)
{
payload.Add((byte)(command.Count() + 1 + 2 + 1));//数据总长
payload.Add(addressType);//地址模式
payload.AddRange(address);
payload.Add(ep ?? (byte)endPoint);
payload.AddRange(command);
}
data.AddRange(payload);
}
@ -689,22 +701,22 @@ namespace IoTNode.DeviceServices.FBee
var ieee = device.Number;
if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
{
//this.X85(sn, ieee);
//this.X85(sn, ieee);//获取开关状态
}
if (deviceId == 0x0210 || deviceId == 0x0220)
{
this.X86(sn, ieee);
this.X87(sn, ieee);
this.X88(sn, ieee);
this.XA9(sn, ieee);
this.X86(sn, ieee);//获取亮度
this.X87(sn, ieee);//获取色调
this.X88(sn, ieee);//获取饱和度
this.XA9(sn, ieee);//色温
}
else if (deviceId == 0x0163)
{
this.XA70080(sn, ieee);
this.XA70080(sn, ieee);//读版本号
}
else if (deviceId == 0x0051)
{
this.X8D07020000(sn, ieee);
this.X8D0702(sn, ieee);//读取电量
}
}
catch (Exception ex)
@ -966,12 +978,16 @@ namespace IoTNode.DeviceServices.FBee
}
/// <summary>
/// 0x8d-0x70发送zcl指令读取簇id为0702属性为0000的电量值
/// 0x8d-0x70发送zcl指令读取簇id为0702的电量、电功率
/// </summary>
public void X8D07020000(string sn, string ieee)
public void X8D0702(string sn, string ieee)
{
this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 2);
this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x0b, 0x05, 0x00 }, 2);
this.Write(sn, RequestType.x8d, ieee, new List<byte>() { 0x02, 0x07, 0x01, 0x03, 0x00 }, 3);//0301电量乘数
this.Write(sn, RequestType.x8d, ieee, new List<byte>() { 0x02, 0x07, 0x02, 0x03, 0x00 }, 3);//0302电量除数
this.Write(sn, RequestType.x8d, ieee, new List<byte>() { 0x04, 0x0b, 0x04, 0x06, 0x00 }, 3);//0604功率乘数
this.Write(sn, RequestType.x8d, ieee, new List<byte>() { 0x04, 0x0b, 0x05, 0x06, 0x00 }, 3);//0605功率除数
this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 2);//0000电量
this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x0b, 0x05, 0x00 }, 2);//050b功率
}
//
@ -1204,6 +1220,43 @@ namespace IoTNode.DeviceServices.FBee
this.Write(sn, RequestType.xa9, ieee, list);
}
public void X50(string sn, byte[] data)
{
try
{
using var ms = new MemoryStream(data);
if (ms.ReadByte() != 0x50)
{
return;
}
var length = ms.ReadByte();
ms.Seek(10, SeekOrigin.Current);
var success = ms.ReadByte();
if (success == 0x01)
{
ms.Seek(1, SeekOrigin.Current);
var controlType = ms.ReadByte();
if (controlType == 0x95)
{
ms.Seek(2, SeekOrigin.Current);
var address = ms.ReadHexStringDesc(2);
using var scope = _applicationServices.CreateScope();
var deviceRepo = scope.ServiceProvider.GetService<IRepository<Device>>();
var device = this.GetDeviceByAddress(deviceRepo, sn, address);
if (device != null)
{
deviceRepo.Delete(device);
deviceRepo.SaveChanges();
}
}
}
}
catch (Exception ex)
{
this._logger.LogError(ex, ex.Message);
}
}
//0xac
//0xaf
//0xb0
@ -1455,6 +1508,10 @@ namespace IoTNode.DeviceServices.FBee
{
foreach (var item in props)
{
if (item.Key == 0x0400)
{
Console.WriteLine(item.Value.ToInt());
}
if (item.Key == 0x0000)
{
var tempBytes = new List<byte>();
@ -1463,8 +1520,14 @@ namespace IoTNode.DeviceServices.FBee
tempBytes.Add(0x00);
if (tempBytes.Count == 8)
{
var electricity = BitConverter.ToInt64(tempBytes.ToArray()) / 10000f;
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Electricity, electricity.ToString("f2"), DeviceDataType.Float, "电量", "kWh", timestamp: timestamp));
var multiplier = device.Data.FirstOrDefault(o => o.Key == Keys.ElectricityMultiplier)?.Value;
var divisor = device.Data.FirstOrDefault(o => o.Key == Keys.ElectricityDivisor)?.Value;
if (!string.IsNullOrEmpty(multiplier) && !string.IsNullOrEmpty(divisor))
{
var electricity = BitConverter.ToInt64(tempBytes.ToArray());
var value = electricity * Convert.ToInt16(multiplier) / Convert.ToSingle(divisor);
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Electricity, value.ToString("f2"), DeviceDataType.Float, "电量", "kWh", timestamp: timestamp));
}
}
else
{
@ -1473,14 +1536,51 @@ namespace IoTNode.DeviceServices.FBee
}
else if (item.Key == 0x050b)
{
var power = BitConverter.ToUInt16(item.Value.ToArray());
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Power, power, DeviceDataType.Float, "功率", "W", timestamp: timestamp));
var multiplier = device.Data.FirstOrDefault(o => o.Key == Keys.PowerMultiplier)?.Value;
var divisor = device.Data.FirstOrDefault(o => o.Key == Keys.PowerDivisor)?.Value;
if (!string.IsNullOrEmpty(multiplier) && !string.IsNullOrEmpty(divisor))
{
var power = BitConverter.ToUInt16(item.Value.ToArray());
var value = power * Convert.ToInt16(multiplier) / Convert.ToSingle(divisor);
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Power, value.ToString("f2"), DeviceDataType.Float, "功率", "W", timestamp: timestamp));
}
}
else if (item.Key == 0x0400)//0x050b
{
var multiplier = device.Data.FirstOrDefault(o => o.Key == Keys.PowerMultiplier)?.Value;
var divisor = device.Data.FirstOrDefault(o => o.Key == Keys.PowerDivisor)?.Value;
if (!string.IsNullOrEmpty(multiplier) && !string.IsNullOrEmpty(divisor))
{
var power = BitConverter.ToUInt16(item.Value.ToArray());
var value = power * Convert.ToInt16(multiplier) / Convert.ToSingle(divisor);
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Power, value.ToString("f2"), DeviceDataType.Float, "功率", "W", timestamp: timestamp));
}
}
else if (item.Key == 0x0301)
{
var value = BitConverter.ToUInt16(item.Value.ToArray());
this.UpdateData(deviceRepo, device, device.CreateData(Keys.ElectricityMultiplier, value, DeviceDataType.Int, "电功乘数", timestamp: timestamp, hidden: true));
}
else if (item.Key == 0x0302)
{
var value = BitConverter.ToUInt16(item.Value.ToArray());
this.UpdateData(deviceRepo, device, device.CreateData(Keys.ElectricityDivisor, value, DeviceDataType.Int, "电功除数", timestamp: timestamp, hidden: true));
}
else if (item.Key == 0x0604)
{
var value = BitConverter.ToUInt16(item.Value.ToArray());
this.UpdateData(deviceRepo, device, device.CreateData(Keys.PowerMultiplier, value, DeviceDataType.Int, "电功乘数", timestamp: timestamp, hidden: true));
}
else if (item.Key == 0x0605)
{
var value = BitConverter.ToUInt16(item.Value.ToArray());
this.UpdateData(deviceRepo, device, device.CreateData(Keys.PowerDivisor, value, DeviceDataType.Int, "电功除数", timestamp: timestamp, hidden: true));
}
}
if (clusterId == ClusterId.SummationDivisor)
{
this.X8D07020000(sn, device.Number);
}
//if (clusterId == ClusterId.SummationDivisor)
//{
// this.X8D0702(sn, device.Number);
//}
}
}
}

@ -7,7 +7,11 @@
public const string EndPoint = "EndPoint";
public const string Version = "Version";
public const string Electricity = "Electricity";
public const string ElectricityMultiplier = "ElectricityMultiplier";
public const string ElectricityDivisor = "ElectricityDivisor";
public const string Power = "Power";
public const string PowerMultiplier = "PowerMultiplier";
public const string PowerDivisor = "PowerDivisor";
public const string KeyPress = "KeyPress";
public const string State = "State";
public const string L1State = "L1State";

@ -8,10 +8,11 @@
public const int x09 = 0x09;
public const int x0a = 0x0a;
public const int x27 = 0x27;
public const int x50 = 0x50;
public const int x70 = 0x70;
public const int x75 = 0x75;
public const int x72 = 0x72;
public const int x15 = 0x15;
public const int x29 = 0x29;
}
}
}

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.20092801")]
[assembly: AssemblyInformationalVersion("1.0.0.20101901")]

@ -1,10 +1,8 @@
@model Node
@{
HtmlTitle = "设备";
var index = 0;
}
<div class="row">
@Model.Name:@Model.Number<a class="btn btn-info btn-sm" href="@Url.Action("Upload","Home")">上传数据</a>
@{ HtmlTitle = "设备";
var index = 0; }
<div class="row" title="@Infrastructure.Extensions.Helper.Instance.GetMacAddress()">
@Model.Name:@Model.Number<a class="btn btn-info btn-sm" href="@Url.Action("Upload","Home")">上传数据</a>
</div>
<div class="row">
<table class="table">
@ -18,32 +16,28 @@
</tr>
@foreach (var item in Model.Devices)
{
<tr>
<td>@(++index)</td>
<td>@item.Product.Number@item.Product.Name</td>
<td>@item.Number@item.Name</td>
<td>@item.DisplayName</td>
<td>@Html.DisplayFor(o => item.IsOnline)</td>
<td>
@if (item.Product.Number.Contains("fbee") && !item.Product.Number.Contains("gateway"))
{
var values = item.Number.Split('-');
var gateway = values[0];
var number = values[1];
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("X95","Gateway",new { gateway = gateway,number=number})" data-number="@item.Number">从网关移除</a>
}
else if (item.Product.Name == "摄像头")
{
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("StartPush","Onvif",new {number=item.Number})" data-number="@item.Number">开始推流</a>
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("StopPush","Onvif",new {number=item.Number})" data-number="@item.Number">停止推流</a>
}
else if (item.Product.Number.Contains("gateway"))
{
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("X95","Gateway",new { number=item.Number})" data-number="@item.Number">查询网关设备</a>
}
</td>
</tr>
}
<tr>
<td>@(++index)</td>
<td>@item.Product.Number@item.Product.Name</td>
<td>@item.Number@item.Name</td>
<td>@item.DisplayName</td>
<td>@Html.DisplayFor(o => item.IsOnline)</td>
<td>
@if (item.Product.Number.Contains("fbee") && !item.Product.Number.Contains("gateway"))
{
var values = item.Number.Split('-');
var gateway = values[0];
var number = values[1];
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("X95","Gateway",new { gateway = gateway,number=number})" data-number="@item.Number">从网关移除</a> }
else if (item.Product.Name == "摄像头")
{
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("StartPush","Onvif",new {number=item.Number})" data-number="@item.Number">开始推流</a>
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("StopPush","Onvif",new {number=item.Number})" data-number="@item.Number">停止推流</a> }
else if (item.Product.Number.Contains("gateway"))
{
<a class="api ajax btn btn-info btn-sm" href="@Url.Action("X95","Gateway",new { number=item.Number})" data-number="@item.Number">查询网关设备</a>}
</td>
</tr>}
</table>
</div>
@section scripts{

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.20092902")]
[assembly: AssemblyInformationalVersion("1.0.0.20101601")]

@ -1,5 +1,5 @@
var config = {
version: '1.0.0.20093001',
version: '1.0.0.20101901',
debug: window.location.search.indexOf('debug') > -1,
baseUrl: window.location.protocol + '//' + window.location.host,
uploadUrl: window.location.protocol + '//' + window.location.host + '/IoTCenter/File/Upload',

@ -49,7 +49,8 @@
url: '/IoTCenter/api/v1/device/getDevice?number=' + this.$route.query.number,
device: null,
events: ['DeviceEntityInserted', 'DeviceEntityUpdated', 'DeviceEntityInserted',
'DataEntityInserted', 'DataEntityUpdated', 'DataEntityInserted']
'DataEntityInserted', 'DataEntityUpdated', 'DataEntityInserted'],
time: '1d'
}
},
mounted: function () {
@ -79,10 +80,11 @@
return o.type === 10 || o.type === 20;
}).toArray();
for (var i = 0; i < dataList.length; i++) {
this.changeTime(dataList[i].key, '1d', dataList[i].name);
this.changeTime(dataList[i].key, this.time, dataList[i].name);
}
},
tabClick: function (event, key, time, title) {
this.time = time;
this.changeTime(key, time, title);
var link = $(event.currentTarget);
if (!link.hasClass('active')) {

@ -8,7 +8,7 @@ network:
addresses: [192.168.1.4/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,223.5.5.5,119.29.29.29,180.76.76.76]
addresses: [223.5.5.5,119.29.29.29,180.76.76.76]
search: []
optional: true
version: 2

@ -54,6 +54,9 @@ fi
if uname -a | grep -q "NanoPC-T4"
then
echo "nanopc-t4"
# sed -i "s/managed=true/managed=false/g" /etc/NetworkManager/NetworkManager.conf
# cp -f /etc/network/interfaces /etc/network/interfaces.bk
# cp ~/publish/interfaces /etc/network/interfaces
nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 192.168.1.3/24 ipv4.gateway 192.168.1.1 ipv4.dns "223.5.5.5 119.29.29.29 180.76.76.76"
nmcli c up 'Wired connection 1'
fi
Loading…
Cancel
Save