You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
using MultiTerm.Protocols.Types;
|
|
|
|
namespace MultiTerm.Protocols;
|
|
|
|
/// <summary>
|
|
/// Interface to interact with a Communication protocol.
|
|
/// </summary>
|
|
public interface ICommunicationProtocol
|
|
{
|
|
/// <summary>
|
|
/// Indicates the protocol type of the implementing class.
|
|
/// </summary>
|
|
ProtocolType ProtocolType { get; }
|
|
|
|
/// <summary>
|
|
/// Short identifier string that allows the user to distinguish different instances.
|
|
/// </summary>
|
|
string InstanceIdentifier { get; }
|
|
|
|
/// <summary>
|
|
/// New data received from connected device.
|
|
/// </summary>
|
|
event EventHandler<ReceivedDataEventArgs>? ReceivedDataEvent;
|
|
|
|
/// <summary>
|
|
/// New data sent to the connected device.
|
|
/// </summary>
|
|
event EventHandler<SentDataEventArgs>? SentDataEvent;
|
|
|
|
/// <summary>
|
|
/// Thrown when the device disconnected.
|
|
/// </summary>
|
|
event EventHandler<DisconnectedEventArgs>? DisconnectedEvent;
|
|
|
|
/// <summary>
|
|
/// Indicates wether the communication protocol is connected.
|
|
/// True if connected and ready to receive data via <see cref="SendBytes(byte[])"/>, false if not.
|
|
/// </summary>
|
|
bool IsConnected { get; }
|
|
|
|
/// <summary>
|
|
/// Connect to the device.
|
|
/// </summary>
|
|
/// <param name="settings">settings required to connect and use the protocol</param>
|
|
/// <returns>
|
|
/// true if connected sucessfully or already connected,
|
|
/// false if the provided settings are invalid or connection was unsuccessful
|
|
/// </returns>
|
|
bool Connect(IProtocolSettings settings);
|
|
|
|
/// <summary>
|
|
/// Disconnect from the device. Ends all internal activities.
|
|
/// </summary>
|
|
void Disconnect();
|
|
|
|
/// <summary>
|
|
/// Send data to the connected device.
|
|
/// </summary>
|
|
/// <param name="bytes">data to send, as an array of bytes</param>
|
|
void SendBytes(byte[] bytes);
|
|
}
|
|
|