WebAPI/WebNFC: Difference between revisions

Jump to navigation Jump to search
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  
- 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.  
  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  
- 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.
  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.
It exposes the following functions public methods to Nfc Gaia applications.
 
- parseNDEF            : Parse a NDEF message
- parseNDEF            : Parse a NDEF message
- parseHandoverNDEF    : Parse a NDEF message that represents a handover request
- parseHandoverNDEF    : Parse a NDEF message that represents a handover request
                          or a handover select message
                        or a handover select message
- searchForBluetoothAC : Search for a Bluetooth Alternate Carrier in a
- searchForBluetoothAC : Search for a Bluetooth Alternate Carrier in a
                          handover NDEF message
                        handover NDEF message
- parseBluetoothSSP    : Parses a Carrier Data Record that contains a
- parseBluetoothSSP    : Parses a Carrier Data Record that contains a
                          Bluetooth Secure Simple Pairing record
                        Bluetooth Secure Simple Pairing record
- encodeHandoverRequest: Returns a NDEF message that contains a handover
- encodeHandoverRequest: Returns a NDEF message that contains a handover
                          request message
                        request message
- encodeHandoverSelect:  Returns a NDEF message that contains a handover
- encodeHandoverSelect:  Returns a NDEF message that contains a handover
                          select message
                        select message
 
''Sample example to demonstrate the construction of an url as an NDEF Message:''
''Sample example to demonstrate the construction of an url as an NDEF Message:''
  var tnf    = NDEF.TNF_WELL_KNOWN;
  var tnf    = NDEF.TNF_WELL_KNOWN;
  var type    = NDEF.RTD_URI;
  var type    = NDEF.RTD_URI;
  var id      = new Uint8Array();
  var id      = new Uint8Array();
  // Short Record, 0x3 or "http://"
  // Short Record, 0x3 or "http://"
  var payload = new Uint8Array(NfcUtils.fromUTF8('\u0003mozilla.org'));
  var payload = new Uint8Array(NfcUtils.fromUTF8('\u0003mozilla.org'));
  var  urlNDEF = new MozNDEFRecord(tnf, type, id, payload);
  var  urlNDEF = new MozNDEFRecord(tnf, type, id, payload);
 
  // Call writeNdef() API with urlNDEF
  // Call writeNdef() API with urlNDEF


== NDEF Connect Example ==
== NDEF Connect Example ==
Confirmed users
118

edits

Navigation menu