XDK API  3.6.0
Documentation
Files | Macros | Functions | Variables
HttpExampleClient

Demo application for communicating with the HTTP to GET and POST content on the Server and demonstrate the use of custom headers. More...

+ Collaboration diagram for HttpExampleClient:

Files

file  AppController.c
 

Macros

#define APP_RESPONSE_FROM_HTTP_SERVER_GET_TIMEOUT   UINT32_C(25000)
 
#define APP_RESPONSE_FROM_HTTP_SERVER_POST_TIMEOUT   UINT32_C(25000)
 
#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER
 

Functions

void AppController_Init (void *cmdProcessorHandle, uint32_t param2)
 Gives control to the Application controller. More...
 
static void AppControllerEnable (void *param1, uint32_t param2)
 To enable the necessary modules for the application. More...
 
static void AppControllerFire (void *pvParameters)
 Responsible for controlling the HTTP Example application control flow. More...
 
static void AppControllerSetup (void *param1, uint32_t param2)
 To setup the necessary modules for the application. More...
 
static Retcode_T AppControllerValidateWLANConnectivity (void)
 This will validate the WLAN network connectivity. More...
 
static void HTTPRestClientGetCB (const char *responseContent, uint32_t responseContentLen, bool isLastMessage)
 The HTTP GET request response callback. More...
 

Variables

static CmdProcessor_TAppCmdProcessor
 
static xTaskHandle AppControllerHandle = NULL
 
static HTTPRestClient_Config_T HTTPRestClientConfigInfo
 
static HTTPRestClient_Get_T HTTPRestClientGetInfo
 
static HTTPRestClient_Post_T HTTPRestClientPostInfo
 
static HTTPRestClient_Setup_T HTTPRestClientSetupInfo
 
static WLAN_Setup_T WLANSetupInfo
 

Detailed Description

This example shows how to use the network stack to perform an HTTP Client Request.

The example connects to the server and establishes a connection to the server.

To view your posts, browse to the directory name DEST_POST_PATH:

You need to add your WLAN-Credentials in AppController.h
When running the program keep the USB plugged in to the PC. You can see in the console output of the XDK-Workbench the content of the GET request.

Macro Definition Documentation

#define APP_RESPONSE_FROM_HTTP_SERVER_GET_TIMEOUT   UINT32_C(25000)

Timeout for completion of HTTP rest client GET

#define APP_RESPONSE_FROM_HTTP_SERVER_POST_TIMEOUT   UINT32_C(25000)

Timeout for completion of HTTP rest client POST

#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER

Function Documentation

void AppController_Init ( void *  cmdProcessorHandle,
uint32_t  param2 
)

This is a template function where the user can write his custom application.

Refer interface header for description

+ Here is the call graph for this function:

static void AppControllerEnable ( void *  param1,
uint32_t  param2 
)
static
  • WLAN
  • ServalPAL
  • SNTP (if HTTPS)
  • HTTP rest client
Parameters
[in]param1Unused
[in]param2Unused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerFire ( void *  pvParameters)
static
  • Synchronize the node with the SNTP server for time-stamp (if HTTPS)
  • Check whether the WLAN network connection is available
  • Do a HTTP rest client POST
  • Wait for INTER_REQUEST_INTERVAL if POST was successful
  • Do a HTTP rest client GET if POST was successful
  • Wait for INTER_REQUEST_INTERVAL if GET was successful
  • Redo the last 5 steps
Parameters
[in]pvParametersUnused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerSetup ( void *  param1,
uint32_t  param2 
)
static
  • WLAN
  • ServalPAL
  • SNTP (if HTTPS)
  • HTTP rest client
Parameters
[in]param1Unused
[in]param2Unused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Retcode_T AppControllerValidateWLANConnectivity ( void  )
static

If there is no connectivity then it will scan for the given network and try to reconnect

Returns
RETCODE_OK on success, or an error code otherwise.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void HTTPRestClientGetCB ( const char *  responseContent,
uint32_t  responseContentLen,
bool  isLastMessage 
)
static
Parameters
[in]responseContentPointer to the GET request response
[in]responseContentLenLength of the GET request response
[in]isLastMessageBoolean to represent if it is the last part of the ongoing message

Refer function definition for description

Variable Documentation

CmdProcessor_T* AppCmdProcessor
static

Handle to store the main Command processor handle to be reused by ServalPAL thread

xTaskHandle AppControllerHandle = NULL
static

OS thread handle for Application controller

HTTPRestClient_Config_T HTTPRestClientConfigInfo
static
Initial value:
=
{
.IsSecure = HTTP_SECURE_ENABLE,
.DestinationServerUrl = DEST_SERVER_HOST,
.DestinationServerPort = DEST_SERVER_PORT,
.RequestMaxDownloadSize = REQUEST_MAX_DOWNLOAD_SIZE,
}
#define HTTP_SECURE_ENABLE
Definition: AppController.h:172
#define REQUEST_MAX_DOWNLOAD_SIZE
Definition: AppController.h:193
#define DEST_SERVER_HOST
Definition: AppController.h:113
#define DEST_SERVER_PORT
Definition: AppController.h:119

HTTP rest client configuration parameters

HTTPRestClient_Get_T HTTPRestClientGetInfo
static
Initial value:
=
{
.Url = DEST_GET_PATH,
.GetOffset = 0UL,
}
static void HTTPRestClientGetCB(const char *responseContent, uint32_t responseContentLen, bool isLastMessage)
The HTTP GET request response callback.
Definition: AppController.c:186
#define DEST_GET_PATH
Definition: AppController.h:134

HTTP rest client GET parameters

HTTPRestClient_Post_T HTTPRestClientPostInfo
static
Initial value:
=
{
.Payload = POST_REQUEST_BODY,
.PayloadLength = (sizeof(POST_REQUEST_BODY) - 1U),
.RequestCustomHeader0 = POST_REQUEST_CUSTOM_HEADER_0,
.RequestCustomHeader1 = POST_REQUEST_CUSTOM_HEADER_1,
}
#define POST_REQUEST_CUSTOM_HEADER_0
Definition: AppController.h:149
#define POST_REQUEST_CUSTOM_HEADER_1
Definition: AppController.h:155
#define DEST_POST_PATH
Definition: AppController.h:142
#define POST_REQUEST_BODY
Definition: AppController.h:160

HTTP rest client POST parameters

HTTPRestClient_Setup_T HTTPRestClientSetupInfo
static
Initial value:
=
{
.IsSecure = HTTP_SECURE_ENABLE,
}
#define HTTP_SECURE_ENABLE
Definition: AppController.h:172

HTTP rest client setup parameters

WLAN_Setup_T WLANSetupInfo
static
Initial value:
=
{
.IsEnterprise = false,
.IsHostPgmEnabled = false,
.SSID = WLAN_SSID,
.Username = WLAN_PSK,
.Password = WLAN_PSK,
.IsStatic = WLAN_STATIC_IP,
.IpAddr = WLAN_IP_ADDR,
.GwAddr = WLAN_GW_ADDR,
.DnsAddr = WLAN_DNS_ADDR,
.Mask = WLAN_MASK,
}
#define WLAN_DNS_ADDR
Definition: AppController.h:101
#define WLAN_PSK
Definition: AppController.h:75
#define WLAN_GW_ADDR
Definition: AppController.h:94
#define WLAN_IP_ADDR
Definition: AppController.h:87
#define WLAN_SSID
Definition: AppController.h:69
#define WLAN_STATIC_IP
Definition: AppController.h:80
#define WLAN_MASK
Definition: AppController.h:108

WLAN setup parameters


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:54 by doxygen 1.8.8