using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace ZigBee.Device
{
public class ZbGatewayData : CommonDevice
{
#region 网关在线标识
///
/// 判断网关是否在线的标识,APP界面会改变它的值,Application会重新刷新它的值
///
public bool GatewayOnlineFlage = false;
#endregion
[Newtonsoft.Json.JsonIgnore]
///
/// 虚拟网关
///
public bool IsVirtual;
#region 网关基本信息
///
/// 该网关应用程序版本
///
public int AppVersion;
///
/// Zigbee协议器程序版本
///
public int ZigbeeVersion;
#endregion
#region 网关信息.
///
/// 网关版本信息,网关反馈信息
///
public GetGwVersionAllData getGwVersionAllData;
///
/// 网关版本信息,网关反馈信息
///
[System.Serializable]
public class GetGwVersionAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 网关版本信息
///
public GetGwVersionData getGwVersion;
}
///
/// 网关版本信息
///
public GetGwVersionData getGwVersion;
///
/// 网关版本信息
///
[System.Serializable]
public class GetGwVersionData
{
///
/// 该网关应用程序版本
///
public int AppVersion;
///
/// Zigbee协议器程序版本
///
public int ZigbeeVersion;
}
#endregion
#region 获取网关信息.
///
/// 网关信息,网关反馈具体信息.
///
public GetGwAllData getGwAllData;
///
/// 网关信息,网关反馈具体信息
///
[System.Serializable]
public class GetGwAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 网关信息
///
public GetGwData getGwData;
}
///
/// 网关信息.
///
public GetGwData getGwInfo;
///
/// 网关信息
///
[System.Serializable]
public class GetGwData
{
///
///网关序列号,该网关唯一标识
///
public string GwId;
///
///网关绑定网卡的mac地址
///
public string GwMac;
///
///网关名称
///
public string GwName;
///
/// 网关的序列号
///
public string GWSN = string.Empty;
///
///是否为主网关。(因为在外网的情况下,这个字段可以获取到,用来更新局域网中基本信息的对象中的主网关信息)
///0:否
///1:是
///
public int IsDominant;
///
///utc时间戳,程序启动时网关的系统时间
///
public int StartTime;
///
///加入局域网模式
///0:wifi连接局域网
///1:有线连接局域网
///2:未加入局域网
///
public int JoinMode;
///
///网关所在局域网的ip地址
///
public string GwIP;
///
/// 主人的Guid(即使是管理员,这里也是主人的Guid)
///
public string AccountId;
///
///当前局域网网络号占用位数,用于计算子网掩码,如Mask=32,则子网掩码为255.255.255.0
///
public int Mask;
///
///上级路由器无线名称
///当 JoinMode = 0时存在
///
public string RouteESSID;
///
///DNS服务器地址
///
public string DNSServer;
///
/// 该网关应用程序版本
///
public int AppVersion;
///
/// Zigbee协议器程序版本
///
public int ZigbeeVersion;
///
///协调器mac地址
///
public string ZigbeeMacAddr;
///
///网关宅id
///
public string HomeId;
///
///是否已经连接云端mqtt
///0:否
///1:是
///
public int IsConnectCloud;
///
///(用于网关程序调试)
///https登陆云端时,最近一次获取的响应状态码。根据云端的定义,有如下状态码。
///(1)Success,则[调用此接口操作成功]
///(2)ParameterOrEmpty,则响应字段中[ErrorInfo] 为错误信息[提交错误信息]
///(3)NoBind,则响应字段中[ErrorInfo] 为错误信息[您所提交的[GatewayUniqueId 网关唯一Id(MAC)]和[住宅主键Id]不存在绑定的关系]
///(4)YouDataNoIsLocalRegion,则响应字段中[ErrorInfo] 为错误信息[您的的数据并不在此HDL区域服务器, 请重定向到如下HDL区域服务器进行处理.]
///
public string StateCode;
///
///Linux网关类型
///
public int LinuxImageType;
///
///Linux网关HW版本
///
public int LinuxHWVersion;
///
/// Linux网关FW版本
///
public int LinuxFWVersion;
///
/// 协调器HW版本
///
public int ZbHWVersion;
///
/// 协调器FW版本
///
public int ZbFWVersion;
///
/// 网关镜像类型
///
public int ZbImageType;
///
/// 虚拟驱动信息
///
public List DriveCodeList = new List();
}
public class DriveCodeListObj
{
///
/// 驱动代号(由网关为驱动分配唯一标识)
///
public int DriveCode;
///
/// 驱动硬件版本
///
public int DriveHwVersion;
///
/// 驱动软件版
///
public int DriveFwVersion;
///
/// 驱动固件类型
///
public int DriveImageType;
///
/// 驱动id
///
public int DriveId;
}
#endregion
#region 修改网关名称
///
/// 修改网关名称,网关反馈具体信息
///
public GwReNameAllData gwReNameAllData;
///
/// 修改网关名称,网关反馈具体信息
///
[System.Serializable]
public class GwReNameAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 修改网关名称
///
public GwReNameData gwReNameData;
}
///
/// 修改网关名称
///
public GwReNameData gwRename;
///
/// 修改网关名称
///
[System.Serializable]
public class GwReNameData
{
///
/// 修改后的网关名称
///
public string GwName;
}
#endregion
#region 设定网关住宅id
///
/// 网关住宅id数据,网关反馈具体信息
///
public GwSetHomeIdAllData gwSetHomeIdAllData;
///
/// 网关住宅id数据,网关反馈具体信息
///
[System.Serializable]
public class GwSetHomeIdAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 网关住宅id数据
///
public GwSetHomeIdData gwSetHomeIdData;
}
///
/// 网关住宅id数据
///
public GwSetHomeIdData gwSetHomeId;
///
/// 网关住宅id数据
///
[System.Serializable]
public class GwSetHomeIdData
{
///
/// 住宅id
///
public string HomeId;
}
///
/// 广播发现协议
///
public GatewayBaseInfo getGatewayBaseInfo = new GatewayBaseInfo { };
///
/// 广播发现协议
///
[System.Serializable]
public class GatewayBaseInfo
{
///
/// 网关Ip地址
///
public string IpAddress;
///
/// 住宅id,4字节整型。(小端结构)如果网关不设置宅id,将默认为0
///
public string HomeId = string.Empty;
///
/// 网关当前时间戳(小端结构)
///
public int Time;
///
/// 是否为主网关
///
public bool IsMainGateWay;
///
/// 网关名称
///
public string GwName;
///
/// RSA公钥
///
//public string PubKey;
//string id;
///
/// 网关ID
///
public string gwID;
//{
// get{
// return id;
// }
// set{
// id = value;
// //System.Console.WriteLine("===========123456");
// }
//}
}
///
/// 网关成为主网关时广播通知
///
public MainGatewayBaseInfo getMainGatewayBaseInfo;
///
/// 网关成为主网关时广播通知
///
[System.Serializable]
public class MainGatewayBaseInfo
{
///
/// 发送方的ip地址
///
public string IpAddress;
///
/// 住宅id,4字节整型。(小端结构)如果网关不设置住宅id,将默认为0
///
public string HomeId;
///
/// 数据命令标识
///
public int Command_Id = 0x03;
///
/// 保留
///
public int Retain = 0x00;
///
/// 网关当前时间戳(小端结构)
///
public int Time;
///
/// RSA公钥
///
public string PubKey;
///
/// 网关名称
///
public string gwName;
///
/// 网关ID
///
public string gwID;
}
#endregion
#region 获取所有网关的节点设备信息(用于主网关)
/////
///// 获取所有网关的节点设备信息(用于主网关)
/////
//public static async System.Threading.Tasks.Task> GetAllGatewayDeviceInfoList()
//{
// if (ZbGateway.MainGateWay == null)
// {
// return null;
// }
// ZbGateway.MainGateWay.AllGatewayDeviceList.Clear();
// return await System.Threading.Tasks.Task.Run((Func>>)(async () =>
// {
// var dateTime = DateTime.Now;
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "DeviceInfoRespon")
// {
// dateTime = DateTime.Now;
// var deviceID = jobject.Value("Device_ID");
// switch ((DeviceType)(deviceID))
// {
// case DeviceType.ColorDimmableLight:
// var dimmableLight = new ColorDimmableLight() { DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID") };
// dimmableLight.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (dimmableLight.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// dimmableLight.CurrentGateWayId = dimmableLight.getAllGatewayDeviceInfo.GwId;
// var light = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
// if (light == null)
// {
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(dimmableLight);
// dimmableLight.DeviceName = dimmableLight.getAllGatewayDeviceInfo.MacName;
// dimmableLight.DeviceEpointName = dimmableLight.getAllGatewayDeviceInfo.DeviceName;
// dimmableLight.ImgVersion = dimmableLight.getAllGatewayDeviceInfo.ImgVersion;
// dimmableLight.IsOnline = dimmableLight.getAllGatewayDeviceInfo.IsOnline;
// dimmableLight.IasDeviceType = dimmableLight.getAllGatewayDeviceInfo.DeviceType;
// dimmableLight.Profile = dimmableLight.getAllGatewayDeviceInfo.Profile;
// dimmableLight.ImgTypeId = dimmableLight.getAllGatewayDeviceInfo.ImgTypeId;
// dimmableLight.InClusterList = dimmableLight.getAllGatewayDeviceInfo.InClusterList;
// dimmableLight.OutClusterList = dimmableLight.getAllGatewayDeviceInfo.OutClusterList;
// dimmableLight.AttributeStatus = dimmableLight.getAllGatewayDeviceInfo.AttributeStatus;
// dimmableLight.Save();
// }
// else
// {
// light.getAllGatewayDeviceInfo = dimmableLight.getAllGatewayDeviceInfo;
// light.DeviceName = dimmableLight.getAllGatewayDeviceInfo.MacName;
// light.DeviceEpointName = dimmableLight.getAllGatewayDeviceInfo.DeviceName;
// light.ImgVersion = dimmableLight.getAllGatewayDeviceInfo.ImgVersion;
// light.IsOnline = dimmableLight.getAllGatewayDeviceInfo.IsOnline;
// light.IasDeviceType = dimmableLight.getAllGatewayDeviceInfo.DeviceType;
// light.Profile = dimmableLight.getAllGatewayDeviceInfo.Profile;
// light.ImgTypeId = dimmableLight.getAllGatewayDeviceInfo.ImgTypeId;
// light.InClusterList = dimmableLight.getAllGatewayDeviceInfo.InClusterList;
// light.OutClusterList = dimmableLight.getAllGatewayDeviceInfo.OutClusterList;
// light.AttributeStatus = dimmableLight.getAllGatewayDeviceInfo.AttributeStatus;
// light.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// case DeviceType.OnOffOutput:
// var toggleLight = new ToggleLight() { Time = jobject.Value("Time"), DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID") };
// toggleLight.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (toggleLight.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// toggleLight.CurrentGateWayId = toggleLight.getAllGatewayDeviceInfo.GwId;
// var localToggleLight = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
// if (localToggleLight == null)
// {
// toggleLight.DeviceName = toggleLight.getAllGatewayDeviceInfo.MacName;
// toggleLight.DeviceEpointName = toggleLight.getAllGatewayDeviceInfo.DeviceName;
// toggleLight.ImgVersion = toggleLight.getAllGatewayDeviceInfo.ImgVersion;
// toggleLight.IsOnline = toggleLight.getAllGatewayDeviceInfo.IsOnline;
// toggleLight.IasDeviceType = toggleLight.getAllGatewayDeviceInfo.DeviceType;
// toggleLight.Profile = toggleLight.getAllGatewayDeviceInfo.Profile;
// toggleLight.ImgTypeId = toggleLight.getAllGatewayDeviceInfo.ImgTypeId;
// toggleLight.InClusterList = toggleLight.getAllGatewayDeviceInfo.InClusterList;
// toggleLight.OutClusterList = toggleLight.getAllGatewayDeviceInfo.OutClusterList;
// toggleLight.AttributeStatus = toggleLight.getAllGatewayDeviceInfo.AttributeStatus;
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(toggleLight);
// toggleLight.Save();
// }
// else
// {
// localToggleLight.getAllGatewayDeviceInfo = toggleLight.getAllGatewayDeviceInfo;
// localToggleLight.DeviceName = toggleLight.getAllGatewayDeviceInfo.MacName;
// localToggleLight.DeviceEpointName = toggleLight.getAllGatewayDeviceInfo.DeviceName;
// localToggleLight.ImgVersion = toggleLight.getAllGatewayDeviceInfo.ImgVersion;
// localToggleLight.IsOnline = toggleLight.getAllGatewayDeviceInfo.IsOnline;
// localToggleLight.IasDeviceType = toggleLight.getAllGatewayDeviceInfo.DeviceType;
// localToggleLight.Profile = toggleLight.getAllGatewayDeviceInfo.Profile;
// localToggleLight.ImgTypeId = toggleLight.getAllGatewayDeviceInfo.ImgTypeId;
// localToggleLight.InClusterList = toggleLight.getAllGatewayDeviceInfo.InClusterList;
// localToggleLight.OutClusterList = toggleLight.getAllGatewayDeviceInfo.OutClusterList;
// localToggleLight.AttributeStatus = toggleLight.getAllGatewayDeviceInfo.AttributeStatus;
// localToggleLight.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// case DeviceType.OnOffSwitch:
// var panel = new Panel() { Time = jobject.Value("Time"), DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID") };
// panel.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (panel.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// panel.CurrentGateWayId = panel.getAllGatewayDeviceInfo.GwId;
// var localPanel = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr && obj.DeviceEpoint == panel.DeviceEpoint);
// if (localPanel == null)
// {
// panel.DeviceName = panel.getAllGatewayDeviceInfo.MacName;
// panel.DeviceEpointName = panel.getAllGatewayDeviceInfo.DeviceName;
// panel.ImgVersion = panel.getAllGatewayDeviceInfo.ImgVersion;
// panel.IsOnline = panel.getAllGatewayDeviceInfo.IsOnline;
// panel.IasDeviceType = panel.getAllGatewayDeviceInfo.DeviceType;
// panel.Profile = panel.getAllGatewayDeviceInfo.Profile;
// panel.ImgTypeId = panel.getAllGatewayDeviceInfo.ImgTypeId;
// panel.InClusterList = panel.getAllGatewayDeviceInfo.InClusterList;
// panel.OutClusterList = panel.getAllGatewayDeviceInfo.OutClusterList;
// panel.AttributeStatus = panel.getAllGatewayDeviceInfo.AttributeStatus;
// if (panel.DeviceAddr != null)
// {
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(panel);
// }
// panel.Save();
// }
// else
// {
// localPanel.getAllGatewayDeviceInfo = panel.getAllGatewayDeviceInfo;
// localPanel.DeviceName = panel.getAllGatewayDeviceInfo.MacName;
// localPanel.DeviceEpointName = panel.getAllGatewayDeviceInfo.DeviceName;
// localPanel.ImgVersion = panel.getAllGatewayDeviceInfo.ImgVersion;
// localPanel.IsOnline = panel.getAllGatewayDeviceInfo.IsOnline;
// localPanel.IasDeviceType = panel.getAllGatewayDeviceInfo.DeviceType;
// localPanel.Profile = panel.getAllGatewayDeviceInfo.Profile;
// localPanel.ImgTypeId = panel.getAllGatewayDeviceInfo.ImgTypeId;
// localPanel.InClusterList = panel.getAllGatewayDeviceInfo.InClusterList;
// localPanel.OutClusterList = panel.getAllGatewayDeviceInfo.OutClusterList;
// localPanel.AttributeStatus = panel.getAllGatewayDeviceInfo.AttributeStatus;
// localPanel.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// case DeviceType.WindowCoveringDevice:
// var windowCovering = new Rollershade() { DeviceID = jobject.Value((object)"Device_ID"), DeviceAddr = jobject.Value((object)"DeviceAddr"), DeviceEpoint = jobject.Value((object)"Epoint"), DataID = jobject.Value((object)"Data_ID") };
// windowCovering.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (windowCovering.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// windowCovering.CurrentGateWayId = windowCovering.getAllGatewayDeviceInfo.GwId;
// var wc = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
// if (wc == null)
// {
// windowCovering.DeviceName = windowCovering.getAllGatewayDeviceInfo.MacName;
// windowCovering.DeviceEpointName = windowCovering.getAllGatewayDeviceInfo.DeviceName;
// windowCovering.ImgVersion = windowCovering.getAllGatewayDeviceInfo.ImgVersion;
// windowCovering.IsOnline = windowCovering.getAllGatewayDeviceInfo.IsOnline;
// windowCovering.IasDeviceType = windowCovering.getAllGatewayDeviceInfo.DeviceType;
// windowCovering.Profile = windowCovering.getAllGatewayDeviceInfo.Profile;
// windowCovering.ImgTypeId = windowCovering.getAllGatewayDeviceInfo.ImgTypeId;
// windowCovering.InClusterList = windowCovering.getAllGatewayDeviceInfo.InClusterList;
// windowCovering.OutClusterList = windowCovering.getAllGatewayDeviceInfo.OutClusterList;
// windowCovering.AttributeStatus = windowCovering.getAllGatewayDeviceInfo.AttributeStatus;
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(windowCovering);
// windowCovering.Save();
// }
// else
// {
// wc.getAllGatewayDeviceInfo = windowCovering.getAllGatewayDeviceInfo;
// wc.DeviceName = windowCovering.getAllGatewayDeviceInfo.MacName;
// wc.DeviceEpointName = windowCovering.getAllGatewayDeviceInfo.DeviceName;
// wc.ImgVersion = windowCovering.getAllGatewayDeviceInfo.ImgVersion;
// wc.IsOnline = windowCovering.getAllGatewayDeviceInfo.IsOnline;
// wc.IasDeviceType = windowCovering.getAllGatewayDeviceInfo.DeviceType;
// wc.Profile = windowCovering.getAllGatewayDeviceInfo.Profile;
// wc.ImgTypeId = windowCovering.getAllGatewayDeviceInfo.ImgTypeId;
// wc.InClusterList = windowCovering.getAllGatewayDeviceInfo.InClusterList;
// wc.OutClusterList = windowCovering.getAllGatewayDeviceInfo.OutClusterList;
// wc.AttributeStatus = windowCovering.getAllGatewayDeviceInfo.AttributeStatus;
// wc.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// case DeviceType.IASZone:
// var ias = new IASZone() { Time = jobject.Value("Time"), DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID") };
// ias.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (ias.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// ias.CurrentGateWayId = ias.getAllGatewayDeviceInfo.GwId;
// var infoIAS = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
// if (infoIAS == null)
// {
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(ias);
// ias.DeviceName = ias.getAllGatewayDeviceInfo.MacName;
// ias.DeviceEpointName = ias.getAllGatewayDeviceInfo.DeviceName;
// ias.ImgVersion = ias.getAllGatewayDeviceInfo.ImgVersion;
// ias.IsOnline = ias.getAllGatewayDeviceInfo.IsOnline;
// ias.IasDeviceType = ias.getAllGatewayDeviceInfo.DeviceType;
// ias.Profile = ias.getAllGatewayDeviceInfo.Profile;
// ias.ImgTypeId = ias.getAllGatewayDeviceInfo.ImgTypeId;
// ias.InClusterList = ias.getAllGatewayDeviceInfo.InClusterList;
// ias.OutClusterList = ias.getAllGatewayDeviceInfo.OutClusterList;
// ias.AttributeStatus = ias.getAllGatewayDeviceInfo.AttributeStatus;
// ias.Save();
// }
// else
// {
// infoIAS.DeviceName = ias.getAllGatewayDeviceInfo.MacName;
// infoIAS.DeviceEpointName = ias.getAllGatewayDeviceInfo.DeviceName;
// infoIAS.getAllGatewayDeviceInfo = ias.getAllGatewayDeviceInfo;
// infoIAS.ImgVersion = ias.getAllGatewayDeviceInfo.ImgVersion;
// infoIAS.IsOnline = ias.getAllGatewayDeviceInfo.IsOnline;
// infoIAS.IasDeviceType = ias.getAllGatewayDeviceInfo.DeviceType;
// infoIAS.Profile = ias.getAllGatewayDeviceInfo.Profile;
// infoIAS.ImgTypeId = ias.getAllGatewayDeviceInfo.ImgTypeId;
// infoIAS.InClusterList = ias.getAllGatewayDeviceInfo.InClusterList;
// infoIAS.OutClusterList = ias.getAllGatewayDeviceInfo.OutClusterList;
// infoIAS.AttributeStatus = ias.getAllGatewayDeviceInfo.AttributeStatus;
// ias.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// case DeviceType.OtaDevice:
// case DeviceType.OtaPanelDevice:
// var ota = new OTADevice() { Time = jobject.Value("Time"), DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID") };
// ota.getAllGatewayDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (ota.getAllGatewayDeviceInfo == null)
// {
// return;
// }
// ota.CurrentGateWayId = ota.getAllGatewayDeviceInfo.GwId;
// var infoOta = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == ota.DeviceID && obj.DeviceAddr == ota.DeviceAddr && obj.DeviceEpoint == ota.DeviceEpoint);
// if (infoOta == null)
// {
// ZbGateway.MainGateWay.AllGatewayDeviceList.Add(ota);
// ota.DeviceName = ota.getAllGatewayDeviceInfo.MacName;
// ota.DeviceEpointName = ota.getAllGatewayDeviceInfo.DeviceName;
// ota.ImgVersion = ota.getAllGatewayDeviceInfo.ImgVersion;
// ota.IsOnline = ota.getAllGatewayDeviceInfo.IsOnline;
// ota.IasDeviceType = ota.getAllGatewayDeviceInfo.DeviceType;
// ota.Profile = ota.getAllGatewayDeviceInfo.Profile;
// ota.ImgTypeId = ota.getAllGatewayDeviceInfo.ImgTypeId;
// ota.InClusterList = ota.getAllGatewayDeviceInfo.InClusterList;
// ota.OutClusterList = ota.getAllGatewayDeviceInfo.OutClusterList;
// ota.AttributeStatus = ota.getAllGatewayDeviceInfo.AttributeStatus;
// ota.Save();
// }
// else
// {
// infoOta.DeviceName = ota.getAllGatewayDeviceInfo.MacName;
// infoOta.DeviceEpointName = ota.getAllGatewayDeviceInfo.DeviceName;
// infoOta.getAllGatewayDeviceInfo = ota.getAllGatewayDeviceInfo;
// infoOta.ImgVersion = ota.getAllGatewayDeviceInfo.ImgVersion;
// infoOta.IsOnline = ota.getAllGatewayDeviceInfo.IsOnline;
// infoOta.IasDeviceType = ota.getAllGatewayDeviceInfo.DeviceType;
// infoOta.Profile = ota.getAllGatewayDeviceInfo.Profile;
// infoOta.ImgTypeId = ota.getAllGatewayDeviceInfo.ImgTypeId;
// infoOta.InClusterList = ota.getAllGatewayDeviceInfo.InClusterList;
// infoOta.OutClusterList = ota.getAllGatewayDeviceInfo.OutClusterList;
// infoOta.AttributeStatus = ota.getAllGatewayDeviceInfo.AttributeStatus;
// ota.ReSave();
// }
// System.Console.WriteLine($"收到通知后的主题_{ topic}");
// break;
// //case DeviceType.Thermostat:
// //var thermostat = new ThermostatObj() { DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
// //thermostat.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// //if (thermostat.DeviceInfo == null)
// //{
// // return;
// //}
// // var ther = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == thermostat.DeviceID && obj.DeviceAddr == thermostat.DeviceAddr && obj.DeviceEpoint == thermostat.DeviceEpoint);
// //if (ther == null)
// //{
// // thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
// // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(thermostat);
// //}
// //else
// //{
// // thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
// // ZigBee.IO.LocalFileUtils.SaveDeviceInfo(thermostat, thermostat.DeviceEpoint.ToString());
// //}
// //break;
// //case DeviceType.TemperatureSensor:
// // var temperatureSensor = new TemperatureSensor() { DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
// // temperatureSensor.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// // if (temperatureSensor.DeviceInfo == null)
// // {
// // return;
// // }
// // var ts = ZbGateway.MainGateWay.AllGatewayDeviceList.Find(obj => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceAddr == temperatureSensor.DeviceAddr && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
// // if (ts == null)
// // {
// // temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
// // ZbGateway.MainGateWay.AllGatewayDeviceList.Add(temperatureSensor);
// // }
// // else
// // {
// // temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
// // IO.LocalFileUtils.SaveDeviceInfo(temperatureSensor, temperatureSensor.DeviceEpoint.ToString());
// // }
// // break;
// }
// }
// };
// ZbGateway.MainGateWay.Actions += action;
// System.Console.WriteLine("MainGatewayDeviceInfo_Actions 启动" + System.DateTime.Now.ToString());
// var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 90 } };
// ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
// ZbGateway.MainGateWay.Send("GetAllDeviceInfo", Common.SecuritySet.Encryption(jObject.ToString()));
// while ((DateTime.Now - dateTime).TotalMilliseconds < 4000)
// {
// await System.Threading.Tasks.Task.Delay(100);
// }
// ZbGateway.MainGateWay.Actions -= action;
// System.Console.WriteLine("MainGatewayDeviceInfo_Actions 退出" + System.DateTime.Now.ToString());
// return ZbGateway.MainGateWay.AllGatewayDeviceList;
// }));
//}
#endregion
#region 网关恢复出厂设置
///
/// 网关恢复出厂设置返回的数据.
///
public GwLinuxResetResponData gwLinuxResetResponData;
///
/// 网关恢复出厂设置返回的数据.
///
[System.Serializable]
public class GwLinuxResetResponData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 网关恢复出厂设置
///
public ErrorResponData errorResponData;
///
/// 0:命令已接收,系统即将恢复出厂并重启。
///
public int Result = 2;
}
#endregion
#region 重启网关系统
///
/// 重启网关系统返回数据
///
public GwRebootResponAllData gwRebootResponAllData;
///
/// 重启网关系统返回数据
///
[System.Serializable]
public class GwRebootResponAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 返回值是0:命令已接收,系统即将重启。
///
public int Result = 999;
}
///
/// 重启网关系统返回数据
///
public GwRebootResponData gwRebootResponData;
///
/// 重启网关系统返回数据
///
[System.Serializable]
public class GwRebootResponData
{
///
/// 0:命令已接收,系统即将重启。
///
public int Result = 999;
}
#endregion
#region 网关和协调器升级
///
/// 保存zigbee协调器组网信息,网关反馈具体信息
///
public SaveNVFileResponseAllData saveNVFileResponseData;
///
/// 保存zigbee协调器组网信息,网关反馈具体信息
///
[System.Serializable]
public class SaveNVFileResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 保存zigbee协调器组网信息
///
public SaveNVFileResponseData saveNVFileResponseData;
}
///
/// 保存zigbee协调器组网信息
///
public SaveNVFileResponseData zbGwOperationSaveNVFileData;
///
/// 保存zigbee协调器组网信息
///
[System.Serializable]
public class SaveNVFileResponseData
{
///
/// 修改后的网关名称
///0:保存成功
///1:文件创建失败
///2:NV分区读取出错
///
public int Flag = 999;
}
#endregion
#region 协调器恢复组网信息
///
/// 协调器恢复组网信息,网关反馈具体信息
///
public RestoreNVAllDtta restoreNVAllDtta;
///
/// 协调器恢复组网信息,网关反馈具体信息
///
[System.Serializable]
public class RestoreNVAllDtta
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 协调器恢复组网信息
///
public RestoreNVDtta restoreNVDtta;
}
///
/// 协调器恢复组网信息
///
public RestoreNVDtta restoreNVDtta;
///
/// 协调器恢复组网信息
///
[System.Serializable]
public class RestoreNVDtta
{
///
/// 修改后的网关名称
/// 0:恢复成功
///1:文件不存在,恢复失败
///2:NV分区写入错误,恢复失败
///7:文件不合法
///
public int Flag = 999;
}
#endregion
#region 协调器升级
///
/// 协调器升级,网关反馈具体信息
///
public ZbGwOperationUpgradeAllData zbGwOperationUpgradeAllData;
///
/// 协调器升级,网关反馈具体信息
///
[System.Serializable]
public class ZbGwOperationUpgradeAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 协调器升级
///
public ZbGwOperationUpgradeData bGwOperationUpgradeData;
}
///
/// 协调器升级
///
public ZbGwOperationUpgradeData zbGwOperationUpgradeData;
///
/// 协调器升级
///
[System.Serializable]
public class ZbGwOperationUpgradeData
{
///
/// 修改后的网关名称
/// 0:升级完成
///1:没有找到升级文件,或升级文件打开失败。
///2:正在升级
///3:写入分区出错
///7:升级文件不合法。
///8:未知错误
///9:升级文件名称中无“ZBMODULE”标识。
///
public int Flag = 999;
///
/// 修改后的网关名称
/// 升级进度。0-100表示0-100% ,该字段在Flag =2时才存在
///
public int Percent;
}
#endregion
#region 升级虚拟驱动设备数据
///
/// 升级虚拟驱动设备,网关反馈具体信息
///
public VirtualDriveUpgradeResponseAllData virtualDriveUpgradeResponseAllData;
///
/// 升级虚拟驱动设备,网关反馈具体信息
///
[System.Serializable]
public class VirtualDriveUpgradeResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 升级虚拟驱动设备
///
public VirtualDriveUpgradeResponData virtualDriveUpgradeResponData;
}
///
/// 升级虚拟驱动设备
///
public VirtualDriveUpgradeResponData virtualDriveUpgradeResponData;
[System.Serializable]
public class VirtualDriveUpgradeResponData
{
/// 0:升级完成
///1:没有找到升级文件,或升级文件打开失败。v
///2:正在升级
///3:写入分区出错
///7:升级文件不合法。
///8:未知错误
///10:错误,驱动代号不存在
public int Flag;
///
///驱动代号
///
public int DriveCode;
///
///升级进度。0-100表示0-100%(该字段在Flag =2时才有效)
///
public int Percent;
}
#endregion
#region 查看网关记录的虚拟驱动数据
///
/// 查看网关记录的虚拟驱动,网关反馈具体信息
///
public CheckVDDriveCodeResponseAllData checkVDDriveCodeResponseAllData;
///
/// 查看网关记录的虚拟驱动,网关反馈具体信息
///
[System.Serializable]
public class CheckVDDriveCodeResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 查看网关记录的虚拟驱动
///
public VDriveDriveCodeResponData vDriveDriveCodeResponData;
}
///
/// 查看网关记录的虚拟驱动
///
public VDriveDriveCodeResponData vDriveDriveCodeResponData;
[System.Serializable]
public class VDriveDriveCodeResponData
{
///
/// 驱动代号列表
///
public List DriveCodeList = new List();
}
///
/// 虚拟驱动
///
[System.Serializable]
public class DriveCodeObj
{
///
/// 驱动代号
///
public int DriveCode;
///
/// 驱动硬件版本
///
public int DriveHwVersion;
///
/// 驱动软件版本
///
public int DriveFwVersion;
///
/// 驱动固件类型
///
public int DriveImageType;
///
/// 驱动标识符
///
public int DriveId;
}
#endregion
#region 网关系统升级
///
/// 网关系统升级,网关反馈具体信息
///
public LinuxUpgradeAllData linuxUpgradeAllData;
///
/// 网关系统升级,网关反馈具体信息
///
[System.Serializable]
public class LinuxUpgradeAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0:正常(默认回复)
///1:找不到升级固件,路径或升级固件名称错误。
///2:固件不合法。(如果强制升级,则返回正常,Result=0)
///3:升级固件过大(使用16MFlash时固件大小不得超过16449536B)
///4:升级文件名称中无“LINUXMODULE”标识。
///
public int Result = 999;
}
#endregion
#region 获取协调器当前信道.
///
/// 获取协调器当前信道,网关反馈具体信息
///
public GwGetChannelResponData zbGwGetChannelResponData;
///
/// 获取协调器当前信道,网关反馈具体信息
///
[System.Serializable]
public class GwGetChannelResponData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 协调器当前信道
///
public int channel = 999;
}
#endregion
#region 更改协调器当前信道.
///
/// 更改协调器当前信道,网关反馈具体信息
///
public ChangeChannelResponAllData changeChannelResponAllData;
///
/// 更改协调器当前信道,网关反馈具体信息
///
[System.Serializable]
public class ChangeChannelResponAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 更改协调器当前信道数据
///
public ChangeChannelResponData changeChannelResponData;
}
///
/// 更改协调器当前信道数据
///
public ChangeChannelResponData changeChannelResponData;
///
/// 更改协调器当前信道数据
///
[System.Serializable]
public class ChangeChannelResponData
{
///
/// 是否配置成功
///0:成功
///1:失败
///2:配置的信道为无效值
///
public int Status = 999;
///
/// 协调器当前信道
///
public int Channel = 999;
}
#endregion
//#region 获取协调器获取协调器当前发射功率.
/////
///// 获取协调器获取协调器当前发射功率
/////
//public static async System.Threading.Tasks.Task GetPowerAsync(ZigBee.Device.ZbGateway gateway)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// GwGetPowerResponData d = null;
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { Time = jobject.Value("Time"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d = new GwGetPowerResponData { errorMessageBase = "网关错误回复,且数据是空" };
// }
// else
// {
// d = new GwGetPowerResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/GetPower_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID") };
// var power = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"]["Power"].ToString());
// if (power == 0)
// {
// d = new GwGetPowerResponData { errorMessageBase = "网关返回的数据为空" };
// }
// else
// {
// d = new GwGetPowerResponData { power = power };
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// System.Console.WriteLine("GetPower_Actions 启动" + "_" + System.DateTime.Now.ToString());
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 10 } };
// gateway.Send(("ZbGw/GetPower"), Common.SecuritySet.Encryption((jObject.ToString())));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// if (d != null)
// {
// break;
// }
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 1000)
// {
// d = new GwGetPowerResponData { errorMessageBase = " 回复超时,请重新操作" };
// }
// gateway.Actions -= action;
// System.Console.WriteLine("GetPower_Actions 退出" + "_" + System.DateTime.Now.ToString());
// return d;
// });
//}
/////
///// 获取协调器获取协调器当前发射功率,网关反馈具体信息
/////
//public GwGetPowerResponData gwGetPowerResponData;
/////
///// 获取协调器获取协调器当前发射功率,网关反馈具体信息
/////
//[System.Serializable]
//public class GwGetPowerResponData
//{
// ///
// /// 错误信息
// ///
// public string errorMessageBase;
// ///
// /// 网关信息错误反馈
// /// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
// ///
// public ErrorResponData errorResponData;
// ///
// /// 协调器发射功率
// ///
// public int power = 999;
//}
//#endregion
//#region 设置发射功.
/////
/////设置发射功率
///// power:要更改的设备发射功率,可设置8,10,11,13,15,16,18,19,20,21,22(dBm)
/////
//public static async System.Threading.Tasks.Task GwSetPowerAsync(ZigBee.Device.ZbGateway gateway, int power)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// SetPowerResponAllData d = null;
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { Time = jobject.Value("Time"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d = new SetPowerResponAllData { errorMessageBase = "网关错误回复,且数据是空" };
// }
// else
// {
// d = new SetPowerResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/SetPower_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID") };
// var tempInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (tempInfo == null)
// {
// d = new SetPowerResponAllData { errorMessageBase = "网关返回的数据为空" };
// }
// else
// {
// d = new SetPowerResponAllData { setPoweResponData = tempInfo };
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// System.Console.WriteLine("ZbGw/SetPower_Actions 启动" + "_" + System.DateTime.Now.ToString());
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 11 } };
// var data = new JObject { { "Power", power } };
// jObject.Add("Data", data);
// gateway.Send(("ZbGw/SetPower"), Common.SecuritySet.Encryption(jObject.ToString(),Password));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// if (d != null)
// {
// break;
// }
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 1000)
// {
// d = new SetPowerResponAllData { errorMessageBase = " 回复超时,请重新操作" };
// }
// gateway.Actions -= action;
// System.Console.WriteLine("ZbGw/SetPower_Actions退出" + "_" + System.DateTime.Now.ToString());
// return d;
// });
//}
/////
///// 设置发射功率,网关反馈具体信息
/////
//public SetPowerResponAllData setPoweResponAllData;
/////
///// 设置发射功率,网关反馈具体信息
/////
//[System.Serializable]
//public class SetPowerResponAllData
//{
// ///
// /// 错误信息
// ///
// public string errorMessageBase;
// ///
// /// 网关信息错误反馈
// /// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
// ///
// public ErrorResponData errorResponData;
// ///
// /// 设置发射功率数据
// ///
// public SetPoweResponData setPoweResponData;
//}
/////
///// 设置发射功率数据
/////
//public SetPoweResponData setPoweResponData;
/////
///// 设置发射功率数据
/////
//[System.Serializable]
//public class SetPoweResponData
//{
// ///
// /// 是否配置成功
// ///0:成功
// ///2:配置的信道为无效值
// ///
// public int Status = 999;
// ///
// /// 功率
// ///
// public int Power = 999;
//}
//#endregion
//#region 读取当前局域网的PANID.
/////
///// 读取当前局域网的PANID
/////
//public static async System.Threading.Tasks.Task ReadPanIdAsync(ZigBee.Device.ZbGateway gateway)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// GetPanIdResponData d = null;
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { Time = jobject.Value("Time"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d = new GetPanIdResponData { errorMessageBase = "网关错误回复,且数据是空" };
// }
// else
// {
// d = new GetPanIdResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/GetPanId_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID") };
// var panID = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"]["PANID"].ToString());
// if (panID == null)
// {
// d = new GetPanIdResponData { errorMessageBase = "网关返回的数据为空" };
// }
// else
// {
// d = new GetPanIdResponData { panID = panID };
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// System.Console.WriteLine("ZbGw/GetPanId_Actions 启动" + "_" + System.DateTime.Now.ToString());
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 12 } };
// gateway.Send(("ZbGw/GetPanId"), Common.SecuritySet.Encryption((jObject.ToString())));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// if (d != null)
// {
// break;
// }
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 1000)
// {
// d = new GetPanIdResponData { errorMessageBase = " 回复超时,请重新操作" };
// }
// gateway.Actions -= action;
// System.Console.WriteLine("ZbGw/GetPanId_Actions 退出" + "_" + System.DateTime.Now.ToString());
// return d;
// });
//}
/////
///// 读取当前局域网的PANID,网关反馈具体信息
/////
//public GetPanIdResponData getPanIdResponData;
/////
///// 读取当前局域网的PANID,网关反馈具体信息
/////
//[System.Serializable]
//public class GetPanIdResponData
//{
// ///
// /// 错误信息
// ///
// public string errorMessageBase;
// ///
// /// 网关信息错误反馈
// /// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
// ///
// public ErrorResponData errorResponData;
// ///
// /// 当前网络的PANID
// ///
// public int panID = 999;
//}
//#endregion
//#region 读取协调器MAC地址.
/////
///// 读取协调器MAC地址
/////
//public static async System.Threading.Tasks.Task ReadMacAsync(ZigBee.Device.ZbGateway gateway)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// GetMacResponData d = null;
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { Time = jobject.Value("Time"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d = new GetMacResponData { errorMessageBase = "网关错误回复,且数据是空" };
// }
// else
// {
// d = new GetMacResponData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/GetMac_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID") };
// var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (tempData == null)
// {
// d = new GetMacResponData { errorMessageBase = "网关返回的数据为空" };
// }
// else
// {
// d = new GetMacResponData { macAddrData = tempData };
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
// gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jObject.ToString())));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// if (d != null)
// {
// break;
// }
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
// {
// d = new GetMacResponData { errorMessageBase = " 回复超时,请重新操作" };
// }
// gateway.Actions -= action;
// return d;
// });
//}
///
/// 读取协调器MAC地址,网关反馈具体信息
///
public GetMacResponData getMacResponData;
///
/// 读取协调器MAC地址,网关反馈具体信息
///
[System.Serializable]
public class GetMacResponData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 协调器mac地址
///
public MacAddrData macAddrData;
}
///
/// 读取协调器MAC地址,网关反馈具体信息
///
[System.Serializable]
public class MacAddrData
{
///
/// 协调器mac地址
///
public string MacAddr;
}
//#endregion
#region 添加Install Codes码
/////
/////添加Install Codes码
///// installCode:InstallCode码 36个字符
///// installCodeAddr:InstallCodes码设备的mac地址16个字符
/////
//public static async System.Threading.Tasks.Task InstallCodeAsync(ZigBee.Device.ZbGateway gateway, string installCode, string installCodeAddr)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// var d = new InstallCodeResponData { };
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { Time = jobject.Value("Time"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d.errorMessageBase = "网关错误回复,且数据是空";
// }
// else
// {
// d.errorResponData = temp;
// d.errorMessageBase = ErrorMess(temp.Error);
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/InstallCode_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID") };
// var code = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (code == null)
// {
// d.errorMessageBase = "网关返回的数据为空";
// }
// else
// {
// d.Status = code;
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
// gateway.Send(("ZbGw/GetMac"), Common.SecuritySet.Encryption((jObject.ToString())));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// //if (d.Status != 999)
// //{
// // break;
// //}
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 1000)
// {
// d.errorMessageBase = " 回复超时,请重新操作";
// }
// gateway.Actions -= action;
// return d;
// });
//}
///
/// 添加Install Codes码,网关反馈具体信息
///
public InstallCodeResponData installCodeResponData;
///
/// 添加Install Codes码,网关反馈具体信息
///
[System.Serializable]
public class InstallCodeResponData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0:成功,1:失败
///
public int Status = 999;
}
#endregion
#region 启用或关闭透传数据上传接口
///
/// 透传数据上传接口,网关反馈信息
///
public PassthroughAllData passthroughAllData;
///
/// 透传数据上传接口,网关反馈信息
///
[System.Serializable]
public class PassthroughAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 已经转换成字符格式的16进制的透传数据
///
public string passData;
}
#endregion
//#region 协调器通用功能操作接口
/////
///// 协调器通用功能操作接口
/////
///// The or get all data async.
///// Gateway.
///// Command identifier.
///// Payload.
//public static async System.Threading.Tasks.Task SetOrGetAllDataAsync(ZigBee.Device.ZbGateway gateway, int commandID, string payload)
//{
// if (gateway == null)
// {
// return null;
// }
// return await System.Threading.Tasks.Task.Run(async () =>
// {
// var d = new SetOrGetAllData { };
// Action action = (topic, message) =>
// {
// var gatewayID = topic.Split('/')[0];
// var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
// if (topic == gatewayID + "/" + "Error_Respon")
// {
// var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value("Device_ID"), DeviceAddr = jobject.Value("DeviceAddr"), DeviceEpoint = jobject.Value("Epoint"), DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (temp == null)
// {
// d.errorMessageBase = "网关错误回复,且数据是空";
// }
// else
// {
// d.errorResponData = temp;
// d.errorMessageBase = ErrorMess(temp.Error);
// }
// }
// if (topic == gatewayID + "/" + "ZbGw/SetOrGetData_Respon")
// {
// var gatewayTemp = new ZbGateway() { DataID = jobject.Value("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
// var temp = Newtonsoft.Json.JsonConvert.DeserializeObject(jobject["Data"].ToString());
// if (gatewayTemp.getGwVersion == null)
// {
// d.errorMessageBase = "网关返回的数据为空";
// }
// else
// {
// d.setOrGetData = temp;
// DebugPrintLog($"UI收到通知后的主题_{ topic}");
// }
// }
// };
// gateway.Actions += action;
// System.Console.WriteLine("ZbDataPassthrough_Actions 启动" + "_" + System.DateTime.Now.ToString());
// var jObject = new JObject { { "Cluster_ID", 64512 }, { "Command", 2 } };
// var data = new JObject { { "Command_ID", commandID }, { "Payload", payload } };
// jObject.Add("Data", data);
// gateway.Send("ZbGw/SetOrGetData", Common.SecuritySet.Encryption(jObject.ToString()));
// var dateTime = DateTime.Now;
// while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
// {
// await System.Threading.Tasks.Task.Delay(10);
// if (d.setOrGetData != null)
// {
// break;
// }
// }
// if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
// {
// d.errorMessageBase = " 回复超时,请重新操作";
// }
// gateway.Actions -= action;
// System.Console.WriteLine("GetGwVersionData_Actions 退出" + System.DateTime.Now.ToString());
// return d;
// });
//}
/////
///// BDB接口,网关反馈信息
/////
//public SetOrGetAllData setOrGetAllData;
/////
///// BDB接口,网关反馈信息
/////
//[System.Serializable]
//public class SetOrGetAllData
//{
// ///
// /// 错误信息
// ///
// public string errorMessageBase;
// ///
// /// 网关信息错误反馈
// /// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
// ///
// public ErrorResponData errorResponData;
// ///
// /// BDB数据
// ///
// public SetOrGetData setOrGetData;
//}
/////
///// BDB数据
/////
//public SetOrGetData setOrGetData;
/////
///// BDB数据
/////
//[System.Serializable]
//public class SetOrGetData
//{
// ///
// /// 协调器指令的command_ID。对应《协调器串口通信协议规范》第2章节指令的command_ID
// ///
// public int commandID;
// ///
// /// 已经转换成字符格式的16进制的data数据。对应《协调器串口通信协议规范》第2章节指令的“数据”内容
// ///
// public string payload;
//}
//#endregion
#region 客户端发送文件流到网关
///
/// 客户端发送文件流到网关
///
[System.Serializable]
public class SendFileResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0: 数据写入成功,请求发送下一个数据包
///1:数据写入失败
///2:数据解析错误
///3:发送数据大小超出限制
///
public int Result = -1;
}
#endregion
#region 客户端发送创建文件命令
///
/// 客户端发送创建文件命令,网关反馈信息
///
public CreateFileResponseAllData createFileResponseAllData;
///
/// 客户端发送创建文件命令,网关反馈信息
///
[System.Serializable]
public class CreateFileResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0:创建成功
///1:失败,无法创建文件
///2:失败,该客户端有文件还没上传完成,请等待文件上传完毕(一个客户端只能同时上传一个文件)
///
public int Result = 999;
}
#endregion
#region 查看网关目录文件信息
///
/// 查看网关目录文件信息,网关反馈信息
///
public FileTransferLsDiResponseAllData fileTransferLsDiResponseAllData;
///
/// 查看网关目录文件信息,网关反馈信息
///
[System.Serializable]
public class FileTransferLsDiResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 查看网关目录文件信息
///
public FileTransferLsDiResponseData fileTransferLsDiResponseData;
}
///
/// 查看网关目录文件信息,网关反馈信息
///
public FileTransferLsDiResponseData fileTransferLsDiResponseData;
///
/// 客户端发送创建文件命令,网关反馈信息
///
[System.Serializable]
public class FileTransferLsDiResponseData
{
///
///0: 成功
///1:查看失败
///
public int Result;
///
/// 目录文件列表
///
public List Dir = new List();
}
///
/// 目录文件
///
[System.Serializable]
public class DriObj
{
///
///文件(包含所在路径和文件名称:如/usr/sbin/aa.txt)
///
public string File;
///
///文件大小(byte)
///
public int FileSize;
///
///文件最后修改的utc时间戳
///
public int LastModifyTime;
}
#endregion
#region 客户端设定要下载的文件名称和路径
///
/// 客户端设定要下载的文件名称和路径,网关反馈信息
///
public SetDownloadFileResponseAllData setDownloadFileResponseAllData;
///
/// 客户端设定要下载的文件名称和路径,网关反馈信息
///
[System.Serializable]
public class SetDownloadFileResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 客户端设定要下载的文件名称和路径
///
public SetDownloadFileResponseData setDownloadFileResponseData;
}
///
/// 客户端设定要下载的文件名称和路径,网关反馈信息
///
public SetDownloadFileResponseData setDownloadFileResponseData;
///
/// 客户端设定要下载的文件名称和路径,网关反馈信息
///
[System.Serializable]
public class SetDownloadFileResponseData
{
///
///0:默认
///1:失败,文件不存在。
///2:BlockStartAddress设置不合理,超出文件大小范围。
///3:当前有文件在下载,需要等待正在进行的下载任务结束。
///
public int Result = -1;
///
/// 网关文件名称
///
//public string BackupFileName ;
///
/// 网关中对应文件中的数据内容
///
//public byte[] BackupFileContent;
}
#endregion
#region 查看单个文件信息
///
/// 查看单个文件信息数据
///
public FileTransferGetFileInfoResponseAllData fileTransferGetFileInfoResponseAllData;
///
/// 查看单个文件信息数据
///
[System.Serializable]
public class FileTransferGetFileInfoResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 查看单个文件信息返回的数据
///
public FileTransferGetFileInfoResponseData fileTransferGetFileInfoResponseData;
}
///
/// 查看单个文件信息返回的数据
///
public FileTransferGetFileInfoResponseData fileTransferGetFileInfoResponseData;
///
/// 查看单个文件信息返回的数据
///
[System.Serializable]
public class FileTransferGetFileInfoResponseData
{
///
/// 0: 成功
///1:查看失败,文件不存在
///
public int Result = -1;
///
///文件(包含所在路径和文件名称:如/etc/hdlDat/aa.txt)
///
public string File;
///
/// 文件大小(byte)(当Result = 0 时存在)
///
public int FileSize;
///
/// 文件最后修改的utc时间戳(当Result = 0 时存在)
///
public int LastModifyTime;
}
#endregion
#region 客户端接收到网关发色数据格式后应反馈给网关到格式数据
///
/// 客户端接收到网关发色数据格式后应反馈给网关到格式数据
///
public DownloadFileResponseAllData downloadFileResponseAllData;
///
/// 客户端接收到网关发色数据格式后应反馈给网关到格式数据
///
[System.Serializable]
public class DownloadFileResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0: 数据写入成功,请求发送下一个数据包
///1:终止下载。当下载出现错误,或者下载已经完成可以发送该值。
///
public int Result = -1;
}
///
/// 客户端接收到网关发色数据格式后应反馈给网关
///
public FileTransferDownloadFileRespon fileTransferDownloadFileRespon;
///
/// 客户端接收到网关发色数据格式后应反馈给网关
///
[System.Serializable]
public class FileTransferDownloadFileRespon
{
///
/// 0: 数据写入成功,请求发送下一个数据包
///1:终止下载。当下载出现错误,或者下载已经完成可以发送该值。
///
public int Result = -1;
}
#endregion
#region 删除文件或目录
///
/// 删除文件或目录,网关反馈信息
///
public DelFileOrDirResponseAllData delFileOrDirResponseAllData;
///
/// 删除文件或目录,网关反馈信息
///
[System.Serializable]
public class DelFileOrDirResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 删除文件或目录
///
public DelFileOrDirResponseData delFileOrDirResponseData;
}
///
/// 删除文件或目录,网关反馈信息
///
public DelFileOrDirResponseData delFileOrDirResponseData;
///
/// 删除文件或目录,网关反馈信息
///
[System.Serializable]
public class DelFileOrDirResponseData
{
///
///0: 删除成功
///1:删除失败,路径不存在
///2:无法删除。
///
public int Result;
///
///目录或文件的路径
///
public string Path;
}
#endregion
#region 创建一个目录
///
/// 创建一个目录,网关反馈信息
///
public CreateDirResponseAllData createDirResponseAllData;
///
/// 创建一个目录,网关反馈信息
///
[System.Serializable]
public class CreateDirResponseAllData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 创建一个目录
///
public CreateDirResponseData createDirResponseData;
}
///
/// 创建一个目录,网关反馈信息
///
public CreateDirResponseData createDirResponseData;
///
/// 创建一个目录,网关反馈信息
///
[System.Serializable]
public class CreateDirResponseData
{
///
///0: 创建成功
///1:创建失败
///
public int Result;
///
///目录或文件的路径
///
public string Path;
}
#endregion
#region 客户端发送DES密钥到网关
///
/// 客户端发送DES密钥到网关,网关反馈具体信息
///
public SendKeyResponData sendDESKeyResponData;
///
/// 客户端发送DES密钥到网关,网关反馈具体信息
///
[System.Serializable]
public class SendKeyResponData
{
///
/// 错误信息
///
public string errorMessageBase;
///
/// 网关信息错误反馈
/// 当网关接收到客户端信息后,出现以下异常情况将反馈错误。
///
public ErrorResponData errorResponData;
///
/// 0:成功
///1:失败,RSA私钥解密失败
///
public int Result = -1;
}
#endregion
}
}