#!/bin/sh

HELP="Usage: $0 <func> <param1> <param2> ..."

LONG_PLAY_AUDIO_TEST="long_play_audio_test"

show_log() {
	# 重定向到串口输出，不会被管道捕获
	echo "/speaker/play_audio_test] ^^^ $*" > /dev/console
}

script_operate() {
	local method=$1

	if [ "$method" = "$LONG_PLAY_AUDIO_TEST" ]; then
		if [ $# = 6 ]; then
			ubus call speaker long_play_audio_test "{\"test_enable\":$2,\"idle_second\":$3,\"test_times\":$4,\"id\":$5,\"volume\":$6}"
			return 1
		else
			echo "$6"
			echo "missing some paras"
			return 0
		fi
	fi

	return 1
}

script_operate $@
if [ $? -ne 1 ]; then
	show_log $HELP
	exit 1
fi
exit 0
