Synergy Software Package User's Manual
NetX Duo HTTP Client (HTTPS/HTTPS 1.1)

NetX Duo Web HTTP/HTTPs Client Introduction

The NetX Web HTTP/HTTPs Client module provides a high-level API for Hyper Text Transport Protocol(HTTP) for transferring content on the web. The HTTP protocol utilizes Transmission Control Protocol (TCP) services to perform its content transfer function. HTTPs is the secure version of the HTTP protocol which uses HTTP on top of the Transport Layer Security (TLS) protocol to secure underlying TCP connection.

HTTP/HTTPs client is implemented on top of NetX Duo IP and NetX Duo Packet Pool. NetX Duo IP attaches itself to appropriate link layer driver such ethernet/Wi-Fi/cellular. HTTP client can optionally connect to HTTP server over secure connection and in such case, it uses service provided by NetX Duo TLS Common

Unsupported Features

  • HTTP Client authentication using username and password integrated but not tested. Request pipelining is not supported 
  • At present, the HTTP Client supports only basic authentication. When using TLS for HTTPS, HTTP authentication may still be used. 
  • No content compression is supported. 
  • TRACE, OPTIONS, and CONNECT requests are not supported. 
  • The packet pool associated with the HTTP Server or Client must be large enough to hold the complete HTTP header.  

NetX Duo Web HTTP/HTTPs Client Module Features

  • NetX Web HTTP/HTTPs client is compliant with below RFCs
    • RFC1945 "Hypertext Transfer Protocol/1.0"
    • RFC 2616 "Hypertext Transfer Protocol – HTTP/1.1"
    • RFC 2818 "HTTP Over TLS"
    • RFC 2581 "TCP Congestion Control"
    • RFC 1122 "Requirements for Internet Hosts", and related RFCs.
    • RFC 2818 "HTTP over TLS" for HTTPS
  • Support HTTP Get/POST/HEAD/PUT/DELETE commands. Note that these commands are generated internally by NetX Web HTTP/HTTPs client APIs.
  • Support basic authentication. When using TLS for HTTPs, HTTP authentication may still be used
  • Provides option to enable/disable TLS for secure communication using NetX Secure in SSP
nxd_web_http_client_BD.png
NetX Duo Web HTTP/HTTPs Client Module Block Diagram
Note
 In the figure above, the NetX Duo Network Driver module has multiple implementation options available. See the description just after the module stack figure in Including the NetX Duo Web HTTP/HTTPs Client Module in an Application for additional details.

NetX Duo Web HTTP/HTTPs Client Module APIs Overview

The NetX Duo Web HTTP/HTTPs Client module defines APIs for creating, deleting, getting and putting. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.

NetX Duo Web HTTP/HTTPs Client Module API Summary

Function Name Example API Call and Description
nx_web_http_client_connect nx_web_http_client_connect(NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS *server_ip, UINT server_port, ULONG wait_option);
Open a plaintext socket to an HTTP server for custom requests.
nx_web_http_client_create nx_web_http_client_create(NX_WEB_HTTP_CLIENT
*client_ptr, CHAR *client_name, NX_IP *ip_ptr,
NX_PACKET_POOL *pool_ptr, ULONG window_size);
Create an HTTP Client Instance.
nx_web_http_client_delete nx_web_http_client_delete(NX_WEB_HTTP_CLIENT
*client_ptr);
Delete an HTTP Client Instance.
nx_web_http_client_delete_start nx_web_http_client_delete_start(NX_WEB_HTTP_CLIE
NT *client_ptr, NXD_ADDRESS ip_address, UINT
server_port, CHAR *resource, CHAR *host, CHAR
*username, CHAR *password, ULONG wait_option);
Start a plaintext HTTP DELETE request.
nx_web_http_client_delete_secure_start nx_web_http_client_delete_secure_start(
NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS
ip_address, UINT server_port, CHAR *resource, CHAR
*host, CHAR *username, CHAR *password, UINT
(*tls_setup)(NX_WEB_HTTP_CLIENT *client_ptr,
NX_SECURE_TLS_SESSION *tls_session), ULONG
wait_option);
Start an encrypted HTTPS DELETE request.
nx_web_http_client_get_start nx_web_http_client_get_start(NX_WEB_HTTP_CLIENT
*client_ptr, NXD_ADDRESS ip_address, UINT
server_port, CHAR *resource, CHAR *host, CHAR
*username, CHAR *password, ULONG wait_option);
Start a plaintext HTTP GET request.
nx_web_http_client_get_secure_start nx_web_http_client_get_secure_start( NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS
ip_address, UINT server_port, CHAR *resource, CHAR
*host, CHAR *username, CHAR *password, UINT
(*tls_setup)(NX_WEB_HTTP_CLIENT *client_ptr,
NX_SECURE_TLS_SESSION *tls_session), ULONG
wait_option);
Start an encrypted HTTPS GET request.
nx_web_http_client_head_start nx_web_http_client_head_start(NX_WEB_HTTP_CLIEN
T *client_ptr, NXD_ADDRESS ip_address, UINT
server_port, CHAR *resource, CHAR *host, CHAR
*username, CHAR *password, ULONG wait_option);
Start a plaintext HTTP HEAD request.
nx_web_http_client_head_secure_start nx_web_http_client_head_secure_start(
NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS
ip_address, UINT server_port, CHAR *resource, CHAR
*host, CHAR *username, CHAR *password, UINT
(*tls_setup)(NX_WEB_HTTP_CLIENT *client_ptr,
NX_SECURE_TLS_SESSION *tls_session), ULONG
wait_option);
Start an encrypted HTTPS HEAD request.
nx_web_http_client_post_start nx_web_http_client_post_start(NX_WEB_HTTP_CLIENT
*client_ptr, NXD_ADDRESS ip_address, UINT
server_port, CHAR *resource, CHAR *host, CHAR
*username, CHAR *password, ULONG total_bytes,
ULONG wait_option);
Start an HTTP POST request.
nx_web_http_client_post_secure_start nx_web_http_client_post_secure_start(
NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS
ip_address, UINT server_port, CHAR *resource, CHAR
*host, CHAR *username, CHAR *password, ULONG
total_bytes, UINT (*tls_setup)(NX_WEB_HTTP_CLIENT
*client_ptr, NX_SECURE_TLS_SESSION *tls_session),
ULONG wait_option);
Start an encrypted HTTPS POST request.
nx_web_http_client_put_start nx_web_http_client_put_start(NX_WEB_HTTP_CLIENT
*client_ptr, NXD_ADDRESS ip_address, UINT
server_port, CHAR *resource, CHAR *host, CHAR
*username, CHAR *password, ULONG total_bytes,
ULONG wait_option);
Start an HTTP PUT request.
nx_web_http_client_put_secure_start nx_web_http_client_put_secure_start(
NX_WEB_HTTP_CLIENT *client_ptr, NXD_ADDRESS
ip_address, UINT server_port, CHAR *resource, CHAR
*host, CHAR *username, CHAR *password, ULONG
total_bytes, UINT (*tls_setup)(NX_WEB_HTTP_CLIENT
*client_ptr, NX_SECURE_TLS_SESSION *tls_session),
ULONG wait_option);
Start an encrypted HTTPS PUT request.
nx_web_http_client_put_packet nx_web_http_client_put_packet(NX_WEB_HTTP_CLIEN
T *client_ptr, NX_PACKET *packet_ptr, ULONG
wait_option);
Send next resource data packet.
nx_web_http_client_request_header_add nx_web_http_client_request_header_add(
NX_WEB_HTTP_CLIENT *client_ptr, CHAR *field_name,
UINT name_length, CHAR *field_value, UINT
value_length, UINT wait_option);
Add a custom header to a custom HTTP request.
nx_web_http_client_request_initialize  nx_web_http_client_request_initialize (
NX_WEB_HTTP_CLIENT *client_ptr, UINT method,
CHAR *resource, CHAR *host, UINT input_size, UINT
transfer_encoding_trunked, CHAR *username, CHAR
*password, UINT wait_option);
Initialize a custom HTTP request.
nx_web_http_client_request_send nx_web_http_client_request_send(NX_WEB_HTTP_CLI
ENT *client_ptr, UINT wait_option);
Send a custom HTTP request.
nx_web_http_client_response_body_get nx_web_http_client_response_body_get(
NX_WEB_HTTP_CLIENT *client_ptr, NX_PACKET
**packet_ptr, ULONG wait_option);
Get next resource data packet.
nx_web_http_client_response_header_callback_set nx_web_http_client_response_header_callback_set(
NX_WEB_HTTP_CLIENT *client_ptr, VOID
(*callback_function)(NX_WEB_HTTP_CLIENT
*client_ptr, CHAR *field_name, UINT field_name_length,
CHAR *field_value, UINT field_value_length));
Set callback to invoke when processing HTTP headers.
nx_web_http_client_secure_connect nx_web_http_client_secure_connect(NX_WEB_HTTP_C
LIENT *client_ptr, NXD_ADDRESS *server_ip, UINT
server_port, UINT (*tls_setup)(NX_WEB_HTTP_CLIENT
*client_ptr, NX_SECURE_TLS_SESSION *tls), ULONG
wait_option);
Open a TLS session to an HTTPS server for custom
requests.
Note
For details on operation and definitions for the function data structures, typedefs, defines, API data, API structures and function variables, review the associated Azure RTOS User’s Manual in the References section.            

