Skip to content

Commit c368780

Browse files
committed
Documentation and minor refactoring
1 parent b4e8678 commit c368780

File tree

10 files changed

+287
-26
lines changed

10 files changed

+287
-26
lines changed

ZWaveDotNet/CommandClassReports/Enums/NotificationState.cs

Lines changed: 254 additions & 4 deletions
Large diffs are not rendered by default.

ZWaveDotNet/CommandClasses/BarrierOperator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ namespace ZWaveDotNet.CommandClasses
2828
[CCVersion(CommandClass.BarrierOperator, 1)]
2929
public class BarrierOperator : CommandClassBase
3030
{
31+
/// <summary>
32+
/// Unsolicited Barrer Report
33+
/// </summary>
3134
public event CommandClassEvent<BarrierReport>? BarrierState;
3235

3336
enum BarrierOperatorCommand : byte

ZWaveDotNet/CommandClasses/ManufacturerProprietary.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public async Task Send(ushort Manufacturer, Memory<byte> data, CancellationToken
3838
payload[0] = manufacturerBytes[1];
3939
data.CopyTo(payload.AsMemory().Slice(1));
4040

41-
CommandMessage msg = new CommandMessage(controller, node.ID, EndPoint, CommandClass, manufacturerBytes[0], false, payload);
42-
await SendCommand(msg, cancellationToken);
41+
await SendCommand(manufacturerBytes[0], cancellationToken, false, payload);
4342
}
4443

4544
///

ZWaveDotNet/CommandClasses/SwitchColor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public async Task<ColorType[]> GetSupported(CancellationToken cancellationToken
101101
/// </summary>
102102
/// <param name="up"></param>
103103
/// <param name="component"></param>
104-
/// <param name="startLevel">If < 0, start level is ignored</param>
104+
/// <param name="startLevel">If &lt; 0, start level is ignored</param>
105105
/// <param name="duration"></param>
106106
/// <param name="cancellationToken"></param>
107107
/// <returns></returns>

ZWaveDotNet/Entities/EndPoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class EndPoint
3131
/// </summary>
3232
public byte ID { get; init; }
3333
private readonly Node node;
34-
private Dictionary<CommandClass, CommandClassBase> commandClasses = new Dictionary<CommandClass, CommandClassBase>();
34+
private readonly Dictionary<CommandClass, CommandClassBase> commandClasses = new Dictionary<CommandClass, CommandClassBase>();
3535

3636
/// <summary>
3737
/// The parent Node

ZWaveDotNet/Entities/Node.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ private enum InterviewState { None, Started, Complete };
5454
private bool failed;
5555
private InterviewState interviewed;
5656

57-
private ConcurrentDictionary<CommandClass, CommandClassBase> commandClasses = new ConcurrentDictionary<CommandClass, CommandClassBase>();
57+
/// <summary>
58+
/// Command Class Instances
59+
/// </summary>
60+
protected ConcurrentDictionary<CommandClass, CommandClassBase> commandClasses = new ConcurrentDictionary<CommandClass, CommandClassBase>();
5861
private List<EndPoint> endPoints = new List<EndPoint>();
5962

6063
/// <summary>
@@ -130,7 +133,14 @@ internal Node(NodeJSON nodeJSON, Controller controller)
130133
nodeInfo = nodeJSON.NodeProtocolInfo;
131134
}
132135

133-
private bool AddCommandClass(CommandClass cls, bool secure = false, byte version = 1)
136+
/// <summary>
137+
/// Create a command class of the given type
138+
/// </summary>
139+
/// <param name="cls"></param>
140+
/// <param name="secure"></param>
141+
/// <param name="version"></param>
142+
/// <returns></returns>
143+
protected bool AddCommandClass(CommandClass cls, bool secure = false, byte version = 1)
134144
{
135145
return commandClasses.TryAdd(cls, CommandClassBase.Create(cls, this, 0, secure, version));
136146
}
@@ -197,7 +207,8 @@ internal void HandleApplicationUpdate(ApplicationUpdate update)
197207
internal async Task HandleApplicationCommand(ApplicationCommand cmd)
198208
{
199209
ReportMessage? msg = new ReportMessage(cmd);
200-
RSSI = msg.RSSI;
210+
if (msg.RSSI != ApplicationCommand.INVALID_RSSI)
211+
RSSI = msg.RSSI;
201212

202213
//Encapsulation Order (inner to outer) - MultiCommand, Supervision, Multichannel, security, transport, crc16
203214
if (CRC16.IsEncapsulated(msg))

ZWaveDotNet/Security/SecurityManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public byte[] CreateS0Nonce(ushort nodeId)
325325
byte[] nonce = new byte[8];
326326
do
327327
{
328-
new Random().NextBytes(nonce);
328+
Random.Shared.NextBytes(nonce);
329329
} while (GetS0Nonce(nodeId, nonce[0]) != null);
330330
SpanRecord nr = new SpanRecord()
331331
{

ZWaveDotNet/SerialAPI/Flow.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public async Task SendAcknowledged(Function function, CancellationToken cancella
5151
await SendAcknowledged(frame, cancellationToken).ConfigureAwait(false);
5252
}
5353

54-
public async Task SendAcknowledged(Message message, CancellationToken cancellationToken = default)
55-
{
56-
Frame frame = new Frame(FrameType.SOF, DataFrameType.Request, message.Function, message.GetPayload());
57-
await SendAcknowledged(frame, cancellationToken).ConfigureAwait(false);
58-
}
59-
6054
public async Task SendAcknowledged(Frame frame, CancellationToken cancellationToken = default)
6155
{
6256
var reader = port.CreateReader();
@@ -75,13 +69,6 @@ public async Task<Message> SendAcknowledgedResponse(Function function, Cancellat
7569
return GetMessage(response);
7670
}
7771

78-
public async Task<Message> SendAcknowledgedResponse(Message message, CancellationToken cancellationToken = default)
79-
{
80-
Frame frame = new Frame(FrameType.SOF, DataFrameType.Request, message.Function, message.GetPayload());
81-
Frame response = await SendAcknowledgedResponse(frame, cancellationToken).ConfigureAwait(false);
82-
return GetMessage(response)!;
83-
}
84-
8572
public async Task<Frame> SendAcknowledgedResponse(Frame frame, CancellationToken cancellationToken = default)
8673
{
8774
var reader = port.CreateReader();

ZWaveDotNet/SerialAPI/Messages/ApplicationCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace ZWaveDotNet.SerialAPI.Messages
1818
{
19-
public class ApplicationCommand : Message
19+
internal class ApplicationCommand : Message
2020
{
2121
public const sbyte INVALID_RSSI = 0x7D;
2222
public const ushort LOCAL_NODE = 0xFF;

ZWaveDotNet/SerialAPI/Messages/Message.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@
1515

1616
namespace ZWaveDotNet.SerialAPI.Messages
1717
{
18+
/// <summary>
19+
/// Base class for all ZWave Messages
20+
/// </summary>
1821
public abstract class Message
1922
{
23+
/// <summary>
24+
/// Serial API Function
25+
/// </summary>
2026
public readonly Function Function;
27+
/// <summary>
28+
/// Base class for all ZWave Messages
29+
/// </summary>
30+
/// <param name="function"></param>
2131
protected Message(Function function)
2232
{
2333
this.Function = function;
@@ -28,6 +38,7 @@ internal virtual PayloadWriter GetPayload()
2838
return new PayloadWriter(256);
2939
}
3040

41+
/// <inheritdoc />
3142
public override string ToString()
3243
{
3344
return "[msg] ";

0 commit comments

Comments
 (0)