Add duty cycle enforcement option, update dashboard duplicate badge text, and implement API fetch with fallback to local presets

This commit is contained in:
Lloyd
2025-10-27 20:47:20 +00:00
parent 733bdc4847
commit 1065949fac
4 changed files with 22 additions and 7 deletions

View File

@@ -97,13 +97,25 @@ echo ""
echo "=== Step 2: Select Radio Settings ==="
echo ""
# Fetch config from API
# Fetch config from API with 5 second timeout, fallback to local file
echo "Fetching radio settings from API..."
API_RESPONSE=$(curl -s https://api.meshcore.nz/api/v1/config)
API_RESPONSE=$(curl -s --max-time 5 https://api.meshcore2.nz/api/v1/config 2>/dev/null)
if [ -z "$API_RESPONSE" ]; then
echo "Error: Failed to fetch configuration from API"
exit 1
echo "Warning: Failed to fetch configuration from API (timeout or error)"
echo "Using local radio presets file..."
LOCAL_PRESETS="$SCRIPT_DIR/radio-presets.json"
if [ ! -f "$LOCAL_PRESETS" ]; then
echo "Error: Local radio presets file not found at $LOCAL_PRESETS"
exit 1
fi
API_RESPONSE=$(cat "$LOCAL_PRESETS")
if [ -z "$API_RESPONSE" ]; then
echo "Error: Failed to read local radio presets file"
exit 1
fi
fi
# Parse JSON entries - one per line, extracting each field