Exemplo n.º 1
0
        public void TxStatusExtFrameTest()
        {
            var txStatusFrame = new TxStatusExtFrame
            {
                FrameId         = 0x47,
                DiscoveryStatus = DiscoveryStatus.RouteDiscovery
            };

            var expectedValue = new byte[] { 0x7e, 0x00, 0x07, 0x8b, 0x47, 0xff, 0xff, 0x00, 0x00, 0x02, 0x2d };

            Check(txStatusFrame, expectedValue);
        }
Exemplo n.º 2
0
        public override async Task TransmitDataAsync(byte[] data, CancellationToken cancellationToken, bool enableAck = true)
        {
            if (Address == null)
            {
                throw new InvalidOperationException("Can't send data to local device.");
            }

            var transmitRequest = new TxRequestExtFrame(Address.LongAddress, data);

            if (!enableAck)
            {
                transmitRequest.Options = TransmitOptionsExt.DisableAck;
                await Controller.ExecuteAsync(transmitRequest, cancellationToken);
            }
            else
            {
                TxStatusExtFrame response = await Controller.ExecuteQueryAsync <TxStatusExtFrame>(transmitRequest, cancellationToken);

                if (response.DeliveryStatus != DeliveryStatusExt.Success)
                {
                    throw new XBeeException($"Delivery failed with status code '{response.DeliveryStatus}'.");
                }
            }
        }