#!/bin/sh

# Script to get AP (tertiary) firmware for Prism 2 and Prism 2.5
# See http://www.teletronics.com/Firmware.html for latest versions and
# release notes.

set -e

# Complete list
files="fw_ap293.zip fw_ap294.zip fw_ap295.zip fw_ap298.zip fw_apv293.zip
       fw_apv294.zip fw_apv295.zip fw_apv298.zip fw_ap405.zip fw_ap413.zip"

# Only latest and greatest - 1.4.0 for Prism 2 and 2.0.4 for Prism 2.5
files="fw_ap295.zip fw_apv298.zip"

site="http://www.teletronics.com/"
unzip=unzip
wget=wget
parse=./parse_prism_ap_fw

for file in $files; do
	test -r $file || $wget $site$file
	test -r $file || continue
	echo "processing $file"
	$unzip -p $file '*.img' >ap.img
	$parse ap.img
	rm -f ap.img
done
