36 lines
1.8 KiB
Bash
36 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -u
|
|
URLS=("http://192.168.68.123/api/mcp" "http://192.168.68.137/api/mcp")
|
|
for URL in "${URLS[@]}"; do
|
|
echo "Trying $URL"
|
|
# First test audio path with a tone if available.
|
|
for tone_args in '{"frequency":660,"duration_ms":180,"volume":80}' '{"freq":660,"duration":180,"volume":80}'; do
|
|
out=$(curl -fsS -m 5 -X POST "$URL" -H 'Content-Type: application/json' --data "{\"jsonrpc\":\"2.0\",\"id\":\"tone\",\"method\":\"tools/call\",\"params\":{\"name\":\"play_tone\",\"arguments\":$tone_args}}" 2>&1)
|
|
rc=$?
|
|
if [ $rc -eq 0 ] && ! echo "$out" | grep -qi 'error'; then
|
|
echo "Tone OK on $URL"
|
|
break
|
|
fi
|
|
done
|
|
# Try direct text/speak-style MCP tools if firmware exposes them.
|
|
for name in speak text_to_speech say play_text; do
|
|
payload=$(printf '{"jsonrpc":"2.0","id":"say-hi","method":"tools/call","params":{"name":"%s","arguments":{"text":"hi","message":"hi","volume":80}}}' "$name")
|
|
out=$(curl -fsS -m 8 -X POST "$URL" -H 'Content-Type: application/json' --data "$payload" 2>&1)
|
|
rc=$?
|
|
if [ $rc -eq 0 ] && ! echo "$out" | grep -qi 'error'; then
|
|
echo "Said hi on $URL using MCP tool $name"
|
|
exit 0
|
|
fi
|
|
done
|
|
# Visual fallback still uses MCP tools to confirm the device path.
|
|
curl -fsS -m 5 -X POST "$URL" -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","id":"clear","method":"tools/call","params":{"name":"clear_screen","arguments":{"color":0}}}' >/dev/null 2>&1 || true
|
|
out=$(curl -fsS -m 5 -X POST "$URL" -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","id":"draw","method":"tools/call","params":{"name":"draw_text","arguments":{"text":"hi","x":130,"y":105,"size":4}}}' 2>&1)
|
|
rc=$?
|
|
if [ $rc -eq 0 ] && ! echo "$out" | grep -qi 'error'; then
|
|
echo "Displayed hi on $URL using MCP draw_text"
|
|
exit 0
|
|
fi
|
|
echo "Failed $URL: $out"
|
|
done
|
|
exit 1
|