TappyReader Class |
[This is preliminary documentation and is subject to change.]
Namespace: TapTrack.Tcmp.Communication
public class TappyReader : IDisposable
The TappyReader type exposes the following members.
Name | Description | |
---|---|---|
![]() | TappyReader | Initializes a new instance of the TappyReader class |
Name | Description | |
---|---|---|
![]() | DeviceName |
Gets the name of the device the driver is currently connected to (USB port name or bluetooth device name depending on the current communcation protocol).
Returns null if there is no device connected.
|
Name | Description | |
---|---|---|
![]() | AutoDetect |
Connect to the first Tappy device the driver finds
|
![]() | Connect |
Connect to a given reader or port.
|
![]() | Disconnect |
Disconnect from the current reader
|
![]() | Dispose | Releases all resources used by the TappyReader |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | FlushBuffer |
Clears the contents of the driver buffer
|
![]() | GetAvailableDevices |
Get all the devices
|
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | SendCommand(Command, Callback) |
Send a command to the Tappy
|
![]() | SendCommandT(Object) |
Send a command with no response call back
|
![]() | SendCommandT(Callback, Object) |
Send a command to the Tappy
|
![]() | SwitchProtocol |
Switch between USB or Bluetooth modes
|
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Reading a UID from a NFC tag
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using TapTrack.Tcmp.CommandFamilies; using TapTrack.Tcmp.Communication; using TapTrack.Tcmp.CommandFamilies.BasicNfc; using TapTrack.Tcmp; namespace TapTrack.Tcmp.Demo { class Program { static void Main(string[] args) { TappyReader tappyReader = new TappyReader(CommunicationProtocol.Usb); if (tappyReader.AutoDetect()) // Find and connect to a Tappy { Command readUid = new DetectSingleTagUid(0, DetectTagSetting.Type2Type4AandMifare); // No time out and no locking detect uid command Callback responseCallback = (ResponseFrame frame, Exception e) => { if(TcmpFrame.IsValidFrame(frame) && frame.ResponseCode == 0x01) { Tag tag = new Tag(frame.Data); string uid = BitConverter.ToString(tag.UID); Console.WriteLine($"UID: {uid}"); } }; Console.WriteLine("Waiting for a tag"); tappyReader.SendCommand(readUid, responseCallback); } else { Console.WriteLine("No Tappy found"); } Console.ReadKey(); } } }
Writing text to a tag
using System; using TapTrack.Tcmp.CommandFamilies; using TapTrack.Tcmp.Communication; using TapTrack.Tcmp.CommandFamilies.BasicNfc; namespace TapTrack.Tcmp.Demo { class Program { static void Main(string[] args) { TappyReader tappyReader = new TappyReader(CommunicationProtocol.Usb); if (tappyReader.AutoDetect()) // Find and connect to a Tappy { Command cmd = new WriteText(0, false, "Hello world!"); // No time out and no locking write command Callback responseCallback = (ResponseFrame frame, Exception e) => { if (TcmpFrame.IsValidFrame(frame) && frame.ResponseCode == 0x05) Console.WriteLine("Write successful"); else Console.WriteLine("Write was unsuccessful"); }; Console.WriteLine("Waiting for a tag"); tappyReader.SendCommand(cmd, responseCallback); } else { Console.WriteLine("No Tappy found"); } Console.ReadKey(); } } }