NFC / NDEF Library for Proximity APIs  4.1.0
Easily parse and create NDEF records with the Windows Proximity APIs / Near Field Communication NFC.
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Properties | List of all members
NdefLibrary.Ndef.NdefSpRecord Class Reference

Handles the Smart Poster meta-record and is able to both parse and assemble a smart poster according to the specification. More...

Inheritance diagram for NdefLibrary.Ndef.NdefSpRecord:
NdefLibrary.Ndef.NdefRecord NdefLibrary.Ndef.NdefSmartUriRecord NdefLibrary.Ndef.NdefGeoRecord NdefLibrary.Ndef.NdefMailtoRecord NdefLibrary.Ndef.NdefSmsRecord NdefLibrary.Ndef.NdefSocialRecord NdefLibrary.Ndef.NdefTelRecord

Public Member Functions

 NdefSpRecord ()
 Create an empty Smart Poster (Sp) record. More...
 
 NdefSpRecord (NdefRecord other)
 Create a Smart Poster record based on the record passed through the argument. More...
 
void SetPayloadAndParse (byte[] payload, bool parseNewPayload)
 Sets the payload of the base class to the byte array from the parameter and optionally parses its contents. More...
 
bool HasSpData ()
 Returns true if this record contains data that requires a Smart Poster and could not be stored in a simple URI record. More...
 
override bool CheckIfValid ()
 Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue. More...
 
void SetUri (NdefUriRecord newUri)
 Set the URI based on another URI record instead of specifying the URI itself. More...
 
void AddTitle (NdefTextRecord newTitle)
 Add an (optional) title to the Smart Poster. More...
 
int TitleCount ()
 Returns how many title text records are stored in the Smart Poster. More...
 
NdefTextRecord Title (int index)
 Retrieve a specific title text record from the list. More...
 
bool ActionInUse ()
 Returns if the action has been defined for this Smart Poster instance. More...
 
bool SizeInUse ()
 Returns if the size has been defined for this Smart Poster instance. More...
 
bool MimeTypeInUse ()
 Returns if the mime type has been defined for this Smart Poster instance. More...
 
bool ImageInUse ()
 Returns if the Smart Poster contains an image (not supported yet). More...
 
- Public Member Functions inherited from NdefLibrary.Ndef.NdefRecord
 NdefRecord ()
 Create an empty record, not setting any information. More...
 
 NdefRecord (TypeNameFormatType tnf, byte[] type)
 Create a new record with the specified type name format and type. Doesn't set the payload and ID. More...
 
 NdefRecord (NdefRecord other)
 Create a new record, copying the information of the record sent through the parameter. More...
 
Type CheckSpecializedType (bool checkForSubtypes)
 Checks the type name format and type of this record and returns the appropriate specialized class, if one is available and known for this record type. More...
 

Static Public Member Functions

static bool IsRecordType (NdefRecord record)
 Checks if the record sent via the parameter is indeed a Smart Poster. Only checks the type and type name format, doesn't analyze if the payload is valid. More...
 

Static Public Attributes

static readonly byte [] SmartPosterType = { (byte)'S', (byte)'p' }
 Type of the NDEF Smart Poster record (well-known, type 'Sp'). More...
 

Protected Attributes

NdefUriRecord RecordUri
 URI sub-record of this Smart Poster. Use Uri property to access if possible. More...
 
- Protected Attributes inherited from NdefLibrary.Ndef.NdefRecord
byte [] _type
 Byte array storing raw contents of the type. Use Type property to access it whenever possible. More...
 
byte [] _payload
 Byte array storing raw contents of the payload. Use Payload property to access it whenever possible. More...
 

Properties

string Uri [get, set]
 Mandatory URI of the Smart Poster More...
 
List< NdefTextRecord > Titles [get]
 List of all title texts for different languages used in the Smart Poster. More...
 
NdefSpActRecord.NfcActionType NfcAction [get, set]
 The action defines how the reader should handle the Smart Poster record. More...
 
uint NfcSize [get, set]
 Size of the linked content. More...
 
string NfcMimeType [get, set]
 MIME type of the linked object. More...
 
NdefMimeImageRecordBase NfcImage [get, set]
 Icon / Image data contained in the Smart Poster. More...
 
