17.01.2015 Views

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 14: Character data fi lter usage.<br />

Using the RSS/XML feed reader<br />

Using the RSS/XML feed reader fi rmware is easy:<br />

Figure 12: RSS/XML datafl ow diagram.<br />

The fi lter takes in an XML or RSS data stream and a list of tags.<br />

It outputs only the character data from the selected tags. The<br />

tag list is an array of pointers to those tag strings that need to<br />

be fi ltered.<br />

Normally the fi lter returns 0. When the fi lter processes the “>” in a<br />

tag in the list, it returns into the fi lter array the index+1 for the tag<br />

that it found. Example: after detecting a tag in an RSS or<br />

XML stream the fi lter will return 1. After detecting a <br />

tag in a stream the fi lter will return 2. The fi lter returns 0 if a tag is<br />

not found.<br />

Const unsigned char *tag_filter[] =<br />

{<br />

{(const unsigned char *)”title”},<br />

{(const unsigned char *)”description”},<br />

{(const unsigned char *)””}<br />

};<br />

Figure 13: Sample tag_fi lter pointer array.<br />

1. Set the variable url to the URL or to the desired RSS or XML server.<br />

static const unsigned char url[] =<br />

“http://www.weather.gov/data/current_<br />

obs/KUGN.rss”;<br />

2. Set the tag_fi lter[] to the type of data you want to display.<br />

For RSS feeds, and would be a fi rst choice.<br />

For XML feeds, this could be any tag name depending on the<br />

information.<br />

const unsigned char *tag_filter[] =<br />

{<br />

{(const unsigned char *)”title”},<br />

{(const unsigned char *)”description”},<br />

{(const unsigned char *)””}<br />

};<br />

3. Set the character buffer size large enough to collect your<br />

fi ltered data.<br />

#define RSS_CHARACTER_BUFF_SIZE2048<br />

4. Compile the project and fl ash it to the board.<br />

After the TCP/IP stack comes up, these actions occur:<br />

1. The DHCP client automatically acquires an IP address and DNS IP<br />

address.<br />

2. It displays and speaks a title screen.<br />

3. It connects to the server specifi ed in the URL.<br />

4. The status of the connection is displayed and spoken.<br />

5. The fi le is downloaded from the server using the HTTP client.<br />

6. After the connection closes, the fi le is displayed and spoken.<br />

7. The RSS/XML feed reader sleeps, waiting for either SW1 or SW2<br />

to be pushed. When that happens, a connection is initiated to<br />

the server specifi ed in the URL that starts the download/display/<br />

speak process all over again.<br />

34

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!