NfcB
class NfcB : TagTechnology
| kotlin.Any | |
| ↳ | android.nfc.tech.NfcB |
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations on a Tag.
Acquire a NfcB object using get.
The primary NFC-B I/O operation is transceive. Applications must implement their own protocol stack on top of transceive.
Note: Methods that perform I/O operations require the android.Manifest.permission#NFC permission.
Summary
| Public methods | |
|---|---|
| Unit |
close()Disable I/O operations to the tag from this |
| Unit |
connect()Enable I/O operations to the tag from this |
| static NfcB! |
Get an instance of |
| ByteArray! |
Return the Application Data bytes from ATQB/SENSB_RES at tag discovery. |
| Int |
Return the maximum number of bytes that can be sent with |
| ByteArray! |
Return the Protocol Info bytes from ATQB/SENSB_RES at tag discovery. |
| Tag! |
getTag()Get the |
| Boolean |
Helper to indicate if I/O operations should be possible. |
| ByteArray! |
transceive(data: ByteArray!)Send raw NFC-B commands to the tag and receive the response. |
Public methods
close
fun close(): Unit
Disable I/O operations to the tag from this TagTechnology object, and release resources.
Also causes all blocked I/O operations on other thread to be canceled and return with IOException.
Requires the android.Manifest.permission#NFC permission.
| Exceptions | |
|---|---|
java.lang.Exception |
if this resource cannot be closed |
java.io.IOException |
if an I/O error occurs |
java.lang.SecurityException |
if the tag object is reused after the tag has left the field |
connect
fun connect(): Unit
Enable I/O operations to the tag from this TagTechnology object.
May cause RF activity and may block. Must not be called from the main application thread. A blocked call will be canceled with IOException by calling #close from another thread.
Only one TagTechnology object can be connected to a Tag at a time.
Applications must call #close when I/O operations are complete.
Requires the android.Manifest.permission#NFC permission.
| Exceptions | |
|---|---|
android.nfc.TagLostException |
if the tag leaves the field |
java.io.IOException |
if there is an I/O failure, or connect is canceled |
java.lang.SecurityException |
if the tag object is reused after the tag has left the field |
get
static fun get(tag: Tag!): NfcB!
Get an instance of NfcB for the given tag.
Returns null if NfcB was not enumerated in Tag.getTechList. This indicates the tag does not support NFC-B.
Does not cause any RF activity and does not block.
| Parameters | |
|---|---|
tag |
Tag!: an NFC-B compatible tag |
| Return | |
|---|---|
NfcB! |
NFC-B object |
getApplicationData
fun getApplicationData(): ByteArray!
Return the Application Data bytes from ATQB/SENSB_RES at tag discovery.
Does not cause any RF activity and does not block.
| Return | |
|---|---|
ByteArray! |
Application Data bytes from ATQB/SENSB_RES bytes |
getMaxTransceiveLength
fun getMaxTransceiveLength(): Int
Return the maximum number of bytes that can be sent with transceive.
| Return | |
|---|---|
Int |
the maximum number of bytes that can be sent with transceive. |
getProtocolInfo
fun getProtocolInfo(): ByteArray!
Return the Protocol Info bytes from ATQB/SENSB_RES at tag discovery.
Does not cause any RF activity and does not block.
| Return | |
|---|---|
ByteArray! |
Protocol Info bytes from ATQB/SENSB_RES bytes |
getTag
fun getTag(): Tag!
Get the Tag object backing this TagTechnology object.
| Return | |
|---|---|
Tag! |
the Tag backing this TagTechnology object. |
isConnected
fun isConnected(): Boolean
Helper to indicate if I/O operations should be possible.
Returns true if connect has completed, and #close has not been called, and the Tag is not known to be out of range.
Does not cause RF activity, and does not block.
| Return | |
|---|---|
Boolean |
true if I/O operations should be possible |
transceive
fun transceive(data: ByteArray!): ByteArray!
Send raw NFC-B commands to the tag and receive the response.
Applications must not append the EoD (CRC) to the payload, it will be automatically calculated.
Applications must not send commands that manage the polling loop and initialization (SENSB_REQ, SLOT_MARKER etc).
Use getMaxTransceiveLength to retrieve the maximum number of bytes that can be sent with transceive.
This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with IOException if #close is called from another thread.
Requires the android.Manifest.permission#NFC permission.
| Parameters | |
|---|---|
data |
ByteArray!: bytes to send |
| Return | |
|---|---|
ByteArray! |
bytes received in response |
| Exceptions | |
|---|---|
android.nfc.TagLostException |
if the tag leaves the field |
java.io.IOException |
if there is an I/O failure, or this operation is canceled |