private void DisplayOnOffStatus() { ZclAttribute attributeOnOff = null; System.Object value; var onOffcluster = m_testedEndPoint.GetCluster(OnOffCluster.CLUSTER_ID); if (onOffcluster != null) { onOffcluster.InternalAttributeList.TryGetValue(OnOffCluster.ATTRIBUTE_ONOFF, out attributeOnOff); } if (attributeOnOff.Read(out value)) { if (value is bool) { var isOn = (bool)value; if (isOn) { Debug.WriteLine(" -> Light is on"); } else { Debug.WriteLine(" -> Light is off"); } } } }
private void TestBitronHome() { ZclAttribute attribute = null; System.Object value; var IasZoneCluster = m_testedEndPoint.GetCluster(IASZoneCluster.CLUSTER_ID); if (IasZoneCluster == null) { Debug.WriteLine("ERROR - CAN'T GET BitronHome IAS Zone cluster !!!!"); return; } IasZoneCluster.InternalAttributeList.TryGetValue(IASZoneCluster.ATTRIBUTE_ZONESTATUS, out attribute); if (attribute != null && attribute.Read(out value) && value is UInt16) { Debug.WriteLine("IAS Zone status = {0}", value); } else { Debug.WriteLine("ERROR - IAS Zone status !!!!"); } IasZoneCluster.InternalAttributeList.TryGetValue(IASZoneCluster.ATTRIBUTE_ZONETYPE, out attribute); if (attribute != null && attribute.Read(out value) && value is UInt16) { Debug.WriteLine("IAS Zone type = {0}", value); } else { Debug.WriteLine("ERROR - IAS Zone type !!!!"); } IasZoneCluster.InternalAttributeList.TryGetValue(IASZoneCluster.ATTRIBUTE_ZONESTATE, out attribute); if (attribute != null && attribute.Read(out value) && value is byte) { Debug.WriteLine("IAS Zone state = {0}", value); } else { Debug.WriteLine("ERROR - IAS Zone state !!!!"); } IasZoneCluster.InternalAttributeList.TryGetValue(IASZoneCluster.ATTRIBUTE_IASCIEADDRESS, out attribute); if (attribute != null && attribute.Read(out value) && value is UInt64) { UInt64 macAddr = (UInt64)value; Debug.WriteLine("IAS Zone Cie address = 0x{0:X}", macAddr); if (macAddr == 0) { attribute.Write(m_zigBeeAdapter.MacAddress); } } else { Debug.WriteLine("ERROR - IAS Zone Cie Address !!!!"); } }
private async Task Initialise() { byte?currentState = (byte?)await _iasZoneCluster.GetAttribute(ZclIasZoneCluster.ATTR_ZONESTATE).ReadValue(long.MaxValue); if (currentState.HasValue) { ZoneStateEnum currentStateEnum = (ZoneStateEnum)currentState; Log.Debug("{Address}: IAS CIE state is currently {StateEnum}[{State}]", _iasZoneCluster.GetZigBeeAddress(), currentStateEnum, currentState); if (currentStateEnum == ZoneStateEnum.ENROLLED) { Log.Debug("{Address}: IAS CIE is already enrolled", _iasZoneCluster.GetZigBeeAddress()); return; } } else { Log.Debug("{Address}: IAS CIE failed to get state", _iasZoneCluster.GetZigBeeAddress()); } ZclAttribute cieAddressAttribute = _iasZoneCluster.GetAttribute(ZclIasZoneCluster.ATTR_IASCIEADDRESS); IeeeAddress currentIeeeAddress = (IeeeAddress)await cieAddressAttribute.ReadValue(0); Log.Debug("{Address}: IAS CIE address is currently {Address2}", _iasZoneCluster.GetZigBeeAddress(), currentIeeeAddress); if (!_ieeeAddress.Equals(currentIeeeAddress)) { // Set the CIE address in the remote device. This is where the device will send its reports. await cieAddressAttribute.WriteValue(_ieeeAddress); currentIeeeAddress = (IeeeAddress)await cieAddressAttribute.ReadValue(0); if (_ieeeAddress.Equals(currentIeeeAddress)) { Log.Debug("{Address}: IAS CIE address is confirmed {Address2}", _iasZoneCluster.GetZigBeeAddress(), currentIeeeAddress); } else { Log.Warning("{Address}: IAS CIE address is NOT confirmed {Address2}", _iasZoneCluster.GetZigBeeAddress(), currentIeeeAddress); } } byte?currentZone = (byte?)await _iasZoneCluster.GetAttribute(ZclIasZoneCluster.ATTR_ZONEID).ReadValue(0); if (currentZone == null) { Log.Debug("{Address}: IAS CIE zone ID request failed", _iasZoneCluster.GetZigBeeAddress()); } else { Log.Debug("{Address}: IAS CIE zone ID is currently {ZoneId}", _iasZoneCluster.GetZigBeeAddress(), currentZone); } ZoneType = (ushort?)await _iasZoneCluster.GetAttribute(ZclIasZoneCluster.ATTR_ZONETYPE).ReadValue(long.MaxValue); if (ZoneType == null) { Log.Debug("{Address}: IAS CIE zone type request failed", _iasZoneCluster.GetZigBeeAddress()); } else { Log.Debug("{Address}: IAS CIE zone type is {ZoneTypeEnum} ({ZoneTypeValue})", _iasZoneCluster.GetZigBeeAddress(), ((ZoneTypeEnum)ZoneType), ZoneType.Value.ToString("X2")); } // Start the auto-enroll timer _autoEnrollmentCancellationToken = new CancellationTokenSource(); _ = Task.Run(RunAutoEnrollmentTask, _autoEnrollmentCancellationToken.Token); }