nahttpapplet: HTTP Applet Sample Application

This application demonstrates the Advanced Web Server (AWS) and how to
serve a Java Applet. The HTML file under directory "html" contains the
source for the web page and the .class files of the Java Applet.  The 
pBuilder tool was used to convert these web page files into C files.  
These C files are built into the application to create a web server to
host the Java Applet.

The application can run on all platforms.

Application requires following running environment:

The Java JRE 1.6 should be installed on the machine that is to view the
Java Applet in the browser.  This can be found on the official Java website:

    http://www.java.com/en/download/index.jsp

Once the JRE (or JDK) 1.6 is installed the browser needs to have the proper
plug-in installed.  This can be found at this website:

    http://www.java.com/en/download/manual.jsp
	

What does this application do?

1. Starts the Advanced Web Server
2. Allows the user to view a Java Applet by going to the boards IP address in a web browser
3. Opens a UDP connection to allow communication between the board and Applet
4. Through the UDP connection, the user can get saved locations from the board and also
   save new locations to the board.

   
Explaining the Java Applet:

The Java Applet does the following things:

1) When the Applet is first loaded it will ask the user for an IP Address. This
   is done as a security measure.  Applets are only allowed to communicate
   with the IP Address that served them.  So at this dialog insert the IP
   address of the board.  If nothing is inserted the value 10.52.35.102 is 
   used as a default.  If the wrong IP address is inserted the Applet will still
   work and operate, it will just not be able to save locations or load locations
   already saved on the board.
   
2) When the Applet has started it will allow the user to change several variable.
      - Latitude :: This is the Latitude to be loaded when the 'MAP' button is pressed
	  - Longitude :: This is the Longitude to be loaded when the 'MAP' button is pressed
	  - Degrees to change :: Number of degrees to change when one of the cardinal diection
		    buttons are pressed
	  - Zoom Level :: This is the zoom level of the map when a map is loaded.  The
            larger the number the closer in the map will be focused on the location.
	  - Map view/Satelite view Radio button :: This will decide if a regular Map will
	        be loaded or if a satelite map is loaded when the 'MAP' button is pressed
	  - Saved Location Name :: The name to be used when the 'Save This Location' button
	        is pressed.
			
3) The Applet also has saved locations and the ability to load saved locations.  (The 
   details of the UDP connection are explained in the "Explaining the UDP" section.)
   The saved locations are stored in RAM on the board and there are 4 locations by
   default; Digi's Branch in Waltham, MA, Digi's Branch in Minnetonka, MN, San Deigo,
   CA, and the Eiffel Tower in Paris.  Locations are saved to the board when the "Save
   This Location" button is pressed.  The location is given the name from the Text box
   located above the button.


Explaining the UDP:

UDP is used in this application to allow the Applet to communicate and transfer data from
the board that served the Applet to the Applet itself and vice versa.  The communication 
enables the Applet to save locations (which include a Name, Latitude, and Longitude) to the
board for storage. This allows faster navigation to certain locations as well as saving certain
locations even when the Applet is reloaded; which happens when the browser's page is reloaded
or navigated away from.  Another advantage is that the locations that are saved are not
local to the Applet or machine that saved them.  The saved locations can be viewed by any
Applet that is loaded on any machine.

There are 4 types of UDP packets that are sent in this application: update, send_saved_location,
send_new_location and done_sending_locations (below they are each explained in more depth).

NOTE: None of the packets are ever acknowledged.  Also there is no guarentee of delivery 
      (this is because of UDP).

update Packet ::
This packet is sent by the Applet to the server.  It is a single byte '1', and when the server
receives this message it knows that the Applet wants an updated list of locations and it should
send the locations to the board. 

send_new_location ::
This packet is sent by the Applet to the server.  It is a message that tells the server to save
the information in the packet to RAM.  It follows the following format: 
"2#name of the location#latitude#longitude$".  The '$' is important, it means the end of the
locations information.  The 2 being the opcode which is a byte, the rest is in the format of a char*.

send_saved_location ::
This packet is sent by the server and it contains the name, latitude, and longitude of the location.
It follows the following format: "3#name of the location#latitude#logitude".  The 3 being the opcode
which is a byte, the rest is in the format of a char*.

done_sending_location::
This packet is sent by the server to the Applet and it contains a single byte '6', and it tells
the Applet that it is done sending locations to the Applet.  The Applet, when it receives this packet,
can stop waiting for more locations.


Following files are provided in this example.

appconf.h         sets application configuration settings

.\32b\makefile    makefile for the GNU toolset.

readme            this file

root.c            contains applicationStart() function which starts appropriate
                  threads
				  
phrasedict.h      contains external references for user language dictionaries

security.c        Contains the security realms for this applications.

server.h          Contains header data for the TCP/IP evaluation.

udp_utils.c       Contains functions to handle UDP send/recv

udp_utils.h       Contains udp_utils.c header information
	
.\pbuilder\list.bat
                  Bat file that is used by the pbuilder to build web portion of application
				  
Following files are inputs/outputs to/from the html-to-c
converter tool and are contained in the .\pbuilder\html directory:

index.htm		  The webpage source file

style.css         A css file that is used to make page look a little better.

index.c 		  HTML-To-C Converter generated file that contains the C-code of the class
				  files, the .htm file and the style.css file
				  
MapApplet.java    Applet Source Code.  Not needed by the application but here as a
				  reference if needed.  The .class files were generated from this 
				  java file
				  
*.class           Class files generated by the Java Compiler.


In addition, the following files in the BSP directory are built
as part of this application.

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The application build file links in the following libraries.

libbsp.a           contains the BSP library
libtcpip.a         contains the TCP/IP stack library
libtx.a            contains the ThreadX kernel library
libfilesys.a       contains the file system library
libposix.a         contains the POSIX layer library
libflash.a         contains the Flash driver library
libhttpd.a         contains the NET+Works HTTPS API library
libcrypto.a	       contains the cryptographic code
libssl.a	       contains SSL/TLS protocol code 
libmanapi.a        contains Application Management code
libdnsclnt.a       contains DNS 
lbaddp.a           contains Advanced Digi Discovery Protocol library
libtelnsrv.a       contians the API that is used to create Telnet servers
libpppintf.a       contains Point-to-Point Protocol (PPP) library
libwpa.a


The application uses the following files located in the
netos\src\bsp\platforms\<platform> directory.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script

