Navigation bar
  Start Previous page  24 of 35  Next page End Home  14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  

Embedded Web Server for the CR16
National Semiconductor
Jeff Wright
24
to adopt a monolithic style.  Both are supported in this server.  Moreover, Web pages may
include provision for dynamic data – i.e. data returned by one of the user-specific tasks may be
inserted into the page by the server prior to transmission.  To support this feature, all
embedded pages follow a defined format, and predefined constructs are utilized to organize
and manage the transmission of each page.  
Formatting your own embedded html page proceeds as follows:
1.
Web pages may comprise one or more discrete sections, each of which will assume the form
of a array of characters.  Sections should be given a common logical name, similar to that of
Figure 17.
2.
Begin the page with 2 (two) CR/LF (\r\n) sequences.  (The user-defined portion is the HTTP
“entity body”.  The body follows the HTTP header, and must be delimited by 2 carriage
return/line feed sequences.)
3.
You may optionally begin each line with a CR/LF sequence (\r\n) to make the browser’s
“source view” easier to read (these may be omitted to save space).
4.
Escape any “C” specific characters (such as quotes or percentage signs).  For example, any
quotation marks within your html code must be replaced with \”. 
5.
Delimit each line with quotes to form one string literal. 
6.
Terminate each array (one or more) with a semicolon as per “C” coding requirements.
As a simple example, consider the following html listing using the above approach.  Figure 21
shows just how Internet Explorer renders this very short section of embedded html code.  
const   UBYTE   err504_htm[]  =
"\r\n\r\n<HTML><HEAD>"
"\r\n<TITLE>HTTP 504</TITLE>"
"\r\n</HEAD>";
const   UBYTE   err504_htm2[]  =
"<BODY><H1>HTTP Error 504 - Remote Node Error</H1>"
"\r\nNode ";
const   UBYTE   err504_htm3[]  =
" responded with error: ";
const   UBYTE   err504_htm4[]  =
"\r\n<P><HR><ADDRESS>Jeffs/1.3.9 Server at www.cr16.com "
"\r\n Port 80</ADDRESS>"
"\r\n<p><a href=\"index.htm\">HomePage</a>"
"\r\n</BODY></HTML>";
Figure 17.  Simple embedded page.
7.
Once your page is written, you now insert pointers to the page’s addresse(s) and other
pertinent parameters into a control structure as defined in Figure 18.  (See Figure 19 for
this page’s data structure.)
8.
Finally, you must give your page an Identifier and insert it into the list of pages as shown in
Figure 20.  This is simply the name you wish to use for the object.  HTTP resources are
commonly identified by what they call a URI, or Uniform Resource Identifier.  For example,
Microcontroller.com White Papers Previous page Top Next page