Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/enhancements'
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhobox committed Nov 26, 2024
2 parents 3a78ffa + 7dd1618 commit 4411fa1
Show file tree
Hide file tree
Showing 14 changed files with 1,674 additions and 677 deletions.
Binary file added ConfigRequest.pcapng
Binary file not shown.
16 changes: 11 additions & 5 deletions Kaenx.Konnect/Builders/ConnectionRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ConnectionRequest : IRequestBuilder
{
private List<byte> bytes = new List<byte>();

public void Build(IPEndPoint source, byte communicationChannel)
public void Build(IPEndPoint source, bool isConfig = false)
{
byte[] header = { 0x06, 0x10, 0x02, 0x05 };
bytes.AddRange(header);
Expand All @@ -31,10 +31,16 @@ public void Build(IPEndPoint source, byte communicationChannel)
bytes.AddRange(port); // IP Adress Port


bytes.Add(0x04); // Request Structure Length
bytes.Add(0x04); // Tunnel Connection
bytes.Add(0x02); // Tunnel Link Layer
bytes.Add(0x00); // Reserved
if(isConfig)
{
bytes.Add(0x02); // Request Structure Length
bytes.Add(0x03); // Config Connection
} else {
bytes.Add(0x04); // Request Structure Length
bytes.Add(0x04); // Tunnel Connection
bytes.Add(0x02); // Tunnel Link Layer
bytes.Add(0x00); // Reserved
}

byte[] length = BitConverter.GetBytes((ushort)(bytes.Count + 2));
Array.Reverse(length);
Expand Down
97 changes: 58 additions & 39 deletions Kaenx.Konnect/Classes/BusDevice.cs

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions Kaenx.Konnect/Classes/ReceiverParserDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ namespace Kaenx.Konnect.Classes
{
class ReceiverParserDispatcher
{
private static ReceiverParserDispatcher _instance;
public static ReceiverParserDispatcher Instance
{
get {
if( _instance == null)
_instance = new ReceiverParserDispatcher();
return _instance;
}
}

private readonly List<IReceiveParser> _responseParsers;

public ReceiverParserDispatcher()
Expand All @@ -23,7 +33,6 @@ public ReceiverParserDispatcher()
parsers.Add(type);
}


foreach (Type t in parsers)
{
IReceiveParser parser = (IReceiveParser)Activator.CreateInstance(t);
Expand All @@ -40,7 +49,7 @@ public IParserMessage Build(byte[] responseBytes)

//Console.WriteLine($"ServiceType: {serviceTypeIdentifier} {responseBytes[2]:X}-{responseBytes[3]:X}");

IReceiveParser parser = _responseParsers.AsQueryable().SingleOrDefault(x => x.ServiceTypeIdentifier == serviceTypeIdentifier);
IReceiveParser parser = _responseParsers.SingleOrDefault(x => x.ServiceTypeIdentifier == serviceTypeIdentifier);
IParserMessage result = parser?.Build(headerLength, protocolVersion, totalLength, responseBytes.Skip(6).ToArray());
return result;
}
Expand Down
12 changes: 6 additions & 6 deletions Kaenx.Konnect/Connections/IKnxConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Kaenx.Konnect.Connections
{
public interface IKnxConnection
public interface IKnxConnection : IDisposable
{
public delegate void TunnelRequestHandler(IMessageRequest message);
public event TunnelRequestHandler OnTunnelRequest;
Expand All @@ -21,11 +21,6 @@ public interface IKnxConnection
public delegate void TunnelAckHandler(MsgAckRes message);
public event TunnelAckHandler OnTunnelAck;

public delegate void SearchResponseHandler(MsgSearchRes message);
public event SearchResponseHandler OnSearchResponse;
public delegate void SearchRequestHandler(MsgSearchReq message);
public event SearchRequestHandler OnSearchRequest;

public delegate void ConnectionChangedHandler(bool isConnected);
public event ConnectionChangedHandler ConnectionChanged;

Expand All @@ -45,6 +40,11 @@ public interface IKnxConnection
/// </summary>
public UnicastAddress PhysicalAddress { get; set; }

/// <summary>
/// Returns the max APDU length of the interface
/// </summary>
public int MaxFrameLength { get; set; }

/// <summary>
/// Connects the interface to the bus.
/// </summary>
Expand Down
Loading

0 comments on commit 4411fa1

Please sign in to comment.