Warning Unreleased Docs! - You may be viewing documentation that reflects an upcoming release and the functionality described may not be in the current version you are using. Change the version above to the most recent version.

Adapter

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`
        extensions: ["nfc"]

<div class="alert alert-warning"><table>
<td><i class="icon-warning-sign icon-2x"></i></td>
<td>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).</td>
</table></div>


Methods

activate
()

Activates the NFC device so that all the NFC operations will be executed.

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.activate()
    • Ruby: Rho::Adapter.activate()
btConnect
(CallBackHandler callback)

Connects the Bluetooth device to obtain device properties.

Parameters

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • btName : STRING

      Device name.

    • btAddress : STRING

      Device MAC address.

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.btConnect(CallBackHandler callback)
    • Ruby: Rho::Adapter.btConnect(CallBackHandler callback)
btDisconnect
()

Disconnects the Bluetooth device.

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.btDisconnect()
    • Ruby: Rho::Adapter.btDisconnect()
getDeviceInfo
()

Gets the NFC device capabilities.

Synchronous Return:

  • HASH :

    Return hash with capabilities.

    • operatingModesSupported : ARRAY

      • Object : STRING

        Possible Values :

        Constant: Rho::Adapter.NFC_P2P (For Ruby use "::" for all "." when referencing constants)
        String: 1
        Constant: Rho::Adapter.NFC_Reader_Writer (For Ruby use "::" for all "." when referencing constants)
        String: 2
        Constant: Rho::Adapter.NFC_CE (For Ruby use "::" for all "." when referencing constants)
        String: 3
        Constant: Rho::Adapter.NFC_CE_UICC (For Ruby use "::" for all "." when referencing constants)
        String: 4
        Constant: Rho::Adapter.NFC_CE_SE (For Ruby use "::" for all "." when referencing constants)
        String: 5
        Constant: Rho::Adapter.NFC_CE_Host (For Ruby use "::" for all "." when referencing constants)
        String: 6
        Constant: Rho::Adapter.Multiple_NDEFMessages (For Ruby use "::" for all "." when referencing constants)
        String: 7
        Constant: Rho::Adapter.NFC_LLCP (For Ruby use "::" for all "." when referencing constants)
        String: 8
        Constant: Rho::Adapter.NFC_SNEP (For Ruby use "::" for all "." when referencing constants)
        String: 9
        Constant: Rho::Adapter.NFC_NPP (For Ruby use "::" for all "." when referencing constants)
        String: 10
        Constant: Rho::Adapter.NFC_BT_StaticHandover (For Ruby use "::" for all "." when referencing constants)
        String: 11
        Constant: Rho::Adapter.NFC_BT_DynamicHandover (For Ruby use "::" for all "." when referencing constants)
        String: 12
    • tagsSupported : ARRAY

      Array with tag types – only those tags will be detected.

      • Object : STRING

        Possible Values :

        Constant: Rho::Adapter.MiFareUL (For Ruby use "::" for all "." when referencing constants)
        String: 1
        Constant: Rho::Adapter.MiFareStd (For Ruby use "::" for all "." when referencing constants)
        String: 2
        Constant: Rho::Adapter.MifareULC (For Ruby use "::" for all "." when referencing constants)
        String: 3
        Constant: Rho::Adapter.ISO14443_4A (For Ruby use "::" for all "." when referencing constants)
        String: 4
        Constant: Rho::Adapter.ISO14443_4B (For Ruby use "::" for all "." when referencing constants)
        String: 5
        Constant: Rho::Adapter.ISO15693 (For Ruby use "::" for all "." when referencing constants)
        String: 6
        Constant: Rho::Adapter.FeliCa (For Ruby use "::" for all "." when referencing constants)
        String: 7
        Constant: Rho::Adapter.Jewel (For Ruby use "::" for all "." when referencing constants)
        String: 8
        Constant: Rho::Adapter.Desfire (For Ruby use "::" for all "." when referencing constants)
        String: 9
        Constant: Rho::Adapter.MiFarePlus (For Ruby use "::" for all "." when referencing constants)
        String: 10
        Constant: Rho::Adapter.NXPIcode (For Ruby use "::" for all "." when referencing constants)
        String: 11
        Constant: Rho::Adapter.Topaz (For Ruby use "::" for all "." when referencing constants)
        String: 12
        Constant: Rho::Adapter.Calypso (For Ruby use "::" for all "." when referencing constants)
        String: 13
        Constant: Rho::Adapter.TITagIt (For Ruby use "::" for all "." when referencing constants)
        String: 14
    • formattingTagsSupported : ARRAY

      Array with tag types – only those tags will be detected. See above tagsSupported parameter.

      • Object : STRING

    • writeProtectedTagsSupported : ARRAY

      Array with tag types – only those tags will be detected. See see above tagsSupported parameter.

      • Object : STRING

    • firmwareVersion : STRING

      This array has only one element.

      • Object : STRING

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.getDeviceInfo()
    • Ruby: Rho::Adapter.getDeviceInfo()
reset
()

Resets the NFC device to default configuration. Pollingtime will set to 90, passkey to empty string.

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.reset()
    • Ruby: Rho::Adapter.reset()
setConfigChangeHandler
(CallBackHandler callback)

Register callback for config change. If you change properties like pollingTimeout, passkey then callback will fire.

Parameters

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • passKey : STRING

      Bluetooth device pass key.

    • pollingTimeout : INTEGER

      Polling timeout in seconds of the NFC device.

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.setConfigChangeHandler(CallBackHandler callback)
    • Ruby: Rho::Adapter.setConfigChangeHandler(CallBackHandler callback)
setMessageHandler
(CallBackHandler callback)

Register callback for Message receive.

Parameters

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • messageId : STRING

      Message Id.

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.setMessageHandler(CallBackHandler callback)
    • Ruby: Rho::Adapter.setMessageHandler(CallBackHandler callback)
setTagDetectionHandler
(ARRAY tagsToBeDetected, CallBackHandler callback)

Register callback for Tag detection.

Parameters

  • tagsToBeDetected : ARRAY

    Array with tag types – only those tags will be detected. If empty array – all types. See below tagsSupported parameter in getDeviceInfo method.

    • Object : INTEGER

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • tagId : STRING

      Tag Id.

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.setTagDetectionHandler(ARRAY tagsToBeDetected, CallBackHandler callback)
    • Ruby: Rho::Adapter.setTagDetectionHandler(ARRAY tagsToBeDetected, CallBackHandler callback)
stop
(CallBackHandler callback)

Stops the NFC device.

Parameters

  • callback : CallBackHandler Optional

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.Adapter.stop(CallBackHandler callback)
    • Ruby: Rho::Adapter.stop(CallBackHandler callback)

Properties

isActive
: BOOLEAN Read Only

Gets a value indicating whether or not the NFC device is currently active.

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.isActive
passkey
: STRING

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:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.passkey
pollingTimeout
: INTEGER

Polling timeout in seconds of the NFC device. 0 – timeout disabled, default: 90. The property is enabled after NFC engine activation.

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.pollingTimeout
supported
: BOOLEAN Read Only

Return true if NFC supported on this device.

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.supported
version
: STRING Read Only

Gets the version of the NFC stack.

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.version