PySide6.QtNfc.QNearFieldTarget¶
- class QNearFieldTarget¶
The
QNearFieldTarget
class provides an interface for communicating with a target device. More_…Synopsis¶
Methods¶
def
__init__()
def
accessMethods()
def
disconnect()
def
hasNdefMessage()
def
sendCommand()
def
type()
def
uid()
Signals¶
def
disconnected()
def
error()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
QNearFieldTarget
provides a generic interface for communicating with an NFC target device. Both NFC Forum devices and NFC Forum Tag targets are supported by this class. All target specific classes subclass this class.The
type()
function can be used to get the type of the target device. Theuid()
function returns the unique identifier of the target. TheAccessMethods
flags returns from theaccessMethods()
function can be tested to determine which access methods are supported by the target.If the target supports
NdefAccess
,hasNdefMessage()
can be called to test if the target has a stored NDEF message,readNdefMessages()
andwriteNdefMessages()
functions can be used to get and set the NDEF message.If the target supports
TagTypeSpecificAccess
,sendCommand()
can be used to send a single proprietary command to the target and retrieve the response.- class Type¶
This enum describes the type of tag the target is detected as.
Constant
Description
QNearFieldTarget.ProprietaryTag
An unidentified proprietary target tag.
QNearFieldTarget.NfcTagType1
An NFC tag type 1 target.
QNearFieldTarget.NfcTagType2
An NFC tag type 2 target.
QNearFieldTarget.NfcTagType3
An NFC tag type 3 target.
QNearFieldTarget.NfcTagType4
An NFC tag type 4 target. This value is used if the NfcTagType4 cannot be further refined by NfcTagType4A or NfcTagType4B below.
QNearFieldTarget.NfcTagType4A
An NFC tag type 4 target based on ISO/IEC 14443-3A.
QNearFieldTarget.NfcTagType4B
An NFC tag type 4 target based on ISO/IEC 14443-3B.
QNearFieldTarget.MifareTag
A Mifare target.
- class AccessMethod¶
(inherits
enum.Flag
) This enum describes the access methods a near field target supports.Constant
Description
QNearFieldTarget.UnknownAccess
The target supports an unknown access type.
QNearFieldTarget.NdefAccess
The target supports reading and writing NDEF messages using
readNdefMessages()
andwriteNdefMessages()
.QNearFieldTarget.TagTypeSpecificAccess
The target supports sending tag type specific commands using
sendCommand()
.QNearFieldTarget.AnyAccess
The target supports any of the known access types.
- class Error¶
This enum describes the error codes that a near field target reports.
Constant
Description
QNearFieldTarget.NoError
No error has occurred.
QNearFieldTarget.UnknownError
An unidentified error occurred.
QNearFieldTarget.UnsupportedError
The requested operation is unsupported by this near field target.
QNearFieldTarget.TargetOutOfRangeError
The target is no longer within range.
QNearFieldTarget.NoResponseError
The target did not respond.
QNearFieldTarget.ChecksumMismatchError
The checksum has detected a corrupted response.
QNearFieldTarget.InvalidParametersError
Invalid parameters were passed to a tag type specific function.
QNearFieldTarget.ConnectionError
Failed to connect to the target.
QNearFieldTarget.NdefReadError
Failed to read NDEF messages from the target.
QNearFieldTarget.NdefWriteError
Failed to write NDEF messages to the target.
QNearFieldTarget.CommandError
Failed to send a command to the target.
QNearFieldTarget.TimeoutError
The request could not be completed within the time specified in
waitForRequestCompleted()
.QNearFieldTarget.UnsupportedTargetError
The target used is unsupported. As example this can occur on missing required entitlement and/or privacy settings from the client app.
Constructs a new near field target with
parent
.- accessMethods()¶
- Return type:
Combination of
AccessMethod
Returns the access methods supported by this near field target.
- disconnect()¶
- Return type:
bool
Closes the connection to the target to enable communication with the target from a different instance. The connection will also be closed, when the
QNearFieldTarget
is destroyed. A connection to the target device is (re)created to process a command or read/write a NDEF messages.Returns
true
only if an existing connection was successfully closed; otherwise returnsfalse
.- disconnected()¶
This signal is emitted when the near field target moves out of proximity.
This signal is emitted when an error occurs while processing request
id
. Theerror
parameter describes the error.- hasNdefMessage()¶
- Return type:
bool
Returns
true
if at least one NDEF message is stored on the near field target; otherwise returnsfalse
.- maxCommandLength()¶
- Return type:
int
Returns the maximum number of bytes that can be sent with
sendCommand
. 0 will be returned if the target does not support sending tag type specific commands.See also
- ndefMessageRead(message)¶
- Parameters:
message –
QNdefMessage
This signal is emitted when a complete NDEF
message
has been read from the target.See also
Starts reading NDEF messages stored on the near field target. Returns a request id which can be used to track the completion status of the request. An invalid request id will be returned if the target does not support reading NDEF messages.
An
ndefMessageRead()
signal will be emitted for each NDEF message. TherequestCompleted()
signal will be emitted was all NDEF messages have been read. Theerror()
signal is emitted if an error occurs.Note
An attempt to read an NDEF message from a tag, that is in INITIALIZED state as defined by NFC Forum, will fail with the
NdefReadError
, as the tag is formatted to support NDEF but does not contain a message yet.This signal is emitted when a request
id
completes.See also
Returns the decoded response for request
id
. If the request is unknown or has not yet been completed an invalid QVariant is returned.- sendCommand(command)¶
- Parameters:
command –
QByteArray
- Return type:
Sends
command
to the near field target. Returns a request id which can be used to track the completion status of the request. An invalid request id will be returned if the target does not support sending tag type specific commands.The
requestCompleted()
signal will be emitted on successful completion of the request; otherwise theerror()
signal will be emitted.Once the request completes successfully the response can be retrieved from the
requestResponse()
function. The response of this request will be a QByteArray.Returns the type of tag type of this near field target.
- uid()¶
- Return type:
Returns the UID of the near field target.
Note
On iOS, this function returns an empty QByteArray for a near field target discovered using
NdefAccess
method.See also
Waits up to
msecs
milliseconds for the requestid
to complete. Returnstrue
if the request completes successfully and the requestCompeted() signal is emitted; otherwise returnsfalse
.Writes the NDEF messages in
messages
to the target. Returns a request id which can be used to track the completion status of the request. An invalid request id will be returned if the target does not support reading NDEF messages.The
requestCompleted()
signal will be emitted when the write operation completes successfully; otherwise theerror()
signal is emitted.- class RequestId¶
A request id handle. More_…
Synopsis¶
Methods¶
def
__init__()
def
isValid()
def
__ne__()
def
__lt__()
def
__eq__()
def
refCount()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
- __init__()¶
Constructs a new invalid request id handle.
- __init__(other)
- Parameters:
other –
RequestId
Constructs a new request id handle that is a copy of
other
.- isValid()¶
- Return type:
bool
Returns
true
if this is a valid request id; otherwise returnsfalse
.- refCount()¶
- Return type:
int
Returns the current reference count of the request id.