LibAwsMqtt

Documentation for LibAwsMqtt.

LibAwsMqtt.aws_mqtt5_client_inbound_topic_alias_behavior_typeType
aws_mqtt5_client_inbound_topic_alias_behavior_type

Inbound topic aliasing behavior is controlled by this type.

Topic alias behavior is described in https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113

This setting controls whether or not the client will send a positive topic alias maximum to the server in its CONNECT packets.

If topic aliasing is not supported by the server, this setting has no net effect.

source
LibAwsMqtt.aws_mqtt5_client_operation_queue_behavior_typeType
aws_mqtt5_client_operation_queue_behavior_type

Controls how disconnects affect the queued and in-progress operations submitted to the client. Also controls how operations are handled while the client is not connected. In particular, if the client is not connected, then any operation that would be failed on disconnect (according to these rules) will be rejected.

source
LibAwsMqtt.aws_mqtt5_client_optionsType
aws_mqtt5_client_options

Basic mqtt5 client configuration struct.

Contains desired connection properties Configuration that represents properties of the mqtt5 CONNECT packet go in the connect view (connect_options)

source
LibAwsMqtt.aws_mqtt5_client_outbound_topic_alias_behavior_typeType
aws_mqtt5_client_outbound_topic_alias_behavior_type

Outbound topic aliasing behavior is controlled by this type.

Topic alias behavior is described in https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113

If the server allows topic aliasing, this setting controls how topic aliases are used on PUBLISH packets sent from the client to the server.

If topic aliasing is not supported by the server, this setting has no effect and any attempts to directly manipulate the topic alias id in outbound publishes will be ignored.

source
LibAwsMqtt.aws_mqtt5_connect_reason_codeType
aws_mqtt5_connect_reason_code

Server return code for CONNECT attempts. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901079

source
LibAwsMqtt.aws_mqtt5_disconnect_reason_codeType
aws_mqtt5_disconnect_reason_code

Reason code inside DISCONNECT packets. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208

source
LibAwsMqtt.aws_mqtt5_extended_validation_and_flow_control_optionsType
aws_mqtt5_extended_validation_and_flow_control_options

Extended validation and flow control options

Potentially a point of expansion in the future. We could add custom controls letting people override the Aws IOT Core limits based on their account properties. We could, with IoT Core support, add dynamic limit recognition via user properties as well.

source
LibAwsMqtt.aws_mqtt5_packet_id_tType

Over-the-wire packet id as defined in the mqtt spec. Allocated at the point in time when the packet is is next to go down the channel and about to be encoded into an io message buffer.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901026

source
LibAwsMqtt.aws_mqtt5_packet_publish_viewType
aws_mqtt5_packet_publish_view

Read-only snapshot of a PUBLISH packet. Used both in configuration of a publish operation and callback data in message receipt.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901100

source
LibAwsMqtt.aws_mqtt5_packet_typeType
aws_mqtt5_packet_type

Type of mqtt packet. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901022

source
LibAwsMqtt.aws_mqtt5_payload_format_indicatorType
aws_mqtt5_payload_format_indicator

Optional property describing a message's payload format. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063

source
LibAwsMqtt.aws_mqtt5_puback_reason_codeType
aws_mqtt5_puback_reason_code

Reason code inside PUBACK packets. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901124

source
LibAwsMqtt.aws_mqtt5_qosType
aws_mqtt5_qos

MQTT Message delivery quality of service. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901234

source
LibAwsMqtt.aws_mqtt5_retain_handling_typeType
aws_mqtt5_retain_handling_type

Configures how retained messages should be handled when subscribing with a topic filter that matches topics with associated retained messages.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169

source
LibAwsMqtt.aws_mqtt5_suback_reason_codeType
aws_mqtt5_suback_reason_code

Reason code inside SUBACK packet payloads. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901178

source
LibAwsMqtt.aws_mqtt5_unsuback_reason_codeType
aws_mqtt5_unsuback_reason_code

Reason code inside UNSUBACK packet payloads. Enum values match mqtt spec encoding values.

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194

source
LibAwsMqtt.aws_mqtt_client_on_connection_complete_fnType

Called when a connection attempt is completed, either in success or error.

If error code is AWS_ERROR_SUCCESS, then a CONNACK has been received from the server and return_code and session_present contain the values received. If error_code is not AWS_ERROR_SUCCESS, it refers to the internal error that occurred during connection, and return_code and session_present are invalid.

source
LibAwsMqtt.aws_mqtt_client_publish_received_fnType

Called when a publish message is received.

Arguments

  • connection:[in] The connection object
  • topic:[in] The information channel to which the payload data was published.
  • payload:[in] The payload data.
  • dup:[in] DUP flag. If true, this might be re-delivery of an earlier attempt to send the message.
  • qos:[in] Quality of Service used to deliver the message.
  • retain:[in] Retain flag. If true, the message was sent as a result of a new subscription being made by the client.
source
LibAwsMqtt.aws_mqtt_connection_optionsType
aws_mqtt_connection_options

