Moved --data flag into curl function.
This commit is contained in:
parent
c66362f87d
commit
471e5dae50
1 changed files with 6 additions and 6 deletions
12
wled
12
wled
|
@ -33,13 +33,13 @@ commands:
|
||||||
|
|
||||||
curl_fetch() {
|
curl_fetch() {
|
||||||
curl --silent --show-error --fail --ipv4 --max-filesize 32768 \
|
curl --silent --show-error --fail --ipv4 --max-filesize 32768 \
|
||||||
--max-redirs 0 --header 'Accept: application/json' "$@"
|
--max-redirs 0 --header 'Accept: application/json' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_send() {
|
curl_send() {
|
||||||
curl --silent --show-error --fail --ipv4 --max-filesize 1024 \
|
curl --silent --show-error --fail --ipv4 --max-filesize 1024 \
|
||||||
--max-redirs 0 --header 'Accept: application/json' \
|
--max-redirs 0 --header 'Accept: application/json' \
|
||||||
--header 'Content-Type: application/json' "$@"
|
--header 'Content-Type: application/json' --data "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
active_preset() {
|
active_preset() {
|
||||||
|
@ -76,10 +76,10 @@ esac
|
||||||
# Parse and execute command argument.
|
# Parse and execute command argument.
|
||||||
case "$2" in
|
case "$2" in
|
||||||
on) # Switch on.
|
on) # Switch on.
|
||||||
api_resp=$(curl_send --data '{"on":true}' "http://$wled_host/json")
|
api_resp=$(curl_send '{"on":true}' "http://$wled_host/json")
|
||||||
;;
|
;;
|
||||||
off) # Switch off.
|
off) # Switch off.
|
||||||
api_resp=$(curl_send --data '{"on":false}' "http://$wled_host/json")
|
api_resp=$(curl_send '{"on":false}' "http://$wled_host/json")
|
||||||
;;
|
;;
|
||||||
-b|--brightness) # Set brightness.
|
-b|--brightness) # Set brightness.
|
||||||
if test -z "$3"; then
|
if test -z "$3"; then
|
||||||
|
@ -95,10 +95,10 @@ case "$2" in
|
||||||
echo "Error: parameter for brightness is out of range." >&2
|
echo "Error: parameter for brightness is out of range." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
api_resp=$(curl_send --data "{'bri':$bright}" "http://$wled_host/json")
|
api_resp=$(curl_send "{'bri':$bright}" "http://$wled_host/json")
|
||||||
;;
|
;;
|
||||||
[1-9]|1[0-7]) # Switch to preset.
|
[1-9]|1[0-7]) # Switch to preset.
|
||||||
api_resp=$(curl_send --data "{'ps':$2}" "http://$wled_host/json")
|
api_resp=$(curl_send "{'ps':$2}" "http://$wled_host/json")
|
||||||
;;
|
;;
|
||||||
l|list) # List presets.
|
l|list) # List presets.
|
||||||
printf "loading ...\r"
|
printf "loading ...\r"
|
||||||
|
|
Loading…
Reference in a new issue