Confirmed users
118
edits
| Line 224: | Line 224: | ||
== NDEF Utilitiy function for parsing / constructing NDEF records== | == NDEF Utilitiy function for parsing / constructing NDEF records== | ||
- Gaia Application developers can avail Nfc-Utility helper library (<$GAIA_HOME>/apps/system/js/nfc_util.js> to perform routine tasks | |||
such as parse incoming NDEF records or construct NDEF records. | |||
- NfcUtils in {{bug|963556}} will provide some basic constants and utility functions to create and parse NDEF records and | |||
offers a set of utility functions to handle NDEF messages according to NFCForum-TS-NDEF_1.0. | |||
It exposes the following functions public methods to Nfc Gaia applications. | |||
- parseNDEF : Parse a NDEF message | |||
- parseHandoverNDEF : Parse a NDEF message that represents a handover request | |||
or a handover select message | |||
- searchForBluetoothAC : Search for a Bluetooth Alternate Carrier in a | |||
handover NDEF message | |||
- parseBluetoothSSP : Parses a Carrier Data Record that contains a | |||
Bluetooth Secure Simple Pairing record | |||
- encodeHandoverRequest: Returns a NDEF message that contains a handover | |||
request message | |||
- encodeHandoverSelect: Returns a NDEF message that contains a handover | |||
select message | |||
''Sample example to demonstrate the construction of an url as an NDEF Message:'' | |||
var tnf = NDEF.TNF_WELL_KNOWN; | |||
var type = NDEF.RTD_URI; | |||
var id = new Uint8Array(); | |||
// Short Record, 0x3 or "http://" | |||
var payload = new Uint8Array(NfcUtils.fromUTF8('\u0003mozilla.org')); | |||
var urlNDEF = new MozNDEFRecord(tnf, type, id, payload); | |||
// Call writeNdef() API with urlNDEF | |||
== NDEF Connect Example == | == NDEF Connect Example == | ||