- Properties inherited from NdefLibrary.Ndef.NdefRecord
TypeNameFormatType TypeNameFormat [get, set]
 Indicates the structure of the value of the TYPE field. More...
 
virtual byte [] Type [get, set]
 An identifier describing the type of the payload. More...
 
byte [] Id [get, set]
 An identifier in the form of a URI reference. More...
 
virtual byte [] Payload [get, set]
 The application data carried within an NDEF record. More...
 

Additional Inherited Members

- Public Types inherited from NdefLibrary.Ndef.NdefRecord
enum  TypeNameFormatType {
  TypeNameFormatType.Empty = 0x00, TypeNameFormatType.NfcRtd = 0x01, TypeNameFormatType.Mime = 0x02, TypeNameFormatType.Uri = 0x03,
  TypeNameFormatType.ExternalRtd = 0x04, TypeNameFormatType.Unknown = 0x05, TypeNameFormatType.Unchanged = 0x06, TypeNameFormatType.Reserved = 0x07
}
 Standardized type name formats, as defined by the NDEF record specification from the Nfc Forum. More...
 

Detailed Description

Handles the Smart Poster meta-record and is able to both parse and assemble a smart poster according to the specification.

The class is able to handle the mandatory URI, any number of text records (for storing the Smart Poster title in multiple languages), the action, size, type and image.

As only the URI is mandatory, various ...InUse() methods can be queried to see if an optional detail was set in the Smart Poster that was read from a tag.

The action, size and type records used within the Smart Poster are only valid within its context according to the specification. Therefore, classes for those record types are defined within the context of the Smart Poster record class.

Due to the more complex nature of the Smart Poster record, which consists of multiple records, this class parses the payload contents and creates instances of the various record classes found within the Smart Poster. However, any changes to details are instantly commited to the raw payload as well.

Constructor & Destructor Documentation

◆ NdefSpRecord() [1/2]

NdefLibrary.Ndef.NdefSpRecord.NdefSpRecord ( )

Create an empty Smart Poster (Sp) record.

Note that in order to write a Smart Poster to a tag, you have to at least add the URL. An empty Smart Poster record is not valid according to the specs.

◆ NdefSpRecord() [2/2]

NdefLibrary.Ndef.NdefSpRecord.NdefSpRecord ( NdefRecord  other)

Create a Smart Poster record based on the record passed through the argument.

Internalizes and parses the payload of the original record. The original record can be a Smart Poster or a URI record.

Parameters
otherRecord to copy into this smart poster record.
Exceptions
NdefExceptionThrown if attempting to create a Smart Poster based on an incompatible record type.

Member Function Documentation

◆ ActionInUse()

bool NdefLibrary.Ndef.NdefSpRecord.ActionInUse ( )

Returns if the action has been defined for this Smart Poster instance.

◆ AddTitle()

void NdefLibrary.Ndef.NdefSpRecord.AddTitle ( NdefTextRecord  newTitle)

Add an (optional) title to the Smart Poster.

It is possible to add more than one title as each title text record can have a different language. The phone is then recommended to choose the text record with the language that makes most sense to the user.

Parameters
newTitle(additional) title to be stored in the Smart Poster.

◆ CheckIfValid()

override bool NdefLibrary.Ndef.NdefSpRecord.CheckIfValid ( )
virtual

Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue.

Exceptions
NdefExceptionThrown if no valid NDEF record can be created based on the record's current contents. The exception message contains further details about the issue.
Returns
True if the record contents are valid, or throws an exception if an issue is found.

Reimplemented from NdefLibrary.Ndef.NdefRecord.

Reimplemented in NdefLibrary.Ndef.NdefTelRecord.

◆ HasSpData()

bool NdefLibrary.Ndef.NdefSpRecord.HasSpData ( )

Returns true if this record contains data that requires a Smart Poster and could not be stored in a simple URI record.

Returns
true if the record contains one or more titles, an image, action, size or type information. It is false if the record only contains a URI.

◆ ImageInUse()

bool NdefLibrary.Ndef.NdefSpRecord.ImageInUse ( )

Returns if the Smart Poster contains an image (not supported yet).

