Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This section describes all the steps required to build a HTTPsHTTP-server based application. The instructions provided in this section are not intended for any particular toolchain, but instead are described in a generic way that can be adapted to any toolchain.

The best way to start building a  HTTPs HTTP-server based project is to start from an existing project. If you are using µC/OS-II or µC/OS-III, Micrium provides example projects for multiple development boards and compilers. If your target board is not listed on Micrium’s web site, you can download an example project for a similar board or microcontroller.

If you are starting from a Micriµm example, section µC/HTTPs Project Example gives more details on the Micriµm example repository and included files.

...

TCP-IP project. 

Working project with µC/TCP-IP

The first step before including the µC/HTTPs HTTP-server is to have a working project with the RTOS of your choiceµC/TCP-IP. As previously mentioned, Micriµm offers  Micriµm may offer starting example with the µC/OS-II and III kernels and µC/TCP-IP and even with µC/OSHTTP-III kernels server for many evalboards. 

Complete documentation for If no project that include µC/OS-II here, including a Getting Started Guide.

Complete documentation for µC/OS-III here, including a Getting Started Guide.

 

TCP-IP is available, you should follow the µC/TCP-IP Getting Started Guide to ensure to have a working project which use fix IP address before installing µC/HTTP-server. Then you can follow the following steps to build and run a first µC/HTTP-server sample application.

Including Additional Modules to the Project

Once you have a working project with your RTOS , and µC/TCP-IP additional modules are needed by the Micriµm HTTP server that are not necessarily already included in your project. Therefore, be sure to add µC/CPU, µC/LIB, µC/Common Commmon and µC/TCPIP to TCP-IP to your project.  

Complete documentation for µC/CPU here.

Complete documentation for µC/LIB here.

Complete documentation for µC/Common here.

Complete documentation for µC/TCPIP here.

Bear in mind to include the required paths associated with those modules to your project’s C compiler settings.

...

Refer to the following manuals for further information about MIcrium modules:.

µC/TCP-IP Documentation

µC/OS-II Documentation

µC/OS-III Documentation

µC/LIB Documentation

µC/CPU Documentation

µC/Common Module

Including µC/HTTP-server Source Code

Include the following files in your project tree from the µC/HTTPs HTTP-server source code distribution, as indicated in Figure - µC/HTTPs Source CodeHTTP-server Directory Tree.

As indicated in the Figure - µC/HTTPs Source Code- HTTP-server Directory Tree, all the files in the Source folder uC-HTTP/Server/Source path must be added to your project tree. Furthermore, as all the files in the chosen File System type uC-HTTP/Common folder.

For the file system, µC/HTTP-server uses the network file system layer included with µC/TCP-IP located inside the uC-TCPIP/FS folder. Therefore, the header file net_fs.h inside this folder must be added include to your project tree. Finally, http-s_os.c file of the selected RTOS must be added as well as the generic http-s_os.h file that can be found in the OS folder. After, no matter what file system your HTTP server is using.

If a conventional file system is used, the port should be located also inside the uC-TCPIP/FS folder. A port for the µC/FS file system is already included in this folder. If a file system other than µC/FS is used, a port template is available inside to be customize according to your file system.

If the Static file system is used, the port for this file system is located inside uC/HTTP-server. Therefore, the source files under the folder name Static must be include to your project. Furthermore, The static file system configuration file must be copied in your application directory. This configuration file can be retrieve inside the folder Cfg (i.e Micrium/Software/uC-HTTP/Server/FS/Static/Cfg/Template).

Compiler settings

Finally, add the following include paths to your project’s C compiler settings:

\Micrium\Software\uC-HTTPsHTTP
\Micrium\Software\uC-HTTPs\OS\<OS type>TCPIP
\Micrium\Software\uC-HTTPs\FS\<File System type >-<OS-Version>

Copying and Modifying Template Files

Copy the files from the uC-HTTP-HTTPs server configuration folder into your application as illustrated in Figure - HTTP-server Copying Template Files.

Panel
titleHTTP-server Copying Template Files

Image Added

 

net_cfg.c is a configuration file including the NET_TASK_CFG objects used to configured the µC/TCP-IP internal tasks. The µC/TCP-IP stack has three internal tasks : the Receive task, the Transmit De-allocation task and the Timer task. Each task as its own NET_TASK_CFG  object defining the task priority, the task's stack size and the pointer to start of task stack. Refer to  section Network Tasks Configuration for more details on the µC/TCP-IP tasks configuration.

