winc3400 TLS wrapper.
#include <stdbool.h>
#include <string.h>
#include "AWS_SDK/aws_iot_src/utils/aws_iot_error.h"
#include "AWS_SDK/aws_iot_src/utils/aws_iot_log.h"
#include "AWS_SDK/aws_iot_src/protocol/mqtt/aws_iot_embedded_client_wrapper/network_interface.h"
#include "driver/include/m2m_wifi.h"
#include "driver/source/nmasic.h"
#include "socket/include/socket.h"
Macros | |
#define | DNS_REQUEST 25 |
#define | IPV4_BYTE(val, index) ((val >> (index * 8)) & 0xFF) |
Using IP address. More... | |
Functions | |
int | iot_tls_connect (Network *pNetwork, TLSConnectParams params) |
TLS connection functionality. More... | |
int | iot_tls_destroy (Network *pNetwork) |
TLS interface de-init function. More... | |
void | iot_tls_disconnect (Network *pNetwork) |
TLS disconnect function. More... | |
int | iot_tls_init (Network *pNetwork) |
Intialization of network interface for TLS function. More... | |
int | iot_tls_is_connected (Network *pNetwork) |
TLS connection status call. More... | |
int | iot_tls_read (Network *pNetwork, unsigned char *pMsg, int len, int timeout_ms) |
Read bytes from the network socket. More... | |
int | iot_tls_write (Network *pNetwork, unsigned char *pMsg, int len, int timeout_ms) |
TLS write functionality. More... | |
static void | resolve_cb (uint8_t *hostName, uint32_t hostIp) |
Callback function of IP address. More... | |
static void | socket_cb (SOCKET sock, uint8_t u8Msg, void *pvMsg) |
Callback function of TCP client socket. More... | |
static void | wait_for_event (uint8_t msg) |
Event handling function for WIFI. More... | |
Variables | |
static uint8_t * | buf_ptr = &gau8SocketTestBuffer |
static int8_t | err = 0 |
static uint8_t | gau8SocketTestBuffer [1460] |
static bool | gbHostIpByName = false |
Get host IP status variable. More... | |
uint32_t | gu32HostIp = 0 |
IP address of host. More... | |
volatile uint32_t | ms_ticks |
TLS read functionality. More... | |
uint32_t | received_bytes = 0 |
uint32_t | sent_bytes = 0 |
static int8_t | state = -1 |
#define DNS_REQUEST 25 |
Referenced by iot_tls_connect(), and resolve_cb().
#define IPV4_BYTE | ( | val, | |
index | |||
) | ((val >> (index * 8)) & 0xFF) |
Using IP address.
Referenced by resolve_cb().
int iot_tls_connect | ( | Network * | pNetwork, |
TLSConnectParams | params | ||
) |
TLS connection functionality.
Create a TLS socket and open the connection.
[in] | pNetwork | Network interface. |
[in] | params | connection parameters for TLS. |
Referenced by iot_tls_init().
int iot_tls_destroy | ( | Network * | pNetwork | ) |
TLS interface de-init function.
Perform any tear-down or cleanup of TLS layer.
[in] | pNetwork | Network interface. |
Referenced by iot_tls_init().
void iot_tls_disconnect | ( | Network * | pNetwork | ) |
TLS disconnect function.
Disconnect from network socket.
[in] | pNetwork | Network interface. |
Referenced by iot_tls_init().
int iot_tls_init | ( | Network * | pNetwork | ) |
Intialization of network interface for TLS function.
Initialize the TLS implementation.
[in] | pNetwork | Network interface. |
Referenced by aws_iot_mqtt_connect().
int iot_tls_is_connected | ( | Network * | pNetwork | ) |
TLS connection status call.
Check if TLS layer is still connected.
[in] | pNetwork | Network interface. |
Referenced by iot_tls_init().
int iot_tls_read | ( | Network * | , |
unsigned char * | , | ||
int | , | ||
int | |||
) |
Read bytes from the network socket.
Network | - Pointer to a Network struct defining the network interface. |
unsigned | char pointer - pointer to buffer where read bytes should be copied |
integer | - number of bytes to read |
integer | - read timeout value in milliseconds |
Referenced by iot_tls_init().
int iot_tls_write | ( | Network * | pNetwork, |
unsigned char * | pMsg, | ||
int | len, | ||
int | timeout_ms | ||
) |
TLS write functionality.
Write bytes to the network socket.
[in] | pNetwork | Network interface. |
[in] | pMsg | data to write |
[in] | len | length of data. |
[in] | timeout_ms | timeout for write function. |
Referenced by iot_tls_init().
|
static |
Callback function of IP address.
[in] | hostName | Domain name. |
[in] | hostIp | Server IP. |
References DNS_REQUEST, gbHostIpByName, gu32HostIp, IPV4_BYTE, printf, and state.
Referenced by iot_tls_init().
|
static |
Callback function of TCP client socket.
[in] | sock | socket handler. |
[in] | u8Msg | Type of Socket notification |
[in] | pvMsg | A structure contains notification informations. |
References err, get_alpn_index(), printf, received_bytes, tstrSocketRecvMsg::s16BufferSize, tstrSocketConnectMsg::s8Error, sent_bytes, tstrSocketConnectMsg::sock, SOCK_ERR_NO_ERROR, SOCKET_MSG_CONNECT, SOCKET_MSG_RECV, SOCKET_MSG_SEND, and state.
Referenced by iot_tls_init().
|
static |
Event handling function for WIFI.
[in] | pvMsg | A structure contains notification informations. |
References m2m_wifi_handle_events(), NULL, and state.
Referenced by iot_tls_connect(), iot_tls_read(), and iot_tls_write().
|
static |
|
static |
|
static |
Referenced by iot_tls_read().
Get host IP status variable.
Referenced by resolve_cb().
uint32_t gu32HostIp = 0 |
IP address of host.
volatile uint32_t ms_ticks |
TLS read functionality.
[in] | pNetwork | Network interface. |
[in] | pMsg | store the data read |
[in] | len | length of data. |
[in] | timeout_ms | timeout for write function. |
TLS read functionality.
SysTick counter for non busy wait delay.
uint32_t received_bytes = 0 |
Referenced by iot_tls_read(), and socket_cb().
uint32_t sent_bytes = 0 |
Referenced by iot_tls_write(), and socket_cb().
|
static |