Skip to content

Commit

Permalink
Upload mqtt 3.3.0.1179
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlab-runner committed Dec 1, 2021
1 parent f5e7e80 commit b169760
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 29 deletions.
18 changes: 12 additions & 6 deletions README.md
Expand Up @@ -48,13 +48,17 @@ Some of the key features include:

- [PSoC™ 62S2 evaluation kit (CY8CEVAL-062S2-LAI-4373M2)](https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-evaluation-kit-cy8ceval-062s2)

- [CYW943907AEVAL1F Evaluation Kit(CYW943907AEVAL1F)](https://www.cypress.com/documentation/development-kitsboards/cyw943907aeval1f-evaluation-kit)

- [CYW954907AEVAL1F Evaluation Kit(CYW954907AEVAL1F)](https://www.cypress.com/documentation/development-kitsboards/cyw954907aeval1f-evaluation-kit)

## Dependent libraries

This MQTT client library depends on the following libraries. These libraries are included by default.

- [Wi-Fi middleware core](https://github.com/cypresssemiconductorco/wifi-mw-core)
- [Wi-Fi middleware core](https://github.com/Infineon/wifi-mw-core)

- [AWS IoT device SDK port](https://github.com/cypresssemiconductorco/aws-iot-device-sdk-port)
- [AWS IoT device SDK port](https://github.com/Infineon/aws-iot-device-sdk-port)

- [AWS IoT device SDK MQTT library](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/202103.00)

Expand All @@ -76,16 +80,18 @@ This MQTT client library depends on the following libraries. These libraries are
`CY_MQTT_MESSAGE_SEND_TIMEOUT_MS` | MQTT message send timeout | `DEFINES += CY_MQTT_MESSAGE_SEND_TIMEOUT_MS=3000`
`CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS` | MQTT message receive timeout | `DEFINES += CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS=500`
`CY_MQTT_MAX_RETRY_VALUE` | MQTT library retry mechanism for MQTT publish/subscribe/unsubscribe messages if the acknowledgement is not received from the broker on time. You can configure the maximum number of retries. | `DEFINES += CY_MQTT_MAX_RETRY_VALUE=3`
`CY_MQTT_MAX_OUTGOING_PUBLISHES` | If user need to perform multiple publish operations simultaneously on a single MQTT instance, then `CY_MQTT_MAX_OUTGOING_PUBLISHES` macro needs be configured with the number of simultaneous publish operation that user wants to perform. For the default value of this macro, refer to MQTT library API header file. This macro can be configured by adding a define in the application Makefile. | `DEFINES += CY_MQTT_MAX_OUTGOING_PUBLISHES=2`
`CY_MQTT_MAX_OUTGOING_SUBSCRIBES` | If user need to perform multiple subscribe operations simultaneously on a single MQTT instance, then `CY_MQTT_MAX_OUTGOING_SUBSCRIBES` macro needs be configured with the number of simultaneous subscribe operation that user wants to perform. For the default value of this macro, refer to MQTT library API header file. This macro can be configured by adding a define in the application Makefile. | `DEFINES += CY_MQTT_MAX_OUTGOING_SUBSCRIBES=2`
`MQTT_PINGRESP_TIMEOUT_MS` | A "reasonable amount of time" (timeout value) to wait for keepalive response from the MQTT broker | `DEFINES += MQTT_PINGRESP_TIMEOUT_MS=5000`
`MQTT_RECV_POLLING_TIMEOUT_MS` | A "maximum polling duration" that is allowed without any data reception from the network for the incoming packet | `DEFINES += MQTT_RECV_POLLING_TIMEOUT_MS=1000`
`MQTT_SEND_RETRY_TIMEOUT_MS` | A "maximum duration" that is allowed for no data transmission over the network through the transport send function | `DEFINES += MQTT_SEND_RETRY_TIMEOUT_MS=500`
<br>

**Note:** It is important to note that having `MQTT_RECV_POLLING_TIMEOUT_MS` timeout too short will result in MQTT being disconnected due to the possibility of partial data being received. If you have small TCP buffers and a high latency network, the optimum value for the timeout can be surprisingly long. In such cases, optimum value for the timeout can be better determined based on experimenting the MQTT applications with payloads bigger than the TCP buffer. See [AWS coreMQTT documentation](https://docs.aws.amazon.com/embedded-csdk/202103.00/lib-ref/libraries/standard/coreMQTT/docs/doxygen/output/html/mqtt_timeouts.html#mqtt_timeouts_receive_polling) for more details.<br>

5. Review and make the required changes to the pre-defined configuration files bundled with the wifi-mw-core library for FreeRTOS, lwIP, and Mbed TLS. See [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md) for details.
5. Review and make the required changes to the pre-defined configuration files bundled with the wifi-mw-core library for FreeRTOS, lwIP, and Mbed TLS. See [README.md](https://github.com/Infineon/wifi-mw-core/blob/master/README.md) for details.

6. Define the following COMPONENTS in the application Makefile for the MQTT library. See [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md).
6. Define the following COMPONENTS in the application Makefile for the MQTT library. See [README.md](https://github.com/Infineon/wifi-mw-core/blob/master/README.md).
```
COMPONENTS=FREERTOS MBEDTLS LWIP SECURE_SOCKETS
```
Expand Down Expand Up @@ -122,7 +128,7 @@ The MQTT library disables all debug log messages by default. Do the following to
DEFINES+=ENABLE_MQTT_LOGS
```

2. Call the `cy_log_init()` function provided by the *cy-log* module. cy-log is part of the *connectivity-utilities* library. See [connectivity-utilities library API documentation](https://cypresssemiconductorco.github.io/connectivity-utilities/api_reference_manual/html/group__logging__utils.html) for cy-log details.
2. Call the `cy_log_init()` function provided by the *cy-log* module. cy-log is part of the *connectivity-utilities* library. See [connectivity-utilities library API documentation](https://infineon.github.io/connectivity-utilities/api_reference_manual/html/group__logging__utils.html) for cy-log details.


## Usage notes
Expand Down Expand Up @@ -197,7 +203,7 @@ Do the following to establish a connection with the broker using credentials sto

- [MQTT client library RELEASE.md](./RELEASE.md)

- [MQTT client API documentation](https://cypresssemiconductorco.github.io/mqtt/api_reference_manual/html/index.html)
- [MQTT client API documentation](https://infineon.github.io/mqtt/api_reference_manual/html/index.html)

- [ModusToolbox&trade; software environment, quick start guide, documentation, and videos](https://www.cypress.com/products/modustoolbox-software-environment)

Expand Down
4 changes: 4 additions & 0 deletions RELEASE.md
Expand Up @@ -10,6 +10,10 @@ See the [README.md](./README.md) for a complete description of the MQTT client l

## Changelog

### v3.3.0

- Added support for CYW943907AEVAL1F and CYW954907AEVAL1F kits

### v3.2.0

- Added support for secured kit (for example: CY8CKIT-064S0S2-4343W)
Expand Down
30 changes: 17 additions & 13 deletions docs/api_reference_manual/html/index.html

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions include/cy_mqtt_api.h
Expand Up @@ -231,14 +231,16 @@ extern "C" {
* Configure value of maximum number of outgoing publishes maintained in MQTT library
* until an ack is received from the broker.
*/
#ifndef CY_MQTT_MAX_OUTGOING_PUBLISHES
#define CY_MQTT_MAX_OUTGOING_PUBLISHES ( 1U )

#endif
/**
* Configure value of maximum number of outgoing subscription topics maintained in MQTT library
* until an ack is received from the broker.
*/
#ifndef CY_MQTT_MAX_OUTGOING_SUBSCRIBES
#define CY_MQTT_MAX_OUTGOING_SUBSCRIBES ( 5U )

#endif
/**
* @}
*/
Expand Down
28 changes: 21 additions & 7 deletions source/cy_mqtt_api.c
Expand Up @@ -371,32 +371,47 @@ static cy_rslt_t mqtt_get_next_free_index_for_publish( cy_mqtt_object_t *mqtt_ob
{
cy_rslt_t result = CY_RSLT_SUCCESS;
uint8_t index = 0;
bool slot_found = false;

if( (mqtt_obj == NULL) || (pindex == NULL) )
{
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "\nBad arguments to mqtt_get_next_free_index_for_publish." );
return CY_RSLT_MODULE_MQTT_BADARG;
}

cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "\nmqtt_get_next_free_index_for_publish - Acquiring Mutex %p ", mqtt_obj->process_mutex );
result = cy_rtos_get_mutex( &(mqtt_obj->process_mutex), CY_RTOS_NEVER_TIMEOUT );
if( result != CY_RSLT_SUCCESS )
{
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "\ncy_rtos_get_mutex for Mutex %p failed with Error : [0x%X] ", mqtt_obj->process_mutex, (unsigned int)result );
return result;
}

cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "\nmqtt_get_next_free_index_for_publish - Acquired Mutex %p ", mqtt_obj->process_mutex );

for( index = 0; index < CY_MQTT_MAX_OUTGOING_PUBLISHES; index++ )
{
/* A free index is marked by the invalid packet ID.
* Check if the the index has a free slot. */
if( mqtt_obj->outgoing_pub_packets[ index ].packetid == MQTT_PACKET_ID_INVALID )
{
result = CY_RSLT_SUCCESS;
slot_found = true;
mqtt_obj->outgoing_pub_packets[ index ].packetid = MQTT_GetPacketId( &(mqtt_obj->mqtt_context) );
*pindex = index;
break;
}
}

if( slot_found == true )
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "\nmqtt_get_next_free_index_for_publish - Releasing Mutex %p ", mqtt_obj->process_mutex );
result = cy_rtos_set_mutex( &(mqtt_obj->process_mutex) );
if( result != CY_RSLT_SUCCESS )
{
/* Copy the available index into the output param. */
*pindex = index;
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "\ncy_rtos_set_mutex for Mutex %p failed with Error : [0x%X] ", (unsigned int)result );

return result;
}
else
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "\nmqtt_get_next_free_index_for_publish - Released Mutex %p ", mqtt_obj->process_mutex );

if( index >= CY_MQTT_MAX_OUTGOING_PUBLISHES )
{
result = CY_RSLT_MODULE_MQTT_ERROR;
}
Expand Down Expand Up @@ -1762,7 +1777,6 @@ cy_rslt_t cy_mqtt_publish( cy_mqtt_t mqtt_handle, cy_mqtt_publish_info_t *pubmsg
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "\ncy_mqtt_publish - Acquired Mutex %p ", mqtt_obj->process_mutex );

/* Get a new packet ID. */
mqtt_obj->outgoing_pub_packets[ publishIndex ].packetid = MQTT_GetPacketId( &(mqtt_obj->mqtt_context) );
mqtt_obj->pub_ack_status.packetid = mqtt_obj->outgoing_pub_packets[ publishIndex ].packetid;

/* Stop MQTT Ping Timer */
Expand Down
2 changes: 1 addition & 1 deletion version.xml
@@ -1 +1 @@
<version>3.2.0.1164</version>
<version>3.3.0.1179</version>

0 comments on commit b169760

Please sign in to comment.