private bool GetOnOffStateFromDevice() { ZclAttribute attributeOnOff = null; System.Object value; // look for OnOff cluster of this end point and get the value of the on/off attribute var onOffCluster = m_endPoint.GetCluster(OnOffCluster.CLUSTER_ID); if (onOffCluster != null && onOffCluster.InternalAttributeList.TryGetValue(OnOffCluster.ATTRIBUTE_ONOFF, out attributeOnOff) && attributeOnOff.Read(out value) && value is bool) { m_onOffState = (bool)value; } return(m_onOffState); }
private void ZclReportAttributeReception(ZclReportAttributes.SOURCE_INFO deviceInfo, UInt16 attributeId, object newValue) { ZigBeeDevice device = null; ZigBeeEndPoint endPoint = null; ZclCluster cluster = null; ZclAttribute attribute = null; // look for corresponding ZigBee device lock (m_deviceMap) { if (!m_deviceMap.TryGetValue(deviceInfo.macAddress, out device)) { // unknown device => do nothing return; } } // look for corresponding end point if (!device.EndPointList.TryGetValue(deviceInfo.endpointId, out endPoint)) { // unknown end point => do nothing return; } // look for corresponding cluster cluster = endPoint.GetCluster(deviceInfo.clusterId); if (cluster == null) { // unknown cluster => do nothing return; } // look for the corresponding attribute if (cluster.InternalAttributeList.TryGetValue(attributeId, out attribute)) { // unknown attribute => do nothing return; } // update value attribute.Value.Data = newValue; // signal value of attribute has changed SignalChangeOfAttributeValue(endPoint, cluster, attribute); }