Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed Jan 13, 2025
1 parent b2674df commit 3b3a194
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions ExampleConsole/ExampleConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0-windows10.0.19041.0; net8.0</TargetFrameworks>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
19 changes: 19 additions & 0 deletions MatterDotNet/OperationalDiscovery/CommissioningPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using MatterDotNet.Security;
using System.Text;

namespace MatterDotNet.OperationalDiscovery
{
Expand Down Expand Up @@ -41,6 +42,10 @@ public enum DiscoveryCapabilities
/// IP
/// </summary>
IP = 0x4,
/// <summary>
/// WiFi Public Action Frame
/// </summary>
WiFi = 0x8
}
/// <summary>
/// Commissioning Flow
Expand Down Expand Up @@ -124,6 +129,20 @@ private CommissioningPayload(string QRCode)
throw new ArgumentException("Invalid QR Code");
}

/// <summary>
/// Create a payload from a NFC Tag NDEF block
/// </summary>
/// <param name="QRCode"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static CommissioningPayload FromNFC(byte[] ndef)
{
if (ndef.Length < 10)
throw new ArgumentException("Invalid Format");
return FromQR(Encoding.UTF8.GetString(ndef.AsSpan(5)));
}


/// <summary>
/// Create a payload from a QR code starting with "MT:"
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions MatterDotNet/Protocol/TLV/TLVWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ public void WriteAny(long tagNumber, object? any)
else if (any is bool)
WriteBool(tagNumber, (bool)any);
else if (any is uint || any is ulong || any is ushort || any is byte)
WriteULong(tagNumber, (ulong)any);
WriteULong(tagNumber, (ulong)(dynamic)any);
else if (any is int || any is long || any is short || any is sbyte)
WriteLong(tagNumber, (long)any);
WriteLong(tagNumber, (long)(dynamic)any);
else if (any is byte[])
WriteBytes(tagNumber, (byte[])any);
else if (any is string)
Expand Down

0 comments on commit 3b3a194

Please sign in to comment.