Building and Running Example Application
Working Project with µC/TCP-IP
The first step before including µC/HTTP-client is to have a working project with µC/TCP-IP. As previously mentioned, Micriµm may offer an example with the µC/OS-III kernel, µC/TCP-IP and even µC/HTTP-client for many evalboards.
If no project with µC/TCP-IP is available for your platform, you should follow the µC/TCP-IP Getting Started Guide to ensure you have a working project before installing µC/HTTP-client. Then you can follow the steps to build and run your first µC/HTTP-client sample application shown below.
Including µC/HTTP-client Stack Source Code
As indicated in the Figure - HTTP-client Folder Tree, all the files in the "Source" folder of the "Client" directory must be added to your project tree.
Furthermore, all files in the "Common" folder under the "HTTP" parent directory must be added to your project tree.
Configuring Compiler settings
Add the following include paths to your project’s C compiler settings:
\Micrium\Software\uC-HTTP
Copying and Modifying Template Files
Copy the files from the uC-HTTP-client configuration folder into your application as illustrated below.
Adding µC/HTTP-client Example Application Code
The code below presents a simple HTTP client application where the µC/HTTP-client suite is initialized before one connection is opened and one request is sent. Every API function call is blocking.
It is also assumed that all prerequisite modules have been initialized before calling the µC/HTTP-client example function.
The functions HTTPcApp_Init()
and HTTPcApp_ReqSendGet()
are example functions that can be retrieve in the Examples directory of µC/HTTP-client. Other example functions are present if you wishes to test other functionality as sending forms, open multiple connections are open a persistent connection.
static void AppTaskStart (void *p_arg) { /* Initialize BSP */ /* Initialize CPU */ /* Initialize Memory */ /* Initialize TCP-IP */ /* Initialize DNSc if necessary */ success = HTTPcApp_Init(); if (success == DEF_FAIL) { printf("Error with HTTPc Initialization.\n"); CPU_SW_EXCEPTION(;); } else { (void)HTTPcApp_ReqSendGet(); } }