Status Return Values

Name Description
NX_SUCCESS Successful connection of TCP socket.
NX_PTR_ERROR Invalid pointer input.
NX_WEB_HTTP_NOT_READY Another request is already in progress.
NX_WEB_HTTP_POOL_ERROR Invalid payload size in packet pool
NX_CALLER_ERROR Invalid caller of this service.
NX_HTTP_PASSWORD_TOO_LONG Password exceeded expected length
NX_WEB_HTTP_ERROR Internal HTTP Client error.
NX_WEB_HTTP_NOT_READY HTTP Client not ready.
NX_WEB_HTTP_FAILED HTTP Client error communicating with the HTTP Server.
NX_WEB_HTTP_AUTHENTICATION_ERROR Invalid name and/or password.
NX_WEB_HTTP_USERNAME_TOO_LONG Username too large for buffer.
NX_SIZE_ERROR Invalid total size of resource.
NX_WEB_HTTP_REQUEST_UNSUCCESSFUL_CODE Received Server error code
NX_WEB_HTTP_BAD_PACKET_LENGTH Invalid packet length.
NX_WEB_HTTP_INCOMPLETE_PUT_ERROR Server responds before PUT is complete.
NX_INVALID_PACKET Packet too small for TCP header.
NX_WEB_HTTP_METHOD_ERROR Some required information was missing (e.g. input_size for PUT or POST).
NX_WEB_HTTP_GET_DONE HTTP Client get packet is done.
Note
Lower-level drivers may return common error codes. See SSP User’s Manual API References for the associated module for a definition of all relevant status return values.

NetX Duo Web HTTP/HTTPs Client Module Operational Overview

HTTP (Hyper Text Transport Protocol) is used to exchange hypertext between HTTP client and server. An HTTP client initiates a HTTP request such as Get/POST/HEAD/PUT/DELETE by establishing a TCP connection to particular port on HTTP server e.g. port 80, port 443. An HTTP server listening on that port waits for a client’s request message. Upon receiving the request, the server sends back a status message such as "HTTP/1.1 200 ok" followed by a message of its own.

The NetX Web HTTP/HTTPs client module can be used in the normal mode or secure mode

NetX Web HTTP/HTTPs client module Normal Mode Operational Description

In normal mode, the communication between HTTP client and server is not secure.

Netx Web HTTP/HTTPs client module Secure Mode Operational Description

In Secure mode, the communication between HTTP client and server is secured using the TLS protocol. In the thread pane, TLS protocol is represented by "Add NetX Duo TLS common [Optional]" block as shown in the figure below

nxd_web_http_client_TP.png
NetX Duo Web HTTP/HTTPs Client Module Component Thread-Pane View

Adding NetX Duo TLS Common block enables TLS support and internally defines the NX_SECURE_ENABLE macro. The figure below shows the thread pane view of HTTP client with TLS support enabled.

nxd_web_http_client_SE.png
NetX Duo Web HTTP/HTTPs Client Module Component with TLS Support Enabled

NetX Duo Web HTTP/HTTPs Client Module Important Operational Notes and Limitations

NetX Duo Web HTTP/HTTPs Client Module Operational Notes

The NetX Web HTTP/HTTPs Client component is added by clicking on the (+) sign in the thread pane window -> Azure RTOS -> NetX Duo -> Protocols -> NetX Web HTTP/HTTPs Client.              

Adding the NetX Web HTTP/HTTPs Client component to a project automatically adds the option to add the NetX Duo TLS component required for secure HTTP client.                              

The NetX Web HTTP/HTTPs Client properties are listed in the following table:   

nxd_web_http_client_CP.png
NetX Duo Web HTTP/HTTPs Client Module Component Configurable Properties

In the figure above, "Common" properties are those configurable options in the NetX Web HTTP/HTTPs Client that are common to all instances of the HTTP/HTTPs client in the project. The "Module" properties are specific to each instance of HTTP/HTTPs Client in the project.

