/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); _data = DeserializeData(); }
/// <summary> /// Cuando el modulo recibe un Paquete por RF, lo envía a la UART usando este tipo de mensaje. /// </summary> /// <param name="arraydebytes">Arreglo de bytes que llega por la UART</param> public ZigbeeReceivePacket(byte[] arraydebytes) { byte tipoframe = arraydebytes[3]; if (tipoframe == (byte)API_Xbee.Commands.TypeApiFramesNames.Zigbee_Receive_Packter_AO_0) { //Aqui todo... //Source Address 64bits for (int i = 4; i < 12; i++) { SA64Bits[11 - i] = arraydebytes[i]; } //Source Address 16bits SA64Bits[1] = arraydebytes[12]; SA64Bits[0] = arraydebytes[13]; if (arraydebytes[14] == (byte)ZigbeeReceivePacket.ReceiveOptions.Packet_Acknowledged) { OptionReceived = ReceiveOptions.Packet_Acknowledged; } if (arraydebytes[14] == (byte)ZigbeeReceivePacket.ReceiveOptions.Packet_Was_A_Broadcast_Packet) { OptionReceived = ReceiveOptions.Packet_Was_A_Broadcast_Packet; } if (arraydebytes[14] == (byte)ZigbeeReceivePacket.ReceiveOptions.Packet_Encrypted_With_APS_Encryption) { OptionReceived = ReceiveOptions.Packet_Encrypted_With_APS_Encryption; } if (arraydebytes[14] == (byte)ZigbeeReceivePacket.ReceiveOptions.Packet_Was_Sent_From_An_End_Device) { OptionReceived = ReceiveOptions.Packet_Was_Sent_From_An_End_Device; } ReceivedData = new byte[arraydebytes.Length - 16]; for (int i = 15; i < arraydebytes.Length - 1; i++) { ReceivedData[i - 15] = arraydebytes[i]; } //if (arraydebytes[1] != this.LengthMSB) throw new Exception("MSB Diferente"); //if (arraydebytes[2] != this.LengthLSB) throw new Exception("LSB Diferente"); System.Text.ASCIIEncoding codificador = new System.Text.ASCIIEncoding(); CadenaRecibida = codificador.GetString(ReceivedData); } else { throw new Exception("No es Respuesta a Paquete recibo por RF"); } //throw new NotImplementedException(); }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); int numberOfAddresses = DeserializeInt8(); _addressList = DeserializeInt16Array(numberOfAddresses); }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); int bootloaderMessageType = DeserializeInt8(); _blockNumber = DeserializeInt8(); _targetAddress = DeserializeIeeeAddress(); }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _sourceEndpoint = DeserializeInt8(); _destinationEndpoint = DeserializeInt8(); _clusterId = DeserializeInt16(); _profileId = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); _data = DeserializeData(); }
private static Packet DecodeZigBeeReceivePacket(byte[] packetData, DateTime receivedDateTime) { const int ReceiveOptionsLength = 1; const int PacketHeaderLength = FrameIdLength + AddressLength + NetworkAddressLength + ReceiveOptionsLength; if (packetData.Length < PacketHeaderLength) { return(CreateInvalidPacket(packetData, receivedDateTime, "ZigBee Receive Packet to small, must be at least [" + PacketHeaderLength + "] found [" + packetData.Length + "]")); } byte[] address = new byte[AddressLength]; byte[] networkAddress = new byte[NetworkAddressLength]; byte[] receiveData = new byte[packetData.Length - PacketHeaderLength]; Array.Copy(packetData, 0, address, 0, AddressLength); Array.Copy(packetData, AddressLength, networkAddress, 0, NetworkAddressLength); ReceiveOptions receiveOptions = (ReceiveOptions)packetData[AddressLength + NetworkAddressLength]; Array.Copy(packetData, PacketHeaderLength, receiveData, 0, receiveData.Length); _log.Debug("Received ZigBeeReceivePacket from address [" + address.ToHexString("") + "], network address [" + networkAddress.ToHexString("") + "], receiveOptions [" + Convert.ToString((byte)receiveOptions, 16) + "], data [" + receiveData.ToHexString() + "]"); return(new ZigBeeReceivePacket(packetData, receivedDateTime, address, networkAddress, receiveOptions, receiveData)); }
private ReceiveMessageResponse ReceiveTestMessage() { var input = new ReceiveParameters { QueueUrl = queueURL, MaxNumberOfMessages = 1 }; var options = new ReceiveOptions { DeleteMessageAfterReceiving = true, VisibilityTimeout = 30, WaitTimeSeconds = 5 }; var awsOptions = new AWSOptions { AWSCredentials = SQS.GetBasicAWSCredentials(credParams), UseDefaultCredentials = false, Region = region }; return(SQS.ReceiveMessage(input, options, awsOptions, new System.Threading.CancellationToken()).Result); }
protected override void Configure(FeatureConfigurationContext context, string connectionString) { var useCallbackReceiver = context.Settings.Get <bool>(UseCallbackReceiverSettingKey); var maxConcurrencyForCallbackReceiver = context.Settings.Get <int>(MaxConcurrencyForCallbackReceiver); var queueName = GetLocalAddress(context.Settings); var callbackQueue = string.Format("{0}.{1}", queueName, RuntimeEnvironment.MachineName); var connectionConfiguration = new ConnectionStringParser(context.Settings).Parse(connectionString); //MessageConverter messageConverter; //if (context.Settings.HasSetting(CustomMessageIdStrategy)) //{ // messageConverter = new MessageConverter(context.Settings.Get<Func<BasicDeliverEventArgs, string>>(CustomMessageIdStrategy)); //} //else //{ // messageConverter = new MessageConverter(); //} string hostDisplayName; if (!context.Settings.TryGet("NServiceBus.HostInformation.DisplayName", out hostDisplayName))//this was added in 5.1.2 of the core { hostDisplayName = RuntimeEnvironment.MachineName; } var consumerTag = string.Format("{0} - {1}", hostDisplayName, context.Settings.EndpointName()); var receiveOptions = new ReceiveOptions(workQueue => { //if this isn't the main queue we shouldn't use callback receiver if (!useCallbackReceiver || workQueue != queueName) { return(SecondaryReceiveSettings.Disabled()); } return(SecondaryReceiveSettings.Enabled(callbackQueue, maxConcurrencyForCallbackReceiver)); }, null, //messageConverter, connectionConfiguration.PrefetchCount, connectionConfiguration.DequeueTimeout * 1000, context.Settings.GetOrDefault <bool>("Transport.PurgeOnStartup"), consumerTag); context.Container.RegisterSingleton(connectionConfiguration); context.Container.ConfigureComponent(builder => new KafkaDequeueStrategy( builder.Build <IManageKafkaConnections>(), SetupCircuitBreaker(builder.Build <CriticalError>()), receiveOptions), DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent <OpenPublishChannelBehavior>(DependencyLifecycle.InstancePerCall); context.Pipeline.Register <OpenPublishChannelBehavior.Registration>(); context.Pipeline.Register <ReadIncomingCallbackAddressBehavior.Registration>(); context.Container.ConfigureComponent(b => new KafkaMessageSender(b.Build <IRoutingTopology>(), b.Build <IChannelProvider>(), b.Build <PipelineExecutor>().CurrentContext), DependencyLifecycle.InstancePerCall); if (useCallbackReceiver) { context.Container.ConfigureComponent <CallbackQueueCreator>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.Enabled, true) .ConfigureProperty(p => p.CallbackQueueAddress, Address.Parse(callbackQueue)); //context.Pipeline.Register<ForwardCallbackQueueHeaderBehavior.Registration>(); context.Pipeline.Register <SetOutgoingCallbackAddressBehavior.Registration>(); context.Container.ConfigureComponent <SetOutgoingCallbackAddressBehavior>(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.CallbackQueue, callbackQueue); } context.Container.ConfigureComponent <ChannelProvider>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.UsePublisherConfirms, connectionConfiguration.UsePublisherConfirms) .ConfigureProperty(p => p.MaxWaitTimeForConfirms, connectionConfiguration.MaxWaitTimeForConfirms); context.Container.ConfigureComponent <KafkaDequeueStrategy>(DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent <KafkaMessagePublisher>(DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent <KafkaSubscriptionManager>(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.EndpointQueueName, queueName); context.Container.ConfigureComponent <KafkaQueueCreator>(DependencyLifecycle.InstancePerCall); if (context.Settings.HasSetting <IRoutingTopology>()) { context.Container.RegisterSingleton(context.Settings.Get <IRoutingTopology>()); } else { //var durable = GetDurableMessagesEnabled(context.Settings); //IRoutingTopology topology; //DirectRoutingTopology.Conventions conventions; //if (context.Settings.TryGet(out conventions)) //{ // topology = new DirectRoutingTopology(conventions, durable); //} //else //{ // topology = new ConventionalRoutingTopology(durable); //} //context.Container.RegisterSingleton(topology); } if (context.Settings.HasSetting("IManageKafkaConnections")) { context.Container.ConfigureComponent(context.Settings.Get <Type>("IManageKafkaConnections"), DependencyLifecycle.SingleInstance); } else { context.Container.ConfigureComponent <KafkaConnectionManager>(DependencyLifecycle.SingleInstance); context.Container.ConfigureComponent(builder => new KafkaConnectionFactory(builder.Build <ConnectionConfiguration>()), DependencyLifecycle.InstancePerCall); } }
protected override void Configure(FeatureConfigurationContext context, string connectionString) { var useCallbackReceiver = context.Settings.Get<bool>(UseCallbackReceiverSettingKey); var maxConcurrencyForCallbackReceiver = context.Settings.Get<int>(MaxConcurrencyForCallbackReceiver); var queueName = GetLocalAddress(context.Settings); var callbackQueue = string.Format("{0}.{1}", queueName, RuntimeEnvironment.MachineName); var connectionConfiguration = new ConnectionStringParser(context.Settings).Parse(connectionString); MessageConverter messageConverter; if (context.Settings.HasSetting(CustomMessageIdStrategy)) { messageConverter = new MessageConverter(context.Settings.Get<Func<BasicDeliverEventArgs, string>>(CustomMessageIdStrategy)); } else { messageConverter = new MessageConverter(); } string hostDisplayName; if (!context.Settings.TryGet("NServiceBus.HostInformation.DisplayName", out hostDisplayName))//this was added in 5.1.2 of the core { hostDisplayName = RuntimeEnvironment.MachineName; } var consumerTag = string.Format("{0} - {1}", hostDisplayName, context.Settings.EndpointName()); var receiveOptions = new ReceiveOptions(workQueue => { //if this isn't the main queue we shouldn't use callback receiver if (!useCallbackReceiver || workQueue != queueName) { return SecondaryReceiveSettings.Disabled(); } return SecondaryReceiveSettings.Enabled(callbackQueue, maxConcurrencyForCallbackReceiver); }, messageConverter, connectionConfiguration.PrefetchCount, connectionConfiguration.DequeueTimeout * 1000, context.Settings.GetOrDefault<bool>("Transport.PurgeOnStartup"), consumerTag); context.Container.RegisterSingleton(connectionConfiguration); context.Container.ConfigureComponent(builder => new RabbitMqDequeueStrategy( builder.Build<IManageRabbitMqConnections>(), SetupCircuitBreaker(builder.Build<CriticalError>()), receiveOptions), DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent<OpenPublishChannelBehavior>(DependencyLifecycle.InstancePerCall); context.Pipeline.Register<OpenPublishChannelBehavior.Registration>(); context.Container.ConfigureComponent<RabbitMqMessageSender>(DependencyLifecycle.InstancePerCall); if (useCallbackReceiver) { context.Container.ConfigureProperty<RabbitMqMessageSender>(p => p.CallbackQueue, callbackQueue); context.Container.ConfigureComponent<CallbackQueueCreator>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.Enabled, true) .ConfigureProperty(p => p.CallbackQueueAddress, Address.Parse(callbackQueue)); context.Pipeline.Register<ForwardCallbackQueueHeaderBehavior.Registration>(); } context.Container.ConfigureComponent<ChannelProvider>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(p => p.UsePublisherConfirms, connectionConfiguration.UsePublisherConfirms) .ConfigureProperty(p => p.MaxWaitTimeForConfirms, connectionConfiguration.MaxWaitTimeForConfirms); context.Container.ConfigureComponent<RabbitMqDequeueStrategy>(DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent<RabbitMqMessagePublisher>(DependencyLifecycle.InstancePerCall); context.Container.ConfigureComponent<RabbitMqSubscriptionManager>(DependencyLifecycle.SingleInstance) .ConfigureProperty(p => p.EndpointQueueName, queueName); context.Container.ConfigureComponent<RabbitMqQueueCreator>(DependencyLifecycle.InstancePerCall); if (context.Settings.HasSetting<IRoutingTopology>()) { context.Container.RegisterSingleton(context.Settings.Get<IRoutingTopology>()); } else { var durable = GetDurableMessagesEnabled(context.Settings); IRoutingTopology topology; DirectRoutingTopology.Conventions conventions; if (context.Settings.TryGet(out conventions)) { topology = new DirectRoutingTopology(conventions, durable); } else { topology = new ConventionalRoutingTopology(durable); } context.Container.RegisterSingleton(topology); } if (context.Settings.HasSetting("IManageRabbitMqConnections")) { context.Container.ConfigureComponent(context.Settings.Get<Type>("IManageRabbitMqConnections"), DependencyLifecycle.SingleInstance); } else { context.Container.ConfigureComponent<RabbitMqConnectionManager>(DependencyLifecycle.SingleInstance); context.Container.ConfigureComponent(builder => new RabbitMqConnectionFactory(builder.Build<ConnectionConfiguration>()), DependencyLifecycle.InstancePerCall); } }
public ZigBeeReceivePacket(byte[] packetData, DateTime receivedDataTime, byte[] address, byte[] networkAddress, ReceiveOptions receiveOptions, byte[] receiveData) : base(packetData, receivedDataTime, address, networkAddress) { _receiveOptions = receiveOptions; _receiveData = receiveData.Copy(); }