nethttp-s_cfg.h is a configuration file used to setup µC/TCPHTTP-IP stack server module static parameters and features such as the number of available sockets, TCP connections and network timers, the ARP and NDP parameters, the number of configurable interface CGI form configuration, dynamic token replacement configuration, header field feature, proxy configuration and so on. Refer to section Static Stack Module Configuration for more details on all the configurations inside nethttp-s_cfg.h 

net_devThe http-s_instance_cfg.c and net_dev_cfg.h are configuration files used to set the wired or wireless device interface parameters such as the number and size of network buffers available for transmission and reception and the base address of the device's registers. They also include the PHY parameters such as the PHY bus mode (RMII or MII) in the case of a wired Ethernet device.

 

Since the device configuration is different depending if your interface is wired or wireless, the details on the device configuration modifications will be shown in the corresponding sub-sections. 

Modifying the Application Configuration Files

The µC/TCP-IP stack /.h pair of files, defines the configuration structure for an HTTP server’s instance (see µC/HTTPs Instance Configuration for more details). If your application requires a secured HTTP server instance, the http-s_instance_secure_cfg.c/.h pair of files should be used as template instead.  The secure template is available in the Examples folder.

Modifying the HEAP memory configuration

The µC/HTTP-server Module uses additional heap memory space. Therefore, it is possible that your sample application will require more allocation of heap memory. If ti is the case, you can increase the value of the #define LIB_MEM_CFG_HEAP_SIZE inside the lib_cfg.h file HEAP memory size of your sample project. You can , refer to section µC/LIB Memory Heap Management Configuration for more details on the heap usage of the µC/TCP-IP stack

Adding µC/

...

HTTP-

...

server application function

Before running the sample application, you will need to add the new funtion, AppInit_TCPIP(), in your app.c function call, in your application file to initialize and setup the µC/TCP-IP stack. Section Tasks and Objects Initialization gives an example of the main application task inside which the AppInit_TCPIP() function will be called. Section Ethernet HTTP-server module. Section Sample Application gives an AppInit_TCPIP() example for a wired Ethernet interface.Those code examples example of how to initialize µC/HTTP-server and start a web server instance. 

This code example will need to be modified in accordance with your project setup. For example, when adding an interface, your network device configuration object name (inside net_dev_cfg.c) will need to be specify and the IP address used in the example could need to be change to match your network.

Once the source code is built and loaded into the target, the target will respond to ICMP Echo (ping) requests.

 

 

Tasks Priority

The http-s_cfg.c file includes the three network task configurations. You will need to defined the priority of each of those tasks. The priorities will depend on the other tasks already present in your application. Refer to section Network Tasks Configuration for all the details on configuring the network tasks and their priority. 

Sample Project Setup

The purpose of this sample project is to setup a network host on the target board to allow it to communicate with other hosts on the network. Figure - Sample Application Setup shows the project test setup for a Ethernet wired interface. The target board is wire-connected to an Ethernet switch or via an Ethernet cross-over cable to a Windows-based PC. The PC’s IP address is set to 10.10.10.111 and the target’s addresses will be configure to 10.10.10.64 as it will be shown in the next section Adding µC/TCP-IP application function.

This sample project contains enough code to be able to ping the board. Therefore, after successfully running the project, You will be able to issue the following command form a command-prompt:

ping 10.10.10.64

Ping (on the PC) should reply back with the ping time to the target. µC/TCP-IP target projects connected to the test PC on the same Ethernet switch or Ethernet cross-over cable achieve ping times of less than 2 milliseconds.

After you have successfully completed and run the sample project, you can use it as a starting point to run other µC/TCP-IP demos you may have purchased.

Adding Additional includes

Since the µC/TCP-IP module was added to the sample project, the following include must be added to the app.c file :

#include  <KAL/kal.h>
#include <Source/net.h>
#include <net_dev_????.h>
#include <net_phy_????.h>
#include <net_dev_cfg.h>
#include <net_bsp.h>

 

 

 

 

DEVELOP

  

Adding Additional includes

#include <Server/Source/http-s.h>
#include  <FS/uC-FS-V4/net_fs_v4.h> (optional if uC/FS is used)
#include  <Server/FS/Static/http-s_fs_static.h> (optional if no File system is available in the project)