#!/bin/sh # # peter lelie 11-Apr-2010 # # 23-Jun-2010 changed link to NOAA data source -pl # 28-Nov-2010 correction for minus temperatures -pl # 24-May-2015 changed link to weather data source -pl # # this script fetches the current Metar weather information for the airport # specified by LOC, converts it into 'readable' data and puts this weather # information into the AXIS camera display overlay text, using onboard # AXIS tools. # # please be aware that doing this will wear out the flash memory of the camera, # which can be typically written about 100k times, but, from my own experience, # probably more often. # # # LOC is the ICAO airport code (see http://www.airport-technology.com/icao-codes/) LOC=EDDL # # USR is the root user name of the device and PWD (you guessed it) is of course the root user's password USR=root PWD= # # PATH=/bin:/sbin:/usr/bin:/usr/sbin # # sleep some seconds to settle down the network initialization, if called upon system boot sleep 15 # /bin/shttpclient -o /var/tmp/$LOC "http://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=$LOC" # # use the following line if you want to get the original Metar code # Example: EDDL 111820Z 03010KT 9999 FEW022 08/02 Q1024 NOSIG #TEXT=$( cat /var/tmp/$LOC | grep \$LOC | sed 's/<.\?raw_text>//g' | sed 's/^ *//' | sed 's/ /%20/g' | tr -s 'M' '-' ) # # use the following line if you want to get the simplified version for 'normal' users # Example: 08°C Dew: 02°C 1024hPa TEXT=$( cat /var/tmp/$LOC | grep \$LOC | sed 's/.* \(M\{0,1\}[0-9]\{2\}\)\(\/\)\(M\{0,1\}[0-9]\{2\}\)\(.*\)Q\([0-9]\{3,4\}\)\(.*\)/\1%B0C%20Dew:%20\3%B0C%20\5hPa%20/' | tr -s 'M' '-' ) /bin/shttpclient -u root -w $PWD http://127.0.0.1/axis-cgi/admin/param.cgi?action=update\&root.Image.I0.Text.TextEnabled=yes echo $TEXT /bin/shttpclient -o /var/tmp/junk -u root -w $PWD http://127.0.0.1/axis-cgi/admin/param.cgi?action=update\&root.Image.I0.Text.String="$TEXT" # # now we're done.