private async Task Initialise()
        {
            if (characteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
            {
                await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);

                characteristic.ValueChanged += (_, changedArgs) =>
                {
                    var bytes = changedArgs.CharacteristicValue.ToArray();
                    builder.AddBlock(bytes);
                    Log.Logger.Information("{name} Received some data", deviceName);
                };

                Log.Logger.Information("{name} Subscribed to {id}", deviceName, characteristic.Uuid);
            }
        }
Ejemplo n.º 2
0
        public void Builds_multiples_into_one_buffer()
        {
            var total = Enumerable.Range(0, 200).Select(x => (byte)x).ToArray();

            var chunks = new PacketChunker(20).Chunks(total);

            chunks = chunks.Take(chunks.Count() - 1);

            foreach (var block in chunks)
            {
                sut.AddBlock(block);
            }

            var fullPacket = sut.GetCompletedPacket();

            fullPacket.Should().BeEquivalentTo(total);
        }