RAFW Flexible Software Package Documentation  Release v2.0.1

 
HTTPS (rm_https_w)

Functions

fsp_err_t RM_HTTPS_W_Open (https_ctrl_t *const p_api_ctrl, https_cfg_t const *const p_cfg)
 
fsp_err_t RM_HTTPS_W_Close (https_ctrl_t *const p_api_ctrl)
 
fsp_err_t RM_HTTPS_W_ServerStart (https_ctrl_t *const p_api_ctrl, https_server_sec_t *p_sec)
 
fsp_err_t RM_HTTPS_W_ServerStop (https_ctrl_t *const p_api_ctrl)
 
fsp_err_t RM_HTTPS_W_CallbackSet (https_ctrl_t *const p_api_ctrl, void(*p_callback)(https_callback_args_t *), void const *const p_context, https_callback_args_t *const p_callback_memory)
 
fsp_err_t RM_HTTPS_W_ServerGetStatus (https_ctrl_t *const p_api_ctrl, https_server_status_t *p_status)
 
fsp_err_t RM_HTTPS_W_ClientSendRequest (https_ctrl_t *const p_api_ctrl, http_client_request_t *p_request)
 

Detailed Description

HTTPS_W to networking system tasks and avoid system freezes. This module implements the HTTPS Interface.

Overview

HTTPS_W (Hypertext Transfer Protocol Secure) is a protocol that encrypts data and transmits it between a web server and a client (such as a browser). Its primary function is to facilitate the transfer of data, including web pages, images, and other content, between the server and the client. It works on top of the TCP/IP protocol.

Features

The HTTPS_W module has the following key features:

Configuration

Build Time Configurations for rm_https_w

The following build time configurations are defined in fsp_cfg/rm_https_w_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
Watchdog Service Support
  • Enabled
  • Disabled
Disabled Enable when using the Watchdog Service.
HTTP Server
  • Disabled
  • Enabled
Enabled If selected HTTP Server role support is included in the build.
HTTP Client
  • Disabled
  • Enabled
Enabled If selected HTTP Client role support is included in the build.

Clock Configuration

This module has no required clock configurations.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Limitations

Note
Should not use this the HTTPS APIs in interrupt context.

Examples

HTTPS Basic Example

This is a basic example of minimal use of the HTTPS_W in an application.

fsp_err_t https_basic_example(void)
{
fsp_err_t err = FSP_SUCCESS;
/* Open the HTTPS module. */
err = RM_HTTPS_W_Open(&g_https_w0_ctrl, &g_https_w0_cfg);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
err = RM_HTTPS_W_CallbackSet(&g_https_w0_ctrl, rm_https_example_callback, NULL, NULL);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
/* Server Start */
err = RM_HTTPS_W_ServerStart(&g_https_w0_ctrl, NULL);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
/* Client Send Request */
.port = HTTP_SERVER_PORT,
.insecure = pdFALSE,
.hostname = "localhost",
.path = "http://localhost/index.html",
};
/* Send Request. */
err = RM_HTTPS_W_ClientSendRequest(&g_https_w0_ctrl, &request);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
err = wait_for_client_transfer_complete(false);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
/* Stop Server. */
err = RM_HTTPS_W_ServerStop(&g_https_w0_ctrl);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
err = RM_HTTPS_W_Close(&g_https_w0_ctrl);
FSP_ERROR_RETURN(FSP_SUCCESS == err, err);
return err;
}
static fsp_err_t wait_for_client_transfer_complete (bool allow_error)
{
uint32_t timeout = 1000000;
while (timeout > 0)
{
timeout--;
if (client_transfer_error)
{
if (allow_error)
{
break;
}
client_transfer_error = 0U;
}
if (client_transfer_complete)
{
break;
}
ulTaskNotifyTake(pdFALSE, portMAX_DELAY);
}
if (0U == timeout)
{
}
client_transfer_complete = 0U;
client_transfer_error = 0U;
return FSP_SUCCESS;
}
/* The callback is called when a transfer completes. */
void rm_https_example_callback (https_callback_args_t * p_args)
{
switch (p_args->event)
{
case HTTPS_EVENT_CLIENT_RESULT:
{
err_t err = *(int8_t *)p_args->p_param;
if (ERR_OK == err)
{
client_transfer_complete = 1;
}
else
{
client_transfer_error = 1;
}
break;
}
default:
break;
}
}

Data Structures

struct  https_w_instance_ctrl_t
 

Data Structure Documentation

◆ https_w_instance_ctrl_t

struct https_w_instance_ctrl_t

Private control block. DO NOT MODIFY. Initialization occurs when RM_WATCHDOG_SERVICE_W_Open() is called.

Data Fields

uint32_t open
 Indicates whether the open() API has been successfully called.
 
https_cfg_t const * p_cfg
 Pointer to instance configuration.
 
https_client_status_t server_status
 Server Status.
 
void(* p_callback )(https_callback_args_t *)
 Pointer to callback.
 
https_callback_args_tp_callback_memory
 Pointer to optional callback argument memory.
 
void const * p_context
 Pointer to context to be passed into callback function.
 

Function Documentation

◆ RM_HTTPS_W_Open()

fsp_err_t RM_HTTPS_W_Open ( https_ctrl_t *const  p_api_ctrl,
https_cfg_t const *const  p_cfg 
)

Open Https module.

Return values
FSP_SUCCESSHTTPS module was opened successfully.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_ALREADY_OPENHTTPS module is already opened.

◆ RM_HTTPS_W_Close()

fsp_err_t RM_HTTPS_W_Close ( https_ctrl_t *const  p_api_ctrl)

Close Https module.

Return values
FSP_SUCCESSHTTPS module was closed successfully.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened

◆ RM_HTTPS_W_ServerStart()

fsp_err_t RM_HTTPS_W_ServerStart ( https_ctrl_t *const  p_api_ctrl,
https_server_sec_t *  p_sec 
)

Start HTTP server.

Return values
FSP_SUCCESSHTTPS server was started successfully.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened
FSP_ERR_INVALID_STATETask was not created successfully.

◆ RM_HTTPS_W_ServerStop()

fsp_err_t RM_HTTPS_W_ServerStop ( https_ctrl_t *const  p_api_ctrl)

Stop HTTP server.

Return values
FSP_SUCCESSHTTPS server was stopped successfully.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened

◆ RM_HTTPS_W_CallbackSet()

fsp_err_t RM_HTTPS_W_CallbackSet ( https_ctrl_t *const  p_api_ctrl,
void(*)(https_callback_args_t *)  p_callback,
void const *const  p_context,
https_callback_args_t *const  p_callback_memory 
)

Updates the user callback with the option to provide memory for the callback argument structure.

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened

◆ RM_HTTPS_W_ServerGetStatus()

fsp_err_t RM_HTTPS_W_ServerGetStatus ( https_ctrl_t *const  p_api_ctrl,
https_server_status_t *  p_status 
)

Get HTTP server status.

Return values
FSP_SUCCESSSuccessfully get the server status.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened

◆ RM_HTTPS_W_ClientSendRequest()

fsp_err_t RM_HTTPS_W_ClientSendRequest ( https_ctrl_t *const  p_api_ctrl,
http_client_request_t p_request 
)

Send HTTP request to HTTP server.

Return values
FSP_SUCCESSSuccessfully send a HTTP request.
FSP_ERR_ASSERTIONNULL pointer to parameters in argument.
FSP_ERR_NOT_OPENHTTPS module has not been opened
FSP_ERR_INVALID_ARGUMENTParameter passed into function was invalid.
FSP_ERR_INVALID_STATEMutex was not created successfully.