| | |
| | | /// <param name="clusterId">镞ID</param>
|
| | | /// <param name="attributeId">属性ID</param>
|
| | | /// <param name="attributeDataType">数据类型</param>
|
| | | /// <param name="attributeData">需要写入的数据</param>
|
| | | /// <param name="attributeData">需要写入的数据(数值或者字符串)</param>
|
| | | /// <returns></returns>
|
| | | public async System.Threading.Tasks.Task<CommonDevice.SetWritableValueResponAllData> WriteDeviceAttribute(CommonDevice device, int clusterId, int attributeId, int attributeDataType, string attributeData)
|
| | | public async System.Threading.Tasks.Task<CommonDevice.SetWritableValueResponAllData> WriteDeviceAttribute(CommonDevice device, int clusterId, int attributeId, int attributeDataType, object attributeData)
|
| | | {
|
| | | var MyGateway = device.Gateway;
|
| | | if (MyGateway == null)
|
| | |
| | | try
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", clusterId }, { "Command", 120 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData } };
|
| | | Newtonsoft.Json.Linq.JObject data = null;
|
| | | if (attributeData is int)
|
| | | {
|
| | | data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", Convert.ToInt32(attributeData) } };
|
| | | }
|
| | | else
|
| | | {
|
| | | data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData.ToString() } };
|
| | | }
|
| | | jObject.Add("Data", data);
|
| | | MyGateway.Send("SetWritableValue", jObject.ToString());
|
| | | }
|