Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
36
assets/webapps/nfc-api-test.gaiamobile.org/index.html
Normal file
36
assets/webapps/nfc-api-test.gaiamobile.org/index.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC privilege API tests</title>
|
||||
<link rel="stylesheet" type="text/css" href="style/nfctest.css">
|
||||
<link rel="stylesheet" type="text/css" href="style/tabs.css" >
|
||||
<script type="text/javascript" src="js/nfctest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="panel list-panel">
|
||||
<div id="API-tests" class="list_and_toolbar">
|
||||
<div class="toolbar">
|
||||
<p></p><p class="toolbar-title">NFC Privileged API Tests</p><p></p>
|
||||
</div>
|
||||
<ul class="list">
|
||||
<li><a href="#test=nfc_read_tag">NFC Read Tag</a></li>
|
||||
<li><a href="#test=nfc_format_tag">NFC Format Tag</a></li>
|
||||
<li><a href="#test=nfc_write_tag">NFC Write Tag</a></li>
|
||||
<li><a href="#test=nfc_send_ndef">Send NDEF to Peer</a></li>
|
||||
<li><a href="#test=nfc_dispatch">NFC Dispatch Test</a></li>
|
||||
<li><a href="#test=nfc_tech">NFC Tag Technology</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="test-panel" class="panel test-panel">
|
||||
<div class="toolbar">
|
||||
<button id="test-panel-back">back</button>
|
||||
<p id="test-panel-title" class="toolbar-title"></p>
|
||||
<p></p>
|
||||
</div>
|
||||
<iframe id="test-iframe" mozallowfullscreen="true"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
75
assets/webapps/nfc-api-test.gaiamobile.org/js/ndef_helper.js
Normal file
75
assets/webapps/nfc-api-test.gaiamobile.org/js/ndef_helper.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
'use strict';
|
||||
|
||||
(function(exports) {
|
||||
var URI = ['', 'http://www.', 'https://www.', 'http://', 'https://', 'tel:',
|
||||
'mailto:', 'ftp://anonymous:anonymous@', 'ftp://ftp.', 'ftps://', 'sftp://',
|
||||
'smb://', 'nfs://', 'ftp://', 'dav://', 'news:', 'telnet://', 'imap:',
|
||||
'rtsp://', 'urn:', 'pop:', 'sip:', 'sips:', 'tftp:', 'btspp://',
|
||||
'btl2cap://', 'btgoep://', 'tcpobex://', 'irdaobex://', 'file://',
|
||||
'urn:epc:id:', 'urn:epc:tag:', 'urn:epc:pat:', 'urn:epc:raw:', 'urn:epc:',
|
||||
'urn:nfc:'];
|
||||
|
||||
function NDEFHelper() { }
|
||||
|
||||
NDEFHelper.prototype = {
|
||||
/**
|
||||
* Create MozNDEFRecord whose content is the uri.
|
||||
*/
|
||||
createURI: function nh_createURI(uri) {
|
||||
|
||||
var id = 0;
|
||||
// start with 1 since index 0 is ''.
|
||||
for (var i = 1; i < URI.length; i++) {
|
||||
if (uri.startsWith(URI[i])) {
|
||||
id = i;
|
||||
}
|
||||
}
|
||||
|
||||
uri = String.fromCharCode(id) + uri.substring(URI[id].length);
|
||||
|
||||
var enc = new TextEncoder('utf-8');
|
||||
|
||||
return new MozNDEFRecord({tnf: 'well-known',
|
||||
type: enc.encode('U'),
|
||||
payload: enc.encode(uri)});
|
||||
},
|
||||
|
||||
parseURI: function nh_parseURI(ndef) {
|
||||
if (!ndef || ndef.tnf != 'well-known' || ndef.type[0] != 0x55) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var payload = ndef.payload;
|
||||
var prefix = URI[payload[0]];
|
||||
if (!prefix) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var dec = new TextDecoder('utf-8');
|
||||
return prefix + dec.decode(payload.subarray(1));
|
||||
},
|
||||
|
||||
/**
|
||||
* Utils to dump Uint8Array.
|
||||
*/
|
||||
dumpUint8Array: function nh_dumpUint8Array(array) {
|
||||
if (!array) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
var str = '[';
|
||||
var i;
|
||||
var arrayLen = array ? array.length : 0;
|
||||
for (i = 0; i < arrayLen; i++) {
|
||||
str += '0x' + array[i].toString(16);
|
||||
if (i != array.length - 1) {
|
||||
str += ', ';
|
||||
}
|
||||
}
|
||||
|
||||
return str + ']';
|
||||
}
|
||||
};
|
||||
|
||||
exports.NDEFHelper = NDEFHelper;
|
||||
})(window);
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
var NfcDispatchDemo = {
|
||||
tagContainer: null,
|
||||
|
||||
init: function nd_init() {
|
||||
dump('NfcDispatchDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var globalMsg = document.getElementById('global-message');
|
||||
this.tagContainer = content.querySelector('[data-type="tag-container"]')
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
globalMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
globalMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('global-message').textContent = '';
|
||||
|
||||
nfc.ontagfound = this.handleTagFound.bind(this);
|
||||
nfc.onpeerfound = this.handlePeerFound.bind(this);
|
||||
},
|
||||
|
||||
handleTagFound: function nd_handleTagFound(event) {
|
||||
var ndefRecords = event.ndefRecords;
|
||||
var tagUri =
|
||||
this.tagContainer.querySelector('[data-type="tag-uri"]');
|
||||
tagUri.textContent = '';
|
||||
var result =
|
||||
this.tagContainer.querySelector('[data-type="dispatch-result"]');
|
||||
|
||||
var ndefHelper = new NDEFHelper();
|
||||
var ndef = Array.isArray(ndefRecords) && ndefRecords[0];
|
||||
var uri = ndefHelper.parseURI(ndef);
|
||||
tagUri.textContent = uri;
|
||||
if (uri.startsWith('https://www.mozilla.org')) {
|
||||
result.textContent = 'Default Prevented';
|
||||
return false;
|
||||
} else {
|
||||
result.textContent = 'Default Action Executed';
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
handlePeerFound: function nd_handlePeerFound(event) {
|
||||
var tagUri =
|
||||
this.tagContainer.querySelector('[data-type="tag-uri"]');
|
||||
tagUri.textContent = '';
|
||||
var result =
|
||||
this.tagContainer.querySelector('[data-type="dispatch-result"]');
|
||||
|
||||
result.textContent = 'Default Prevented';
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => NfcDispatchDemo.init());
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
var NfcFormatDemo = {
|
||||
tagContainer: null,
|
||||
|
||||
init: function nd_init() {
|
||||
dump('NfcFormatDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var globalMsg = document.getElementById('global-message');
|
||||
this.tagContainer = content.querySelector('[data-type="tag-container"]')
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
globalMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
globalMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('global-message').textContent = '';
|
||||
|
||||
nfc.ontagfound = this.handleTagFound.bind(this);
|
||||
},
|
||||
|
||||
handleTagFound: function nd_handleTagFound(event) {
|
||||
var tag = event.tag;
|
||||
var formatable =
|
||||
this.tagContainer.querySelector('[data-type="formatable"]');
|
||||
formatable.textContent = tag.isFormatable != null ?
|
||||
tag.isFormatable : 'null';
|
||||
|
||||
var result = this.tagContainer.querySelector('[data-type="format-result"]');
|
||||
|
||||
tag.format().then(() => {
|
||||
result.style.color = "Green";
|
||||
result.textContent = "Pass";
|
||||
}).catch((err) => {
|
||||
result.style.color = "Red";
|
||||
result.textContent = err;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => NfcFormatDemo.init());
|
||||
173
assets/webapps/nfc-api-test.gaiamobile.org/js/nfc_read_tag.js
Normal file
173
assets/webapps/nfc-api-test.gaiamobile.org/js/nfc_read_tag.js
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
var NfcReadDemo = {
|
||||
tagContainer: null,
|
||||
ndefMsgContainer: null,
|
||||
|
||||
tag: null,
|
||||
|
||||
init: function nd_init() {
|
||||
dump('NfcReadDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var errorMsg = document.getElementById('error-message');
|
||||
this.tagContainer = document.getElementById('tag-container');
|
||||
this.ndefMsgContainer = document.getElementById('ndef-msg-container');
|
||||
this.ndefMsgContainer.hidden = true;
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
errorMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
errorMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('error-message').textContent = '';
|
||||
|
||||
nfc.ontagfound = this.handleTagFound.bind(this);
|
||||
nfc.ontaglost = this.handleTagLost.bind(this);
|
||||
},
|
||||
|
||||
handleTagFound: function nd_handleTagFound(event) {
|
||||
// clear success/error message.
|
||||
var errorMsg = document.getElementById('error-message');
|
||||
errorMsg.textContent = '';
|
||||
var sucMsg = document.getElementById('success-message');
|
||||
sucMsg.textContent = '';
|
||||
|
||||
this.tag = event.tag;
|
||||
|
||||
var tag = event.tag;
|
||||
var techList = this.tagContainer.querySelector('[data-type="tech-list"]');
|
||||
var tagId = this.tagContainer.querySelector('[data-type="tag-id"]');
|
||||
var tagType = this.tagContainer.querySelector('[data-type="tag-type"]');
|
||||
var maxNDEFSize = this.tagContainer.
|
||||
querySelector('[data-type="max-ndef-size"]');
|
||||
var readOnly = this.tagContainer.querySelector('[data-type="read-only"]');
|
||||
var formatable = this.tagContainer.
|
||||
querySelector('[data-type="formatable"]');
|
||||
var canReadOnly =
|
||||
this.tagContainer.querySelector('[data-type="can-be-made-read-only"]');
|
||||
var isLost = this.tagContainer.querySelector('[data-type="is-lost"]');
|
||||
|
||||
var ndefHelper = new NDEFHelper();
|
||||
techList.textContent = tag.techList || 'null';
|
||||
tagId.textContent = ndefHelper.dumpUint8Array(tag.id);
|
||||
tagType.textContent = tag.type || 'null';
|
||||
maxNDEFSize.textContent = tag.maxNDEFSize || 'null';
|
||||
readOnly.textContent = tag.isReadOnly != null ?
|
||||
tag.isReadOnly : 'null';
|
||||
formatable.textContent = tag.isFormatable != null ?
|
||||
tag.isFormatable : 'null';
|
||||
canReadOnly.textContent = tag.canBeMadeReadOnly != null ?
|
||||
tag.canBeMadeReadOnly : 'null';
|
||||
isLost.textContent = tag.isLost;
|
||||
|
||||
var ndefRecords = event.ndefRecords;
|
||||
var ndefLen = ndefRecords ? ndefRecords.length : 0;
|
||||
|
||||
// clear previous ndef information
|
||||
var recordCount = this.ndefMsgContainer.
|
||||
querySelector('[data-type="record-count"]');
|
||||
var previousCount = recordCount.textContent;
|
||||
var i;
|
||||
for (i = 0; i < previousCount; i++) {
|
||||
var ndefContainer = document.getElementById("ndef#" + i);
|
||||
if (ndefContainer) {
|
||||
this.ndefMsgContainer.removeChild(ndefContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// if no NDEF Records are contained, bail out.
|
||||
if (!ndefLen) {
|
||||
this.ndefMsgContainer.hidden = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
this.showNDEFRecords(event.ndefRecords);
|
||||
|
||||
tag.readNDEF().then(
|
||||
function (ndefRecords) {
|
||||
this.compareRecords(ndefRecords, event.ndefRecords);
|
||||
}.bind(this),
|
||||
error => {
|
||||
errorMsg.textContent = 'readNDEF failed, ' + error;
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
handleTagLost: function nd_handleTagLost() {
|
||||
// update tag.isLost field.
|
||||
var tag = this.tag;
|
||||
var isLost = this.tagContainer.querySelector('[data-type="is-lost"]');
|
||||
isLost.textContent = tag.isLost;
|
||||
},
|
||||
|
||||
compareRecords: function nd_compareRecords(recordsA, recordsB) {
|
||||
var errorMsg = document.getElementById('error-message');
|
||||
|
||||
if (recordsA.length != recordsB.length) {
|
||||
errorMsg.textContent = 'Number of Records are different.';
|
||||
return;
|
||||
}
|
||||
|
||||
var identical = true;
|
||||
for (var i = 0; i < recordsA.length; i++) {
|
||||
var A = recordsA[i];
|
||||
var B = recordsB[i];
|
||||
|
||||
var props = ['tnf', 'type', 'id', 'payload'];
|
||||
for (var prop of props) {
|
||||
if (A.prop != B.prop) {
|
||||
identical = false;
|
||||
errorMsg.textContent = prop + ' mismatched in the ' + i + 'th record';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (identical) {
|
||||
var sucMsg = document.getElementById('success-message');
|
||||
sucMsg.textContent = 'readNDEF succeeds.';
|
||||
}
|
||||
},
|
||||
|
||||
showNDEFRecords: function nd_showNDEFRecords(ndefRecords) {
|
||||
var ndefLen = ndefRecords.length;
|
||||
var recordCount = this.ndefMsgContainer.
|
||||
querySelector('[data-type="record-count"]');
|
||||
recordCount.textContent = ndefLen;
|
||||
var ndefTemplate = document.getElementById("ndef-template");
|
||||
ndefTemplate.hidden = true;
|
||||
|
||||
var ndefHelper = new NDEFHelper();
|
||||
for (i = 0; i < ndefLen; i++) {
|
||||
var ndefContainer = document.getElementById("ndef#" + i);
|
||||
if (!ndefContainer) {
|
||||
ndefContainer = ndefTemplate.cloneNode(true);
|
||||
ndefContainer.id = 'ndef#' + i;
|
||||
|
||||
var tnf = ndefContainer.querySelector('[data-type="ndef-tnf"]');
|
||||
tnf.textContent = ndefRecords[i].tnf;
|
||||
|
||||
var type = ndefContainer.querySelector('[data-type="ndef-type"]');
|
||||
type.textContent = ndefHelper.dumpUint8Array(ndefRecords[i].type);
|
||||
|
||||
var id = ndefContainer.querySelector('[data-type="ndef-id"]');
|
||||
id.textContent = ndefHelper.dumpUint8Array(ndefRecords[i].id);
|
||||
|
||||
var payload = ndefContainer.querySelector('[data-type="ndef-payload"]');
|
||||
payload.textContent = ndefHelper.dumpUint8Array(ndefRecords[i].payload);
|
||||
|
||||
ndefContainer.hidden = false;
|
||||
this.ndefMsgContainer.appendChild(ndefContainer);
|
||||
}
|
||||
}
|
||||
|
||||
this.ndefMsgContainer.hidden = false;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => NfcReadDemo.init());
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
var NfcSendDemo = {
|
||||
tagContainer: null,
|
||||
|
||||
init: function nd_init() {
|
||||
dump('NfcSendDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var globalMsg = document.getElementById('global-message');
|
||||
this.tagContainer = content.querySelector('[data-type="tag-container"]')
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
globalMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
globalMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('global-message').textContent = '';
|
||||
|
||||
nfc.onpeerfound = this.handlePeerFound.bind(this);
|
||||
},
|
||||
|
||||
handlePeerFound: function nd_handlePeerFound(event) {
|
||||
var peer = event.peer;
|
||||
var result = this.tagContainer.querySelector('[data-type="send-result"]');
|
||||
var ndefHelper = new NDEFHelper();
|
||||
var url = document.getElementById('urlOptions');
|
||||
var record = ndefHelper.createURI(url[url.selectedIndex].value);
|
||||
|
||||
peer.sendNDEF([record]).then(() => {
|
||||
result.style.color = "Green";
|
||||
result.textContent = "Pass";
|
||||
}).catch((err) => {
|
||||
result.style.color = "Red";
|
||||
result.textContent = err;
|
||||
});
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => NfcSendDemo.init());
|
||||
200
assets/webapps/nfc-api-test.gaiamobile.org/js/nfc_tech.js
Normal file
200
assets/webapps/nfc-api-test.gaiamobile.org/js/nfc_tech.js
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
var NfcTechDemo = {
|
||||
init: function nd_init() {
|
||||
dump('NfcTechDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var errorMsg = document.getElementById('error-message');
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
errorMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
errorMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('isoDep-container').hidden = true;
|
||||
document.getElementById('nfcA-container').hidden = true;
|
||||
|
||||
nfc.ontagfound = this.handleTagFound.bind(this);
|
||||
nfc.ontaglost = this.handleTagLost.bind(this);
|
||||
},
|
||||
|
||||
handleTagFound: function nd_handleTagFound(event) {
|
||||
// clear success/error message.
|
||||
var errorMsg = document.getElementById('error-message');
|
||||
errorMsg.textContent = '';
|
||||
var sucMsg = document.getElementById('success-message');
|
||||
sucMsg.textContent = '';
|
||||
|
||||
document.getElementById('isoDep-container').hidden = true;
|
||||
document.getElementById('nfcA-container').hidden = true;
|
||||
|
||||
var tag = event.tag;
|
||||
var tagContainer = document.getElementById('tag-container');
|
||||
var techList = tagContainer.querySelector('[data-type="tech-list"]');
|
||||
techList.textContent = tag.techList || 'null';
|
||||
|
||||
if (tag.techList.indexOf('ISO-DEP') != -1) {
|
||||
this.processIsoDep(tag);
|
||||
sucMsg.textContent = 'transceive ISO-DEP succeeds.';
|
||||
} else if (tag.techList.indexOf('NFC-A') != -1 && tag.type) {
|
||||
this.processNfcA(tag);
|
||||
sucMsg.textContent = 'transceive NFCA succeeds.';
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
handleTagLost: function nd_handleTagLost() {
|
||||
},
|
||||
|
||||
processIsoDep: function nd_processIsoDep(tag) {
|
||||
var container = document.getElementById('isoDep-container');
|
||||
container.hidden = false;
|
||||
var isoDep = tag.selectTech('ISO-DEP');
|
||||
this.getVersion(isoDep, container).then(
|
||||
() => { return this.getKeyInfo(isoDep, container); });
|
||||
},
|
||||
|
||||
processNfcA: function nd_processNfcA(tag) {
|
||||
document.getElementById('nfcA-container').hidden = false;
|
||||
var container;
|
||||
var nfcA = tag.selectTech('NFC-A');
|
||||
|
||||
if (tag.type.toLowerCase() === "type2") {
|
||||
document.getElementById('type1-container').hidden = true;
|
||||
document.getElementById('type2-container').hidden = false;
|
||||
|
||||
container = document.getElementById('type2-container');
|
||||
container.querySelector('[data-type="tag-type"]').textContent = tag.type;
|
||||
|
||||
this.write1BlockType2(nfcA, container).
|
||||
then(this.read4BlocksType2(nfcA, container));
|
||||
} else if (tag.type.toLowerCase() === "type1") {
|
||||
document.getElementById('type1-container').hidden = false;
|
||||
document.getElementById('type2-container').hidden = true;
|
||||
|
||||
container = document.getElementById('type1-container');
|
||||
container.querySelector('[data-type="tag-type"]').textContent = tag.type;
|
||||
|
||||
this.getUIDType1(nfcA, container);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getVersion: function nd_getVersion(isoDep, container) {
|
||||
var ndefHelper = new NDEFHelper();
|
||||
return new Promise((resolve, reject) => {
|
||||
isoDep.transceive(new Uint8Array([0x90, 0x60, 0x00, 0x00, 0x00])).
|
||||
then(response => {
|
||||
container.querySelector('[data-type="hw-vendor-id"]').textContent =
|
||||
response[0].toString(16);
|
||||
container.querySelector('[data-type="hw-type"]').textContent =
|
||||
response[1].toString(16) + '.' + response[2].toString(16);
|
||||
container.querySelector('[data-type="hw-version"]').textContent =
|
||||
response[3].toString(16) + '.' + response[4].toString(16);
|
||||
container.querySelector('[data-type="hw-storage"]').textContent =
|
||||
1 << (response[5] >> 1);
|
||||
container.querySelector('[data-type="hw-protocol"]').textContent =
|
||||
response[6].toString(16);
|
||||
// Assuming the status code is 0x91, 0xaf,
|
||||
// sending 0xaf to get additional info.
|
||||
return isoDep.transceive(new Uint8Array([0x90, 0xaf, 0x00, 0x00, 0x00])); }).
|
||||
then(response => {
|
||||
container.querySelector('[data-type="sw-vendor-id"]').textContent =
|
||||
response[0].toString(16);
|
||||
container.querySelector('[data-type="sw-type"]').textContent =
|
||||
response[1].toString(16) + '.' + response[2].toString(16);
|
||||
container.querySelector('[data-type="sw-version"]').textContent =
|
||||
response[3].toString(16) + '.' + response[4].toString(16);
|
||||
container.querySelector('[data-type="sw-storage"]').textContent =
|
||||
1 << (response[5] >> 1);
|
||||
container.querySelector('[data-type="sw-protocol"]').textContent =
|
||||
response[6].toString(16);
|
||||
// Assuming the status code is 0x91, 0xaf,
|
||||
// sending 0xaf to get additional info.
|
||||
return isoDep.transceive(new Uint8Array([0x90, 0xaf, 0x00, 0x00, 0x00])); }).
|
||||
then(response => {
|
||||
// Assuming it uses 7 bytes UID, if a random ID is used, it will be of
|
||||
// 4 bytes.
|
||||
container.querySelector('[data-type="uid"]').textContent =
|
||||
ndefHelper.dumpUint8Array(response.subarray(0, 7));
|
||||
container.querySelector('[data-type="batch-num"]').textContent =
|
||||
ndefHelper.dumpUint8Array(response.subarray(7, 12));
|
||||
container.querySelector('[data-type="production-date"]').textContent =
|
||||
'Week ' + response[12].toString(16) + '/ 20' + response[13].toString(16);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getKeyInfo: function nd_getKeyInfo(isoDep, container) {
|
||||
return new Promise((resolve, reject) => {
|
||||
isoDep.transceive(new Uint8Array([0x90, 0x45, 0x00, 0x00, 0x00])).
|
||||
then(response => {
|
||||
container.querySelector('[data-type="key-settings"]').textContent =
|
||||
response[0].toString(16);
|
||||
container.querySelector('[data-type="max-keys"]').textContent =
|
||||
response[1].toString(16);
|
||||
return isoDep.transceive(new Uint8Array([0x90, 0x64, 0x00, 0x00, 0x01, 0x00, 0x00])); }).
|
||||
then(response => {
|
||||
container.querySelector('[data-type="key-version"]').textContent =
|
||||
response[0].toString(16);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
read4BlocksType2: function nd_read4BlocksType2(nfcA, container) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var command = new Uint8Array([0x30, 0x05]);
|
||||
nfcA.transceive(command).
|
||||
then(response => {
|
||||
var ndefHelper = new NDEFHelper();
|
||||
container.querySelector('[data-type="read"]').textContent =
|
||||
ndefHelper.dumpUint8Array(response);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
write1BlockType2: function nd_write1BlockType2(nfcA, container) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var command = new Uint8Array([0xA2, 0x05, 0x01, 0x02, 0x03, 0x04]);
|
||||
nfcA.transceive(command).
|
||||
then(response => {
|
||||
var ndefHelper = new NDEFHelper();
|
||||
container.querySelector('[data-type="write"]').textContent =
|
||||
ndefHelper.dumpUint8Array(command.subarray(2,6));
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getUIDType1: function nd_getUIDType1(nfcA, container) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var command = new Uint8Array([0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
||||
nfcA.transceive(command).
|
||||
then(response => {
|
||||
container.querySelector('[data-type="hr0"]').textContent =
|
||||
response[0].toString(16);
|
||||
container.querySelector('[data-type="hr1"]').textContent =
|
||||
response[1].toString(16);
|
||||
container.querySelector('[data-type="uid0"]').textContent =
|
||||
response[2].toString(16);
|
||||
container.querySelector('[data-type="uid1"]').textContent =
|
||||
response[3].toString(16);
|
||||
container.querySelector('[data-type="uid2"]').textContent =
|
||||
response[4].toString(16);
|
||||
container.querySelector('[data-type="uid3"]').textContent =
|
||||
response[5].toString(16);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
window.addEventListener('load', () => NfcTechDemo.init());
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
var NfcWriteDemo = {
|
||||
tagContainer: null,
|
||||
|
||||
init: function nd_init() {
|
||||
dump('NfcWriteDemo init');
|
||||
var content = document.getElementById('content');
|
||||
var globalMsg = document.getElementById('global-message');
|
||||
this.tagContainer = content.querySelector('[data-type="tag-container"]')
|
||||
|
||||
var nfc = window.navigator.mozNfc;
|
||||
if (!nfc) {
|
||||
globalMsg.textContent = 'NFC API not available.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nfc.enabled) {
|
||||
globalMsg.textContent = 'NFC is not enabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('global-message').textContent = '';
|
||||
|
||||
nfc.ontagfound = this.handleTagFound.bind(this);
|
||||
},
|
||||
|
||||
handleTagFound: function nd_handleTagFound(event) {
|
||||
var tag = event.tag;
|
||||
var result = this.tagContainer.querySelector('[data-type="write-result"]');
|
||||
var ndefHelper = new NDEFHelper();
|
||||
var url = document.getElementById('urlOptions');
|
||||
var record = ndefHelper.createURI(url[url.selectedIndex].value);
|
||||
|
||||
tag.writeNDEF([record]).then(() => {
|
||||
result.style.color = "Green";
|
||||
result.textContent = "Pass";
|
||||
}).catch((err) => {
|
||||
result.style.color = "Red";
|
||||
result.textContent = err;
|
||||
});
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => NfcWriteDemo.init());
|
||||
141
assets/webapps/nfc-api-test.gaiamobile.org/js/nfctest.js
Normal file
141
assets/webapps/nfc-api-test.gaiamobile.org/js/nfctest.js
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
'use stricts';
|
||||
|
||||
var NfcTest = {
|
||||
get APItests() {
|
||||
delete this.APItests;
|
||||
return this.APItests = document.getElementById('API-tests');
|
||||
},
|
||||
get iframe() {
|
||||
delete this.iframe;
|
||||
return this.iframe = document.getElementById('test-iframe');
|
||||
},
|
||||
get backBtn() {
|
||||
delete this.backBtn;
|
||||
return this.backBtn = document.getElementById('test-panel-back');
|
||||
},
|
||||
get panelTitle() {
|
||||
delete this.panelTitle;
|
||||
return this.panelTitle = document.getElementById('test-panel-title');
|
||||
},
|
||||
get tabs() {
|
||||
delete this.tabs;
|
||||
return this.tabs = document.querySelectorAll('[role="tab"]');
|
||||
},
|
||||
get APITab() {
|
||||
delete this.APITab;
|
||||
return this.APITab = document.getElementById('API');
|
||||
},
|
||||
currentTab: 'API',
|
||||
handleNotificationMessage: function(message) {
|
||||
if (!message.clicked) {
|
||||
return;
|
||||
}
|
||||
|
||||
// handle notifications when this app is closed
|
||||
navigator.mozApps.getSelf().onsuccess = function gotSelf(evt) {
|
||||
var app = evt.target.result;
|
||||
|
||||
app.launch();
|
||||
};
|
||||
},
|
||||
init: function ut_init() {
|
||||
this.iframe.addEventListener('load', this);
|
||||
this.iframe.addEventListener('unload', this);
|
||||
document.body.addEventListener('transitionend', this);
|
||||
window.addEventListener('keyup', this);
|
||||
window.addEventListener('hashchange', this);
|
||||
this.backBtn.addEventListener('click', this);
|
||||
navigator.mozSetMessageHandler('notification', function(msg) {
|
||||
this.handleNotificationMessage(msg);
|
||||
}.bind(this));
|
||||
|
||||
var name = this.getNameFromHash();
|
||||
if (name) {
|
||||
this.openTest(name);
|
||||
}
|
||||
else {
|
||||
// if no test is specified, load UI tests list (select UI tab)
|
||||
window.location.hash = 'UI';
|
||||
}
|
||||
},
|
||||
uninit: function ut_uninit() {
|
||||
this.iframe.removeEventListener('load', this);
|
||||
this.iframe.removeEventListener('unload', this);
|
||||
document.body.removeEventListener('transitionend', this);
|
||||
window.removeEventListener('keyup', this);
|
||||
window.removeEventListener('hashchange', this);
|
||||
this.backBtn.removeEventListener('click', this);
|
||||
},
|
||||
getNameFromHash: function ut_getNameFromHash() {
|
||||
return (/\btest=(.+)(&|$)/.exec(window.location.hash) || [])[1];
|
||||
},
|
||||
handleEvent: function ut_handleEvent(ev) {
|
||||
switch (ev.type) {
|
||||
case 'click':
|
||||
if (ev.target != this.backBtn) {
|
||||
return;
|
||||
}
|
||||
if (window.location.hash) {
|
||||
window.location.hash = '';
|
||||
}
|
||||
break;
|
||||
case 'load':
|
||||
this.iframe.contentWindow.addEventListener('keyup', this);
|
||||
break;
|
||||
case 'unload':
|
||||
this.iframe.contentWindow.removeEventListener('keyup', this);
|
||||
break;
|
||||
case 'hashchange':
|
||||
if (window.location.hash == '#API')
|
||||
{
|
||||
this.APItests.classList.remove('invisible');
|
||||
AccessibilityHelper.setAriaSelected(this.APITab, this.tabs);
|
||||
if (!this.UItests.classList.contains('invisible'))
|
||||
this.UItests.classList.add('invisible');
|
||||
if (!this.HWtests.classList.contains('invisible'))
|
||||
this.HWtests.classList.add('invisible');
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = this.getNameFromHash();
|
||||
if (!name) {
|
||||
this.closeTest();
|
||||
return;
|
||||
}
|
||||
this.panelTitle.textContent = name;
|
||||
this.openTest(name);
|
||||
}
|
||||
break;
|
||||
case 'transitionend':
|
||||
var name = this.getNameFromHash();
|
||||
if (!name)
|
||||
this.iframe.src = 'about:blank';
|
||||
break;
|
||||
}
|
||||
},
|
||||
openTest: function ut_openTest(name) {
|
||||
// save tab name from URL
|
||||
// e.g. '#test=UI/empty' => 'UI'
|
||||
this.currentTab = (/=\b(.+)\//.exec(window.location.hash) || [])[1];
|
||||
document.body.classList.add('test');
|
||||
|
||||
var self = this;
|
||||
window.setTimeout(function openTestPage() {
|
||||
self.iframe.src = './tests_html/' + name + '.html';
|
||||
// we need to focus the iframe to let the key event send to it.
|
||||
self.iframe.focus();
|
||||
}, 200);
|
||||
},
|
||||
closeTest: function ut_closeTest() {
|
||||
var isOpened = document.body.classList.contains('test');
|
||||
if (!isOpened)
|
||||
return false;
|
||||
document.body.classList.remove('test');
|
||||
|
||||
// select tab after close test iframe
|
||||
window.location.hash = this.currentTab;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', NfcTest.init.bind(NfcTest));
|
||||
1
assets/webapps/nfc-api-test.gaiamobile.org/manifest.webapp
Executable file
1
assets/webapps/nfc-api-test.gaiamobile.org/manifest.webapp
Executable file
|
|
@ -0,0 +1 @@
|
|||
{"name":"NFC API tests","launch_path":"/index.html","type":"privileged","developer":{"name":"The TW QA Team","url":"https://github.com/Mozilla-TWQA","e-mail":"tw-qa@mozilla.com"},"messages":[{"notification":"/index.html"}],"icons":{"84":"/style/icons/default_84.png","126":"/style/icons/default_126.png","142":"/style/icons/default_142.png","189":"/style/icons/default_189.png","284":"/style/icons/default_284.png"},"permissions":{"nfc":{}},"origin":"app://nfc-api-test.gaiamobile.org","version":"2.5"}
|
||||
42
assets/webapps/nfc-api-test.gaiamobile.org/style/API.css
Normal file
42
assets/webapps/nfc-api-test.gaiamobile.org/style/API.css
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
select, [contenteditable] {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.center {
|
||||
display: block;
|
||||
margin: 0px auto;
|
||||
text-align: center
|
||||
}
|
||||
.inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
p.success {
|
||||
color: green;
|
||||
}
|
||||
p.error {
|
||||
color: red;
|
||||
}
|
||||
input {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
button, input[type='button'] {
|
||||
font-size: 2rem;
|
||||
}
|
||||
/* for mozId, smaller buttons */
|
||||
li > button, .small {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.tiny > button {
|
||||
font-size: 1rem;
|
||||
}
|
||||
.success {
|
||||
color: green;
|
||||
}
|
||||
.error {
|
||||
color: red;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
168
assets/webapps/nfc-api-test.gaiamobile.org/style/nfctest.css
Normal file
168
assets/webapps/nfc-api-test.gaiamobile.org/style/nfctest.css
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
html, body {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #000;
|
||||
|
||||
/* XXX: The below overflow property is being ignored by B2G Phone
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=777672
|
||||
*/
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.invisible {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.panel {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-moz-transition: -moz-transform 0.3s ease;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.test-panel {
|
||||
-moz-transform: translateX(100%);
|
||||
}
|
||||
|
||||
.list-panel{
|
||||
-moz-transform: translateX(0);
|
||||
}
|
||||
|
||||
body.test .list-panel{
|
||||
-moz-transform: translateX(-100%);
|
||||
}
|
||||
|
||||
body.test .test-panel {
|
||||
-moz-transform: translateX(0);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
-moz-box-sizing: border-box;
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
position: absolute;
|
||||
|
||||
height: 3rem;
|
||||
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-bottom: solid 3px #9b9b9b;
|
||||
background-color: #fff;
|
||||
background: url("images/app-texture.png") repeat scroll 50% 50%, -moz-linear-gradient(center top , rgb(244, 244, 244), rgb(234, 234, 234)) repeat scroll 0% 0% transparent;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.toolbar-title {
|
||||
font-size: 1.7rem;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
color: rgb(51, 51, 51);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.list {
|
||||
background: url("images/app-texture.png") repeat scroll 50% 50%, rgb(243, 243, 243);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
top: 3rem;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
overflow-y: auto;
|
||||
-moz-user-select: none;
|
||||
|
||||
border-bottom-left-radius: 8px;
|
||||
border-bottom-right-radius: 8px;
|
||||
}
|
||||
|
||||
.list > li {
|
||||
-moz-box-sizing: border-box;
|
||||
|
||||
padding: 0px 16px;
|
||||
border-top: 1px solid hsla(207,22%,92%,1);
|
||||
border-bottom: 1px solid hsla(223,7%,81%,1);
|
||||
|
||||
font-size: 1.7rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.list > li > a {
|
||||
outline: none;
|
||||
width: 100%; height: 100%;
|
||||
color: rgb(18, 47, 64);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.list > li:active {
|
||||
background: hsla(35,100%,50%,.2);
|
||||
}
|
||||
|
||||
#test-iframe {
|
||||
border: none;
|
||||
width: 100%;
|
||||
height: calc(100% - 3rem);
|
||||
top: 3rem;
|
||||
background-color: #fff;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#test-panel-back {
|
||||
font-size: 1.5rem;
|
||||
height: 2.5rem;
|
||||
}
|
||||
|
||||
|
||||
@media (orientation: landscape)
|
||||
{
|
||||
.list_and_toolbar {
|
||||
position: absolute;
|
||||
left: 0rem;
|
||||
right: 3rem; /* tabs are at right, keep some space for it */
|
||||
top: 0rem;
|
||||
bottom: 0rem;
|
||||
}
|
||||
|
||||
.list > li {
|
||||
height: calc(100% / 5);
|
||||
}
|
||||
}
|
||||
|
||||
@media (orientation: portrait)
|
||||
{
|
||||
.list_and_toolbar {
|
||||
position: absolute;
|
||||
left: 0rem;
|
||||
right: 0rem;
|
||||
top: 0rem;
|
||||
bottom: 0rem; /* tabs are at bottom, keep some space for it */
|
||||
}
|
||||
|
||||
.list > li {
|
||||
height: calc(100% / 7);
|
||||
}
|
||||
}
|
||||
78
assets/webapps/nfc-api-test.gaiamobile.org/style/tabs.css
Normal file
78
assets/webapps/nfc-api-test.gaiamobile.org/style/tabs.css
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/* ----------------------------------
|
||||
* Tabs
|
||||
* ---------------------------------- */
|
||||
|
||||
@media (orientation: landscape)
|
||||
{
|
||||
.bb-tablist {
|
||||
right: 0;
|
||||
width: 3rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.bb-tablist > li {
|
||||
width: 100%;
|
||||
height: calc(100% / 3);
|
||||
}
|
||||
}
|
||||
|
||||
@media (orientation: portrait)
|
||||
{
|
||||
.bb-tablist {
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 3rem;
|
||||
}
|
||||
|
||||
.bb-tablist > li {
|
||||
width: calc(100% / 3);
|
||||
height: 100%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.bb-tablist {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.bb-tablist > li {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.bb-tablist > li > a {
|
||||
font-size: 1.3rem;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
color: #FFF;
|
||||
float: left;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000 no-repeat center top;
|
||||
position: relative;
|
||||
color: #fff;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.bb-tablist > li > a:active {
|
||||
background-color: #00bbff;
|
||||
}
|
||||
|
||||
/* Selected state */
|
||||
.bb-tablist > li > a:target,
|
||||
.bb-tablist > li > a[aria-selected="true"] {
|
||||
color: #62c6f5
|
||||
}
|
||||
|
||||
.bb-tablist a:target ~.bb-tabpanel,
|
||||
.bb-tablist a[aria-selected="true"] ~.bb-tabpanel {
|
||||
z-index: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/ndef_helper.js"></script>
|
||||
<script defer src="../../js/nfc_dispatch.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC tag, the app will show 'Default Prevented' if the content
|
||||
of the tag starts with "https://www.mozilla.org", otherwise the tag will be
|
||||
re-dispatched to System app and this app will show
|
||||
'Default Action Executed'.
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<h4 id="global-message" class="error"></h4>
|
||||
|
||||
<div data-type="tag-container">
|
||||
<div><b>URI: </b><span data-type="tag-uri"/> </div>
|
||||
<div><span data-type="dispatch-result" style="font-weight:bold"></span> </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/nfc_format_tag.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC tag, then this app will try to format the tag as NDEF.
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<h4 id="global-message" class="error"></h4>
|
||||
|
||||
<div data-type="tag-container">
|
||||
<div><b>Formatable: </b><span data-type="formatable"/> </div>
|
||||
<div><span data-type="format-result" style="font-weight:bold"></span> </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/ndef_helper.js"></script>
|
||||
<script defer src="../../js/nfc_read_tag.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC tag, then this app will show the information of that tag, and
|
||||
display the NDEF Records contained within this tag. If the tag is not
|
||||
compliant with NFC Forum Tag, or is not formated as NDEF, some information
|
||||
will be null.
|
||||
</h5>
|
||||
</div>
|
||||
<div>
|
||||
<h2>NFC Tag Info</h2>
|
||||
</div>
|
||||
<h4 id="success-message" class="success"></h4>
|
||||
<h4 id="error-message" class="error"></h4>
|
||||
|
||||
<div id="tag-container">
|
||||
<ul>
|
||||
<li><b>Supported Technology List: </b><span data-type="tech-list"/> </li>
|
||||
<li><b>Tag ID: </b><span data-type="tag-id"/> </li>
|
||||
<li><b>Tag Type: </b><span data-type="tag-type"/> </li>
|
||||
<li><b>Max NDEF size: </b><span data-type="max-ndef-size"/> </li>
|
||||
<li><b>Read-Only: </b><span data-type="read-only"/> </li>
|
||||
<li><b>Formatable: </b><span data-type="formatable"/> </li>
|
||||
<li><b>Can be made Read-Only: </b><span data-type="can-be-made-read-only"/> </li>
|
||||
<li><b>is Lost: </b><span data-type="is-lost"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="ndef-msg-container">
|
||||
<ul>
|
||||
<li><b>Number of NDEF Records: </b><span data-type="record-count"/> </li>
|
||||
<div id="ndef-template">
|
||||
<ul>
|
||||
<li><b> tnf: </b> <span data-type="ndef-tnf"/> </li>
|
||||
<li><b> Type: </b> <span data-type="ndef-type"/> </li>
|
||||
<li><b> Id: </b> <span data-type="ndef-id"/> </li>
|
||||
<li><b> Payload: </b> <span data-type="ndef-payload"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/ndef_helper.js"></script>
|
||||
<script defer src="../../js/nfc_send_ndef.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<legend>URL to be written</legend>
|
||||
<section>
|
||||
<select id="urlOptions">
|
||||
<option value="https://www.mozilla.org">Mozilla</option>
|
||||
<option value="https://www.mozilla.org/en-US/firefox/os/">FirefoxOS</option>
|
||||
<option value="https://www.mozilla.org/en-US/firefox/">Firefox</option>
|
||||
<option value="https://www.yahoo.com/">Yahoo</option>
|
||||
</select>
|
||||
</section>
|
||||
</fieldset>
|
||||
|
||||
<div id="content">
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC device, then this app will try to send URL to that device.
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<h4 id="global-message" class="error"></h4>
|
||||
<div data-type="tag-container">
|
||||
<div><span data-type="send-result" style="font-weight:bold"></span> </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/ndef_helper.js"></script>
|
||||
<script defer src="../../js/nfc_tech.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC tag, then this app will send some raw command to that tag.
|
||||
</h5>
|
||||
</div>
|
||||
<div>
|
||||
<h2>NFC Tag Info</h2>
|
||||
</div>
|
||||
<h4 id="success-message" class="success"></h4>
|
||||
<h4 id="error-message" class="error"></h4>
|
||||
|
||||
<div id="tag-container">
|
||||
<ul>
|
||||
<li><b>Supported Technology List: </b><span data-type="tech-list"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="isoDep-container">
|
||||
<ul>
|
||||
<li><b>Hardware Vendor ID: </b><span data-type="hw-vendor-id"/> </li>
|
||||
<li><b>Hardware Type: </b><span data-type="hw-type"/> </li>
|
||||
<li><b>Hardware Version: </b><span data-type="hw-version"/> </li>
|
||||
<li><b>Hardware Storage Size: </b><span data-type="hw-storage"/> </li>
|
||||
<li><b>Hardware Protocol: </b><span data-type="hw-protocol"/> </li>
|
||||
<li><b>Software Vendor ID: </b><span data-type="sw-vendor-id"/> </li>
|
||||
<li><b>Software Type: </b><span data-type="sw-type"/> </li>
|
||||
<li><b>Software Version: </b><span data-type="sw-version"/> </li>
|
||||
<li><b>Software Storage Size: </b><span data-type="sw-storage"/> </li>
|
||||
<li><b>Software Protocol: </b><span data-type="sw-protocol"/> </li>
|
||||
<li><b>UID: </b><span data-type="uid"/> </li>
|
||||
<li><b>Batch Number: </b><span data-type="batch-num"/> </li>
|
||||
<li><b>Production Date: </b><span data-type="production-date"/> </li>
|
||||
<li><b>Key Settings: </b><span data-type="key-settings"/> </li>
|
||||
<li><b>Max number of keys: </b><span data-type="max-keys"/> </li>
|
||||
<li><b>Key Version: </b><span data-type="key-version"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="nfcA-container">
|
||||
<div id="type1-container">
|
||||
<ul>
|
||||
<li><b>Tag type: </b><span data-type="tag-type"/> </li>
|
||||
<li><b>HR0 </b><span data-type="hr0" /> </li>
|
||||
<li><b>HR1 </b><span data-type="hr1" /> </li>
|
||||
<li><b>UID0 </b><span data-type="uid0"/> </li>
|
||||
<li><b>UID1 </b><span data-type="uid1"/> </li>
|
||||
<li><b>UID2 </b><span data-type="uid2"/> </li>
|
||||
<li><b>UID3 </b><span data-type="uid3"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="type2-container">
|
||||
<ul>
|
||||
<li><b>Tag type: </b><span data-type="tag-type"/> </li>
|
||||
<li><b>Write to block 5 </b><span data-type="write"/> </li>
|
||||
<li><b>Read blocks 5~8 </b><span data-type="read"/> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<title>NFC test</title>
|
||||
<script defer src="../../js/ndef_helper.js"></script>
|
||||
<script defer src="../../js/nfc_write_tag.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/API.css">
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
<legend>URL to be written</legend>
|
||||
<section>
|
||||
<select id="urlOptions">
|
||||
<option value="https://www.mozilla.org">Mozilla</option>
|
||||
<option value="https://www.mozilla.org/en-US/firefox/os/">FirefoxOS</option>
|
||||
<option value="https://www.mozilla.org/en-US/firefox/">Firefox</option>
|
||||
<option value="https://www.yahoo.com/">Yahoo</option>
|
||||
</select>
|
||||
</section>
|
||||
</fieldset>
|
||||
|
||||
<div id="content">
|
||||
<div>
|
||||
<h2>Test Description</h2>
|
||||
<h5>
|
||||
Tap an NFC tag, then this app will try to write URL to that tag.
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<h4 id="global-message" class="error"></h4>
|
||||
<div data-type="tag-container">
|
||||
<div><span data-type="write-result" style="font-weight:bold"></span> </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue