NetBurner Weather Demo Example Program

Overview

This example program gathers weather data from the government NOAA web site and displays the
information as line plots, images, and text.

Specifically, it demonstrates how to:

  1. Dynamically create line plots and display them as gif images on a web page
  2. Dynamically display various real-time weather data on a web page
  3. Connect to Internet web servers and gather data
  4. Use DNS
  5. Run multiple tasks

 

Hardware and Connections

The program will run on a NetBurner CFV2-40 or CFV2-66 with an Internet connection. This demo is running
on a CFV2-40. The program can be run on a SB72 if the animated gif satellite image removed to reduce code
size. The board will need some way to connect to the Internet, either directly or through a gateway if you are
on a LAN.

 

 

Status information on what the program is doing will be sent out the RS-232 debug port if you wish to monitor
program execution.

 

Configuration Settings

Use IPSetup to configure the IP Address and mask (unless you are using DHCP), the Gateway IP address, and the DNS IP address.

 

Program Details

The program consists of a number of individual code modules. The file extensions are .cpp, but knowledge of
C++ is not required (only an intelligent subset of C++ is used in the source code). Four of the code modules
listed comprise the application code you would have to write to implement this demo: main.cpp, getdata.cpp,
plot.cpp, and processHTTP.cpp. You can view the source code by clicking on the file name.

main.cpp

Initializes network functions, calls routine to initialize task to gather data, and displays count on LEDs

getdata.cpp

Gathers data from NOAA web site

plot.cpp

Creates line plot of weather history and formats it as a gif image

processHTTP.cpp

Handles incoming HTTP requests from client web browsers

drawimage.cpp

Library code module used in creating gif images

htmldata.cpp

Automatically generated by NetBurner tools; do not modify

fontdata.c

Fonts used for images

 

Program Flowcharts

UserMain

The UserMain task gets called on startup, and is located in main.cpp. It initializes the network stack, call the
function to initialize the GetData task, then loops forever. After initialization, the UserMain task has nothing to
do; all the action takes place when a client requests a web page from the web server.

Code to display a binary count on the LEDs was added to indicate when the main task is running.

 

 

 

 

GetDataTask

The GetDataTask is located in getdata.cpp. The task is responsible for making a connection to the NOAA
web site, obtaining the weather data, and parsing the weather data.

 

 

 

 Processing HTTP Requests

Responding to an HTTP requests involves a number of code modules. Code for this example application is
located in processHTTP.cpp and plot.cpp.

When a request comes in from a web browser, the functions in these code modules dynamically create and
format the weather information to send to the web browser.

The format of the web page is defined in index.htm, which is located in the html subdirectory of the project.
The index.htm file contains FUNCTIONCALL tags that call the functions defined in processHTTP.cpp.