Macros

group mqtt_defines

MQTT library preprocessor directives such as results and error codes.

Cypress middleware APIs return results of type cy_rslt_t and consist of three parts:

  • module base

  • type

  • error code

           Module base         Type    Library-specific error code
   +-------------------------+------+------------------------------+
   |          0x0200         | 0x2  |           Error Code         |
   +-------------------------+------+------------------------------+
             14 bits          2 bits            16 bits

See the macro section of this document for library-specific error codes.
Result Format

The data structure cy_rslt_t is part of cy_result.h. In Mbed OS, the PSoC 6 MCU target platform is located in <mbed-os/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/core_lib/include>. In AnyCloud, PSoC 6 MCU target platform is located in <core_lib/include>.

Module base: This base is derived from CY_RSLT_MODULE_MIDDLEWARE_BASE (defined in cy_result.h) and is an offset of CY_RSLT_MODULE_MIDDLEWARE_BASE. Details of the offset and the middleware base are defined in cy_result_mw.h, which is part of Github connectivity-utilities.

Type: This type is defined in cy_result.h and can be one of CY_RSLT_TYPE_FATAL, CY_RSLT_TYPE_ERROR, CY_RSLT_TYPE_WARNING, or CY_RSLT_TYPE_INFO. MQTT library error codes are of type CY_RSLT_TYPE_ERROR which is 0x2.

Library-specific error codes: These error codes are library-specific and defined in the macro section.

Helper macros used for creating library-specific results are provided as part of cy_result.h.

note

The functions defined in this library can return errors other than the error codes listed in this section. Please decode the error using the information provided above. Based on the module base value, refer the header file of corresponding module to identify the error.

Defines

CY_RSLT_MQTT_ERR_BASE

MQTT error code base.

CY_RSLT_MODULE_MQTT_ERROR

Generic MQTT API error.

CY_RSLT_MODULE_MQTT_BADARG

Invalid argument.

CY_RSLT_MODULE_MQTT_NOMEM

Out of memory.

CY_RSLT_MODULE_MQTT_INIT_FAIL

MQTT library Init failure.

CY_RSLT_MODULE_MQTT_DEINIT_FAIL

MQTT library Deinit failure.

CY_RSLT_MODULE_MQTT_CREATE_FAIL

MQTT library Create failure.

CY_RSLT_MODULE_MQTT_DELETE_FAIL

MQTT library Delete failure.

CY_RSLT_MODULE_MQTT_OBJ_NOT_INITIALIZED

MQTT object not initialized failure.

CY_RSLT_MODULE_MQTT_CONNECT_FAIL

MQTT library Connect failure.

CY_RSLT_MODULE_MQTT_DISCONNECT_FAIL

MQTT library Disconnect failure.

CY_RSLT_MODULE_MQTT_PUBLISH_FAIL

MQTT library Publish failure.

CY_RSLT_MODULE_MQTT_SUBSCRIBE_FAIL

MQTT library Subscribe failure.

CY_RSLT_MODULE_MQTT_UNSUBSCRIBE_FAIL

MQTT library Unsubscribe failure.

CY_RSLT_MODULE_MQTT_NOT_CONNECTED

MQTT client not connected.

CY_RSLT_MODULE_MQTT_CLOSED

MQTT client connection closed.

CY_RSLT_MODULE_MQTT_ALREADY_CONNECTED

MQTT client already connected.

CY_RSLT_MODULE_MQTT_PROTOCOL_NOT_SUPPORTED

Protocol not supported.

CY_RSLT_MODULE_MQTT_INVALID_CREDENTIALS

Invalid credentials.

CY_RSLT_MODULE_MQTT_HANDSHAKE_FAILED

TLS handshake failed.

CY_MQTT_EVENT_TYPE_PUBLISH_RECEIVE

MQTT event type for subscribed message receive event.

Macro is added for library backward compatibility.

note

This macro is defined only for backward compatibility. Application should not modify this macro.

CY_MQTT_MIN_NETWORK_BUFFER_SIZE

Minimum network buffer size in bytes, for sending and receiving an MQTT packet.

note

This is the default value configured in the library. This value can be modified to suit the application use case requirements.

CY_MQTT_ACK_RECEIVE_TIMEOUT_MS

Maximum wait time in milliseconds to receive acknowledgment packet from the MQTT broker for QoS1/QoS2 Publish/Subscribe message.

MQTT library function returns to the caller immediately, if the MQTT acknowledgment message is received before the timeout/wait time. Else, the function returns the failure status at the end of wait time.

note

This is the default value configured in the library. This value can be modified depending on the network condition.

CY_MQTT_MESSAGE_SEND_TIMEOUT_MS

MQTT message send timeout in milliseconds.

MQTT library function returns to the caller immediately, if the MQTT message is sent before the timeout/wait time. Else, the function returns the failure status at the end of wait time.

note

This is the default value configured in the library. This value can be modified depending on the network condition.

CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS

MQTT message receive timeout for the subscribed topic, represented in milliseconds.

MQTT network receive function waits for this timeout value, in case if partial data is received from the network socket. If the complete data is received before this timeout value, the network receive functions returns to the caller immediately after reading the requested data from the socket.

note

This is the default value configured in the library. This value can be modified depending on the network condition.

CY_MQTT_MAX_RETRY_VALUE

Maximum number of retry for MQTT publish/subscribe/unsubcribe message send.

note

This is the default value configured in the library. This value can be modified by defining macro in application makefile.

CY_MQTT_MAX_HANDLE

Maximum number of MQTT instances supported.

CY_MQTT_MAX_OUTGOING_PUBLISHES

Configure value of maximum number of outgoing publishes maintained in MQTT library until an ack is received from the broker.

CY_MQTT_MAX_OUTGOING_SUBSCRIBES

Configure value of maximum number of outgoing subscription topics maintained in MQTT library until an ack is received from the broker.