◆ IsRecordType()

static bool NdefLibrary.Ndef.NdefSpRecord.IsRecordType ( NdefRecord  record)
static

Checks if the record sent via the parameter is indeed a Smart Poster. Only checks the type and type name format, doesn't analyze if the payload is valid.

Parameters
recordRecord to check.
Returns
True if the record has the correct type and type name format to be a Smart Poster, false if it's a different record.

◆ MimeTypeInUse()

bool NdefLibrary.Ndef.NdefSpRecord.MimeTypeInUse ( )

Returns if the mime type has been defined for this Smart Poster instance.

◆ SetPayloadAndParse()

void NdefLibrary.Ndef.NdefSpRecord.SetPayloadAndParse ( byte []  payload,
bool  parseNewPayload 
)

Sets the payload of the base class to the byte array from the parameter and optionally parses its contents.

The parsing needs to be done when the Smart Poster is read from a tag. If a detail of an existing Smart Poster class is modified, it will just update its internal payload, but doesn't need to parse it again (as the details are already stored in instances of the various record classes).

Parameters
payloadnew payload
parseNewPayloadwhether to parse the new payload to update the internal records (url, title, type, etc.).

◆ SetUri()

void NdefLibrary.Ndef.NdefSpRecord.SetUri ( NdefUriRecord  newUri)

Set the URI based on another URI record instead of specifying the URI itself.

Parameters
newUri

◆ SizeInUse()

bool NdefLibrary.Ndef.NdefSpRecord.SizeInUse ( )

Returns if the size has been defined for this Smart Poster instance.

◆ Title()

NdefTextRecord NdefLibrary.Ndef.NdefSpRecord.Title ( int  index)

Retrieve a specific title text record from the list.

Returns an empty record in case the index is invalid.

Parameters
indexnumber of the title record to return
Returns
title record at the specified index, or empty record if the index is invalid.

◆ TitleCount()

int NdefLibrary.Ndef.NdefSpRecord.TitleCount ( )

Returns how many title text records are stored in the Smart Poster.

Member Data Documentation

◆ RecordUri

NdefUriRecord NdefLibrary.Ndef.NdefSpRecord.RecordUri
protected

URI sub-record of this Smart Poster. Use Uri property to access if possible.

◆ SmartPosterType

readonly byte [] NdefLibrary.Ndef.NdefSpRecord.SmartPosterType = { (byte)'S', (byte)'p' }
static

Type of the NDEF Smart Poster record (well-known, type 'Sp').

Property Documentation

◆ NfcAction

NdefSpActRecord.NfcActionType NdefLibrary.Ndef.NdefSpRecord.NfcAction
getset

The action defines how the reader should handle the Smart Poster record.

Make sure to check actionInUse() before retrieving the action; if the Smart Poster doesn't have an action defined, itd will return the default NdefNfcSpRecord::DoAction.

◆ NfcImage

NdefMimeImageRecordBase NdefLibrary.Ndef.NdefSpRecord.NfcImage
getset

Icon / Image data contained in the Smart Poster.

A reader device should display the icon prior to acting on the URI record. Note that the Smart Poster standard would allow to use multiple icons. However, as no currently available phones actually show the image contained in the Smart Poster and the standard does not contain an indication as to what would be the use of having multiple images if the device should only show one anyway (and there is no distinction between the images), this class is deliberately limited to only one image record.

◆ NfcMimeType

string NdefLibrary.Ndef.NdefSpRecord.NfcMimeType
getset

MIME type of the linked object.

This can be used to tell the mobile device what kind of an object it can expect before it opens the connection.

◆ NfcSize

uint NdefLibrary.Ndef.NdefSpRecord.NfcSize
getset

Size of the linked content.

This is useful if the reader device needs to decide in advance whether it has the capability to process the referenced object.

◆ Titles

List<NdefTextRecord> NdefLibrary.Ndef.NdefSpRecord.Titles
get

List of all title texts for different languages used in the Smart Poster.

Can be no title at all, or multiple titles. Each title should have a different language.

◆ Uri

string NdefLibrary.Ndef.NdefSpRecord.Uri
getset

Mandatory URI of the Smart Poster


The documentation for this class was generated from the following file: