Click or drag to resize
TappyReader Class

[This is preliminary documentation and is subject to change.]

The Driver class is used to communicate(send commands and receive data) with a Tappy device
Inheritance Hierarchy
SystemObject
  TapTrack.Tcmp.CommunicationTappyReader

Namespace: TapTrack.Tcmp.Communication
Assembly: TapTrack.Tcmp (in TapTrack.Tcmp.dll) Version: 0.4.0.0 (0.4.0.0)
Syntax
C#
public class TappyReader : IDisposable

The TappyReader type exposes the following members.

Constructors
  NameDescription
Public methodTappyReader
Initializes a new instance of the TappyReader class
Top
Properties
  NameDescription
Public propertyDeviceName
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.
Top
Methods
  NameDescription
Public methodAutoDetect
Connect to the first Tappy device the driver finds
Public methodConnect
Connect to a given reader or port.
Public methodDisconnect
Disconnect from the current reader
Public methodDispose
Releases all resources used by the TappyReader
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFlushBuffer
Clears the contents of the driver buffer
Public methodGetAvailableDevices
Get all the devices
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSendCommand(Command, Callback)
Send a command to the Tappy
Public methodSendCommandT(Object)
Send a command with no response call back
Public methodSendCommandT(Callback, Object)
Send a command to the Tappy
Public methodSwitchProtocol
Switch between USB or Bluetooth modes
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples

Reading a UID from a NFC tag

C#
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

C#
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();
        }
    }
}
See Also