using MultiTerm.Protocols.Types;
namespace MultiTerm.Protocols;
///
/// Interface to interact with a Communication protocol.
///
public interface ICommunicationProtocol
{
///
/// Indicates the protocol type of the implementing class.
///
ProtocolType ProtocolType { get; }
///
/// Short identifier string that allows the user to distinguish different instances.
/// e.g. Cut off IPv6 after first 15 characters.
///
string InstanceIdentifier { get; }
///
/// Long identifier string that provides full information about the instance.
/// e.g. full IPv6.
///
string LongInstanceIdentifier { get; }
///
/// New data received from connected device.
///
event EventHandler? ReceivedDataEvent;
///
/// New data sent to the connected device.
///
event EventHandler? SentDataEvent;
///
/// 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 .
///
ProtocolConnectionState State { get; }
///
/// Raised when the changed.
/// The handed is the new state.
///
event EventHandler? ConnectionStateChangedEvent;
///
/// Connect to the device.
///
/// settings required to connect and use the protocol
///
/// true if connected sucessfully or already connected,
/// false if the provided settings are invalid or connection was unsuccessful
///
bool Connect(IProtocolSettings settings);
///
/// Disconnect from the device. Ends all internal activities.
///
void Disconnect();
///
/// Send data to the connected device.
///
/// data to send, as an array of bytes
/// true if the sending was successful
bool SendBytes(byte[] bytes);
}