host_name The server name to connect to. This resource may be freed immediately on return. port The port on the server to connect to client_id The clientid to place in the CONNECT packet. socket_options The socket options to pass to the aws_client_bootstrap functions. This is copied into the connection tls_options TLS settings to use when opening a connection. This is copied into the connection Pass NULL to connect without TLS (NOT RECOMMENDED) clean_session True to discard all server session data and start fresh keep_alive_time_secs The keep alive value to place in the CONNECT PACKET, a PING will automatically be sent at this interval as well. If you specify 0, defaults will be used and a ping will be sent once per 20 minutes. This duration must be longer than ping_timeout_ms. ping_timeout_ms Network connection is re-established if a ping response is not received within this amount of time (milliseconds). If you specify 0, a default value of 3 seconds is used. Alternatively, tcp keep-alive may be away to accomplish this in a more efficient (low-power) scenario, but keep-alive options may not work the same way on every platform and OS version. This duration must be shorter than keep_alive_time_secs. protocol_operation_timeout_ms Timeout when waiting for the response to some operation requires response by protocol. Set to zero to disable timeout. Otherwise, the operation will fail with error AWS_ERROR_MQTT_TIMEOUT if no response is received within this amount of time after the packet is written to the socket. The timer is reset if the connection is interrupted. It applied to PUBLISH (QoS>0) and UNSUBSCRIBE now. Note: While the MQTT 3 specification states that a broker MUST respond, some brokers are known to ignore publish packets in exceptional circumstances (e.g. AWS IoT Core will not respond if the publish quota is exceeded). on_connection_complete The callback to fire when the connection attempt completes user_data Passed to the userdata param of on_connection_complete

source
LibAwsMqtt.aws_mqtt_suback_fnType

Called when a single-topic subscription request is complete. Note: If the qos value is AWS_MQTT_QOS_FAILURE, then the subscription was rejected by the broker.

source
LibAwsMqtt.aws_mqtt_suback_multi_fnType

Called when a multi-topic subscription request is complete. Note: If any topic_suback's qos value is AWS_MQTT_QOS_FAILURE, then that topic subscription was rejected by the broker.

source
LibAwsMqtt.aws_mqtt_transform_websocket_handshake_fnType

Function that may transform the websocket handshake request. Called each time a websocket connection is attempted.

The default request uses path "/mqtt". All required headers are present, plus the optional header "Sec-WebSocket-Protocol: mqtt".

The user MUST invoke the complete_fn when transformation is complete or the application will soft-lock. When invoking the complete_fn, pass along the request and complete_ctx provided here and an error code. The error code should be AWS_ERROR_SUCCESS if transformation was successful, otherwise pass a different AWS_ERROR_X value.

source
LibAwsMqtt.aws_mqtt_validate_websocket_handshake_fnType

Function that may accept or reject a websocket handshake response. Called each time a valid websocket connection is established.

All required headers have been checked already (ex: "Sec-Websocket-Accept"),

Return AWS_OP_SUCCESS to accept the connection or AWS_OP_ERR to stop the connection attempt.

source
LibAwsMqtt.aws_mqtt5_client_acquireMethod
aws_mqtt5_client_acquire(client)

Acquires a reference to an mqtt5 client

Arguments

  • client: client to acquire a reference to. May be NULL.

Returns

what was passed in as the client (a client or NULL)

Prototype

struct aws_mqtt5_client *aws_mqtt5_client_acquire(struct aws_mqtt5_client *client);
source
LibAwsMqtt.aws_mqtt5_client_get_statsMethod
aws_mqtt5_client_get_stats(client, stats)

Queries the client's internal statistics for incomplete operations.

Arguments

  • client: client to get statistics for
  • stats: set of incomplete operation statistics

Prototype

void aws_mqtt5_client_get_stats(struct aws_mqtt5_client *client, struct aws_mqtt5_client_operation_statistics *stats);
source
LibAwsMqtt.aws_mqtt5_client_newMethod
aws_mqtt5_client_new(allocator, options)

Creates a new mqtt5 client using the supplied configuration

Arguments

  • allocator: allocator to use with all memory operations related to this client's creation and operation
  • options: mqtt5 client configuration

Returns

a new mqtt5 client or NULL

Prototype

struct aws_mqtt5_client *aws_mqtt5_client_new( struct aws_allocator *allocator, const struct aws_mqtt5_client_options *options);
source
LibAwsMqtt.aws_mqtt5_client_publishMethod
aws_mqtt5_client_publish(client, publish_options, completion_options)

Queues a Publish operation in an mqtt5 client

Arguments

  • client: mqtt5 client to queue a Publish for
  • publish_options: configuration options for the Publish operation
  • completion_options: completion callback configuration. Successful QoS 0 publishes invoke the callback when the data has been written to the socket. Successful QoS1+ publishes invoke the callback when the corresponding ack is received. Unsuccessful publishes invoke the callback at the point in time a failure condition is reached.

Returns

success/failure in the synchronous logic that kicks off the publish operation

Prototype

int aws_mqtt5_client_publish( struct aws_mqtt5_client *client, const struct aws_mqtt5_packet_publish_view *publish_options, const struct aws_mqtt5_publish_completion_options *completion_options);
source
LibAwsMqtt.aws_mqtt5_client_releaseMethod
aws_mqtt5_client_release(client)

Release a reference to an mqtt5 client. When the client ref count drops to zero, the client will automatically trigger a stop and once the stop completes, the client will delete itself.

Arguments

  • client: client to release a reference to. May be NULL.

Returns

NULL

Prototype

