AWS IoT for ESP32 v1.0.0
An ESP-IDF based solution
lib_http.h File Reference

HTTP library header file. More...

Go to the source code of this file.

Data Structures

struct  httpConfig_st
 An HTTP Configuration structure. More...
 

Enumerations

enum  httpReq_et {
  HTTP_REQUEST_GET = 0 , HTTP_REQUEST_POST , HTTP_REQUEST_PUT , HTTP_REQUEST_PATCH ,
  HTTP_REQUEST_DELETE , HTTP_REQUEST_HEAD , HTTP_REQUEST_NOTIFY , HTTP_REQUEST_SUBSCRIBE ,
  HTTP_REQUEST_UNSUBSCRIBE , HTTP_REQUEST_OPTIONS , HTTP_REQUEST_MAX
}
 
enum  httpStates_et {
  STATE_HTTP_IDLE , STATE_HTTP_START , STATE_HTTP_SET_REQUEST_HEADER , STATE_HTTP_SET_RESPONSE_HEADER ,
  STATE_HTTP_CONNECT , STATE_HTTP_SET_URL , STATE_HTTP_GET_REQUEST , STATE_HTTP_POST_REQUEST ,
  STATE_HTTP_POST_DATA , STATE_HTTP_WAIT_FOR_POST_RESPONSE , STATE_HTTP_READ , STATE_HTTP_WAIT_FOR_FILE_HEADER ,
  STATE_HTTP_DOWNLOAD_FILE , STATE_HTTP_DOWNLOAD_COMPLETE , STATE_HTTP_RETRY , STATE_HTTP_TIMEOUT ,
  STATE_HTTP_FAILED , STATE_HTTP_CLOSE , STATE_HTTP_MAX
}
 

Functions

bool HTTP_start (httpConfig_st *ps_config)
 Initialize HTTP configuration request and send the request. More...
 
uint16_t HTTP_availableToRead ()
 Check if HTTP data is available for read. More...
 
bool HTTP_read (packet_st *ps_packet)
 Read HTTP response. More...
 
void HTTP_close ()
 Close HTTP connection. More...
 
const char * HTTP_getStateString (httpStates_et state_e)
 Get HTTP state as string. More...
 

Detailed Description

HTTP library header file.

Enumeration Type Documentation

◆ httpReq_et

enum httpReq_et

An enum that represents HTTP requests supported by the library.

Enumerator
HTTP_REQUEST_GET 

HTTP GET Method

HTTP_REQUEST_POST 

HTTP POST Method

HTTP_REQUEST_PUT 

HTTP PUT Method

HTTP_REQUEST_PATCH 

HTTP PATCH Method

HTTP_REQUEST_DELETE 

HTTP DELETE Method

HTTP_REQUEST_HEAD 

HTTP HEAD Method

HTTP_REQUEST_NOTIFY 

HTTP NOTIFY Method

HTTP_REQUEST_SUBSCRIBE 

HTTP SUBSCRIBE Method

HTTP_REQUEST_UNSUBSCRIBE 

HTTP UNSUBSCRIBE Method

HTTP_REQUEST_OPTIONS 

HTTP OPTIONS Method

◆ httpStates_et

An enum that represents HTTP states of the library.

Enumerator
STATE_HTTP_IDLE 

HTTP idle state

STATE_HTTP_START 

HTTP start state

STATE_HTTP_SET_REQUEST_HEADER 

Set HTTP request header

STATE_HTTP_SET_RESPONSE_HEADER 

Set HTTP response header

STATE_HTTP_CONNECT 

Initiate connection

STATE_HTTP_SET_URL 

Set the URL for HTTP request

STATE_HTTP_GET_REQUEST 

HTTP idle state

STATE_HTTP_POST_REQUEST 

Send HTTP POST request

STATE_HTTP_POST_DATA 

Send HTTP POST data

STATE_HTTP_WAIT_FOR_POST_RESPONSE 

Wait for HTTP response

STATE_HTTP_READ 

Read HTTP response

STATE_HTTP_WAIT_FOR_FILE_HEADER 

Wait for HTTP file header

STATE_HTTP_DOWNLOAD_FILE 

File download in progress

STATE_HTTP_DOWNLOAD_COMPLETE 

File download completed

STATE_HTTP_RETRY 

Retry last operation

STATE_HTTP_TIMEOUT 

Timeout occured

STATE_HTTP_FAILED 

HTTP operation failed

STATE_HTTP_CLOSE 

Close HTTP connection

STATE_HTTP_MAX 

Total number of HTTP states

Function Documentation

◆ HTTP_availableToRead()

uint16_t HTTP_availableToRead ( )

Check if HTTP data is available for read.

Parameters
none
Returns
Number of bytes available to read

◆ HTTP_close()

void HTTP_close ( )

Close HTTP connection.

Parameters
none
Returns
none

◆ HTTP_getStateString()

const char * HTTP_getStateString ( httpStates_et  state_e)

Get HTTP state as string.

Parameters
[in]state_eHTTP state
Returns
String version of HTTP states httpStates_et

◆ HTTP_read()

bool HTTP_read ( packet_st ps_packet)

Read HTTP response.

Parameters
[out]ps_packetResponse data
Returns
read status
Return values
trueon success
falseon failure

◆ HTTP_start()

bool HTTP_start ( httpConfig_st ps_config)

Initialize HTTP configuration request and send the request.

Parameters
[in]ps_configHTTP configuration
Returns
Status of HTTP start request
Return values
trueon success
falseon failure