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.
70 lines
2.3 KiB
70 lines
2.3 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.
|
|
/// e.g. Cut off IPv6 after first 15 characters.
|
|
/// </summary>
|
|
string InstanceIdentifier { get; }
|
|
|
|
/// <summary>
|
|
/// Long identifier string that provides full information about the instance.
|
|
/// e.g. full IPv6.
|
|
/// </summary>
|
|
string LongInstanceIdentifier { 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>
|
|
/// Reports the state of connection to the communication protocol.
|
|
/// This property shall be used to check if the protocol is ready to receive data via <see cref="SendBytes(byte[])"/>.
|
|
/// </summary>
|
|
ProtocolConnectionState State { get; }
|
|
|
|
/// <summary>
|
|
/// Raised when the <see cref="State"/> changed.
|
|
/// The handed <see cref="ProtocolConnectionState"/> is the new state.
|
|
/// </summary>
|
|
event EventHandler<ProtocolConnectionState>? ConnectionStateChangedEvent;
|
|
|
|
/// <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>
|
|
/// <returns>true if the sending was successful</returns>
|
|
bool SendBytes(byte[] bytes);
|
|
}
|
|
|