Files
2026-08-03 11:47:09 -04:00

21 lines
1.0 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
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}}}' >/tmp/esp32_happy_clear.out 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":"😊","x":120,"y":105,"size":4}}}' 2>&1)
rc=$?
if [ $rc -eq 0 ] && ! echo "$out" | grep -qi 'error'; then
echo "Sent 😊 to $URL"
exit 0
fi
out=$(curl -fsS -m 5 -X POST "$URL" -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","id":"draw2","method":"tools/call","params":{"name":"draw_text","arguments":{"text":":)","x":130,"y":105,"size":4}}}' 2>&1)
rc=$?
if [ $rc -eq 0 ] && ! echo "$out" | grep -qi 'error'; then
echo "Sent :) fallback to $URL"
exit 0
fi
echo "Failed $URL: $out"
done
exit 1