XDK API  3.6.0
Documentation
Files | Data Structures | Typedefs | Functions
HTTP REST client

This module handles the HTTP rest client services (POST and GET). More...

+ Collaboration diagram for HTTP REST client:

Files

file  XDK_HTTPRestClient.h
 

Data Structures

struct  HTTPRestClient_Config_S
 Structure to represent the HTTP Rest Client POST/GET common configurations. More...
 
struct  HTTPRestClient_Get_S
 Structure to represent the HTTP Rest Client GET configurations. More...
 
struct  HTTPRestClient_Post_S
 Structure to represent the HTTP Rest Client POST configurations. More...
 
struct  HTTPRestClient_Setup_S
 Structure to represent the HTTP Rest Client setup features. More...
 

Typedefs

typedef struct
HTTPRestClient_Config_S 
HTTPRestClient_Config_T
 Typedef to represent the HTTP Rest Client POST/GET common configuration. More...
 
typedef struct HTTPRestClient_Get_S HTTPRestClient_Get_T
 Typedef to represent the HTTP Rest Client GET configuration. More...
 
typedef void(* HTTPRestClient_GetCB_T )(const char *responseContent, uint32_t responseContentLen, bool isLastMessage)
 Typedef of the HTTP GET payload callback. More...
 
typedef struct
HTTPRestClient_Post_S 
HTTPRestClient_Post_T
 Typedef to represent the HTTP Rest Client POST configuration. More...
 
typedef struct
HTTPRestClient_Setup_S 
HTTPRestClient_Setup_T
 Typedef to represent the HTTP Rest Client setup feature. More...
 

Functions

Retcode_T HTTPRestClient_Enable (void)
 This will enable the HTTP rest client. More...
 
Retcode_T HTTPRestClient_Get (HTTPRestClient_Config_T *config, HTTPRestClient_Get_T *get, uint32_t timeout)
 This will do a HTTP rest client GET request. More...
 
Retcode_T HTTPRestClient_GetFirmware (HTTPRestClient_Config_T *config, HTTPRestClient_Get_T *get, uint32_t timeout)
 This will do Firmware download through http and stored it in sd card if the get->GetCB is NULL. If get->GetCB is defined, then firmware data will be passed to application. More...
 
Retcode_T HTTPRestClient_Post (HTTPRestClient_Config_T *config, HTTPRestClient_Post_T *post, uint32_t timeout)
 This will do a HTTP rest client POST. More...
 
Retcode_T HTTPRestClient_Setup (HTTPRestClient_Setup_T *setup)
 This will setup the HTTP rest client. More...
 

Detailed Description


Data Structure Documentation

struct HTTPRestClient_Config_S

Data Fields

uint16_t DestinationServerPort
 
const char * DestinationServerUrl
 
bool IsSecure
 
uint32_t RequestMaxDownloadSize
 

Field Documentation

uint16_t DestinationServerPort

Value of the destination server port number

const char* DestinationServerUrl

Pointer to the destination server URL

bool IsSecure

Boolean representing if it is a HTTP secure communication

uint32_t RequestMaxDownloadSize

Value of the maximum amount of data we download in a single request (in bytes)

struct HTTPRestClient_Get_S

Data Fields

HTTPRestClient_GetCB_T GetCB
 
uint32_t GetOffset
 
const char * Url
 

Field Documentation

Function Pointer to be notified of the GET responses

uint32_t GetOffset

Offset for GET

const char* Url

Pointer to the destination server GET URL extension

struct HTTPRestClient_Post_S

Data Fields

const char * Payload
 
uint32_t PayloadLength
 
const char * RequestCustomHeader0
 
const char * RequestCustomHeader1
 
const char * Url
 

Field Documentation

const char* Payload

Pointer to the payload to be POST'ed

uint32_t PayloadLength

Length of the payload to be POST'ed

const char* RequestCustomHeader0

Pointer to the POST request custom header 0

const char* RequestCustomHeader1

Pointer to the POST request custom header 1

const char* Url

Pointer to the destination server POST URL extension

struct HTTPRestClient_Setup_S
+ Collaboration diagram for HTTPRestClient_Setup_S:

Data Fields

CmdProcessor_TCmdProcessor
 
bool IsSecure
 

Field Documentation

CmdProcessor_T* CmdProcessor

Commandprocessor Representation

bool IsSecure

Boolean representing if we will do a HTTP secure communication

Typedef Documentation

