diff -Naur open2300-1.10/linux2300.c open2300-1.10.patched.rapidfire/linux2300.c --- open2300-1.10/linux2300.c 2006-04-30 20:43:37.000000000 +0100 +++ open2300-1.10.patched.rapidfire/linux2300.c 2007-01-10 16:59:25.000000000 +0000 @@ -241,19 +241,26 @@ * Action: Send a http request to Weather Underground * ********************************************************************/ -int http_request_url(char *urlline) +int http_request_url(char *urlline, int *rapidfire) { int sockfd; struct hostent *hostinfo; struct sockaddr_in urladdress; char buffer[1024]; int bytes_read; - - if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL)) == NULL ) - { - perror("Host not known by DNS server or DNS server not working"); - return(-1); - } + if (rapidfire == 1) { + if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL_RAPIDFIRE)) == NULL ) + { + perror("Host not known (rapid fire) by DNS server or DNS server not working"); + return(-1); + }; + } else { + if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL)) == NULL ) + { + perror("Host not known by DNS server or DNS server not working"); + return(-1); + }; + }; if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { @@ -273,7 +280,7 @@ return(-1); } // sprintf(buffer, "GET %s\nHTTP/1.0\n\n", urlline); - sprintf(buffer, "GET %s HTTP/1.0\r\nUser-Agent: open2300/1.10-2\r\nAccept: */*\r\nHost: weatherstation.wunderground.com\r\nConnection: Keep-Alive\r\n\r\n", urlline); + sprintf(buffer, "GET %s HTTP/1.0\r\nUser-Agent: open2300/1.10-2\r\nAccept: */*\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n", urlline, WEATHER_UNDERGROUND_BASEURL); send(sockfd, buffer, strlen(buffer), 0); /* While there's data, read and print it */ diff -Naur open2300-1.10/Makefile open2300-1.10.patched.rapidfire/Makefile --- open2300-1.10/Makefile 2006-06-19 12:03:01.000000000 +0100 +++ open2300-1.10.patched.rapidfire/Makefile 2007-01-10 21:44:35.000000000 +0000 @@ -23,6 +23,7 @@ LOGOBJ = log2300.o rw2300.o linux2300.o win2300.o FETCHOBJ = fetch2300.o rw2300.o linux2300.o win2300.o WUOBJ = wu2300.o rw2300.o linux2300.o win2300.o +WUROBJ = wu2300_RapidFire.o rw2300.o linux2300.o win2300.o CWOBJ = cw2300.o rw2300.o linux2300.o win2300.o DUMPOBJ = dump2300.o rw2300.o linux2300.o win2300.o HISTOBJ = history2300.o rw2300.o linux2300.o win2300.o @@ -46,7 +47,7 @@ ####### Build rules -all: open2300 dump2300 log2300 fetch2300 wu2300 cw2300 history2300 histlog2300 bin2300 xml2300 light2300 interval2300 minmax2300 +all: open2300 dump2300 log2300 fetch2300 wu2300 wu2300_RapidFire cw2300 history2300 histlog2300 bin2300 xml2300 light2300 interval2300 minmax2300 open2300 : $(OBJ) $(CC) $(CFLAGS) -o $@ $(OBJ) $(CC_LDFLAGS) @@ -62,6 +63,9 @@ wu2300 : $(WUOBJ) $(CC) $(CFLAGS) -o $@ $(WUOBJ) $(CC_LDFLAGS) $(CC_WINFLAG) + +wu2300_RapidFire : $(WUROBJ) + $(CC) $(CFLAGS) -o $@ $(WUROBJ) $(CC_LDFLAGS) $(CC_WINFLAG) cw2300 : $(CWOBJ) $(CC) $(CFLAGS) -o $@ $(CWOBJ) $(CC_LDFLAGS) $(CC_WINFLAG) @@ -100,6 +104,7 @@ $(INSTALL) log2300 $(bindir) $(INSTALL) fetch2300 $(bindir) $(INSTALL) wu2300 $(bindir) + $(INSTALL) wu2300_RapidFire $(bindir) $(INSTALL) cw2300 $(bindir) $(INSTALL) histlog2300 $(bindir) $(INSTALL) xml2300 $(bindir) @@ -108,10 +113,10 @@ $(INSTALL) minmax2300 $(bindir) uninstall: - rm -f $(bindir)/open2300 $(bindir)/dump2300 $(bindir)/log2300 $(bindir)/fetch2300 $(bindir)/wu2300 $(bindir)/cw2300 $(bindir)/xml2300 $(bindir)/light2300 $(bindir)/interval2300 $(bindir)/minmax2300 + rm -f $(bindir)/open2300 $(bindir)/dump2300 $(bindir)/log2300 $(bindir)/fetch2300 $(bindir)/wu2300 $(bindir)/wu2300_RapidFire $(bindir)/cw2300 $(bindir)/xml2300 $(bindir)/light2300 $(bindir)/interval2300 $(bindir)/minmax2300 clean: - rm -f *~ *.o open2300 dump2300 log2300 fetch2300 wu2300 cw2300 history2300 histlog2300 bin2300 xml2300 mysql2300 pgsql2300 light2300 interval2300 minmax2300 + rm -f *~ *.o open2300 dump2300 log2300 fetch2300 wu2300 wu2300_RapidFire cw2300 history2300 histlog2300 bin2300 xml2300 mysql2300 pgsql2300 light2300 interval2300 minmax2300 cleanexe: - rm -f *~ *.o open2300.exe dump2300.exe log2300.exe fetch2300.exe wu2300.exe cw2300.exe history2300.exe histlog2300.exe bin2300.exe xml2300.exe mysql2300.exe pgsql2300.exe light2300.exe interval2300.exe minmax2300.exe + rm -f *~ *.o open2300.exe dump2300.exe log2300.exe fetch2300.exe wu2300.exe wu2300_RapidFire.exe cw2300.exe history2300.exe histlog2300.exe bin2300.exe xml2300.exe mysql2300.exe pgsql2300.exe light2300.exe interval2300.exe minmax2300.exe diff -Naur open2300-1.10/rw2300.h open2300-1.10.patched.rapidfire/rw2300.h --- open2300-1.10/rw2300.h 2005-03-05 08:29:13.000000000 +0000 +++ open2300-1.10.patched.rapidfire/rw2300.h 2007-01-10 16:59:15.000000000 +0000 @@ -51,6 +51,8 @@ /* ONLY EDIT THESE IF WEATHER UNDERGROUND CHANGES URL */ #define WEATHER_UNDERGROUND_BASEURL "weatherstation.wunderground.com" #define WEATHER_UNDERGROUND_PATH "/weatherstation/updateweatherstation.php" +#define WEATHER_UNDERGROUND_BASEURL_RAPIDFIRE "rtupdate.wunderground.com" +#define WEATHER_UNDERGROUND_PATH_RAPIDFIRE "/weatherstation/updateweatherstation.php" #define WEATHER_UNDERGROUND_SOFTWARETYPE "open2300%20v" @@ -305,7 +307,7 @@ int write_device(WEATHERSTATION serdevice, unsigned char *buffer, int size); void sleep_short(int milliseconds); void sleep_long(int seconds); -int http_request_url(char *urlline); +int http_request_url(char *urlline, int *rapidfire); int citizen_weather_send(struct config_type *config, char *datastring); #endif /* _INCLUDE_RW2300_H_ */ diff -Naur open2300-1.10/win2300.c open2300-1.10.patched.rapidfire/win2300.c --- open2300-1.10/win2300.c 2005-03-05 08:28:22.000000000 +0000 +++ open2300-1.10.patched.rapidfire/win2300.c 2007-01-10 21:48:58.000000000 +0000 @@ -237,7 +237,7 @@ * Action: Send a http request to Weather Underground * ********************************************************************/ -int http_request_url(char *urlline) +int http_request_url(char *urlline, int *rapidfire) { WORD wVersionRequested; WSADATA wsaData; @@ -267,12 +267,20 @@ return(-1); } - if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL)) == NULL ) - { - perror("Host not known by DNS server or DNS server not working"); - return(-1); - } - + if (rapidfire == 1) { + if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL_RAPIDFIRE)) == NULL ) + { + perror("Host not known (rapid fire) by DNS server or DNS server not working"); + return(-1); + } + } else { + if ( (hostinfo = gethostbyname(WEATHER_UNDERGROUND_BASEURL)) == NULL ) + { + perror("Host not known by DNS server or DNS server not working"); + return(-1); + } + }; + sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd == INVALID_SOCKET) diff -Naur open2300-1.10/wu2300.c open2300-1.10.patched.rapidfire/wu2300.c --- open2300-1.10/wu2300.c 2006-04-30 20:44:09.000000000 +0100 +++ open2300-1.10.patched.rapidfire/wu2300.c 2007-01-10 21:49:36.000000000 +0000 @@ -38,9 +38,6 @@ /* START WITH URL, ID AND PASSWORD */ - //sprintf(urlline, "http://%s%s?ID=%s&PASSWORD=%s", - // WEATHER_UNDERGROUND_BASEURL,WEATHER_UNDERGROUND_PATH, - // config.weather_underground_id,config.weather_underground_password); sprintf(urlline, "%s?ID=%s&PASSWORD=%s", WEATHER_UNDERGROUND_PATH, config.weather_underground_id,config.weather_underground_password); @@ -115,7 +112,7 @@ } else { - http_request_url(urlline); + http_request_url(urlline, 0); } return(0); diff -Naur open2300-1.10/wu2300_RapidFire.c open2300-1.10.patched.rapidfire/wu2300_RapidFire.c --- open2300-1.10/wu2300_RapidFire.c 1970-01-01 01:00:00.000000000 +0100 +++ open2300-1.10.patched.rapidfire/wu2300_RapidFire.c 2007-01-10 21:46:10.000000000 +0000 @@ -0,0 +1,125 @@ +/* open2300 - wu2300_RapidFire.c + * + * Version 1.10 + * + * Control WS2300 weather station + * + * Copyright 2004-2005, Kenneth Lavrsen + * This program is published under the GNU General Public license + */ + +#define DEBUG 0 // wu2300 stops writing to standard out if setting this to 0 + +#include "rw2300.h" + +/********** MAIN PROGRAM ************************************************ + * + * This program reads all current weather data from a WS2300 + * and sends it to Weather Underground. + * + * It takes one parameter which is the config file name with path + * If this parameter is omitted the program will look at the default paths + * See the open2300.conf-dist file for info + * + ***********************************************************************/ +int main(int argc, char *argv[]) +{ + WEATHERSTATION ws2300; + struct config_type config; + unsigned char urlline[3000] = ""; + char datestring[50]; //used to hold the date stamp for the log file + double tempfloat; + time_t basictime; + int runforever; + + get_configuration(&config, argv[1]); + + runforever = 1; + + while (runforever == 1) { + + ws2300 = open_weatherstation(config.serial_device_name); + + /* START WITH URL, ID AND PASSWORD */ + + sprintf(urlline, "%s?realtime=1&rtfreq=3&ID=%s&PASSWORD=%s", + WEATHER_UNDERGROUND_PATH, + config.weather_underground_id,config.weather_underground_password); + + + /* GET DATE AND TIME FOR URL */ + time(&basictime); + basictime = basictime - atof(config.timezone) * 60 * 60; + strftime(datestring,sizeof(datestring),"&dateutc=%Y-%m-%d+%H%%3A%M%%3A%S", + localtime(&basictime)); + sprintf(urlline, "%s%s", urlline, datestring); + + + /* READ TEMPERATURE OUTDOOR - deg F for Weather Underground */ + + sprintf(urlline, "%s&tempf=%.2f", urlline, + temperature_outdoor(ws2300, FAHRENHEIT) ); + + + /* READ DEWPOINT - deg F for Weather Underground*/ + + sprintf(urlline, "%s&dewptf=%.2f", urlline, dewpoint(ws2300, FAHRENHEIT) ); + + + /* READ RELATIVE HUMIDITY OUTDOOR */ + + sprintf(urlline, "%s&humidity=%d", urlline, humidity_outdoor(ws2300) ); + + + /* READ WIND SPEED AND DIRECTION - miles/hour for Weather Underground */ + + if (wind_current(ws2300, MILES_PER_HOUR, &tempfloat) > 100) + { + printf("wu2300 ERROR : Wind speed above 100 mph\n"); + exit(1); + }; + + sprintf(urlline,"%s&windspeedmph=%.2f", urlline, + wind_current(ws2300, MILES_PER_HOUR, &tempfloat) ); + sprintf(urlline,"%s&winddir=%.1f", urlline, tempfloat); + + + /* READ RAIN 1H - inches for Weather Underground */ + + sprintf(urlline,"%s&rainin=%.2f", urlline, rain_1h(ws2300, INCHES) ); + + + /* READ RAIN 24H - inches for Weather Underground */ + + sprintf(urlline,"%s&dailyrainin=%.2f", urlline, rain_24h(ws2300, INCHES) ); + + + /* READ RELATIVE PRESSURE - Inches of Hg for Weather Underground */ + + sprintf(urlline,"%s&baromin=%.3f",urlline, + rel_pressure(ws2300, INCHES_HG) ); + + + /* ADD SOFTWARE TYPE AND ACTION */ + sprintf(urlline,"%s&softwaretype=%s%s&action=updateraw",urlline, + WEATHER_UNDERGROUND_SOFTWARETYPE,VERSION); + + + if (DEBUG) + { + printf("%s\n",urlline); + } + else + { + http_request_url(urlline, 1); + } + + + close_weatherstation(ws2300); + + /* Loop should end here */ + }; + + return(0); +} +