Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

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"]

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.

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 "::" instead of ".")
        String: 1
        Constant: Rho::Adapter.NFC_Reader_Writer (For Ruby use "::" instead of ".")
        String: 2
        Constant: Rho::Adapter.NFC_CE (For Ruby use "::" instead of ".")
        String: 3
        Constant: Rho::Adapter.NFC_CE_UICC (For Ruby use "::" instead of ".")
        String: 4
        Constant: Rho::Adapter.NFC_CE_SE (For Ruby use "::" instead of ".")
        String: 5
        Constant: Rho::Adapter.NFC_CE_Host (For Ruby use "::" instead of ".")
        String: 6
        Constant: Rho::Adapter.Multiple_NDEFMessages (For Ruby use "::" instead of ".")
        String: 7
        Constant: Rho::Adapter.NFC_LLCP (For Ruby use "::" instead of ".")
        String: 8
        Constant: Rho::Adapter.NFC_SNEP (For Ruby use "::" instead of ".")
        String: 9
        Constant: Rho::Adapter.NFC_NPP (For Ruby use "::" instead of ".")
        String: 10
        Constant: Rho::Adapter.NFC_BT_StaticHandover (For Ruby use "::" instead of ".")
        String: 11
        Constant: Rho::Adapter.NFC_BT_DynamicHandover (For Ruby use "::" instead of ".")
        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 "::" instead of ".")
        String: 1
        Constant: Rho::Adapter.MiFareStd (For Ruby use "::" instead of ".")
        String: 2
        Constant: Rho::Adapter.MifareULC (For Ruby use "::" instead of ".")
        String: 3
        Constant: Rho::Adapter.ISO14443_4A (For Ruby use "::" instead of ".")
        String: 4
        Constant: Rho::Adapter.ISO14443_4B (For Ruby use "::" instead of ".")
        String: 5
        Constant: Rho::Adapter.ISO15693 (For Ruby use "::" instead of ".")
        String: 6
        Constant: Rho::Adapter.FeliCa (For Ruby use "::" instead of ".")
        String: 7
        Constant: Rho::Adapter.Jewel (For Ruby use "::" instead of ".")
        String: 8
        Constant: Rho::Adapter.Desfire (For Ruby use "::" instead of ".")
        String: 9
        Constant: Rho::Adapter.MiFarePlus (For Ruby use "::" instead of ".")
        String: 10
        Constant: Rho::Adapter.NXPIcode (For Ruby use "::" instead of ".")
        String: 11
        Constant: Rho::Adapter.Topaz (For Ruby use "::" instead of ".")
        String: 12
        Constant: Rho::Adapter.Calypso (For Ruby use "::" instead of ".")
        String: 13
        Constant: Rho::Adapter.TITagIt (For Ruby use "::" instead of ".")
        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:

  • Class: This property can only be accessed via the API class object.
    • Javascript: Rho.Adapter.isActive
    • Ruby: Rho::Adapter.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:

  • Class: This property can only be accessed via the API class object.
    • Javascript: Rho.Adapter.passkey
    • Ruby: Rho::Adapter.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:

  • Class: This property can only be accessed via the API class object.
    • Javascript: Rho.Adapter.pollingTimeout
    • Ruby: Rho::Adapter.pollingTimeout

supported : BOOLEAN Read Only

Return true if NFC supported on this device.

Property Access:

  • Class: This property can only be accessed via the API class object.
    • Javascript: Rho.Adapter.supported
    • Ruby: Rho::Adapter.supported

version : STRING Read Only

Gets the version of the NFC stack.

Property Access:

  • Class: This property can only be accessed via the API class object.
    • Javascript: Rho.Adapter.version
    • Ruby: Rho::Adapter.version