Changed|Added(NfcAPI): Add all APIs for all NFC technologies #796
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add all APIs (78 in total) listed in the official doc for all NFC technologies (NfcA, NfcB, NfcF, NfcV, IsoDep, Ndef, MifareClassic, MifareUltralight, NfcBarcode, NdefFormatable).
The API call request in JSON format is passed into stdin of termux-api in the format of:
{"op": "discoverTag"}
{"op": "api", "class": "<CLASSNAME>", "method": "<METHODNAME>", "args": [<ARG1>, <ARG2>, ...]}
All APIs have a corresponding wrapper. The only exceptions are the static
get()
functions, which are combined into the correspondingconnect()
functions.A new activity with NFC figure will pop up during
{"op": "discoverTag"}
which indicates that it's scanning for a new tag. After successfully discovering a new tag, the activity goes to background.Command-line Examples
See termux/termux-api-package#214.
Breaking Changes
Ndef
The previously hard-coded custom commands (
-r
,-w
,-t
) for Ndef are replaced by raw API wrappers for getNdefMessage and writeNdefMessage.Stateful helper activity
To support stateful cards, NfcAPI now takes continuous input from stdin instead of one-time input as intent extras.
Future works
byte[]
orNdefMessage
etc can only be passed and returned in hex format. It might be helpful to support more formats like base64, ascii string, NdefRecord as json dictionary, etc.