Skip to content

Commit

Permalink
Script for run Nfc activity from Termux:API (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Svyatoslav2 authored Dec 6, 2020
1 parent 70bd13b commit 34b8d6a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions scripts/termux-nfc
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 "$@"

0 comments on commit 34b8d6a

Please sign in to comment.