Class: NfcHandoverManager

NfcHandoverManager

new NfcHandoverManager()

NfcHandoverManager handles handovers from other Bluetooth devices according to the specification of the NFC Forum (Document: NFCForum-TS-ConnectionHandover_1_2.doc).

NfcHandoverManager handles handovers from other Bluetooth devices according to the specification of the NFC Forum (Document: NFCForum-TS-ConnectionHandover_1_2.doc).

Source:

Members

_adapter :Object

Default bluetooth adapter

.

Default bluetooth adapter

Type:
  • Object
Source:

actionQueue :Array

Keeps a list of actions that need to be performed after Bluetooth is turned on.

Keeps a list of actions that need to be performed after Bluetooth is turned on.

Type:
  • Array
Source:

bluetoothAutoEnabled :boolean

Remembers whether Bluetooth was enabled or automatically.

Remembers whether Bluetooth was enabled or automatically.

Type:
  • boolean
Source:

bluetoothStatusSaved :boolean

Remembers whether Bluetooth was already saved during an earlier file transfer.

Remembers whether Bluetooth was already saved during an earlier file transfer.

Type:
  • boolean
Source:

DEBUG :boolean

Flag which turns on debuging messages

.

Flag which turns on debuging messages

Type:
  • boolean
Source:

incomingFileTransferInProgress :boolean

Set to true during a file transfer that was initiated by another device.

Set to true during a file transfer that was initiated by another device.

Type:
  • boolean
Source:

responseTimeoutFunction :Object

Set whenever a timeout is defined while waiting for an outstanding handover response.

Set whenever a timeout is defined while waiting for an outstanding handover response.

Type:
  • Object
Source:

responseTimeoutMillis :Number

The length of the timeout in milliseconds to wait for an outstanding handover response.

The length of the timeout in milliseconds to wait for an outstanding handover response.

Type:
  • Number
Source:

sendFileQueue :Object

Keeps a list of send file requests made via peer.sendFile(blob).

Keeps a list of send file requests made via peer.sendFile(blob). It will be inspected in the handling of Handover Select messages to distinguish between static and negotiated handovers.

Type:
  • Object
Source:

settingsNotified

Used to prevent triggering Settings multiple times.

Used to prevent triggering Settings multiple times.

Source:

Methods

_cancelIncomingFileTransfer()

This function will be called after a timeout when we did not receive the Hs record within three seconds.

This function will be called after a timeout when we did not receive the Hs record within three seconds. At this point we cancel the file transfer.

Source:

_cancelSendFileTransfer()

This function will be called after a timeout when we did not receive the Hs record within three seconds.

This function will be called after a timeout when we did not receive the Hs record within three seconds. At this point we cancel the file transfer.

Source:

_checkConnected(btssp)

Check if a device is already paired and connected.

Check if a device is already paired and connected.

BTv2 deprecate the device.connected property. connect stat should be retrieved by adapter.getConnectedDevices API

Parameters:
Name Type Description
btssp Object

BT SSP record

Source:

_clearBluetoothStatus()

Forget a previously saved Bluetooth status.

Forget a previously saved Bluetooth status.

Source:

_clearTimeout()

Clears timeout that handles the case an outstanding handover message has not been received within a certain timeframe.

Clears timeout that handles the case an outstanding handover message has not been received within a certain timeframe.

Source:

_dispatchSendFileStatus(status, request)

Dispatches status of file sending to mozNfc.

Dispatches status of file sending to mozNfc.

Parameters:
Name Type Description
status number

status of file send operation

request string

ID of the operation

Source:

_doConnect(device)

Connects via bluetooth to the paired device.

Connects via bluetooth to the paired device.

Parameters:
Name Type Description
device string

Device to be paired

Source:

_doFileTransfer(mac)

Performs bluetooth file transfer if this.sendFileRequest exists to other device

.

Performs bluetooth file transfer if this.sendFileRequest exists to other device

Parameters:
Name Type Description
mac string

MAC address of the other device

Source:

_doHandoverRequest(ndef, MozNFCPeer)

Performs tha actual handover request

.

Performs tha actual handover request

Parameters:
Name Type Description
ndef Array

NDEF message conating the handover request record

MozNFCPeer MozNFCPeer

object.

Source:

_doPairing(mac)

Performs bluetooth pairing with other device

.

Performs bluetooth pairing with other device

Parameters:
Name Type Description
mac string

MAC address of the peer device

Source:

_findPairedDevice(mac, foundCb, notFoundCb)

Look for a paired device and invoke the appropriate callback function.

Look for a paired device and invoke the appropriate callback function.

Parameters:
Name Type Description
mac string

MAC address of the device

foundCb function

Found callback

notFoundCb function

Not found callback

Source:

_getBluetoothSSP(ndef) → {Object|string|string}

Gets the data about other device taking part in handover proces from NDEF message

.

Gets the data about other device taking part in handover proces from NDEF message

Parameters:
Name Type Description
ndef Array

NDEF message

Source:
Returns:
  • ssp - object containing info about other devices

    Type
    Object
  • ssp.mac - mac addres of other devices

    Type
    string
  • ssp.localName - local name if present in NDEF message, null otherwise

    Type
    string

_handleHandoverRequest(ndef, MozNFCPeer)

Handles NDEF Handover Request message.

Handles NDEF Handover Request message.

Parameters:
Name Type Description
ndef Array

NDEF message containing handover request record

MozNFCPeer MozNFCPeer

object.

Source:

_handleHandoverSelect(ndef)

Handle NDEF Handover Select message.

Handle NDEF Handover Select message.

Parameters:
Name Type Description
ndef Array

NDEF message containing handover select record

Source:

_handleSimplifiedPairingRecord(ndef)

Handles simplified pairing record.

Handles simplified pairing record.

Parameters:
Name Type Description
ndef Array

NDEF message containing simplified pairing record

Source:

_initiateFileTransfer(msg)

Initiate a file transfer by sending a Handover Request to the remote device.

Initiate a file transfer by sending a Handover Request to the remote device.

Parameters:
Name Type Description
msg Object

message object

Properties
Name Type Description
peer MozNFCPeer

An instance of MozNFCPeer object.

blob Blob

File to be sent.

requestId String

Request ID.

Source:

_logVisibly(msg, opObject)

Logs message in logcat

.

Logs message in logcat

Parameters:
Name Type Description
msg String

debug messages

opObject Object

object to printed after doing JSON.stringfy

Source:

_onRequestConnect(btssp)

Handles connection request by asking user for confirmation.

Handles connection request by asking user for confirmation.

Parameters:
Name Type Description
btssp Object

BT SSP (Secure Simple Pairing) data.

Source:

_restoreBluetoothStatus()

Restore the Bluetooth status.

Restore the Bluetooth status.

Source:

_saveBluetoothStatus()

Save the on/off status of Bluetooth.

Save the on/off status of Bluetooth.

Source:

_showFailedNotification(msg)

Show an error notification when file transfer failed.

Show an error notification when file transfer failed.

Parameters:
Name Type Description
msg String

Optional message.

Source:

_showTryAgainNotification()

Show 'send failed, try again' notification.

Show 'send failed, try again' notification.

Source:

_start()

Initializes event and message handlers, initializes properties.

Initializes event and message handlers, initializes properties.

Source:

_transferStarted()

BluetoothTransfer notifies us that a file transfer has started.

BluetoothTransfer notifies us that a file transfer has started.

Source:

handleFileTransfer(msg)

Trigger a file transfer with a remote device via BT.

Trigger a file transfer with a remote device via BT.

Parameters:
Name Type Description
msg Object

message object

Properties
Name Type Description
peer MozNFCPeer

An instance of MozNFCPeer object.

blob Blob

File to be sent.

requestId String

Request ID.

Source:

isHandoverInProgress() → {boolean}

Returns true if a handover is in progress.

Returns true if a handover is in progress.

Source:
Returns:

true if handover is in progress.

Type
boolean

transferComplete(details)

Tells NfcHandoverManager that a BT file transfer has been completed.

Tells NfcHandoverManager that a BT file transfer has been completed.

Parameters:
Name Type Description
details

succeeded True if file transfer was successfull.

Source:

tryHandover(ndefMsg, MozNFCPeer) → {boolean}

Checks if the first record of NDEF message is a handover record.

Checks if the first record of NDEF message is a handover record. If yes the NDEF message is handled according to handover record type.

Parameters:
Name Type Description
ndefMsg Array

array of NDEF records

MozNFCPeer MozNFCPeer

object.

Source:
Returns:

true if handover record was found and handled, false if no handover record was found

Type
boolean