#!/bin/sh

# Get firmware for Symbol Spectrum24 Trilogy.
# Both the header file and the binary firmware files are produced.

# Copyright (C) 2004 Pavel Roskin <proski@gnu.org>

# This script is Free Software, and it can be copied, distributed and
# modified as defined in the GNU General Public License.  A copy of
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html

# Usage: get_symbol_fw
# Output: spectrum_fw.h symbol_sp24t_prim_fw symbol_sp24t_sec_fw
# Needed tools: curl (or wget), unzip, perl.

set -e

URL_BASE=ftp://symstore.longisland.com/Symstore/exe/downloads/
DL_FILE=S24DRVR392B62_02.exe
DL_INT_PATH='Driver Only Installer/NetWLan5.sys'
DRIVER=symbol.drv

get_file() {
	curl --remote-name "$1" || \
	wget --passive-ftp "$1" || \
	wget "$1" || \
	ftp "$1" </dev/null || \
	exit 1
}

if ! test -f $DL_FILE; then
	get_file $URL_BASE/$DL_FILE
fi

unzip -p $DL_FILE "$DL_INT_PATH" >$DRIVER

perl parse_symbol_fw $DRIVER spectrum_fw.h symbol_sp24t_prim_fw \
	symbol_sp24t_sec_fw

rm -f $DRIVER
