aboutsummaryrefslogtreecommitdiffstats
path: root/bin/lib4a-tools.sh
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@iot.bzh>2018-07-21 16:17:44 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2019-04-24 14:18:11 +0200
commite8b23b37394800332baf1ffc9b9777c67dc664cd (patch)
treec044db0ab9d1164c9f6c1ca4b2e3e28beeca3ca4 /bin/lib4a-tools.sh
parent28e86894895d16d1a707fd218990a0a58403bee8 (diff)
change media paths
Change-Id: I0d4783d37da25a315073eb847c7f525ed1b51d5c Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'bin/lib4a-tools.sh')
-rw-r--r--bin/lib4a-tools.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/lib4a-tools.sh b/bin/lib4a-tools.sh
new file mode 100644
index 0000000..4029046
--- /dev/null
+++ b/bin/lib4a-tools.sh
@@ -0,0 +1,35 @@
+stdout_in_terminal=0
+[[ -t 1 ]] && stdout_in_terminal=1
+function color {
+ [[ $stdout_in_terminal == 0 ]] && return
+ for k in $*; do
+ case $k in
+ bold) tput bold 2>/dev/null;;
+ none) tput sgr0 2>/dev/null;;
+ *) tput setaf $k 2>/dev/null;;
+ esac
+ done
+}
+color_green=$(color bold 2)
+color_yellow=$(color bold 3)
+color_red=$(color bold 1)
+color_blue=$(color bold 4)
+color_none=$(color none)
+
+function error() { echo "${color_red}$@${color_none}" >&2; }
+function warning() { echo "${color_yellow}$@${color_none}" >&2; }
+function info() { echo "${color_green}$@${color_none}" >&2; }
+function log() { echo "$@" >&2; }
+function debug() { [[ "$DEBUG" == 1 ]] && echo "${color_blue}DEBUG:" "$@" "${color_none}" >&2; }
+
+function 4a-client() {
+ # get port for audio service
+ local port=$(grep -sr X-AFM-http /var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service | cut -f2 -d'=')
+
+ debug "Detected 4A service on port $port"
+ afb-client-demo -H "localhost:$port/api?token=HELLO&uuid=magic" "$@"
+}
+
+function 4a-roles() {
+ 4a-client ahl-4a get_roles "" | tail -n +2 | jq '.response|.[]'
+}