AWS IoT Device SDK C:
Platform
Platform portability layer
|
Return to main page ↑ |
Abstraction of network functions used by libraries in this SDK. More...
#include "iot_config.h"
#include <stdint.h>
#include <stdlib.h>
#include "types/iot_platform_types.h"
Go to the source code of this file.
Data Structures | |
struct | IotNetworkInterface_t |
Represents the functions of a network stack. More... | |
struct | IotNetworkServerInfo |
Information on the remote server for connection setup. More... | |
struct | IotNetworkCredentials |
Contains the credentials necessary for connection setup. More... | |
Typedefs | |
typedef void(* | IotNetworkReceiveCallback_t) (IotNetworkConnection_t pConnection, void *pContext) |
Provide an asynchronous notification of incoming network data. More... | |
typedef void(* | IotNetworkCloseCallback_t) (IotNetworkConnection_t pConnection, IotNetworkCloseReason_t reason, void *pContext) |
Provide an asynchronous notification of network closing. More... | |
typedef IotNetworkError_t(* | IotNetworkCreate_t) (IotNetworkServerInfo_t pServerInfo, IotNetworkCredentials_t pCredentialInfo, IotNetworkConnection_t *pConnection) |
Create a new network connection. More... | |
typedef IotNetworkError_t(* | IotNetworkSetReceiveCallback_t) (IotNetworkConnection_t pConnection, IotNetworkReceiveCallback_t receiveCallback, void *pContext) |
Register an IotNetworkReceiveCallback_t. More... | |
typedef IotNetworkError_t(* | IotNetworkSetCloseCallback_t) (IotNetworkConnection_t pConnection, IotNetworkCloseCallback_t closeCallback, void *pContext) |
Register an IotNetworkReceiveCallback_t. More... | |
typedef size_t(* | IotNetworkSend_t) (IotNetworkConnection_t pConnection, const uint8_t *pMessage, size_t messageLength) |
Send data over a return connection. More... | |
typedef size_t(* | IotNetworkReceive_t) (IotNetworkConnection_t pConnection, uint8_t *pBuffer, size_t bytesRequested) |
Block and wait for incoming network data. More... | |
typedef IotNetworkError_t(* | IotNetworkClose_t) (IotNetworkConnection_t pConnection) |
Close a network connection. More... | |
typedef IotNetworkError_t(* | IotNetworkDestroy_t) (IotNetworkConnection_t pConnection) |
Free resources used by a network connection. More... | |
Enumerations | |
enum | IotNetworkError_t { IOT_NETWORK_SUCCESS = 0, IOT_NETWORK_FAILURE, IOT_NETWORK_BAD_PARAMETER, IOT_NETWORK_NO_MEMORY, IOT_NETWORK_SYSTEM_ERROR } |
Return codes for network functions. More... | |
enum | IotNetworkCloseReason_t { IOT_NETWORK_NOT_CLOSED = 0, IOT_NETWORK_SERVER_CLOSED, IOT_NETWORK_TRANSPORT_FAILURE, IOT_NETWORK_CLIENT_CLOSED, IOT_NETWORK_UNKNOWN_CLOSED } |
Disconnect reasons for the network close callback. More... | |
Abstraction of network functions used by libraries in this SDK.
typedef void( * IotNetworkReceiveCallback_t) (IotNetworkConnection_t pConnection, void *pContext) |
Provide an asynchronous notification of incoming network data.
A function with this signature may be set with IotNetworkInterface_t::setReceiveCallback to be invoked when data is available on the network.
[in] | pConnection | The connection on which data is available, defined by the network stack. |
[in] | pContext | The third argument passed to IotNetworkInterface_t::setReceiveCallback. |
typedef void( * IotNetworkCloseCallback_t) (IotNetworkConnection_t pConnection, IotNetworkCloseReason_t reason, void *pContext) |
Provide an asynchronous notification of network closing.
A function with this signature may be set with IotNetworkInterface_t::setCloseCallback to be invoked when the network connection is closed.
[in] | pConnection | The connection that was closed, defined by the network stack. |
[in] | reason | The reason the connection was closed |
[in] | pContext | The third argument passed to IotNetworkInterface_t::setCloseCallback. |
typedef IotNetworkError_t( * IotNetworkCreate_t) (IotNetworkServerInfo_t pServerInfo, IotNetworkCredentials_t pCredentialInfo, IotNetworkConnection_t *pConnection) |
Create a new network connection.
This function allocates resources and establishes a new network connection.
[in] | pServerInfo | Represents information needed to set up the new connection, defined by the network stack. |
[in] | pCredentialInfo | Represents information needed to secure the new connection, defined by the network stack. |
[out] | pConnection | Set to represent a new connection, defined by the network stack. |
typedef IotNetworkError_t( * IotNetworkSetReceiveCallback_t) (IotNetworkConnection_t pConnection, IotNetworkReceiveCallback_t receiveCallback, void *pContext) |
Register an IotNetworkReceiveCallback_t.
Sets an IotNetworkReceiveCallback_t to be called asynchronously when data arrives on the network. The network stack should invoke this function "as if" it were the thread routine of a detached thread.
Each network connection may only have one receive callback at any time. IotNetworkInterface_t::close is expected to remove any active receive callbacks.
[in] | pConnection | The connection to associate with the receive callback. |
[in] | receiveCallback | The function to invoke for incoming network data. |
[in] | pContext | A value to pass as the first parameter to the receive callback. |
typedef IotNetworkError_t( * IotNetworkSetCloseCallback_t) (IotNetworkConnection_t pConnection, IotNetworkCloseCallback_t closeCallback, void *pContext) |
Register an IotNetworkReceiveCallback_t.
Sets an IotNetworkReceiveCallback_t to be called asynchronously when the network connection closes. The network stack should invoke this function "as if" it were the thread routine of a detached thread.
Each network connection may only have one close callback at any time. IotNetworkInterface_t::close is expected to remove any active close callbacks.
[in] | pConnection | The connection to associate with the close callback. |
[in] | receiveCallback | The function to invoke for incoming network close events. |
[in] | pContext | A value to pass as the first parameter to the close callback. |
typedef size_t( * IotNetworkSend_t) (IotNetworkConnection_t pConnection, const uint8_t *pMessage, size_t messageLength) |
Send data over a return connection.
Attempts to transmit messageLength
bytes of pMessage
across the connection represented by pConnection
. Returns the number of bytes actually sent, 0
on failure.
[in] | pConnection | The connection used to send data, defined by the network stack. |
[in] | pMessage | The message to send. |
[in] | messageLength | The length of pMessage . |
0
on failure. typedef size_t( * IotNetworkReceive_t) (IotNetworkConnection_t pConnection, uint8_t *pBuffer, size_t bytesRequested) |
Block and wait for incoming network data.
Wait for a message of size bytesRequested
to arrive on the network and place it in pBuffer
.
[in] | pConnection | The connection to wait on, defined by the network stack. |
[out] | pBuffer | Where to place the incoming network data. This buffer must be at least bytesRequested in size. |
[in] | bytesRequested | How many bytes to wait for. pBuffer must be at least this size. |
bytesRequested
when successful. Any other value may indicate an error. typedef IotNetworkError_t( * IotNetworkClose_t) (IotNetworkConnection_t pConnection) |
Close a network connection.
This function closes the connection, but does not release the resources used by the connection. This allows calls to other networking functions to return an error and handle a closed connection without the risk of crashing. Once it can be guaranteed that pConnection
will no longer be used, the connection can be destroyed with IotNetworkInterface_t::destroy.
In addition to closing the connection, this function should also remove any active receive callback.
[in] | pConnection | The network connection to close, defined by the network stack. |
typedef IotNetworkError_t( * IotNetworkDestroy_t) (IotNetworkConnection_t pConnection) |
Free resources used by a network connection.
This function releases the resources of a closed connection. It should be called after IotNetworkInterface_t::close.
[in] | pConnection | The network connection to destroy, defined by the network stack. |