Skip to content

Commit

Permalink
Adding virtual NDEF card with PN532 (#2159)
Browse files Browse the repository at this point in the history
* initial commit

* Adding writing and events

* Improving doc

* adding more doc

* improved sample and doc

* compatibility suppressions

* adjusting default padding for felica and adding phone app link

* fixing markdown lint
  • Loading branch information
Ellerbach authored Dec 14, 2023
1 parent 925f67b commit 131e63d
Show file tree
Hide file tree
Showing 21 changed files with 1,012 additions and 16 deletions.
14 changes: 14 additions & 0 deletions src/Iot.Device.Bindings/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Iot.Device.Pn532.AsTarget.TargetBaudRateInialized</Target>
<Left>lib/net6.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net6.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Iot.Device.Pn532.AsTarget.TargetBaudRateInialized</Target>
<Left>lib/netstandard2.0/Iot.Device.Bindings.dll</Left>
<Right>lib/netstandard2.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Iot.Device.Axp192.BatteryStatus.Overwinered</Target>
Expand Down
39 changes: 36 additions & 3 deletions src/devices/Card/CreditCard/ApduCommands.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Iot.Device.Card.CreditCardProcessing
namespace Iot.Device.Card
{
/// <summary>
/// The list of predefined commands to communicate with the card
/// </summary>
internal class ApduCommands
public class ApduCommands
{
/// <summary>Application block.</summary>
public static byte[] ApplicationBlock = { 0x80, 0x1E };
public static byte[] ApplicaitonUnBlock = { 0x80, 0x18 };

/// <summary>Application unblock.</summary>
public static byte[] ApplicationUnBlock = { 0x80, 0x18 };

/// <summary>Card block.</summary>
public static byte[] CardBlock = { 0x80, 0x16 };

/// <summary>External authenticate.</summary>
public static byte[] ExternalAuthenticate = { 0x00, 0x82 };

/// <summary>Generate application cryptogram.</summary>
public static byte[] GenerateApplicationCryptogram = { 0x80, 0xAE };

/// <summary>Get challenge.</summary>
public static byte[] GetChallenge = { 0x00, 0x84 };

/// <summary>Get data.</summary>
public static byte[] GetData = { 0x80, 0xCA };

/// <summary>Get processing options.</summary>
public static byte[] GetProcessingOptions = { 0x80, 0xA8 };

/// <summary>Internal authenticate.</summary>
public static byte[] InternalAuthenticate = { 0x00, 0x88 };

/// <summary>PIN number change unblock.</summary>
public static byte[] PersonalIdentificationNumberChangeUnblock = { 0x80, 0x24 };

/// <summary>Read binary.</summary>
public static byte[] ReadBinary = { 0x00, 0xB0 };

/// <summary>Update binary.</summary>
public static byte[] UpdateBinary = { 0x00, 0xD6 };

/// <summary>Read record.</summary>
public static byte[] ReadRecord = { 0x00, 0xB2 };

/// <summary>Select a file.</summary>
public static byte[] Select = { 0x00, 0xA4 };

/// <summary>Verify.</summary>
public static byte[] Verify = { 0x80, 0x20 };

/// <summary>Get bytes to read.</summary>
public static byte[] GetBytesToRead = { 0x00, 0xC0 };
}
}
32 changes: 32 additions & 0 deletions src/devices/Card/CreditCard/ApduReturnCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Iot.Device.Card
{
/// <summary>
/// The list of predefined commands to communicate with the card
/// </summary>
public class ApduReturnCommands
{
/// <summary>Command completed properly.</summary>
public static byte[] CommandComplete = { 0x90, 0x00 };

/// <summary>Tag not found.</summary>
public static byte[] TagNotFound = { 0x6A, 0x82 };

/// <summary>Function not supported.</summary>
public static byte[] FunctionNotSupported = { 0x6A, 0x81 };

/// <summary>Memory Failure.</summary>
public static byte[] MemoryFailure = { 0x65, 0x81 };

/// <summary>Security status not satisfied.</summary>
public static byte[] SecurityNotSatisfied = { 0x69, 0x82 };

/// <summary>Wrong legnth.</summary>
public static byte[] WrongLength = { 0x6C, 0x00 };

/// <summary>End of file before being able to send all.</summary>
public static byte[] EndOfFileBefore = { 0x62, 0x82 };
}
}
20 changes: 20 additions & 0 deletions src/devices/Card/EmulatedTag/CardStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace EmulatedTag
{
/// <summary>
/// The state of the card.
/// </summary>
public enum CardStatus
{
/// <summary>Card is in released state.</summary>
Released = 0,

/// <summary>Car is in activated state.</summary>
Activated,

/// <summary>Card is on delected state.</summary>
Deselected
}
}
Loading

0 comments on commit 131e63d

Please sign in to comment.