Common Properties

  • Parameter Checking: This enables/disables basic HTTP error checking. It is typically used after the application has been debugged. The default value is BSP.
  • Minimum Packet Size (bytes): The minimum size of the packets in the pool specified at Client creation. The minimum size is needed to ensure the complete HTTP header can be contained in one packet. The default value is 300 bytes.
  • HTTPS: This enables/disables TLS which is used to establish secure channel. The default value is disable.

Module Properties

  • Name: Name of the HTTP/HTTPs client instance.
  • TCP socket window size(bytes) : Set the size of client’s TCP socket receive window size. The default is 1024 bytes.
  • Name of generated initialization function: Name of initialization function which creates HTTP/HTTPs client instance. The default is the auto-generated function named web_http_client_init0.
  • Auto Initialization: Enable/disable call to initialization function. This determines if the function specified in the Name of Generated Initialization function option is called. If set to Enable, it will invoke this function. Otherwise if set to Disable, the application must call the nx_web_http_client_create() API before using any NetX Web HTTP/HTTPs Client services.

NetX Duo Web HTTP Common Configurable Properties

The common properties are listed in the following table:

nxd_web_http_client_CC.png
NetX Duo Web HTTP/HTTPs Client Module Component Common Configurable Properties
  • Type of Service: Type of network service required for the HTTP TCP requests. The network service can be of type (Normal, Minimum delay, Maximum data, Maximum reliability, Minimum cost) and the default value is Normal.
  • Fragmentation Option: This enables/disables TCP fragmentation for HTTP client request. The default value is Don’t Fragment.
  • MD5 Support: This enables/disables MD5 digest support required for digest authentication. The default value is disable.
  • Time to live: This specifies maximum no. of routers the HTTP packet can pass through before it get discarded. The default is 128.
  • Maximum password length (bytes): This defines the maximum length of client supplied password. The default is 20.
  • The Maximum username length (bytes): This defines the maximum length of client supplied username. The default is 20.

NetX Duo Web HTTP/HTTPs Client Module Limitations

  • Request pipelining is not supported
  • No content compression is not supported
  • TRACE, OPTIONS, and CONNECT HTTP requests are not supported
  • The packet pool associated with client must be large enough to hold the complete HTTP header
  • Refer to the most recent SSP Release Notes for any additional operational limitations for this module.

Including the NetX Duo Web HTTP/HTTPs Client Module in an Application

This section describes how to include either or both the NetX Duo Web HTTP/HTTPs Client module in an application using the SSP configurator.                                                                    

Note
It is assumed you are familiar with creating a project, adding threads, adding a stack to a thread and configuring a block within the stack. If you are unfamiliar with any of these items, refer to the first few chapters of the SSP User’s Manual to learn how to manage each of these important steps in creating SSP-based applications.

To add the NetX Duo Web HTTP/HTTPs Client module to an application, simply add it to a thread using the stacks selection sequence given in the following table.

NetX Duo Web HTTP/HTTPs Client Module Selection Sequence

Resource ISDE Tab Stacks Selection Sequence
g_web_http_client0 NetX Duo Web HTTP/HTTPs Client Threads New Stack> X-Ware> NetX Duo> Protocols> NetX Duo Web
HTTP/HTTPs Client

When the NetX Duo Web HTTP/HTTPs Client module is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower-level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.  

nxd_web_http_client_MS.png
NetX Duo Web HTTP/HTTPs Client Module Stack

In the stack above, the NetX Duo Network Driver has not been populated yet. There are multiple possible selections for the Network Driver; they are not all provided so as not to needlessly complicate the figure and the following configuration tables. The available options depend on the MCU target, but some typical options include:

  • NetX Duo Port using PPP on nxd_ppp
  • NetX Port ETHER on sf_el_nx
  • NetX Port using Cellular Framework on sf_cellular_nsal_nx
  • NetX Port using PPP on nx_ppp
  • NetX Port using Wi-Fi Framework on sf_wifi_nsal_nx

Configuring the NetX Duo Web HTTP/HTTPs Client Module

The NetX Duo Web HTTP/HTTPs Client module must be configured by the user for the desired operation. The SSP configuration window automatically identifies (by highlighting the block in red) any required configuration selections, such as interrupts or operating modes, which must be configured for lower-level modules for successful operation. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.

Note
You may want to open your ISDE, create the module and explore the property settings in parallel with looking over the following configuration table values. This helps to orient you and can be a useful hands-on approach to learning the ins and outs of developing with SSP.                            

