-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script for run Nfc activity from Termux:API (#113)
- Loading branch information
1 parent
70bd13b
commit 34b8d6a
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |