@@ -187,11 +187,27 @@ public async Task SendCustomCommand(Guid connectionId, byte address, CommandData
187187 await SendCommand ( connectionId , address , command ) . ConfigureAwait ( false ) ;
188188 }
189189
190- /// <summary>Request to get an ID Report from the PD.</summary>
191- /// <param name="connectionId">Identify the connection for communicating to the device.</param>
192- /// <param name="address">Address assigned to the device.</param>
193- /// <returns>ID report reply data that was requested.</returns>
194- public async Task < DeviceIdentification > IdReport ( Guid connectionId , byte address ) =>
190+ /// <summary>
191+ /// Enqueue a custom command to be sent without waiting for a response.
192+ /// </summary>
193+ /// <param name="connectionId">Identify the connection for communicating to the device.</param>
194+ /// <param name="address">Address assigned to the device.</param>
195+ /// <param name="command">The custom command to send.</param>
196+ public void EnqueueCustomCommand ( Guid connectionId , byte address , CommandData command )
197+ {
198+ if ( ! _buses . TryGetValue ( connectionId , out var bus ) )
199+ {
200+ throw new ArgumentException ( "Connection could not be found" , nameof ( connectionId ) ) ;
201+ }
202+
203+ bus . SendCommand ( address , command ) ;
204+ }
205+
206+ /// <summary>Request to get an ID Report from the PD.</summary>
207+ /// <param name="connectionId">Identify the connection for communicating to the device.</param>
208+ /// <param name="address">Address assigned to the device.</param>
209+ /// <returns>ID report reply data that was requested.</returns>
210+ public async Task < DeviceIdentification > IdReport ( Guid connectionId , byte address ) =>
195211 await IdReport ( connectionId , address , CancellationToken . None ) . ConfigureAwait ( false ) ;
196212
197213 /// <summary>Request to get an ID Report from the PD.</summary>
@@ -1447,8 +1463,9 @@ private void OnConnectionStatusChanged(Guid connectionId, byte address, bool isC
14471463 private void OnReplyReceived ( ReplyTracker reply )
14481464 {
14491465 ReplyReceived ? . Invoke ( this , new ReplyEventArgs { Reply = reply } ) ;
1466+ RawReplyReceived ? . Invoke ( this , new RawReplyEventArgs ( reply . ConnectionId , reply . ReplyMessage . Address , reply . ReplyMessage . Type , reply . ReplyMessage . Payload ) ) ;
14501467
1451- switch ( ( ReplyType ) reply . ReplyMessage . Type )
1468+ switch ( ( ReplyType ) reply . ReplyMessage . Type )
14521469 {
14531470 case ReplyType . Nak :
14541471 NakReplyReceived ? . Invoke ( this ,
@@ -1530,10 +1547,15 @@ private void OnReplyReceived(ReplyTracker reply)
15301547
15311548 private event EventHandler < ReplyEventArgs > ReplyReceived ;
15321549
1533- /// <summary>
1534- /// Occurs when connection status changed.
1535- /// </summary>
1536- public event EventHandler < ConnectionStatusEventArgs > ConnectionStatusChanged ;
1550+ /// <summary>
1551+ /// Occurs when any reply is received
1552+ /// </summary>
1553+ public event EventHandler < RawReplyEventArgs > RawReplyReceived ;
1554+
1555+ /// <summary>
1556+ /// Occurs when connection status changed.
1557+ /// </summary>
1558+ public event EventHandler < ConnectionStatusEventArgs > ConnectionStatusChanged ;
15371559
15381560 /// <summary>
15391561 /// Occurs when a negative reply is received.
@@ -2152,7 +2174,48 @@ internal FileTransferException(string msg, FileTransferStatus status) : base(msg
21522174 public FileTransferStatus Status { get ; }
21532175 }
21542176
2155- private class ReplyEventArgs : EventArgs
2177+ /// <summary>
2178+ /// A reply has been received.
2179+ /// </summary>
2180+ public class RawReplyEventArgs : EventArgs
2181+ {
2182+ /// <summary>
2183+ /// Initializes a new instance of the <see cref="RawReplyEventArgs"/> class.
2184+ /// </summary>
2185+ /// <param name="connectionId">Identify the connection for communicating to the device.</param>
2186+ /// <param name="address">Address assigned to the device.</param>
2187+ /// <param name="command">The reply code of the message.</param>
2188+ /// <param name="payload">The raw reply payload.</param>
2189+ public RawReplyEventArgs ( Guid connectionId , byte address , byte command , byte [ ] payload )
2190+ {
2191+ ConnectionId = connectionId ;
2192+ Address = address ;
2193+ Command = command ;
2194+ Payload = payload ;
2195+ }
2196+
2197+ /// <summary>
2198+ /// Identify the connection for communicating to the device.
2199+ /// </summary>
2200+ public Guid ConnectionId { get ; }
2201+
2202+ /// <summary>
2203+ /// Address assigned to the device.
2204+ /// </summary>
2205+ public byte Address { get ; }
2206+
2207+ /// <summary>
2208+ /// The reply code of the message.
2209+ /// </summary>
2210+ public byte Command { get ; }
2211+
2212+ /// <summary>
2213+ /// The raw reply payload.
2214+ /// </summary>
2215+ public byte [ ] Payload { get ; }
2216+ }
2217+
2218+ private class ReplyEventArgs : EventArgs
21562219 {
21572220 public ReplyTracker Reply { get ; set ; }
21582221 }
0 commit comments