Guide for porting the HTTP client library to a new platform.
To use the HTTP client library, a platform must implement the following components:
Settings that can be set as macros in the config header core_http_config.h
, or passed in as compiler options.
core_http_config.h
is not provided, then the HTTP_DO_NOT_USE_CUSTOM_CONFIG macro must be defined.The following macros can be configured for this library:
In addition, the following logging macros are used throughout this library:
The HTTP client library relies on transport interface callbacks that must be implemented in order to send and receive packets on a network.
The transport interface API used by the HTTP client is defined in transport_interface.h. A port must implement functions corresponding to the following functions pointers:
The above two functions take in a pointer to a NetworkContext_t, the type name of a struct NetworkContext
. The NetworkContext struct must also be defined by the user's implementation, and ought to contain any information necessary to send and receive data with the TransportSend_t and TransportRecv_t implementations, respectively:
The HTTP library optionally relies on a function to generate millisecond timestamps, for the purpose of calculating the elapsed time when no data has been sent or received.
Applications can supply their platform-specific function capable of generating 32-bit timestamps of millisecond resolution. These timestamps need not correspond with any real world clock; the only requirement is that the difference between two timestamps must be an accurate representation of the duration between them, in milliseconds.
This function is used in conjunction with macros HTTP_SEND_RETRY_TIMEOUT_MS and HTTP_RECV_RETRY_TIMEOUT_MS.