Configuration Settings for the NetX Duo Web HTTP/HTTPs Client Module

ISDE Property Value Description
Parameter Checking Enable, Disable, BSP

Default: BSP
Selects if code for parameter checking is to be included in the build.
Minimum packet size (bytes) 300 Select the minimum packet size in bytes.
HTTPS Support Enable, Disable

Default: Disable
Select whether to enable HTTPS support.
Name g_web_http_client0 Module name.
TCP socket window size (bytes) 1024 Select the TCP socket window size in bytes.
Name of generated initialization web_http_client_init0 Name of generated initialization selection.
Auto Initialization Enable, Disable

Default: Enable
Auto initialization selection.
Note
The example settings and defaults are for a project using the S7G2 Synergy MCU Group. Other MCUs may have different default values and available configuration settings.

In some cases, settings other than the defaults for lower-level modules can be desirable. For example, it might be useful to select different pins for the Ethernet peripheral. The configurable properties for the lower-level stack modules are provided in the following sections for completeness and as a reference.

Note
Most of the property settings for lower-level modules are intuitive and usually can be determined by inspection of the associated properties window from the SSP configurator.

Configuration Settings for the NetX Duo Web HTTP/HTTPs Client Lower-Level Modules

Only a small number of settings must be modified from the default for the IP layer and lower-level drivers as indicated via the red text in the thread stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and are locked to prevent user modification. The following table identifies all the settings within the properties section for the module:                                   

Configuration Settings for the NetX Duo IP Instance

ISDE Property Value Description
Name g_ip0 Module name
IPv4 Address (use commas for separation) 192,168,0,2 IPv4 Address selection
Subnet Mask (use commas for separation) 255,255,255,0 Subnet Mask selection
Default Gateway Address (use commas for separation) 0,0,0,0 Default gateway address selection
IPv6 Global Address (use commas for separation) 0x2001, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1 IPv6 global address selection
IPv6 Link Local Address (use commas for separation, All zeros means use MAC address) 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 IPv6 link local address selection
IP Helper Thread Stack Size (bytes) 2048 IP Helper Thread Stack Size (bytes) selection
IP Helper Thread Priority 3 IP Helper Thread Priority selection
ARP Enable ARP selection
ARP Cache Size in Bytes 512 ARP Cache Size in Bytes selection
Reverse ARP Enable, Disable

Default: Disable
Reverse ARP selection
TCP Enable, Disable

Default: Disable
TCP selection
UDP Enable, Disable

Default: Disable
UDP selection
ICMP Enable, Disable

Default: Disable
ICMP selection
IGMP Enable, Disable

Default: Disable
IGMP selection
IP fragmentation Enable, Disable

Default: Disable
IP fragmentation selection
Name of generated initialization function ip_init0 Name of generated initialization function selection
Auto Initialization Enable, Disable

Default: Enable
Auto initialization function
Link status change callback NULL Link status change callback selection
Note
The example settings and defaults are for a project using the Synergy S7G2 MCU Group. Other MCUs may have different default values and available configuration settings.

Configuration Settings for the NetX Duo Web HTTP Common Instance

ISDE Property Value Description
Type of Service Normal, Minimum delay, Maximum data, Maximum reliability, Minimum cost

Default: Normal
Type of service selection.
Fragmentation option Don't fragment, Fragment okay

Default: Don't fragment
Fragmentation option selection.
MD5 Support Enable, Disable

Default: Disable
MD5 support selection.
Time to live 128 Time to live selection.
Maximum password length (bytes) 20 Maximum password length in bytes.
Maximum username length (bytes) 20 Maximum username length in bytes.
Note
The example settings and defaults are for a project using the S7G2 Synergy MCU Group. Other MCUs may have different default values and available configuration settings.

Configuration Settings for the NetX Duo Common Instance

ISDE Property Value Description
Name of generated initialization function nx_common_init0 Name of generated initialization function selection
Auto Initialization Enable, Disable

Default: Enable
Auto initialization selection
Note
The example settings and defaults are for a project using the S7G2 Synergy MCU Group. Other MCUs may have different default values and available configuration settings.

Configuration Settings for the NetX Duo Packet Pool Instance

ISDE Property Value Description
Name g_packet_pool0 Module name
Packet Size in Bytes 640 Packet size selection
Number of Packets in Pool 16 Number of packets in pool selection
Name of generated initialization function packet_pool_init0 Name of generated initialization
function selection
Auto Initialization Enable, Disable

