Ejemplo n.º 1
0
        public async Task <Bytes> SendAndGetPacket(Bytes packet, byte repeat_count, ushort delay_ms, uint timeout_ms, byte retry_count, ushort preamble_ext_ms)
        {
            try
            {
                await Connect();

                var data      = ManchesterEncoding.Encode(packet);
                var cmdParams = new Bytes()
                                .Append((byte)0)
                                .Append(repeat_count)
                                .Append(delay_ms)
                                .Append((byte)0)
                                .Append(timeout_ms)
                                .Append(retry_count)
                                .Append(preamble_ext_ms)
                                .Append(data);
                var result = await this.SendCommand(RileyLinkCommandType.SendAndListen, cmdParams, 5000);

                if (result != null)
                {
                    var decoded = ManchesterEncoding.Decode(result.Sub(2));
                    return(result.Sub(0, 2).Append(decoded));
                }
                else
                {
                    return(null);
                }
            }
            catch (OmniCoreException) { throw; }
            catch (Exception e)
            {
                throw new PacketRadioException("Error while sending and receiving data with RL", e);
            }
        }
Ejemplo n.º 2
0
        public async Task <Bytes> GetPacket(uint timeout = 5000)
        {
            try
            {
                await Connect();

                var cmdParams = new Bytes((byte)0);
                cmdParams.Append(timeout);

                var result = await this.SendCommand(RileyLinkCommandType.SendAndListen, cmdParams, (int)timeout + 500);

                if (result != null)
                {
                    return(result.Sub(0, 2).Append(ManchesterEncoding.Decode(result.Sub(2))));
                }
                else
                {
                    return(null);
                }
            }
            catch (OmniCoreException) { throw; }
            catch (Exception e)
            {
                throw new PacketRadioException("Error while receiving data with RL", e);
            }
        }
Ejemplo n.º 3
0
        public async Task SendPacket(Bytes packet, byte repeat_count, ushort delay_ms, ushort preamble_ext_ms)
        {
            try
            {
                await Connect();

                Debug.WriteLine($"SEND radio packet: {packet}");
                var data      = ManchesterEncoding.Encode(packet);
                var cmdParams = new Bytes((byte)0).Append(repeat_count);
                cmdParams.Append(delay_ms);
                cmdParams.Append(preamble_ext_ms);
                cmdParams.Append(data);
                await this.SendCommand(RileyLinkCommandType.SendAndListen, cmdParams, 30000);
            }
            catch (OmniCoreException) { throw; }
            catch (Exception e)
            {
                throw new PacketRadioException("Error while sending data with RL", e);
            }
        }