struct aws_mqtt5_client *aws_mqtt5_client_release(struct aws_mqtt5_client *client);
source
LibAwsMqtt.aws_mqtt5_client_startMethod
aws_mqtt5_client_start(client)

Asynchronous notify to the mqtt5 client that you want it to attempt to connect to the configured endpoint. The client will attempt to stay connected using the properties of the reconnect-related parameters in the mqtt5 client configuration.

Arguments

  • client: mqtt5 client to start

Returns

success/failure in the synchronous logic that kicks off the start process

Prototype

int aws_mqtt5_client_start(struct aws_mqtt5_client *client);
source
LibAwsMqtt.aws_mqtt5_client_stopMethod
aws_mqtt5_client_stop(client, disconnect_options, completion_options)

Asynchronous notify to the mqtt5 client that you want it to transition to the stopped state. When the client reaches the stopped state, all session state is erased.

Arguments

  • client: mqtt5 client to stop
  • disconnect_options: (optional) properties of a DISCONNECT packet to send as part of the shutdown process

Returns

success/failure in the synchronous logic that kicks off the stop process

Prototype

int aws_mqtt5_client_stop( struct aws_mqtt5_client *client, const struct aws_mqtt5_packet_disconnect_view *disconnect_options, const struct aws_mqtt5_disconnect_completion_options *completion_options);
source
LibAwsMqtt.aws_mqtt5_client_subscribeMethod
aws_mqtt5_client_subscribe(client, subscribe_options, completion_options)

Queues a Subscribe operation in an mqtt5 client

Arguments

  • client: mqtt5 client to queue a Subscribe for
  • subscribe_options: configuration options for the Subscribe operation
  • completion_options: Completion callback configuration. Invoked when the corresponding SUBACK is received or a failure condition is reached. An error code implies complete failure of the subscribe, while a success code implies the user must still check all of the SUBACK's reason codes for per-subscription feedback.

Returns

success/failure in the synchronous logic that kicks off the Subscribe operation

Prototype

int aws_mqtt5_client_subscribe( struct aws_mqtt5_client *client, const struct aws_mqtt5_packet_subscribe_view *subscribe_options, const struct aws_mqtt5_subscribe_completion_options *completion_options);
source
LibAwsMqtt.aws_mqtt5_client_unsubscribeMethod
aws_mqtt5_client_unsubscribe(client, unsubscribe_options, completion_options)

Queues an Unsubscribe operation in an mqtt5 client

Arguments

  • client: mqtt5 client to queue an Unsubscribe for
  • unsubscribe_options: configuration options for the Unsubscribe operation
  • completion_options: Completion callback configuration. Invoked when the corresponding UNSUBACK is received or a failure condition is reached. An error code implies complete failure of the unsubscribe, while a success code implies the user must still check all of the UNSUBACK's reason codes for per-topic-filter feedback.

Returns

success/failure in the synchronous logic that kicks off the Unsubscribe operation

Prototype

int aws_mqtt5_client_unsubscribe( struct aws_mqtt5_client *client, const struct aws_mqtt5_packet_unsubscribe_view *unsubscribe_options, const struct aws_mqtt5_unsubscribe_completion_options *completion_options);
source
LibAwsMqtt.aws_mqtt5_listener_acquireMethod
aws_mqtt5_listener_acquire(listener)

Adds a reference to an mqtt5 listener.

Arguments

  • listener: listener to add a reference to

Returns

the listener object

Prototype

struct aws_mqtt5_listener *aws_mqtt5_listener_acquire(struct aws_mqtt5_listener *listener);
source
LibAwsMqtt.aws_mqtt5_listener_newMethod
aws_mqtt5_listener_new(allocator, config)

Creates a new MQTT5 listener object. For as long as the listener lives, incoming publishes and lifecycle events will be forwarded to the callbacks configured on the listener.

Arguments

  • allocator: allocator to use
  • config: listener configuration

Returns

a new aws_mqtt5_listener object

Prototype

struct aws_mqtt5_listener *aws_mqtt5_listener_new( struct aws_allocator *allocator, struct aws_mqtt5_listener_config *config);
source
LibAwsMqtt.aws_mqtt5_listener_releaseMethod
aws_mqtt5_listener_release(listener)

Removes a reference to an mqtt5 listener. When the reference count drops to zero, the listener's asynchronous destruction will be started.

Arguments

  • listener: listener to remove a reference from

Returns

NULL

Prototype

struct aws_mqtt5_listener *aws_mqtt5_listener_release(struct aws_mqtt5_listener *listener);
source
LibAwsMqtt.aws_mqtt5_negotiated_settings_clean_upMethod
aws_mqtt5_negotiated_settings_clean_up(negotiated_settings)

Clean up owned memory in negotiated_settings

Arguments

  • negotiated_settings: settings to clean up

Prototype

void aws_mqtt5_negotiated_settings_clean_up(struct aws_mqtt5_negotiated_settings *negotiated_settings);
source
LibAwsMqtt.aws_mqtt5_negotiated_settings_copyMethod
aws_mqtt5_negotiated_settings_copy(source, dest)

Makes an owning copy of a negotiated settings structure.

Used in downstream.

Arguments

  • source: settings to copy from
  • dest: settings to copy into. Must be in a zeroed or initialized state because it gets clean up called on it as the first step of the copy process.

Returns

success/failure

Prototype

