summaryrefslogtreecommitdiffstats
path: root/bin/4a-api
blob: 1e1bb3931273b6ec51f10bbf2e2ded67c11359b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash

# load shell lib
. $(dirname $BASH_SOURCE)/lib4a-tools.sh

cmd=$1
shift

function usage() {
	log "Usage: $0 <cmd> [opts]"
	log "Commands:"
	log "   help: show this help"
	log "   api <verb> [args]: send direct request to API verb with args"
	log "   roles: get AHL roles"
	log "   hals [-a|--all] [-v|--verbose]: get HALs status"
	log "   mediaplayer ... : interact with mediaplayer service"
	log "   radio ... : interact with radio service"
	exit 1
}

case $cmd in
	roles)
		4a-client ahl-4a get_roles ""
		;;
	api)
		4a-client "$@"
		;;
	hals)
		verbose=false
		all=false
		while [[ -n "$1" ]]; do
			case $1 in
				-a|--all) all=true;;
				-v|--verbose) verbose=true;;
				-av) all=true; verbose=true;;
			esac
			shift
		done
		4a-client 4a-hal-manager loaded "{'verbose':$verbose,'all':$all}"
		;;
	mediaplayer)
		echo "TODO"
		;;
	radio)
		echo "TODO"
		;;
	help|-h|--help)
		usage
		;;
	*)
		error "Invalid command"
		usage
		;;
esac

# commandes HAL manager:
# 4a-hal-manager loaded
# 4a-hal-manager loaded { "verbose": true } <= +metadata
# 4a-hal-manager loaded { "all": true } <= hals avec un json
# 4a-hal-manager loaded { "all": true, "verbose":true }

# open/close  multimedia
#afb-client-demo -H -d $WS4A << EOF
#multimedia { "action":"open" }
#multimedia { "action":"close" }
#EOF

# volume  multimedia
#afb-client-demo -H -d $WS4A << EOF
#multimedia { "action":"open" }
#multimedia { "action":"close" }
#EOF