Example #1
0
        public void CanSerializeMediaTone2Off()
        {
            var message = new MediaToneMessage(0xbabe, MediaDirection.TxRx, 0, Array.Empty <MediaToneMessage.Tone>());

            Assert.Equal(12, message.Length);
            var data = new byte[12];

            message.Serialize(data);
            Assert.Equal(2, data[0]);
            Assert.Equal(0xb, data[1]);
            Assert.Equal(0, data[2]);
            Assert.Equal(8, data[3]);
            Assert.Equal(0xbe, data[4]);
            Assert.Equal(0xba, data[5]);
            Assert.Equal(3, data[6]);
            Assert.True(data.AsSpan(7).IsEmpty());
        }
Example #2
0
        private async Task InjectAsync(RfpIdentifier rfp, ushort handle, MediaToneMessage.Tone[] tones, CancellationToken cancellationToken)
        {
            var message = new MediaToneMessage(handle, MediaDirection.TxRx, 0, Array.Empty <MediaToneMessage.Tone>());
            var data    = new byte[message.Length];

            message.Serialize(data);
            cancellationToken.ThrowIfCancellationRequested();
            await WriteAsync(MessageDirection.ToRfp, 0, rfp, data, cancellationToken);

            message = new MediaToneMessage(handle, MediaDirection.TxRx, 0, tones);
            data    = new byte[message.Length];
            message.Serialize(data);
            cancellationToken.ThrowIfCancellationRequested();
            await Task.Delay(1000, cancellationToken);

            await WriteAsync(MessageDirection.ToRfp, 0, rfp, data, cancellationToken);
        }