int aws_mqtt5_negotiated_settings_copy( const struct aws_mqtt5_negotiated_settings *source, struct aws_mqtt5_negotiated_settings *dest);
source
LibAwsMqtt.aws_mqtt5_negotiated_settings_initMethod
aws_mqtt5_negotiated_settings_init(allocator, negotiated_settings, client_id)

Initializes the Client ID byte buf in negotiated settings

Arguments

  • allocator: allocator to use for memory allocation
  • negotiated_settings: settings to apply client id to
  • client_id: client id to set

Prototype

int aws_mqtt5_negotiated_settings_init( struct aws_allocator *allocator, struct aws_mqtt5_negotiated_settings *negotiated_settings, const struct aws_byte_cursor *client_id);
source
LibAwsMqtt.aws_mqtt5_packet_connack_storage_initMethod
aws_mqtt5_packet_connack_storage_init(connack_storage, allocator, connack_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_connack_storage_init( struct aws_mqtt5_packet_connack_storage *connack_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_connack_view *connack_options);
source
LibAwsMqtt.aws_mqtt5_packet_connect_storage_initMethod
aws_mqtt5_packet_connect_storage_init(connect_storage, allocator, connect_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_connect_storage_init( struct aws_mqtt5_packet_connect_storage *connect_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_connect_view *connect_options);
source
LibAwsMqtt.aws_mqtt5_packet_disconnect_storage_initMethod
aws_mqtt5_packet_disconnect_storage_init(disconnect_storage, allocator, disconnect_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_disconnect_storage_init( struct aws_mqtt5_packet_disconnect_storage *disconnect_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_disconnect_view *disconnect_options);
source
LibAwsMqtt.aws_mqtt5_packet_puback_storage_initMethod
aws_mqtt5_packet_puback_storage_init(puback_storage, allocator, puback_view)

Documentation not found.

Prototype

int aws_mqtt5_packet_puback_storage_init( struct aws_mqtt5_packet_puback_storage *puback_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_puback_view *puback_view);
source
LibAwsMqtt.aws_mqtt5_packet_publish_storage_initMethod
aws_mqtt5_packet_publish_storage_init(publish_storage, allocator, publish_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_publish_storage_init( struct aws_mqtt5_packet_publish_storage *publish_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_publish_view *publish_options);
source
LibAwsMqtt.aws_mqtt5_packet_suback_storage_initMethod
aws_mqtt5_packet_suback_storage_init(suback_storage, allocator, suback_view)

Documentation not found.

Prototype

int aws_mqtt5_packet_suback_storage_init( struct aws_mqtt5_packet_suback_storage *suback_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_suback_view *suback_view);
source
LibAwsMqtt.aws_mqtt5_packet_subscribe_storage_initMethod
aws_mqtt5_packet_subscribe_storage_init(subscribe_storage, allocator, subscribe_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_subscribe_storage_init( struct aws_mqtt5_packet_subscribe_storage *subscribe_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_subscribe_view *subscribe_options);
source
LibAwsMqtt.aws_mqtt5_packet_unsuback_storage_initMethod
aws_mqtt5_packet_unsuback_storage_init(unsuback_storage, allocator, unsuback_view)

Documentation not found.

Prototype

int aws_mqtt5_packet_unsuback_storage_init( struct aws_mqtt5_packet_unsuback_storage *unsuback_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_unsuback_view *unsuback_view);
source
LibAwsMqtt.aws_mqtt5_packet_unsubscribe_storage_initMethod
aws_mqtt5_packet_unsubscribe_storage_init(unsubscribe_storage, allocator, unsubscribe_options)

Documentation not found.

Prototype

int aws_mqtt5_packet_unsubscribe_storage_init( struct aws_mqtt5_packet_unsubscribe_storage *unsubscribe_storage, struct aws_allocator *allocator, const struct aws_mqtt5_packet_unsubscribe_view *unsubscribe_options);
source
LibAwsMqtt.aws_mqtt5_user_property_set_init_with_storageMethod
aws_mqtt5_user_property_set_init_with_storage(property_set, allocator, storage_buffer, property_count, properties)

Documentation not found.

Prototype

int aws_mqtt5_user_property_set_init_with_storage( struct aws_mqtt5_user_property_set *property_set, struct aws_allocator *allocator, struct aws_byte_buf *storage_buffer, size_t property_count, const struct aws_mqtt5_user_property *properties);
source
LibAwsMqtt.aws_mqtt_client_acquireMethod
aws_mqtt_client_acquire(client)

Increments the ref count to an mqtt client, allowing the caller to take a reference to it

Arguments

  • client:[in] The client to increment the ref count on

Returns

the mqtt client

Prototype

struct aws_mqtt_client *aws_mqtt_client_acquire(struct aws_mqtt_client *client);
source
LibAwsMqtt.aws_mqtt_client_connection_acquireMethod
aws_mqtt_client_connection_acquire(connection)

Increments the ref count to an mqtt client connection, allowing the caller to take a reference to it

Arguments

  • connection:[in] The connection object

Returns

the mqtt connection

Prototype

struct aws_mqtt_client_connection *aws_mqtt_client_connection_acquire(struct aws_mqtt_client_connection *connection);
source
LibAwsMqtt.aws_mqtt_client_connection_connectMethod
aws_mqtt_client_connection_connect(connection, connection_options)

Opens the actual connection defined by aws_mqtt_client_connection_new. Once the connection is opened, on_connack will be called. Only called when connection is disconnected.

Arguments

  • connection:[in] The connection object
  • connection_options:[in] Configuration information for the connection attempt

Returns

AWS_OP_SUCCESS if the connection has been successfully initiated, otherwise AWS_OP_ERR and aws_last_error() will be set.

Prototype

int aws_mqtt_client_connection_connect( struct aws_mqtt_client_connection *connection, const struct aws_mqtt_connection_options *connection_options);
source
LibAwsMqtt.aws_mqtt_client_connection_disconnectMethod
aws_mqtt_client_connection_disconnect(connection, on_disconnect, userdata)

Closes the connection asynchronously, calls the on_disconnect callback. All uncompleted requests (publish/subscribe/unsubscribe) will be cancelled, regardless to the status of clean_session. DISCONNECT packet will be sent, which deletes the will message from server.

Arguments

  • connection:[in] The connection to close
  • on_disconnect:[in] (nullable) Callback function to invoke when the connection is completely disconnected.
  • userdata:[in] (nullable) passed to on_disconnect

Returns

AWS_OP_SUCCESS if the connection is open and is being shutdown, otherwise AWS_OP_ERR and aws_last_error() is set.

Prototype

int aws_mqtt_client_connection_disconnect( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_disconnect_fn *on_disconnect, void *userdata);
source
LibAwsMqtt.aws_mqtt_client_connection_get_statsMethod
aws_mqtt_client_connection_get_stats(connection, stats)

Queries the connection's internal statistics for incomplete/unacked operations.

Arguments

  • connection: connection to get statistics for
  • stats: set of incomplete/unacked operation statistics

Returns

AWS_OP_SUCCESS if getting the operation statistics were successful, AWS_OP_ERR otherwise

Prototype

int aws_mqtt_client_connection_get_stats( struct aws_mqtt_client_connection *connection, struct aws_mqtt_connection_operation_statistics *stats);
source
LibAwsMqtt.aws_mqtt_client_connection_newMethod
aws_mqtt_client_connection_new(client)

Spawns a new connection object.

Arguments

  • client:[in] The client to spawn the connection from

Returns

a new mqtt connection on success, NULL otherwise

Prototype

struct aws_mqtt_client_connection *aws_mqtt_client_connection_new(struct aws_mqtt_client *client);
source
LibAwsMqtt.aws_mqtt_client_connection_new_from_mqtt5_clientMethod
aws_mqtt_client_connection_new_from_mqtt5_client(client)

Creates a new MQTT311 connection object that uses an MQTT5 client under the hood

Arguments

  • client:[in] The mqtt5 client to create the connection from

Returns

a new mqtt (311) connection on success, NULL otherwise

Prototype

struct aws_mqtt_client_connection *aws_mqtt_client_connection_new_from_mqtt5_client(struct aws_mqtt5_client *client);
source
LibAwsMqtt.aws_mqtt_client_connection_publishMethod
aws_mqtt_client_connection_publish(connection, topic, qos, retain, payload, on_complete, userdata)

Send a PUBLISH packet over connection.

Arguments

  • connection:[in] The connection to publish on
  • topic:[in] The topic to publish on
  • qos:[in] The requested QoS of the packet
  • retain:[in] True to have the server save the packet, and send to all new subscriptions matching topic
  • payload:[in] The data to send as the payload of the publish
  • on_complete:[in] (nullable) For QoS 0, called as soon as the packet is sent For QoS 1, called when PUBACK is received For QoS 2, called when PUBCOMP is received
  • user_data:[in] (nullable) Passed to on_complete

Returns

The packet id of the publish packet if successfully sent, otherwise 0.

Prototype

uint16_t aws_mqtt_client_connection_publish( struct aws_mqtt_client_connection *connection, const struct aws_byte_cursor *topic, enum aws_mqtt_qos qos, bool retain, const struct aws_byte_cursor *payload, aws_mqtt_op_complete_fn *on_complete, void *userdata);
source
LibAwsMqtt.aws_mqtt_client_connection_reconnectMethod
aws_mqtt_client_connection_reconnect(connection, on_connection_complete, userdata)

DEPRECATED Opens the actual connection defined by aws_mqtt_client_connection_new. Once the connection is opened, on_connack will be called.

Must be called on a connection that has previously been open, as the parameters passed during the last connection will be reused.

Arguments

  • connection:[in] The connection object
  • on_connection_complete:[in] The callback to fire when the connection attempt completes
  • userdata:[in] (nullable) Passed to the userdata param of on_connection_complete

Returns

AWS_OP_SUCCESS if the connection has been successfully initiated, otherwise AWS_OP_ERR and aws_last_error() will be set.

Prototype

int aws_mqtt_client_connection_reconnect( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_connection_complete_fn *on_connection_complete, void *userdata);
source
LibAwsMqtt.aws_mqtt_client_connection_releaseMethod
aws_mqtt_client_connection_release(connection)

Decrements the ref count on an mqtt connection. If the ref count drops to zero, the connection is cleaned up. Note: cannot call this with lock held, since it will start the destroy process and cause a dead lock.

Arguments

  • connection:[in] The connection object

Prototype

void aws_mqtt_client_connection_release(struct aws_mqtt_client_connection *connection);
source
LibAwsMqtt.aws_mqtt_client_connection_set_connection_closed_handlerMethod
aws_mqtt_client_connection_set_connection_closed_handler(connection, on_closed, on_closed_ud)

Sets the callback to call when the connection is closed normally by user request. This is different than the connection interrupted or lost, this only covers successful closure.

Arguments

  • connection:[in] The connection object
  • on_closed:[in] The function to call when a connection is closed
  • on_closed_ud:[in] Userdata for on_closed

Prototype

int aws_mqtt_client_connection_set_connection_closed_handler( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_connection_closed_fn *on_closed, void *on_closed_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_set_connection_interruption_handlersMethod
aws_mqtt_client_connection_set_connection_interruption_handlers(connection, on_interrupted, on_interrupted_ud, on_resumed, on_resumed_ud)

Sets the callbacks to call when a connection is interrupted and resumed.

Arguments

  • connection:[in] The connection object
  • on_interrupted:[in] The function to call when a connection is lost
  • on_interrupted_ud:[in] Userdata for on_interrupted
  • on_resumed:[in] The function to call when a connection is resumed (if clean_session is true, calling aws_mqtt_resubscribe_existing_topics is suggested)
  • on_resumed_ud:[in] Userdata for on_resumed

Prototype

int aws_mqtt_client_connection_set_connection_interruption_handlers( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_connection_interrupted_fn *on_interrupted, void *on_interrupted_ud, aws_mqtt_client_on_connection_resumed_fn *on_resumed, void *on_resumed_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_set_connection_result_handlersMethod
aws_mqtt_client_connection_set_connection_result_handlers(connection, on_connection_success, on_connection_success_ud, on_connection_failure, on_connection_failure_ud)

Sets the callbacks to call when a connection succeeds or fails

Arguments

  • connection:[in] The connection object
  • on_connection_success:[in] The function to call when a connection is successful or gets resumed
  • on_connection_success_ud:[in] Userdata for on_connection_success
  • on_connection_failure:[in] The function to call when a connection fails
  • on_connection_failure_ud:[in] Userdata for on_connection_failure

Prototype

int aws_mqtt_client_connection_set_connection_result_handlers( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_connection_success_fn *on_connection_success, void *on_connection_success_ud, aws_mqtt_client_on_connection_failure_fn *on_connection_failure, void *on_connection_failure_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_set_connection_termination_handlerMethod
aws_mqtt_client_connection_set_connection_termination_handler(connection, on_termination, on_termination_ud)

Sets the callback to call on a connection destruction.

Arguments

  • connection:[in] The connection object.
  • on_termination:[in] The function to call when a connection is destroyed.
  • on_termination_ud:[in] Userdata for on_termination.

Prototype

int aws_mqtt_client_connection_set_connection_termination_handler( struct aws_mqtt_client_connection *connection, aws_mqtt_client_on_connection_termination_fn *on_termination, void *on_termination_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_set_host_resolution_optionsMethod
aws_mqtt_client_connection_set_host_resolution_options(connection, host_resolution_config)

Set host resolution ooptions for the connection.

Prototype

int aws_mqtt_client_connection_set_host_resolution_options( struct aws_mqtt_client_connection *connection, const struct aws_host_resolution_config *host_resolution_config);
source
LibAwsMqtt.aws_mqtt_client_connection_set_http_proxy_optionsMethod
aws_mqtt_client_connection_set_http_proxy_options(connection, proxy_options)

Set http proxy options for the connection.

Prototype

int aws_mqtt_client_connection_set_http_proxy_options( struct aws_mqtt_client_connection *connection, struct aws_http_proxy_options *proxy_options);
source
LibAwsMqtt.aws_mqtt_client_connection_set_loginMethod
aws_mqtt_client_connection_set_login(connection, username, password)

Sets the username and/or password to send with the CONNECT packet.

Arguments

  • connection:[in] The connection object
  • username:[in] The username to connect with
  • password:[in] [optional] The password to connect with

Prototype

int aws_mqtt_client_connection_set_login( struct aws_mqtt_client_connection *connection, const struct aws_byte_cursor *username, const struct aws_byte_cursor *password);
source
LibAwsMqtt.aws_mqtt_client_connection_set_on_any_publish_handlerMethod
aws_mqtt_client_connection_set_on_any_publish_handler(connection, on_any_publish, on_any_publish_ud)

Sets the callback to call whenever ANY publish packet is received. Only safe to set when connection is not connected.

Arguments

  • connection:[in] The connection object
  • on_any_publish:[in] The function to call when a publish is received (pass NULL to unset)
  • on_any_publish_ud:[in] Userdata for on_any_publish

Prototype

int aws_mqtt_client_connection_set_on_any_publish_handler( struct aws_mqtt_client_connection *connection, aws_mqtt_client_publish_received_fn *on_any_publish, void *on_any_publish_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_set_reconnect_timeoutMethod
aws_mqtt_client_connection_set_reconnect_timeout(connection, min_timeout, max_timeout)

Sets the minimum and maximum reconnect timeouts.

The time between reconnect attempts will start at min and multiply by 2 until max is reached.

Arguments

  • connection:[in] The connection object
  • min_timeout:[in] The timeout to start with
  • max_timeout:[in] The highest allowable wait time between reconnect attempts

Prototype

int aws_mqtt_client_connection_set_reconnect_timeout( struct aws_mqtt_client_connection *connection, uint64_t min_timeout, uint64_t max_timeout);
source
LibAwsMqtt.aws_mqtt_client_connection_set_willMethod
aws_mqtt_client_connection_set_will(connection, topic, qos, retain, payload)

Sets the will message to send with the CONNECT packet.

Arguments

  • connection:[in] The connection object
  • topic:[in] The topic to publish the will on
  • qos:[in] The QoS to publish the will with
  • retain:[in] The retain flag to publish the will with
  • payload:[in] The data if the will message

Prototype

int aws_mqtt_client_connection_set_will( struct aws_mqtt_client_connection *connection, const struct aws_byte_cursor *topic, enum aws_mqtt_qos qos, bool retain, const struct aws_byte_cursor *payload);
source
LibAwsMqtt.aws_mqtt_client_connection_subscribeMethod
aws_mqtt_client_connection_subscribe(connection, topic_filter, qos, on_publish, on_publish_ud, on_ud_cleanup, on_suback, on_suback_ud)

Subscribe to a single topic filter. on_publish will be called when a PUBLISH matching topic_filter is received.

Arguments

  • connection:[in] The connection to subscribe on
  • topic_filter:[in] The topic filter to subscribe on. This resource must persist until on_suback.
  • qos:[in] The maximum QoS of messages to receive
  • on_publish:[in] (nullable) Called when a PUBLISH packet matching topic_filter is received
  • on_publish_ud:[in] (nullable) Passed to on_publish
  • on_ud_cleanup:[in] (nullable) Called when a subscription is removed, on_publish_ud is passed.
  • on_suback:[in] (nullable) Called when a SUBACK has been received from the server and the subscription is complete
  • on_suback_ud:[in] (nullable) Passed to on_suback

Returns

The packet id of the subscribe packet if successfully sent, otherwise 0.

Prototype

uint16_t aws_mqtt_client_connection_subscribe( struct aws_mqtt_client_connection *connection, const struct aws_byte_cursor *topic_filter, enum aws_mqtt_qos qos, aws_mqtt_client_publish_received_fn *on_publish, void *on_publish_ud, aws_mqtt_userdata_cleanup_fn *on_ud_cleanup, aws_mqtt_suback_fn *on_suback, void *on_suback_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_subscribe_multipleMethod
aws_mqtt_client_connection_subscribe_multiple(connection, topic_filters, on_suback, on_suback_ud)

Subscribe to topic filters. on_publish will be called when a PUBLISH matching each topic_filter is received.

Arguments

  • connection:[in] The connection to subscribe on
  • topic_filters:[in] An array_list of aws_mqtt_topic_subscription (NOT pointers) describing the requests.
  • on_suback:[in] (nullable) Called when a SUBACK has been received from the server and the subscription is complete. Broker may fail one of the topics, check the qos in aws_mqtt_topic_subscription from the callback
  • on_suback_ud:[in] (nullable) Passed to on_suback

Returns

The packet id of the subscribe packet if successfully sent, otherwise 0.

Prototype

uint16_t aws_mqtt_client_connection_subscribe_multiple( struct aws_mqtt_client_connection *connection, const struct aws_array_list *topic_filters, aws_mqtt_suback_multi_fn *on_suback, void *on_suback_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_unsubscribeMethod
aws_mqtt_client_connection_unsubscribe(connection, topic_filter, on_unsuback, on_unsuback_ud)

Unsubscribe to a topic filter.

Arguments

  • connection:[in] The connection to unsubscribe on
  • topic_filter:[in] The topic filter to unsubscribe on. This resource must persist until on_unsuback.
  • on_unsuback:[in] (nullable) Called when a UNSUBACK has been received from the server and the subscription is removed
  • on_unsuback_ud:[in] (nullable) Passed to on_unsuback

Returns

The packet id of the unsubscribe packet if successfully sent, otherwise 0.

Prototype

uint16_t aws_mqtt_client_connection_unsubscribe( struct aws_mqtt_client_connection *connection, const struct aws_byte_cursor *topic_filter, aws_mqtt_op_complete_fn *on_unsuback, void *on_unsuback_ud);
source
LibAwsMqtt.aws_mqtt_client_connection_use_websocketsMethod
aws_mqtt_client_connection_use_websockets(connection, transformer, transformer_ud, validator, validator_ud)

Use MQTT over websockets when connecting. Requires the MQTT_WITH_WEBSOCKETS build option.

In this scenario, an HTTP connection is established, which is then upgraded to a websocket connection, which is then used to send MQTT data.

Arguments

  • connection:[in] The connection object.
  • transformer:[in] [optional] Function that may transform the websocket handshake request. See aws_mqtt_transform_websocket_handshake_fn for more info.
  • transformer_ud:[in] [optional] Userdata for request_transformer.
  • validator:[in] [optional] Function that may reject the websocket handshake response.
  • validator_ud:[in] [optional] Userdata for response_validator.

Prototype

int aws_mqtt_client_connection_use_websockets( struct aws_mqtt_client_connection *connection, aws_mqtt_transform_websocket_handshake_fn *transformer, void *transformer_ud, aws_mqtt_validate_websocket_handshake_fn *validator, void *validator_ud);
source
LibAwsMqtt.aws_mqtt_client_get_payload_for_outstanding_publish_packetMethod
aws_mqtt_client_get_payload_for_outstanding_publish_packet(connection, packet_id, allocator, result)

result buffer will be initialized and payload will be written into it

Prototype

int aws_mqtt_client_get_payload_for_outstanding_publish_packet( struct aws_mqtt_client_connection *connection, uint16_t packet_id, struct aws_allocator *allocator, struct aws_byte_buf *result);
source
LibAwsMqtt.aws_mqtt_client_get_topic_for_outstanding_publish_packetMethod
aws_mqtt_client_get_topic_for_outstanding_publish_packet(connection, packet_id, allocator, result)

Documentation not found.

Prototype

int aws_mqtt_client_get_topic_for_outstanding_publish_packet( struct aws_mqtt_client_connection *connection, uint16_t packet_id, struct aws_allocator *allocator, struct aws_string **result);
source
LibAwsMqtt.aws_mqtt_client_newMethod
aws_mqtt_client_new(allocator, bootstrap)

Creates an instance of aws_mqtt_client.

Arguments

  • allocator:[in] The allocator the client will use for all future allocations
  • bootstrap:[in] The client bootstrap to use to initiate new socket connections

Returns

a new instance of an aws_mqtt_client if successful, NULL otherwise

Prototype

struct aws_mqtt_client *aws_mqtt_client_new(struct aws_allocator *allocator, struct aws_client_bootstrap *bootstrap);
source
LibAwsMqtt.aws_mqtt_client_releaseMethod
aws_mqtt_client_release(client)

Decrements the ref count on an mqtt client. If the ref count drops to zero, the client is cleaned up.

Arguments

  • client:[in] The client to release a ref count on

Prototype

void aws_mqtt_client_release(struct aws_mqtt_client *client);
source
LibAwsMqtt.aws_mqtt_library_initMethod
aws_mqtt_library_init(allocator)

Initializes internal datastructures used by aws-c-mqtt. Must be called before using any functionality in aws-c-mqtt.

Prototype

void aws_mqtt_library_init(struct aws_allocator *allocator);
source
LibAwsMqtt.aws_mqtt_request_response_client_create_streaming_operationMethod
aws_mqtt_request_response_client_create_streaming_operation(client, streaming_options)

Documentation not found.

Prototype

struct aws_mqtt_rr_client_operation *aws_mqtt_request_response_client_create_streaming_operation( struct aws_mqtt_request_response_client *client, const struct aws_mqtt_streaming_operation_options *streaming_options);
source
LibAwsMqtt.aws_mqtt_request_response_client_new_from_mqtt311_clientMethod
aws_mqtt_request_response_client_new_from_mqtt311_client(allocator, client, options)

Documentation not found.

Prototype

struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_from_mqtt311_client( struct aws_allocator *allocator, struct aws_mqtt_client_connection *client, const struct aws_mqtt_request_response_client_options *options);
source
LibAwsMqtt.aws_mqtt_request_response_client_new_from_mqtt5_clientMethod
aws_mqtt_request_response_client_new_from_mqtt5_client(allocator, client, options)

Documentation not found.

Prototype

struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_from_mqtt5_client( struct aws_allocator *allocator, struct aws_mqtt5_client *client, const struct aws_mqtt_request_response_client_options *options);
source
LibAwsMqtt.aws_mqtt_request_response_client_submit_requestMethod
aws_mqtt_request_response_client_submit_request(client, request_options)

Documentation not found.

Prototype

int aws_mqtt_request_response_client_submit_request( struct aws_mqtt_request_response_client *client, const struct aws_mqtt_request_operation_options *request_options);
source
LibAwsMqtt.aws_mqtt_resubscribe_existing_topicsMethod
aws_mqtt_resubscribe_existing_topics(connection, on_suback, on_suback_ud)

Resubscribe to all topics currently subscribed to. This is to help when resuming a connection with a clean session.

Arguments

  • connection:[in] The connection to subscribe on
  • on_suback:[in] (nullable) Called when a SUBACK has been received from the server and the subscription is complete
  • on_suback_ud:[in] (nullable) Passed to on_suback

Returns

The packet id of the subscribe packet if successfully sent, otherwise 0 (and aws_last_error() will be set).

Prototype

uint16_t aws_mqtt_resubscribe_existing_topics( struct aws_mqtt_client_connection *connection, aws_mqtt_suback_multi_fn *on_suback, void *on_suback_ud);
source
LibAwsMqtt.aws_mqtt_rr_client_operation_acquireMethod
aws_mqtt_rr_client_operation_acquire(operation)

Documentation not found.

Prototype

struct aws_mqtt_rr_client_operation *aws_mqtt_rr_client_operation_acquire( struct aws_mqtt_rr_client_operation *operation);
source
LibAwsMqtt.aws_mqtt_rr_client_operation_releaseMethod
aws_mqtt_rr_client_operation_release(operation)

Documentation not found.

Prototype

struct aws_mqtt_rr_client_operation *aws_mqtt_rr_client_operation_release( struct aws_mqtt_rr_client_operation *operation);
source
LibAwsMqtt.aws_mqtt_validate_utf8_textMethod
aws_mqtt_validate_utf8_text(text)

Validate utf-8 string under mqtt specs

Arguments

  • text:

Returns

AWS_OP_SUCCESS if the text is validate, otherwise AWS_OP_ERR

Prototype

int aws_mqtt_validate_utf8_text(struct aws_byte_cursor text);
source