NFC Adapter
NFC Adapter provides access to the NFC device to perform device related operations.
All properties and methods should be used after activate. Besides supported and isActive.
## Enabling the API
In order to use this API you must include the following extension in your build.yml
:::ruby
extensions: [“nfc”]
If you are building a Windows Mobile or Windows CE app with this API, you must set your app_type as "rhoelements" in your build.yml as shown [here](../guide/build_config#other-build-time-settings).
Activates the NFC device so that all the NFC operations will be executed.
Synchronous Return:
Method Access:
Rho.Adapter.activate()
Rho::Adapter.activate()
Connects the Bluetooth device to obtain device properties.
Parameters
Async Callback Returning Parameters: HASH
Device name.
Device MAC address.
Synchronous Return:
Method Access:
Rho.Adapter.btConnect(CallBackHandler callback)
Rho::Adapter.btConnect(CallBackHandler callback)
Disconnects the Bluetooth device.
Synchronous Return:
Method Access:
Rho.Adapter.btDisconnect()
Rho::Adapter.btDisconnect()
Gets the NFC device capabilities.
Synchronous Return:
Return hash with capabilities.
Possible Values :
Array with tag types - only those tags will be detected.
Possible Values :
Array with tag types - only those tags will be detected. See above tagsSupported parameter.
Array with tag types - only those tags will be detected. See see above tagsSupported parameter.
This array has only one element.
Method Access:
Rho.Adapter.getDeviceInfo()
Rho::Adapter.getDeviceInfo()
Resets the NFC device to default configuration. Pollingtime will set to 90, passkey to empty string.
Synchronous Return:
Method Access:
Rho.Adapter.reset()
Rho::Adapter.reset()
Register callback for config change. If you change properties like pollingTimeout, passkey then callback will fire.
Parameters
Async Callback Returning Parameters: HASH
Bluetooth device pass key.
Polling timeout in seconds of the NFC device.
Synchronous Return:
Method Access:
Rho.Adapter.setConfigChangeHandler(CallBackHandler callback)
Rho::Adapter.setConfigChangeHandler(CallBackHandler callback)
Register callback for Message receive.
Parameters
Async Callback Returning Parameters: HASH
Message Id.
Synchronous Return:
Method Access:
Rho.Adapter.setMessageHandler(CallBackHandler callback)
Rho::Adapter.setMessageHandler(CallBackHandler callback)
Register callback for Tag detection.
Parameters
Array with tag types - only those tags will be detected. If empty array - all types. See below tagsSupported parameter in getDeviceInfo method.
Async Callback Returning Parameters: HASH
Tag Id.
Synchronous Return:
Method Access:
Rho.Adapter.setTagDetectionHandler(ARRAY tagsToBeDetected, CallBackHandler callback)
Rho::Adapter.setTagDetectionHandler(ARRAY tagsToBeDetected, CallBackHandler callback)
Stops the NFC device.
Parameters
Synchronous Return:
Method Access:
Rho.Adapter.stop(CallBackHandler callback)
Rho::Adapter.stop(CallBackHandler callback)
Gets a value indicating whether or not the NFC device is currently active.
Property Access:
myObject.isActive
Bluetooth device pass key. Max of 6 characters, empty string is no Passkey (Default is No Passkey). The property is enabled after NFC engine activation.
Property Access:
myObject.passkey
Polling timeout in seconds of the NFC device. 0 - timeout disabled, default: 90. The property is enabled after NFC engine activation.
Property Access:
myObject.pollingTimeout
Return true if NFC supported on this device.
Property Access:
myObject.supported
Gets the version of the NFC stack.
Property Access:
myObject.version