Default: Enable
Auto initialization selection
Note
The example settings and defaults are for a project using the S7G2 Synergy MCU Group. Other MCUs may have different default values and available configuration settings.

Configuration Settings for the NetX MD5 Instance

ISDE Property Value Description
No configurable properties    
Note
The example settings and defaults are for a project using the S7G2 Synergy MCU Group. Other MCUs may have different default values and available configuration settings.

NetX Duo Web HTTP/HTTPs Client Module Clock Configuration

The ETHERC peripheral module uses the PCLKA as its clock source. The PCLKA frequency is set using the SSP configurator Clock tab prior to a build or by using the CGC interface at run-time.

NetX Duo Web HTTP/HTTPs Client Module Pin Configuration

The ETHERC peripheral module uses pins on the MCU device to communicate to external devices. I/O pins must be selected and configured by the external device as required. The following table illustrates the method for selecting the pins within the SSP configuration window and the subsequent table illustrates an example selection for the I2C pins.

Note
The selected operation mode determines what peripheral signals available and what MCU pins are required.

Pin Selection for the ETHERC Module

Resource ISDE Tab Pin Selection Sequence
ETHERC Pins Select Peripherals > Connectivity:ETHERC > ETHERC1.RMII
Note
The selection sequence assumes ETHERC1 is the desired hardware target for the driver.

Pin Configuration Settings for the ETHERC1

Property Value Description
Operation Mode Disabled, Custom, RMII

Default: Disabled
Select RMII as the Operation Mode for ETHERC1
Pin Group Selection Mixed, _A only

Default: _A only
Pin group selection
REF50CK P701 REF50CK Pin
TXD0 P700 TXD0 Pin
TXD1 P406 TXD1 Pin
TXD_EN P405 TXD_EN Pin
RXD0 P702 RXD0 Pin
RXD1 P703 RXD1 Pin
RX_ER P704 RX_ER Pin
CRS_DV P705 CRS_DV Pin
MDC P403 MDC Pin
MDIO P404 MDIO Pin
Note
The example settings are for a project using the S7G2 Synergy MCU and the SK-S7G2 Kit. Other Synergy MCUs and other Synergy Kits may have different available pin configuration settings.

Using the NetX Duo Web HTTP/HTTPs Client Module in an Application

Once the module has been configured and the files auto generated, the NetX Web HTTP/HTTPs client Module is ready to be used in an application. Note that the auto generated code includes the initialization function with the name specified under the Name of generated initialization function property. This function internally calls the nx_web_http_client_create() API to create a HTTP/HTTPs client instance with the name specified under the Name property. Calls to this initialization function will be enabled or disabled depending the Auto Initialization property value. Once the client instance is created, the typical steps in using the module in an application are: 

  1. The application can connect to a plaintext HTTP server by invoking nx_web_http_client_connect(). If the application needs to use secure connection, it can connect to a secure HTTP server by invoking nx_web_http_client_secure_connect(). Note that application needs to implement the TLS setup callback function for secure connection. If needed, the application can include additional server certificate validation using DNS validation, certificate revocation and certificate policy enforcement. This can be done by invoking nx_secure_tls_session_certificate_callback_set() inside the TLS setup callback function. A reference implementation of TLS setup callback function is provided in Figure 1 of appendix.These APIs just opens a plain or secure connection to server but does not send any request.
  2. After connecting to the server, the client can create a custom HTTP request such as GET by calling nx_web_http_- client_request_initialize().  
  3. The client can add custom header to request created in step 2 by invoking nx_web_http_client_request_header_add()API.   
  4. After connecting to the server, the client can send request to server using nx_web_http_client_request_send() API.
  5. The application can retrieve the response sent by the server by repeatedly calling the nx_web_http_client_response_body_get() API until the entire response is retrieved.
  6. The application should invoke nx_web_http_client_delete() to delete all the resources associated with HTTP client instance.                                      
Note
If the application does not want to create custom requests, then it can use nx_web_http_*_start() APIs to send a standard request. For example, to send a standard GET request to plain text server, the application can use nx_web_http_client_get_start(). Similarly, the application can use nx_web_http_client_get_secure_start() to send a standard GET request over a secure channel to server. The nx_web_http_*_start() APIs internally uses nx_web_http_client_request_initialize() to create and send the desired HTTP request.

 

The following figure illustrates common steps in a typical operational flow diagram:

nxd_web_http_client_TA.png
Flow Diagram of a Typical NetX Duo Web HTTP/HTTPs Client Module Application