| | |
| | | //设备控制状态反馈
|
| | | else if (reportTopic == "DeviceDefaultAck")
|
| | | {
|
| | | //this.DeviceControlResponePush(JObject.Parse(msgData));
|
| | | this.DeviceControlResponePush(JObject.Parse(msgData));
|
| | | }
|
| | | //撤防
|
| | | else if (topic == gatewayId + "/Security/WithdrawMode_Respon")
|
| | |
| | | ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 电量推送
|
| | | //电量推送
|
| | | if (report.DeviceStatusReport.CluterID == 1)
|
| | | {
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //电量
|
| | | if (attData.AttributeId == 33)
|
| | | {
|
| | | string receiptData = string.Empty;
|
| | | //两个两个位置替换
|
| | | for (int i = attData.AttriButeDataHex.Length - 1; i >= 0; i = i - 2)
|
| | | {
|
| | | receiptData += attData.AttriButeDataHex[i - 1].ToString() + attData.AttriButeDataHex[i].ToString();
|
| | | }
|
| | | int batteryValue = Convert.ToInt32(receiptData, 16);
|
| | | //低于20%,则代表电量低
|
| | | locadevice.IsBatteryDown = batteryValue < 20;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 蜂鸣器推送
|
| | | //蜂鸣器数据
|
| | | else if (report.DeviceStatusReport.CluterID == 1282)
|
| | | {
|
| | | //mini夜灯
|
| | | if (Common.LocalDevice.Current.IsMiniLight(locadevice) == true)
|
| | | {
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | if (attData.AttributeId == 0)
|
| | | {
|
| | | //这个是报警持续时间(大于2秒时,标记为还在响着)
|
| | | ((ColorTemperatureLight)locadevice).IsBuzzerRing = attData.AttriButeData > 2 ? true : false;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | else if (report.DeviceStatusReport.CluterID == 8)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | if (locadevice.Type == DeviceType.DimmableLight && report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | {
|
| | | //此属性表明当前亮度程度
|
| | | ((DimmableLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | if (locadevice.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | //此属性表明当前亮度程度
|
| | | ((DimmableLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | }
|
| | | else if (locadevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | //此属性表明当前亮度程度
|
| | | ((ColorTemperatureLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | |
|
| | | //if (locadevice is LightBase)
|
| | | //{
|
| | | // //当接收到亮度值时,默认打开
|
| | | // ((LightBase)locadevice).OnOffStatus = 1;
|
| | | //}
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 色温数据
|
| | | //色温数据
|
| | | else if (report.DeviceStatusReport.CluterID == 768)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | {
|
| | | if (locadevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | //此属性表明当前色温
|
| | | int value = report.DeviceStatusReport.AttriBute[0].AttriButeData != 0 ? 1000000 / report.DeviceStatusReport.AttriBute[0].AttriButeData : 0;
|
| | | ((ColorTemperatureLight)locadevice).ColorTemperature = value;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | |
| | | //温度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Temperatrue = temperatrue;
|
| | | ((TemperatureSensor)locadevice).currentTemperature = temperatrue;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | |
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | //温度值需要保存
|
| | | locadevice.ReSave();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | //温度传感器
|
| | | //湿度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Humidity = humidity;
|
| | | ((TemperatureSensor)locadevice).currentHumidity = humidity;
|
| | | }
|
| | | //新风的湿度传感器
|
| | | else if (locadevice is HumiditySensor)
|
| | | {
|
| | | ((HumiditySensor)locadevice).currentHumidity = humidity;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | | {
|
| | | ((PMSensor)locadevice).currentHumidity = (int)humidity;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | //湿度值需要保存
|
| | | locadevice.ReSave();
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | |
|
| | | #region ■ 设备基础信息
|
| | |
|
| | | else if (report.DeviceStatusReport.CluterID == 0)
|
| | | {
|
| | | var listLocalDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr, false);
|
| | | //属性都是一样的
|
| | | foreach (var myDevice in listLocalDevice)
|
| | | {
|
| | | //属性是否改变
|
| | | bool attriButeChanged = false;
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //生产商名字
|
| | | if (data.AttributeId == 4 && data.AttriButeDataHex.Length > 2)
|
| | | {
|
| | | if (data.AttriButeDataHex.Length > 2)
|
| | | {
|
| | | var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
|
| | | if (myDevice.ManufacturerName != value)
|
| | | {
|
| | | //属性变更了
|
| | | attriButeChanged = true;
|
| | | }
|
| | | myDevice.ManufacturerName = value;
|
| | | }
|
| | | }
|
| | | //型号码(也叫模块ID)
|
| | | if (data.AttributeId == 5)
|
| | | {
|
| | | if (data.AttriButeDataHex.Length > 2)
|
| | | {
|
| | | var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
|
| | | if (myDevice.ModelIdentifier != value)
|
| | | {
|
| | | //属性变更了
|
| | | attriButeChanged = true;
|
| | | }
|
| | | myDevice.ModelIdentifier = value;
|
| | | }
|
| | | }
|
| | | //生产日期
|
| | | if (data.AttributeId == 6)
|
| | | {
|
| | | if (data.AttriButeDataHex.Length > 2)
|
| | | {
|
| | | var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
|
| | | if (myDevice.ProductionDate != value)
|
| | | {
|
| | | //属性变更了
|
| | | attriButeChanged = true;
|
| | | }
|
| | | myDevice.ProductionDate = value;
|
| | | }
|
| | | }
|
| | | //电源
|
| | | if (data.AttributeId == 7)
|
| | | {
|
| | | myDevice.PowerSource = data.AttriButeData;
|
| | | }
|
| | | //序列号
|
| | | if (data.AttributeId == 13)
|
| | | {
|
| | | if (data.AttriButeDataHex.Length > 2)
|
| | | {
|
| | | string value;
|
| | | if (Common.LocalDevice.Current.IsHdlDevice(myDevice) == false)
|
| | | {
|
| | | //第三方设备
|
| | | value = data.AttriButeDataHex.Substring(2);
|
| | | }
|
| | | else
|
| | | {
|
| | | //河东设备
|
| | | value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
|
| | | }
|
| | | if (myDevice.SerialNumber != value)
|
| | | {
|
| | | //属性变更了
|
| | | attriButeChanged = true;
|
| | | }
|
| | | myDevice.SerialNumber = value;
|
| | | }
|
| | | }
|
| | | }
|
| | | //如果属性变更了
|
| | | if (attriButeChanged == true && myDevice.IsCustomizeImage == false)
|
| | | {
|
| | | //UI重新生成
|
| | | myDevice.IconPath = string.Empty;
|
| | | myDevice.ReSave();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | else if (deviceEpoint == 200)
|
| | | {
|
| | | var localOta = Common.LocalDevice.Current.GetOTADevice(deviceAddr);
|
| | | if (localOta != null)
|
| | | {
|
| | | #region ■ 固件版本
|
| | | //固件版本
|
| | | if (report.DeviceStatusReport.CluterID == (int)Cluster_ID.Ota)
|
| | | {
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //镜像版本
|
| | | if (data.AttributeId == (int)AttriButeId.ImgVersion)
|
| | | {
|
| | | localOta.ImgVersion = data.AttriButeData;
|
| | | }
|
| | | //硬件版本
|
| | | if (data.AttributeId == (int)AttriButeId.mgHWversion)
|
| | | {
|
| | | localOta.HwVersion = data.AttriButeData;
|
| | | }
|
| | | //镜像ID
|
| | | if (data.AttributeId == (int)AttriButeId.ImgTypeId)
|
| | | {
|
| | | localOta.ImgTypeId = data.AttriButeData;
|
| | | }
|
| | | }
|
| | | localOta.ReSave();
|
| | | }
|
| | | #endregion
|
| | | }
|
| | | }
|
| | | this.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | | }
|
| | |
|