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); } }
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); } }