2013-11-06 21:36:19 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* Part of this idl is from:
|
|
|
|
* http://w3c.github.io/nfc/proposals/common/nfc.html#nfctag-interface
|
|
|
|
*
|
|
|
|
* Copyright © 2013 Deutsche Telekom, Inc.
|
|
|
|
*/
|
|
|
|
|
2014-12-30 14:33:52 +03:00
|
|
|
/**
|
|
|
|
* The enumeration of NFC Tag technologies.
|
|
|
|
*/
|
2013-11-06 21:36:19 +04:00
|
|
|
enum NFCTechType {
|
2014-12-30 14:33:52 +03:00
|
|
|
"NFC-A", // NFCForum-TS-DigitalProtocol-1.1 NFC-A.
|
|
|
|
"NFC-B", // NFCForum-TS-DigitalProtocol-1.1 NFC-B.
|
|
|
|
"NFC-F", // NFCForum-TS-DigitalProtocol-1.1 NFC-F.
|
|
|
|
"NFC-V", // ISO 15693.
|
|
|
|
"ISO-DEP", // NFCForum-TS-DigitalProtocol-1.1 ISO-DEP.
|
|
|
|
"MIFARE-Classic", // MIFARE Classic from NXP.
|
|
|
|
"MIFARE-Ultralight", // MIFARE Ultralight from NXP.
|
2015-01-27 06:02:56 +03:00
|
|
|
"NFC-Barcode", // NFC Barcode from Kovio.
|
|
|
|
"Unknown"
|
2013-11-06 21:36:19 +04:00
|
|
|
};
|
|
|
|
|
2014-10-22 07:48:40 +04:00
|
|
|
/**
|
|
|
|
* The enumeration of the types of the tag, the type of a tag could be either
|
2014-12-30 14:33:52 +03:00
|
|
|
* one of those types defined in NFC Forum Tag Types (Type1 ~ Type 4), or it
|
|
|
|
* could be a NXP-specific tag, like MIFARE Classic.
|
2014-10-22 07:48:40 +04:00
|
|
|
*/
|
|
|
|
enum NFCTagType {
|
2014-12-30 14:33:52 +03:00
|
|
|
"Type1",
|
|
|
|
"Type2",
|
|
|
|
"Type3",
|
|
|
|
"Type4",
|
|
|
|
"MIFARE-Classic"
|
2014-10-22 07:48:40 +04:00
|
|
|
};
|
|
|
|
|
2015-01-13 09:50:24 +03:00
|
|
|
typedef MozIsoDepTech MozTagTech;
|
|
|
|
|
2014-12-26 15:57:11 +03:00
|
|
|
[JSImplementation="@mozilla.org/nfc/tag;1", AvailableIn="PrivilegedApps"]
|
2013-11-06 21:36:19 +04:00
|
|
|
interface MozNFCTag {
|
2014-10-22 07:48:40 +04:00
|
|
|
/**
|
|
|
|
* The supported technologies of this tag, null if unknown.
|
|
|
|
*/
|
|
|
|
[Cached, Pure] readonly attribute sequence<NFCTechType>? techList;
|
|
|
|
|
2014-12-26 11:07:45 +03:00
|
|
|
/**
|
|
|
|
* The identifier of this tag.
|
|
|
|
*/
|
2015-01-16 06:13:59 +03:00
|
|
|
[Constant] readonly attribute Uint8Array? id;
|
2014-12-26 11:07:45 +03:00
|
|
|
|
2014-10-22 07:48:40 +04:00
|
|
|
/**
|
|
|
|
* The type of this tag, null if unknown.
|
|
|
|
*/
|
|
|
|
readonly attribute NFCTagType? type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum size of the NDEF supported on this tag, null if unknown.
|
|
|
|
*/
|
|
|
|
readonly attribute long? maxNDEFSize;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate if this tag is Read-Only, null if unknown.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean? isReadOnly;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate if this tag is formatable, null if unknown.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean? isFormatable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate if this tag could be made Read-Only, null if unknown.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean? canBeMadeReadOnly;
|
|
|
|
|
2014-12-31 12:08:17 +03:00
|
|
|
/**
|
|
|
|
* Indicate if this tag is already lost.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean isLost;
|
|
|
|
|
2014-11-21 12:54:04 +03:00
|
|
|
/**
|
|
|
|
* Read current NDEF data on the tag.
|
|
|
|
*/
|
2014-10-29 06:15:11 +03:00
|
|
|
[Throws]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<sequence<MozNDEFRecord>> readNDEF();
|
2014-10-29 06:15:11 +03:00
|
|
|
|
2014-11-21 12:54:04 +03:00
|
|
|
/**
|
|
|
|
* Write NDEF data to the tag.
|
|
|
|
*/
|
2014-10-29 06:15:11 +03:00
|
|
|
[Throws]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> writeNDEF(sequence<MozNDEFRecord> records);
|
2014-10-29 06:15:11 +03:00
|
|
|
|
2014-11-21 12:54:04 +03:00
|
|
|
/**
|
|
|
|
* Make a tag read-only.
|
|
|
|
*/
|
2014-10-29 06:15:11 +03:00
|
|
|
[Throws]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> makeReadOnly();
|
2014-11-18 04:52:39 +03:00
|
|
|
|
2014-11-21 12:54:04 +03:00
|
|
|
/**
|
|
|
|
* Format a tag as NDEF.
|
|
|
|
*/
|
2014-11-18 04:52:39 +03:00
|
|
|
[Throws]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> format();
|
2015-01-13 09:50:24 +03:00
|
|
|
|
|
|
|
[NewObject, Throws]
|
|
|
|
MozTagTech selectTech(NFCTechType tech);
|
2013-11-06 21:36:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Mozilla Only
|
|
|
|
partial interface MozNFCTag {
|
|
|
|
[ChromeOnly]
|
|
|
|
attribute DOMString session;
|
2014-10-29 06:15:11 +03:00
|
|
|
|
2014-12-31 12:08:17 +03:00
|
|
|
[ChromeOnly]
|
|
|
|
void notifyLost();
|
2015-01-09 05:42:48 +03:00
|
|
|
|
|
|
|
[ChromeOnly, Throws]
|
|
|
|
Promise<Uint8Array> transceive(NFCTechType tech, Uint8Array command);
|
2013-11-06 21:36:19 +04:00
|
|
|
};
|