libPocuter  1.0
Support library for programming the Pocuter
PocuterHTTP Class Referenceabstract

HTTP(S) download. More...

#include <PocuterHTTP.h>

Public Types

enum  HTTPERROR {
  HTTPERROR_OK = 0, HTTPERROR_CONNECT_FAILED, HTTPERROR_NO_MEMORY, HTTPERROR_FILE_OPEN_FAILED,
  HTTPERROR_DOWNLOAD_FAILED, HTTPERROR_MORE_STEPS, HTTPERROR_UNKNOWN
}
 

Public Member Functions

virtual HTTPERROR downloadFile (const uint8_t *url, const uint8_t *destination, bool stepwise, uint8_t *percent, const uint8_t *PEMcert=NULL)=0
 download a file from web More...
 
virtual HTTPERROR getResponse (const uint8_t *url, uint8_t *response, size_t maxSize, uint16_t timeout=5000, const uint8_t *PEMcert=NULL)=0
 sends a get request to a server More...
 

Detailed Description

HTTP(S) download.

Member Enumeration Documentation

◆ HTTPERROR

Enumerator
HTTPERROR_OK 
HTTPERROR_CONNECT_FAILED 
HTTPERROR_NO_MEMORY 
HTTPERROR_FILE_OPEN_FAILED 
HTTPERROR_DOWNLOAD_FAILED 
HTTPERROR_MORE_STEPS 
HTTPERROR_UNKNOWN 

Member Function Documentation

◆ downloadFile()

virtual HTTPERROR PocuterHTTP::downloadFile ( const uint8_t *  url,
const uint8_t *  destination,
bool  stepwise,
uint8_t *  percent,
const uint8_t *  PEMcert = NULL 
)
pure virtual

download a file from web

Parameters
urlthe url to the file
destinationthe destination on the sd card (beginning with the value you get from PocuterSDCard::getMountPoint() )
stepwiseIf true download a file step by step instead of downloading everything at once. This way you can realize a progress bar for example.
percent(out) Shows how much percent of the file has been downloaded so far. Is always 100 if stepwise=false. This is only available if the http header contains "content-length"
PEMcert(optional) if it is an https address, you need to add the root certificate to trust the server.

◆ getResponse()

virtual HTTPERROR PocuterHTTP::getResponse ( const uint8_t *  url,
uint8_t *  response,
size_t  maxSize,
uint16_t  timeout = 5000,
const uint8_t *  PEMcert = NULL 
)
pure virtual

sends a get request to a server

Parameters
urlthe url for the get request
responsethe response text. You must allocate enough memory for the response.
maxSizethe max size you can hold in the response
timeout(optional) timeout in ms
PEMcert(optional) if it is an https address, you need to add the root certificate to trust the server.

The documentation for this class was generated from the following file: