From fda7357d16b6d799f3e33688c4c4e15ad6d3fd8c Mon Sep 17 00:00:00 2001 From: Svyatoslav2 <20020511@bk.ru> Date: Wed, 11 Nov 2020 20:38:40 +0300 Subject: [PATCH 1/3] Create termux-nfc --- scripts/termux-nfc | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/termux-nfc diff --git a/scripts/termux-nfc b/scripts/termux-nfc new file mode 100644 index 0000000..1bf0986 --- /dev/null +++ b/scripts/termux-nfc @@ -0,0 +1,47 @@ +#!@TERMUX_PREFIX@/bin/bash + +set -e -u + +show_usage() { + echo "Usage: termux-nfc [-r [short|full]] [-w] [-t [text for TAG] " + echo " read/write data from/to NDEF tag " + echo " -r, read tag " + echo " short, read short information from tag " + echo " full, read full information from tag " + echo " -w, write information on tag " + echo " -t, text for tag" + exit 0 +} + +ARG_R="" +OPT_R="" +ARG_W="" +OPT_T="" +ARG_T="" + +PARAM="" + +if [ $# -eq 0 ];then show_usage;fi + +while getopts ":r:t:w" opt +do + case "$opt" in + r) ARG_R="--es mode read"; OPT_R="--es param $OPTARG"; ;; + w) ARG_W="--es mode write";; + t) ARG_T="--es param text --es value"; OPT_T="$OPTARG"; ;; + ?) echo "Error: unknown parameters: $opt $OPTARG;";show_usage; ;; + esac +done + + +shift $((OPTIND-1)) + +if [ "$#" != 0 ]; then echo "Error: too many parameters!"; show_usage;fi +if [ -n "$ARG_R" ]; then if [ -n "$ARG_W" ]; then echo "Error: Incompatible parameters! \"-r and \"-n";show_usage;fi;fi + + + +if [ -n "$ARG_R" ]; then set -- "$@" $ARG_R $OPT_R;fi +if [ -n "$ARG_W" ]; then set -- "$@" $ARG_W;fi +if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T";fi +@TERMUX_PREFIX@/libexec/termux-api nfc "$@" \ No newline at end of file From 25bfd776248b875ce6393ad93f2a53230680f2b6 Mon Sep 17 00:00:00 2001 From: Svyatoslav2 <20020511@bk.ru> Date: Wed, 11 Nov 2020 20:51:20 +0300 Subject: [PATCH 2/3] Update termux-nfc --- scripts/termux-nfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/termux-nfc b/scripts/termux-nfc index 1bf0986..f8f7af6 100644 --- a/scripts/termux-nfc +++ b/scripts/termux-nfc @@ -44,4 +44,4 @@ if [ -n "$ARG_R" ]; then if [ -n "$ARG_W" ]; then echo "Error: Incompatible para if [ -n "$ARG_R" ]; then set -- "$@" $ARG_R $OPT_R;fi if [ -n "$ARG_W" ]; then set -- "$@" $ARG_W;fi if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T";fi -@TERMUX_PREFIX@/libexec/termux-api nfc "$@" \ No newline at end of file +@TERMUX_PREFIX@/libexec/termux-api Nfc "$@" \ No newline at end of file From 1b325f65e02c7cfb2475c84d7208601662f3861f Mon Sep 17 00:00:00 2001 From: Svyatoslav2 <20020511@bk.ru> Date: Wed, 11 Nov 2020 21:11:11 +0300 Subject: [PATCH 3/3] script for run Nfc application from Termux:API --- scripts/termux-nfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/termux-nfc b/scripts/termux-nfc index f8f7af6..b1b26c1 100644 --- a/scripts/termux-nfc +++ b/scripts/termux-nfc @@ -44,4 +44,4 @@ if [ -n "$ARG_R" ]; then if [ -n "$ARG_W" ]; then echo "Error: Incompatible para if [ -n "$ARG_R" ]; then set -- "$@" $ARG_R $OPT_R;fi if [ -n "$ARG_W" ]; then set -- "$@" $ARG_W;fi if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T";fi -@TERMUX_PREFIX@/libexec/termux-api Nfc "$@" \ No newline at end of file +@TERMUX_PREFIX@/libexec/termux-api Nfc "$@"