public static bool TryParseIEEEAddressResponse(EzspIncomingMessageHandlerResponse message, out EmberEui64 eui) { bool result = false; eui = null; if (message.ApsFrame.ProfileId == ZdoConstants.ZdoProfileId && message.ApsFrame.ClusterId == ZdoClusterIds.IEEEAddressResponse) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Read Sequence Number buffer.ReadByte(); // Read Status eui = new EmberEui64(buffer.ReadArray(EUI_LENGTH).Reverse().ToArray()); result = true; } catch { result = false; } } return(result); }
public static bool TryParseIasZoneEnrollRequest(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.IasZone) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Header buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (command == CommandIds.IasZoneServer.ZoneEnrollRequest) { result = true; } } catch { result = false; } } return(result); }
public static bool TryParseReadOffResponse(EzspIncomingMessageHandlerResponse message, out byte buttonId) { bool result = false; buttonId = byte.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OnOffCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (command == CommandIds.OnOffClient.OffClusterCommand && (header & ZclConstants.ZclFrameControlClusterSpecificBit) != 0) { buttonId = message.ApsFrame.SourceEndpoint; result = true; } } catch { result = false; } } return(result); }
public static bool TryParseOnOffDefaultResponse(EzspIncomingMessageHandlerResponse message, out byte payloadCommand) { bool result = false; payloadCommand = byte.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OnOffCluster) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); buffer.ReadByte(); var command = buffer.ReadByte(); if (command == CommandIds.Global.DefaultResponse) { var payload = buffer.ReadByte(); var status = buffer.ReadByte(); if (status == ZCLStatus.ZclStatusSuccess) { payloadCommand = payload; result = true; } } } catch { result = false; } } return(result); }
public static bool TryParseSelfTestDefaultResponse(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.BasicCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); if (header == (ZclConstants.ZclFrameControlManufacturerSpecificBit | ZclConstants.ZclFrameControlClusterServerToClientBit) || header == (ZclConstants.ZclFrameControlManufacturerSpecificBit | ZclConstants.ZclFrameControlClusterServerToClientBit | ZclConstants.ZclFrameControlClusterSpecificBit)) { var mfgCode = buffer.ReadUInt16(); buffer.ReadByte(); var command = buffer.ReadByte(); if (mfgCode == ZclConstants.CentraliteManufacturerId && command == CommandIds.Global.DefaultResponse) { var status = buffer.ReadByte(); return(status == ZCLStatus.ZclStatusSuccess); } } } catch { result = false; } } return(result); }
public static bool TryParseActiveEndpointResponse(EzspIncomingMessageHandlerResponse message, out ushort networkAddress, out byte endpointCount) { bool result = false; networkAddress = ushort.MaxValue; endpointCount = byte.MaxValue; if (message.ApsFrame.ProfileId == ZdoConstants.ZdoProfileId && message.ApsFrame.ClusterId == ZdoClusterIds.ActiveEndpointResponse) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Sequence var status = buffer.ReadByte(); if (status == ZCLStatus.ZclStatusSuccess) { networkAddress = buffer.ReadUInt16(); endpointCount = buffer.ReadByte(); result = true; } } catch { result = false; } } return(result); }
public static bool TryParseFirmwareVersion(EzspIncomingMessageHandlerResponse message, out uint firmwareVersion) { bool result = false; firmwareVersion = default(uint); if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OtaUpgradeCluster) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Control buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); var attributeId = buffer.ReadUInt16(); var status = buffer.ReadByte(); buffer.ReadByte(); // DataType if (command == CommandIds.Global.ReadAttributesResponse && attributeId == AttributeIds.OtaServer.CurrentFileVersion && status == ZCLStatus.ZclStatusSuccess) { firmwareVersion = buffer.ReadUInt32(); result = true; } } catch { result = false; } } return(result); }
public static bool TryParseDeviceDefaultedResponse(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.BasicCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (command == CommandIds.Global.DefaultResponse && (header & ZclConstants.ZclFrameControlClusterServerToClientBit) != 0) { var status = buffer.ReadByte(); result = status == ZCLStatus.ZclStatusSuccess; } } catch { result = false; } } return(result); }
public static bool TryParseProximityDetectedResponse(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.BasicCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); var mfgCode = buffer.ReadUInt16(); buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (mfgCode == ZclConstants.CentraliteManufacturerId && command == CommandIds.Keypad.ProximityDetected && header == (ZclConstants.ZclFrameControlManufacturerSpecificBit | ZclConstants.ZclFrameControlClusterSpecificBit | ZclConstants.ZclFrameControlClusterServerToClientBit)) { result = true; } } catch { result = false; } } return(result); }
public static bool TryParseUpgradeEndRequestCommand(EzspIncomingMessageHandlerResponse message, out byte status) { bool result = false; status = byte.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OtaUpgradeCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var control = buffer.ReadByte(); buffer.ReadByte(); // Sequence Number var command = buffer.ReadByte(); if (command == CommandIds.OtaUpgrade.UpgradeEndRequest) { status = buffer.ReadByte(); var mfgCode = buffer.ReadUInt16(); var imageType = buffer.ReadUInt16(); var fileVersion = buffer.ReadUInt32(); result = true; } } catch { result = false; } } return(result); }
public static bool TryParseIasZoneStatusChange(EzspIncomingMessageHandlerResponse message, out ushort zoneStatus) { bool result = false; zoneStatus = ushort.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.IasZone) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if ((command == CommandIds.IasZoneServer.ZoneStatusChanged) && (header == (ZclConstants.ZclFrameControlClusterSpecificBit | ZclConstants.ZclFrameControlClusterServerToClientBit))) { zoneStatus = buffer.ReadUInt16(); result = true; } } catch { result = false; } } return(result); }
public static bool TryParsePowerMeasurementResponse(EzspIncomingMessageHandlerResponse message, out double power) { bool result = false; power = double.NaN; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.ElectricalMeasurement) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Header buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (command == CommandIds.Global.ReadAttributesResponse) { var attribute = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (status == ZCLStatus.ZclStatusSuccess) { buffer.ReadByte(); // DataType var tempPower = buffer.ReadInt16(); power = (double)tempPower / 10.0; result = true; } } } catch { result = false; } } return(result); }
public void AddMessage(EzspIncomingMessageHandlerResponse message, ZigbeeDeviceBase device) { lock (Messages) { Messages.Enqueue(Tuple.Create(message, device)); } MessageAddedEvent?.Invoke(); }
public static bool TryParseImageBlockRequestCommand(EzspIncomingMessageHandlerResponse message, out ushort mfgCode, out ushort imageType, out uint fileVersion, out uint fileOffset, out byte maxDataSize, out ushort blockRequestDelay) { bool result = false; mfgCode = ushort.MaxValue; imageType = ushort.MaxValue; fileVersion = uint.MaxValue; fileOffset = uint.MaxValue; maxDataSize = byte.MaxValue; blockRequestDelay = ushort.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OtaUpgradeCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var control = buffer.ReadByte(); buffer.ReadByte(); // Sequence Number var command = buffer.ReadByte(); if (command == CommandIds.OtaUpgrade.ImageBlockRequest) { var fieldControl = buffer.ReadByte(); mfgCode = buffer.ReadUInt16(); imageType = buffer.ReadUInt16(); fileVersion = buffer.ReadUInt32(); fileOffset = buffer.ReadUInt32(); maxDataSize = buffer.ReadByte(); EmberEui64 eui; if ((fieldControl & ImageBlockRequestFieldControl.IEEEAddressPresent) != 0) { eui = new EmberEui64(buffer.ReadArray(EUI_LENGTH).Reverse().ToArray()); } if ((fieldControl & ImageBlockRequestFieldControl.BlockRequestDelayPresent) != 0) { blockRequestDelay = buffer.ReadUInt16(); } result = true; } } catch { result = false; } } return(result); }
public static bool TryParseModelString(EzspIncomingMessageHandlerResponse message, out string modelString) { bool result = false; modelString = null; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.BasicCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var control = buffer.ReadByte(); ushort?manufacturerCode = null; if ((control & ZclConstants.ZclFrameControlManufacturerSpecificBit) == ZclConstants.ZclFrameControlManufacturerSpecificBit) { manufacturerCode = buffer.ReadUInt16(); } buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (((control & COMMAND_ACROSS_ENTIRE_PROFILE_MASK) == 0x00) && (command == CommandIds.Global.ReadAttributesResponse)) { var identifier = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (status == ZCLStatus.ZclStatusSuccess) { if (identifier == AttributeIds.BasicServer.ModelIdentifier) { var dataType = buffer.ReadByte(); var length = buffer.ReadByte(); if (dataType == ZclDataTypes.CharacterString) { modelString = Encoding.ASCII.GetString(buffer.ReadArray(length)); result = true; } } } } } catch { result = false; } } return(result); }
public void TestRetrieveMessage() { var message = new EzspIncomingMessageHandlerResponse(); var device = new DemoZigbeeDeviceBase(); messageQueueService.AddMessage(message, device); var tuple = messageQueueService.RetrieveMessage(); Assert.AreEqual(tuple.Item1, message); Assert.AreEqual(tuple.Item2, device); tuple = messageQueueService.RetrieveMessage(); Assert.AreEqual(tuple, null); }
public static bool TryParseReadOrientationResponse(EzspIncomingMessageHandlerResponse message, out byte orienationResult) { bool result = false; orienationResult = byte.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.CentraliteAccelerometer) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); var mfgCode = buffer.ReadUInt16(); buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (mfgCode == ZclConstants.CentraliteManufacturerId && command == CommandIds.Global.ReadAttributesResponse && (header & ZclConstants.ZclFrameControlClusterServerToClientBit) != 0) { var attributeId = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (attributeId == AttributeIds.AccelerometerServer.AccelerometerOrientation && status == ZCLStatus.ZclStatusSuccess) { var dataType = buffer.ReadByte(); if (dataType == ZclDataTypes.Enumeration8Bit) { orienationResult = buffer.ReadByte(); result = true; } } } } catch { result = false; } } return(result); }
public void TestClearConsumerEvents() { bool messageAddedEventCalled = false; messageQueueService.MessageAddedEvent += delegate() { messageAddedEventCalled = true; }; messageQueueService.ClearConsumerEvents(); var message = new EzspIncomingMessageHandlerResponse(); var device = new DemoZigbeeDeviceBase(); messageQueueService.AddMessage(message, device); Assert.IsFalse(messageAddedEventCalled); }
public void TestAddMessage() { bool messageAddedEventCalled = false; messageQueueService.MessageAddedEvent += delegate() { messageAddedEventCalled = true; }; var message = new EzspIncomingMessageHandlerResponse(); var device = new DemoZigbeeDeviceBase(); messageQueueService.AddMessage(message, device); var messages = (Queue <Tuple <EzspIncomingMessageHandlerResponse, ZigbeeDeviceBase> >) typeof(MessageQueueService).GetField("Messages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(messageQueueService); Assert.IsTrue(messageAddedEventCalled); Assert.AreEqual(messages.Peek().Item1, message); Assert.AreEqual(messages.Peek().Item2, device); }
public static bool TryParseReadHumidityResponse(EzspIncomingMessageHandlerResponse message, uint expectedManufacturerCode, out double humidity) { bool result = false; humidity = double.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.CentraliteHumidity) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); var manufacturerCode = buffer.ReadUInt16(); buffer.ReadByte(); var command = buffer.ReadByte(); if (manufacturerCode == expectedManufacturerCode && command == CommandIds.Global.ReadAttributesResponse && (header & ZclConstants.ZclFrameControlClusterServerToClientBit) != 0) { var attributeId = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (attributeId == AttributeIds.TemperatureMeasurementServer.MeasuredValue && status == ZCLStatus.ZclStatusSuccess) { buffer.ReadByte(); // Data Type double humidityValue = buffer.ReadUInt16(); humidity = humidityValue / 100; result = true; } } } catch { result = false; } } return(result); }
public static bool TryParseThermostatTemperatureResponse(EzspIncomingMessageHandlerResponse message, out double temperature) { bool result = false; temperature = double.NaN; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.Thermostat) { try { var buffer = new CommandBuffer(message.MessageContents); var header = buffer.ReadByte(); // Header buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); // Command if (command == CommandIds.Global.ReadAttributesResponse && (header & ZclConstants.ZclFrameControlClusterServerToClientBit) != 0) { var attributeId = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (attributeId == AttributeIds.TemperatureMeasurementServer.MeasuredValue && status == ZCLStatus.ZclStatusSuccess) { var dataType = buffer.ReadByte(); // Data Type if (dataType == ZclDataTypes.Int16) { var temp = buffer.ReadInt16(); temperature = ((temp / 100) * 1.8) + 32; result = true; } } } } catch { result = false; } } return(result); }
public static bool TryParseLongPollIntervalMin(EzspIncomingMessageHandlerResponse message, out uint longPollIntervalMin) { bool result = false; longPollIntervalMin = uint.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.PollControl) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Control buffer.ReadByte(); // Sequence var command = buffer.ReadByte(); if (command == CommandIds.Global.ReadAttributesResponse) { var attributeId = buffer.ReadUInt16(); if (attributeId == AttributeIds.PollControl.LongPollIntervalMin) { var status = buffer.ReadByte(); if (status == ZCLStatus.ZclStatusSuccess) { buffer.ReadByte(); // DataType longPollIntervalMin = buffer.ReadUInt32(); result = true; } } } } catch { result = false; } } return(result); }
public void ValidateDevice(ZigbeeDeviceBase device, EzspIncomingMessageHandlerResponse message) { if (message != null) { EmberEui64 eui; string modelString; uint firmwareVersion; if ((ZdoMessageParser.TryParseDeviceAnnounce(message, out eui) || ZdoMessageParser.TryParseIEEEAddressResponse(message, out eui))) { if (VerifyEui(eui)) { device.Eui = eui; OnAddDevice?.Invoke(device); } else { OnRemoveDevice?.Invoke(device); } } else if (HaMessageParser.TryParseModelString(message, out modelString)) { if (VerifyModelString(modelString)) { device.ModelString = modelString; } else { OnRemoveDevice?.Invoke(device); } } else if (HaMessageParser.TryParseFirmwareVersion(message, out firmwareVersion)) { device.LongFirmwareVersion = (firmwareVersion == default(uint)) ? uint.MaxValue : firmwareVersion; } } RequestDeviceInformation(device); }
public static bool TryParseLeaveResponse(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZdoConstants.ZdoProfileId && message.ApsFrame.ClusterId == ZdoClusterIds.ManagementLeaveResponse && message.ApsFrame.DestinationEndpoint == 0 && message.ApsFrame.SourceEndpoint == 0) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); // Sequence Number var status = buffer.ReadByte(); // Status result = status == ZCLStatus.ZclStatusSuccess; } catch { result = false; } } return(result); }
public static bool TryParseImagePageRequest(EzspIncomingMessageHandlerResponse message) { bool result = false; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OtaUpgradeCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var control = buffer.ReadByte(); buffer.ReadByte(); var command = buffer.ReadByte(); if (command == CommandIds.OtaUpgrade.ImagePageRequest) { var fieldControl = buffer.ReadByte(); var mfgCode = buffer.ReadUInt16(); var imageType = buffer.ReadUInt16(); var fileVersion = buffer.ReadUInt16(); var fileOffset = buffer.ReadUInt16(); var maxDataSize = buffer.ReadByte(); var pageSize = buffer.ReadUInt16(); var responseSpacing = buffer.ReadUInt16(); if ((fieldControl & 0x01) != 0) { var ieeeAddress = buffer.ReadArray(EUI_LENGTH).Reverse().ToArray(); } } } catch { result = false; } } return(result); }
public static bool TryParseQueryNextImageRequest(EzspIncomingMessageHandlerResponse message, out ushort mfgCode, out ushort imageType, out uint fileVersion) { bool result = false; mfgCode = ushort.MaxValue; imageType = ushort.MaxValue; fileVersion = uint.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OtaUpgradeCluster) { try { var buffer = new CommandBuffer(message.MessageContents); var control = buffer.ReadByte(); buffer.ReadByte(); // Sequence Number var command = buffer.ReadByte(); if (command == CommandIds.OtaUpgrade.QueryNextImageRequest) { var fieldControl = buffer.ReadByte(); mfgCode = buffer.ReadUInt16(); imageType = buffer.ReadUInt16(); fileVersion = buffer.ReadUInt32(); result = true; } } catch { result = false; } } return(result); }
public static bool TryParseOccupancyStatusResponse(EzspIncomingMessageHandlerResponse message, out byte occupancyStatus) { bool result = false; occupancyStatus = byte.MaxValue; if (message.ApsFrame.ProfileId == ZclConstants.HomeAutomationProfileId && message.ApsFrame.ClusterId == ClusterIds.OccupancySensing) { try { var buffer = new CommandBuffer(message.MessageContents); buffer.ReadByte(); buffer.ReadByte(); var command = buffer.ReadByte(); if (command == CommandIds.Global.ReadAttributesResponse) { var attribute = buffer.ReadUInt16(); var status = buffer.ReadByte(); if (attribute == AttributeIds.OccupancySensingServer.MotionStatus && status == ZCLStatus.ZclStatusSuccess) { buffer.ReadByte(); // Datatype occupancyStatus = buffer.ReadByte(); result = true; } } } catch { result = false; } } return(result); }
protected abstract void ProcessMessage(EzspIncomingMessageHandlerResponse message, ZigbeeDeviceBase device);
public void SetupTests() { Mock <IManufacturingStoreRepository> mockManufacturingStoreRepository = new Mock <IManufacturingStoreRepository>(); var product = new Product() { Board = new Board() { ChipType = new ChipType() { Name = TEST_CHIPTYPE_NAME } }, ModelString = TEST_MODEL_STRING, SKU = TEST_SKU }; var targetDevices = new List <TargetDevice>(); targetDevices.Add(new TargetDevice() { TestSession = new TestSession() { Product = product } }); var mockTargetDevices = MockHelper.MockDbSet(targetDevices); var euiLists = new List <EuiList>(); euiLists.Add(new EuiList() { Id = 0, EUI = TEST_EUI, TargetDevices = targetDevices }); var mockEuiLists = MockHelper.MockDbSet(euiLists); mockManufacturingStoreRepository.Setup(x => x.EuiLists).Returns(mockEuiLists); mockManufacturingStoreRepository.Setup(x => x.TargetDevices).Returns(mockTargetDevices); deviceValidationService = new DeviceValidationService(mockEzspService.Object, mockDataContextFactory.Object, mockErrorProducerService.Object); mockEzspService.SetupAllProperties(); mockDataContextFactory.SetupAllProperties(); mockDataContextFactory.Setup(x => x.CreateManufacturingStoreRepository()).Returns(mockManufacturingStoreRepository.Object); mockErrorProducerService.SetupAllProperties(); deviceValidationService.ValidProduct = product; var deviceAnnounceBuffer = new CommandBuffer(); deviceAnnounceBuffer.Add((byte)0); deviceAnnounceBuffer.Add(new EmberApsFrame(ZdoConstants.ZdoProfileId, ZdoClusterIds.DeviceAnnounce, 0, 0, EmberApsOption.EMBER_APS_OPTION_STANDARD, 0, 0)); deviceAnnounceBuffer.Add((byte)0); deviceAnnounceBuffer.Add((sbyte)0); deviceAnnounceBuffer.Add((uint)0xFFFF); deviceAnnounceBuffer.Add((byte)11); deviceAnnounceBuffer.AddArray(new byte[] { 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255 }); deviceAnnounceMessage = new EzspIncomingMessageHandlerResponse(deviceAnnounceBuffer); var ieeeAddressBuffer = new CommandBuffer(); ieeeAddressBuffer.Add((byte)0); ieeeAddressBuffer.Add(new EmberApsFrame(ZdoConstants.ZdoProfileId, ZdoClusterIds.IEEEAddressResponse, 0, 0, EmberApsOption.EMBER_APS_OPTION_STANDARD, 0, 0)); ieeeAddressBuffer.Add((byte)0); ieeeAddressBuffer.Add((sbyte)0); ieeeAddressBuffer.Add((uint)0xFFFF); ieeeAddressBuffer.Add((byte)10); ieeeAddressBuffer.AddArray(new byte[] { 0, 0, 255, 255, 255, 255, 255, 255, 255, 255 }); ieeeAddressMessage = new EzspIncomingMessageHandlerResponse(ieeeAddressBuffer); var modelStringArray = Encoding.ASCII.GetBytes(TEST_MODEL_STRING); var modelStringBuffer = new CommandBuffer(); modelStringBuffer.Add((byte)0); modelStringBuffer.Add(new EmberApsFrame(ZclConstants.HomeAutomationProfileId, ClusterIds.BasicCluster, 0, 0, EmberApsOption.EMBER_APS_OPTION_STANDARD, 0, 0)); modelStringBuffer.Add((byte)0); modelStringBuffer.Add((sbyte)0); modelStringBuffer.Add((uint)0xFFFF); modelStringBuffer.Add(((byte)(modelStringArray.Count() + 10))); modelStringBuffer.Add(ZclConstants.ZclFrameControlManufacturerSpecificBit); modelStringBuffer.Add(ZclConstants.CentraliteManufacturerId); modelStringBuffer.Add((byte)0); modelStringBuffer.Add(CommandIds.Global.ReadAttributesResponse); modelStringBuffer.Add(AttributeIds.BasicServer.ModelIdentifier); modelStringBuffer.Add(ZCLStatus.ZclStatusSuccess); modelStringBuffer.Add(ZclDataTypes.CharacterString); modelStringBuffer.Add(((byte)modelStringArray.Count())); modelStringBuffer.AddArray(modelStringArray); modelStringMessage = new EzspIncomingMessageHandlerResponse(modelStringBuffer); var firmwareVersionBuffer = new CommandBuffer(); firmwareVersionBuffer.Add((byte)0); firmwareVersionBuffer.Add(new EmberApsFrame(ZclConstants.HomeAutomationProfileId, ClusterIds.OtaUpgradeCluster, 0, 0, EmberApsOption.EMBER_APS_OPTION_STANDARD, 0, 0)); firmwareVersionBuffer.Add((byte)0); firmwareVersionBuffer.Add((sbyte)0); firmwareVersionBuffer.Add((uint)0xFFFF); firmwareVersionBuffer.Add((byte)11); firmwareVersionBuffer.Add((byte)0); firmwareVersionBuffer.Add((byte)0); firmwareVersionBuffer.Add(CommandIds.Global.ReadAttributesResponse); firmwareVersionBuffer.Add(AttributeIds.OtaServer.CurrentFileVersion); firmwareVersionBuffer.Add(ZCLStatus.ZclStatusSuccess); firmwareVersionBuffer.Add((byte)0); firmwareVersionBuffer.Add(TEST_FIRMWARE_VERSION); firmwareVersionMessage = new EzspIncomingMessageHandlerResponse(firmwareVersionBuffer); }
private void Ezsp_IncomingMessageHandler(object sender, EzspIncomingMessageHandlerResponse response) { OnIncomingMessageResponse?.Invoke(response); }