BSD Sockets#
Functions#
Create a web socket client. This is a blocking API.
Send data from the web socket client. This is a non-blocking API.
Close the web socket client. This is a non-blocking API.
Set the network application protocols configuration. This is a non-blocking API.
Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.
Get socket descriptor from port_number.
This is a non-blocking API.
Calculate number of buffers required for the data packet.
This is a non-blocking API.
Calculate the length available in the buffers for the message. This is a non-blocking API.
Set the socket configuration parameters. The configurations can be done using the Socket configuration in the rsi_wlan_config.h file.
Using this API is highly recommended. Based on the socket configuration, module will use available buffers effectively.
This is a blocking API.
Function Documentation#
rsi_web_socket_create#
int32_t rsi_web_socket_create (int8_t flags, uint8_t * server_ip_addr, uint16_t server_port, uint16_t device_port, uint8_t * webs_resource_name, uint8_t * webs_host_name, int32_t * socket_id, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) web_socket_data_receive_notify_callback, sock_no, buffer, length)
Create a web socket client. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| int8_t | [in] | flags | - Select IP version and security |
| uint8_t * | [in] | server_ip_addr | - Web server IP address |
| uint16_t | [in] | server_port | - Web server socket port |
| uint16_t | [in] | device_port | - Local port |
| uint8_t * | [in] | webs_resource_name | - Web resource name |
| uint8_t * | [in] | webs_host_name | - Web host name |
| int32_t * | [in] | socket_id | - Socket ID |
| void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) | [in] | web_socket_data_receive_notify_callback | - Callback when data packet is received on the created socket |
| [out] | sock_no | - Application socket ID | |
| [out] | buffer | - Buffer pointer | |
| [out] | length | - Length of data |
Returns
0 - Success
Negative Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffc)
Note
Precondition - rsi_config_ipaddress() API needs to be called before this API.
Refer to Error Codes for the description of above error codes.
rsi_web_socket_send_async#
int32_t rsi_web_socket_send_async (int32_t sockID, uint8_t opcode, int8_t * msg, int32_t msg_length)
Send data from the web socket client. This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| int32_t | [in] | sockID | - Application socket ID |
| uint8_t | [in] | opcode | - Type of the packet to be included in web socket header |
| int8_t * | [in] | msg | - Data |
| int32_t | [in] | msg_length | - Data length |
Returns
0 - Success
Negative Value - Failure
Note
Precondition - rsi_config_ipaddress() API needs to be called before this API.
rsi_web_socket_close#
int32_t rsi_web_socket_close (int32_t sockID)
Close the web socket client. This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| int32_t | [in] | sockID | - Socket ID of particular socket |
Returns
0 - Success
Negative Value - Failure
Note
Precondition - rsi_config_ipaddress() API needs to be called before this API
rsi_network_app_protocol_config#
uint32_t rsi_network_app_protocol_config (nw_app_protocol protocol, nw_app_config config_type, void * config, uint16_t config_length)
Set the network application protocols configuration. This is a non-blocking API.
| Type | Direction | Argument Name | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| nw_app_protocol | [in] | protocol | - The following table lists in below
| ||||||
| nw_app_config | [in] | config_type | - The following table lists in below
| ||||||
| void * | [in] | config | - The following table lists in below
| ||||||
| uint16_t | [in] | config_length | - Length of the config parameter |
rsi_network_app_protocol_config() API needs to be called after only.
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xffffff82)
Note
Precondition - rsi_config_ipaddress() API needs to be called before this API.
Examples : rsi_network_app_protocol_config(RSI_HTTP, RSI_CIPHER_SELECTION, &cipher_value, 4);
cipher_value : (SSL_NEW_CIPHERS | BIT_DHE_RSA_GCM | BIT_ECDHE_RSA_GCM )RSI_WLAN_REQ_NWK_APP_PROTOCOL_CONFIG is introduced to pass network application configurations to firmware.
ROM_WL_rsi_get_application_socket_descriptor#
int32_t ROM_WL_rsi_get_application_socket_descriptor (global_cb_t * global_cb_p, int32_t sock_id)
Get the application socket descriptor from module’s socket descriptor. This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| global_cb_t * | [in] | global_cb_p | - Pointer to the global control block |
| int32_t | [in] | sock_id | - Module's socket descriptor |
Returns
Positive value - Application socket descriptor
Negative value - If socket is not found
ROM_WL_rsi_get_primary_socket_id#
int32_t ROM_WL_rsi_get_primary_socket_id (global_cb_t * global_cb_p, uint16_t port_number)
Get socket descriptor from port_number.
This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| global_cb_t * | [in] | global_cb_p | - Pointer to the global control block |
| uint16_t | [in] | port_number | - Port number |
Returns
Positive value - Socket descriptor
Negative value - If socket is not found
ROM_WL_calculate_buffers_required#
uint8_t ROM_WL_calculate_buffers_required (global_cb_t * global_cb_p, uint8_t type, uint16_t length)
Calculate number of buffers required for the data packet.
This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| global_cb_t * | [in] | global_cb_p | - Pointer to the global control block |
| uint8_t | [in] | type | - Type of socket to create |
| uint16_t | [in] | length | - Length of the message |
Returns
Number of buffers required for the data packet
ROM_WL_calculate_length_to_send#
uint16_t ROM_WL_calculate_length_to_send (global_cb_t * global_cb_p, uint8_t type, uint8_t buffers)
Calculate the length available in the buffers for the message. This is a non-blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| global_cb_t * | [in] | global_cb_p | - Pointer to the global control block |
| uint8_t | [in] | type | - Type of the socket stream |
| uint8_t | [in] | buffers | - Available buffers |
Returns
Length available in the buffers for message
rsi_socket_config#
int32_t rsi_socket_config (void )
Set the socket configuration parameters. The configurations can be done using the Socket configuration in the rsi_wlan_config.h file.
Using this API is highly recommended. Based on the socket configuration, module will use available buffers effectively.
This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0x0021, 0x0025, 0x002C, 0xFF6D)
Note
Precondition - rsi_config_ipaddress() API and socket creation should be done before this API is called.
The following parameters are provided by user,
Parameters
Description
total socket
Desired total number of sockets to open
total_tcp_sockets
Desired total number of TCP sockets to open
total_udp_sockets
Desired total number of UDP sockets to open
tcp_tx_only_sockets
Desired total number of TCP sockets to open which are used only for data transmission
tcp_rx_only_sockets
Desired total number of TCP sockets to open which are used only for data reception
udp_tx_only_sockets
Desired total number of UDP sockets to open which are used only for data transmission
udp_rx_only_sockets
Desired total number of UDP sockets to open which are used only for data reception
tcp_rx_high_performance_sockets
Desired total number of high performance TCP sockets to open. High performance sockets can be
^ allocated with more buffers based on the buffers availability. This option is valid only for TCP
^ data receive sockets. Socket can be opened as high performance by setting high performance bit in
^ socket create command. tcp_rx_window_size_cap | Desired total to increase the TCP RX window size tcp_ack_window_div_factor | In case of high latency networks to configure the TCP ACK division factor with respective to the
^ window size; Increases the ACK frequency for asynchronous sockets
^ Note:
^ Default value is tcp_rx_window_size_cap.The following conditions must be met:
total_sockets <= Maximum allowed sockets(10)
(total_tcp_sockets + total_udp_sockets) <= total_sockets
(total_tcp_tx_only_sockets + total_tcp_rx_only_sockets) <= total_tcp_sockets
(total_udp_tx_only_sockets + total_udp_rx_only_sockets) <= total_udp_sockets
total_tcp_rx_high_performance_sockets <= total_tcp_rx_only_sockets
Refer to Error Codes for the description of above error codes.