mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 20:54:46 +00:00
Added ICommunicationReceiver Interface
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -135,10 +135,22 @@ namespace PepperDash.Core
|
|||||||
var output = Regex.Replace(args.Text,
|
var output = Regex.Replace(args.Text,
|
||||||
@"\p{Cc}",
|
@"\p{Cc}",
|
||||||
a => string.Format("[{0:X2}]", (byte)a.Value[0]));
|
a => string.Format("[{0:X2}]", (byte)a.Value[0]));
|
||||||
Debug.Console(2, Port, "RX: '{0}", output);
|
Debug.Console(2, Port, "RX: '{0}'", output);
|
||||||
}
|
}
|
||||||
ReceiveBuffer.Append(args.Text);
|
ReceiveBuffer.Append(args.Text);
|
||||||
var str = ReceiveBuffer.ToString();
|
var str = ReceiveBuffer.ToString();
|
||||||
|
|
||||||
|
// Case: Receiving DEVICE get version\x0d\0x0a+OK "value":"1234"\x0d\x0a
|
||||||
|
|
||||||
|
// RX: DEV
|
||||||
|
// Split: (1) "DEV"
|
||||||
|
// RX: I
|
||||||
|
// Split: (1) "DEVI"
|
||||||
|
// RX: CE get version
|
||||||
|
// Split: (1) "DEVICE get version"
|
||||||
|
// RX: \x0d\x0a+OK "value":"1234"\x0d\x0a
|
||||||
|
// Split: (2) DEVICE get version, +OK "value":"1234"
|
||||||
|
|
||||||
var lines = Regex.Split(str, StringDelimiter);
|
var lines = Regex.Split(str, StringDelimiter);
|
||||||
if (lines.Length > 1)
|
if (lines.Length > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,19 +10,26 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An incoming communication stream
|
||||||
|
/// </summary>
|
||||||
|
public interface ICommunicationReceiver : IKeyed
|
||||||
|
{
|
||||||
|
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
bool IsConnected { get; }
|
||||||
|
void Connect();
|
||||||
|
void Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device that uses basic connection
|
/// Represents a device that uses basic connection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicCommunication : IKeyed
|
public interface IBasicCommunication : ICommunicationReceiver
|
||||||
{
|
{
|
||||||
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
|
||||||
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
|
||||||
|
|
||||||
bool IsConnected { get; }
|
|
||||||
void SendText(string text);
|
void SendText(string text);
|
||||||
void SendBytes(byte[] bytes);
|
void SendBytes(byte[] bytes);
|
||||||
void Connect();
|
|
||||||
void Disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user