typedef void(* HTTPRestClient_GetCB_T)(const char *responseContent, uint32_t responseContentLen, bool isLastMessage)
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

Function Documentation

Retcode_T HTTPRestClient_Enable ( void  )
Returns
RETCODE_OK on success, or an error code otherwise.
Note
  • If setup->IsSecure was enabled at the time of HTTPRestClient_Setup, then we will enable the HTTPs server certificates as well.
  • HTTPRestClient_Setup must have been successful prior.
  • WLAN_Enable must have been successful prior.
  • Do not call this API more than once.

+ Here is the caller graph for this function:

Retcode_T HTTPRestClient_Get ( HTTPRestClient_Config_T config,
HTTPRestClient_Get_T get,
uint32_t  timeout 
)
Parameters
[in]configPointer to the HTTP Rest Client general configuration
[in]getPointer to the HTTP Rest Client GET specific configuration
[in]timeoutTimeout in milli-second to complete a GET cycle
Returns
RETCODE_OK on success, or an error code otherwise.
Note
  • HTTPRestClient_Setup and HTTPRestClient_Enable must have been successful prior.
  • This is a blocking call
  • If get->GetCB can be NULL, but then the application will not be notified of the response received from the server.
See also
HTTPRestClient_Post note. GET is similar to POST w.r.t TCP Socket layer. Therefore 100 milli-second delay is expected to be provided by the user as a wait time if he is to GET continuously.

+ Here is the caller graph for this function:

Retcode_T HTTPRestClient_GetFirmware ( HTTPRestClient_Config_T config,
HTTPRestClient_Get_T get,
uint32_t  timeout 
)
Parameters
[in]configPointer to the HTTP Rest Client general configuration
[in]getPointer to the HTTP Rest Client GET specific configuration
[in]timeoutGET cycle response timeout in milli second
Returns
RETCODE_OK on success, or an error code otherwise.
Note
  • File system and sd card must be initialized before calling this api
  • After successful completion of fota download, firmware verification also done in this function
  • If get->GetCB can be NULL, but then the application will not be notified of the response received from the server.
  • This is a blocking call
  • If get->GetCB is NULL then,
    • Provide the Url path from where can get the bin data. While downloading, this api will append the get size and offset to the given url
      • Example: if the given get->Url = "/range", then while downloading it will append get size and offset like "/range/512/0/" – Here 512 is get size and 0 is bin file offset position – Final url "/range/512/0/" only used to request the bin data from server
      • Firmware file is stored as firmware.bin after the verification. it will overwrite if it is already present.
  • If get->GetCB is defined then,
    • Provide the Url path from where can get the bin data along with size and offset
Retcode_T HTTPRestClient_Post ( HTTPRestClient_Config_T config,
HTTPRestClient_Post_T post,
uint32_t  timeout 
)
Parameters
[in]configPointer to the HTTP Rest Client general configuration
[in]postPointer to the HTTP Rest Client POST specific configuration
[in]timeoutTimeout in milli-second to complete a POST cycle
Returns
RETCODE_OK on success, or an error code otherwise.
Note
  • HTTPRestClient_Setup and HTTPRestClient_Enable must have been successful prior.
  • This is a blocking call
  • HTTP is on top of TCP for XDK, there is something called “KeepAlive” feature for the HTTP session which the serval stack currently doesn’t allow it to be configured. This is currently “false”. This means that every single time, when there is a HTTP POST, a new TCP socket is opened, HTTP session is established and data is POST’ed followed by socket closure. Now, from an application perspective, the moment a payload is POST’ed, we would receive a notification that this was successful. And then the ServalStack will proceed to close the session and the socket. This takes some time based on the system load. During this time, if we trigger another HTTP POST, since the socket is busy with “close procedure”, the trigger would fail. Worst case, 100 milli-second delay is expected to be provided by the user as a wait time if he is to POST continuously.

+ Here is the caller graph for this function:

Retcode_T HTTPRestClient_Setup ( HTTPRestClient_Setup_T setup)
Parameters
[in]setupPointer to the HTTP Rest Client setup feature
Returns
RETCODE_OK on success, or an error code otherwise.
Note
  • If setup->IsSecure is enabled, then we will setup the HTTPs server certificates as well.
  • This must be the first API to be called if HTTP Rest Client feature is to be used.
  • Do not call this API more than once.

+ Here is the caller graph for this function:


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:50 by doxygen 1.8.8