Skip to content

Commit

Permalink
Upload mqtt 3.1.1.830
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlab-runner committed May 10, 2021
1 parent fa139c5 commit 0f60b52
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 30 deletions.
1 change: 1 addition & 0 deletions .cyignore
@@ -0,0 +1 @@
docs
37 changes: 22 additions & 15 deletions README.md
Expand Up @@ -24,6 +24,8 @@ Some of the key features include:

- Supports MQTT connection over both secured and non-secured TCP connections.

- Supports both X509 certificate and SAS tokens based authentication for MQTT connection with Azure broker.

- Glue layer implementation for MQTT library to work on Cypress connectivity platforms.

- Built on top of FreeRTOS, lwIP, and Mbed TLS (that are bundled as part of Wi-Fi Middleware Core library).
Expand All @@ -50,46 +52,48 @@ This MQTT Client library depends on the following libraries. These libraries are

## Quick Start

1. A "reasonable amount of time" to wait for keepalive response from the MQTT broker is configured using `MQTT_PINGRESP_TIMEOUT_MS` in *./include/core_mqtt_config.h*. This value may be adjusted to suit the use case and network environment.
1. The application must include *./include/cy_mqtt_api.h* to use library API's and structure.

2. The reference *./include/core_mqtt_config.h* file that is bundled with this library provides the configurations required for the [AWS IoT Device SDK](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/202011.00) library. The application must copy this file to the root directory where the application Makefile is present, and suitably adjust the default settings.

2. A "reasonable amount of time" to wait for receiving the acknowledgment packet from the MQTT broker for MQTT publish/Subscribe messages with QoS1/QoS2. The timeout value can be configured using the macro `CY_MQTT_ACK_RECEIVE_TIMEOUT_MS` in the application makefile. This value may be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
3. A "reasonable amount of time" to wait for keepalive response from the MQTT broker is configured using `MQTT_PINGRESP_TIMEOUT_MS` in *./include/core_mqtt_config.h*. This value may be adjusted to suit the use case and network environment.

4. A "reasonable amount of time" to wait for receiving the acknowledgment packet from the MQTT broker for MQTT publish/Subscribe messages with QoS1/QoS2. The timeout value can be configured using the macro `CY_MQTT_ACK_RECEIVE_TIMEOUT_MS` in the application makefile. This value may be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
```
DEFINES += CY_MQTT_ACK_RECEIVE_TIMEOUT_MS=3000
```

3. MQTT message send timeout can be configured using the macro `CY_MQTT_MESSAGE_SEND_TIMEOUT_MS` in the application makefile. This value can be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
5. MQTT message send timeout can be configured using the macro `CY_MQTT_MESSAGE_SEND_TIMEOUT_MS` in the application makefile. This value can be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
```
DEFINES += CY_MQTT_MESSAGE_SEND_TIMEOUT_MS=3000
```

4. MQTT message receive timeout can be configured using the macro `CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS` in the application makefile. This value can be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
6. MQTT message receive timeout can be configured using the macro `CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS` in the application makefile. This value can be adjusted to suit the use case and network conditions. The Makefile entry would look like the following:
```
DEFINES += CY_MQTT_MESSAGE_RECEIVE_TIMEOUT_MS=500
```

5. MQTT library provides a retry mechanism for MQTT publish/subscribe/unsubcribe messages, incase if the acknowledgement is not received from the broker on time. User can configure the maximum number of retries by defining the macro `CY_MQTT_MAX_RETRY_VALUE` in the application makefile. The Makefile entry would look like the following:
7. MQTT library provides a retry mechanism for MQTT publish/subscribe/unsubcribe messages, incase if the acknowledgement is not received from the broker on time. User can configure the maximum number of retries by defining the macro `CY_MQTT_MAX_RETRY_VALUE` in the application makefile. The Makefile entry would look like the following:
```
DEFINES += CY_MQTT_MAX_RETRY_VALUE=3
```

6. The reference *./include/core_mqtt_config.h* file that is bundled with this library provides the configurations required for the [AWS IoT Device SDK](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/202011.00) library. The application must copy this file to the root directory where the application Makefile is present, and suitably adjust the default settings.

7. This MQTT Client library does not support secure connections to the public `test.mosquitto.org` broker by default because the server uses the SHA1 hashing algorithm. As cautioned by Mbed TLS, SHA-1 is considered a weak message digest and is therefore not enabled in Mbed TLS by default. The use of SHA-1 for certificate signing constitutes a security risk. It is recommended to avoid dependencies on it, and consider stronger message digests instead.
8. This MQTT Client library does not support secure connections to the public `test.mosquitto.org` broker by default because the server uses the SHA1 hashing algorithm. As cautioned by Mbed TLS, SHA-1 is considered a weak message digest and is therefore not enabled in Mbed TLS by default. The use of SHA-1 for certificate signing constitutes a security risk. It is recommended to avoid dependencies on it, and consider stronger message digests instead.

8. A set of pre-defined configuration files have been bundled with the wifi-mw-core library for FreeRTOS, lwIP, and Mbed TLS. You should review the configuration and make the required adjustments. See the "Quick Start" section in [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md) for more details.
9. A set of pre-defined configuration files have been bundled with the wifi-mw-core library for FreeRTOS, lwIP, and Mbed TLS. You should review the configuration and make the required adjustments. See the "Quick Start" section in [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md) for more details.

9. Define the following COMPONENTS in the application's makefile for the MQTT Library. For additional information, see the "Quick Start" section in [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md).
10. Define the following COMPONENTS in the application's makefile for the MQTT Library. For additional information, see the "Quick Start" section in [README.md](https://github.com/cypresssemiconductorco/wifi-mw-core/blob/master/README.md).
```
COMPONENTS=FREERTOS MBEDTLS LWIP SECURE_SOCKETS
```

10. The "aws-iot-device-sdk-port" layer includes the "coreHTTP" and "coreMQTT" modules of the "aws-iot-device-sdk-embedded-C" library by default. If the user application doesn't use HTTP client features, add the following path in the .cyignore file of the application to exclude the coreHTTP source files from the build.
11. The "aws-iot-device-sdk-port" layer includes the "coreHTTP" and "coreMQTT" modules of the "aws-iot-device-sdk-embedded-C" library by default. If the user application doesn't use HTTP client features, then update the application makefile to exclude the coreHTTP source files from the build. The Makefile entry would look like the following:
```
$(SEARCH_aws-iot-device-sdk-embedded-C)/libraries/standard/coreHTTP
libs/aws-iot-device-sdk-embedded-C/libraries/standard/coreHTTP
CY_IGNORE+= $(SEARCH_aws-iot-device-sdk-embedded-C)/libraries/standard/coreHTTP
CY_IGNORE+= libs/aws-iot-device-sdk-embedded-C/libraries/standard/coreHTTP
```

11. The MQTT Library disables all debug log messages by default. To enable log messages, the application must perform the following:
12. The MQTT Library disables all debug log messages by default. To enable log messages, the application must perform the following:

1. Add the `ENABLE_MQTT_LOGS` macro to the *DEFINES* in the code example's Makefile. The Makefile entry would look like as follows:
```
Expand All @@ -98,7 +102,6 @@ This MQTT Client library depends on the following libraries. These libraries are
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.

## Library Usage Notes

- Functions `cy_mqtt_init()` and `cy_mqtt_deinit()` are not thread-safe.

- The application should allocate a network buffer; the same buffer must be passed while creating the MQTT object. The MQTT Library uses this buffer for sending and receiving MQTT packets. `CY_MQTT_MIN_NETWORK_BUFFER_SIZE` is the minimum size of the network buffer required for the library to handle MQTT packets. The `CY_MQTT_MIN_NETWORK_BUFFER_SIZE` is defined in *./include/cy_mqtt_api.h* .
Expand All @@ -109,6 +112,10 @@ This MQTT Client library depends on the following libraries. These libraries are

- After calling the `cy_mqtt_delete` API function, all the resource associated with the MQTT handle are freed. Therefore, you should not use the same MQTT handle after delete.

- In case of X509 certificate based authentication, Password should be NULL in MQTT connect request for Azure MQTT broker.

- In case of SAS tokens based authentication, Private key and device cert value should be NULL in MQTT connect request for Azure MQTT broker.

- The MQTT disconnection event notification is not sent to the application when disconnection is initiated from the application.

- When the application receives an MQTT disconnection event notification due to physical network disconnection or not receiving the ping response on time, the application should call the `cy_mqtt_disconnect()` function to release the resource allocated during `cy_mqtt_connect()`.
Expand Down
22 changes: 19 additions & 3 deletions RELEASE.md
Expand Up @@ -5,10 +5,18 @@
Refer to the [README.md](./README.md) for a complete description of the MQTT Client Library

## Known Issues
| Problem | Workaround |
| ------- | ---------- |
| The MQTT library version v3.x doesn’t support asynchronous APIs. Hence, it uses a thread based polling logic to check for incoming MQTT packets. The same thread is used for sending a periodic PING mqtt message to broker. This may wake-up the host MCU periodically in deep-sleep mode, which could impact low-power system use case. | Use MQTT v2.x for low-power use case. |

None.

## Changelog
### v3.1.1
- Documentation updates.

- Upgraded the library to integrate with wifi-mw-core 3.x library version for AnyCloud.

- Introduced ARMC6 compiler support for AnyCloud build.

### v3.1.0
- Performance improvements.
Expand All @@ -26,6 +34,11 @@ None.

- This version of the library is not backward compatible with pervious library versions.

### v2.1.0
- Introduced asynchronous receive logic.

- Added support for SAS token based authentication, for Azure borker connection.

### v2.0.0

- Changes to adapt to ModusToolbox® 2.2.0 flow and AnyCloud's support for multiple Wi-Fi interfaces - STA, softAP, and concurrent STA+softAP mode.
Expand All @@ -44,7 +57,10 @@ This version of the library was validated for compatibility with the following s

| Software and Tools | Version |
| :--- | :----: |
| ModusToolbox Software Environment | 2.2 |
| PSoC 6 Peripheral Driver Library (PDL) | 2.0 |
| ModusToolbox Software Environment | 2.3 |
| - ModusToolbox Device Configurator | 3.0 |
| - ModusToolbox CapSense Configurator / Tuner tools | 3.15 |
| PSoC 6 Peripheral Driver Library (PDL) | 2.2.0 |
| GCC Compiler | 9.3.1 |
| IAR Compiler | 8.32 |
| Arm Compiler 6 | 6.14 |
1 change: 1 addition & 0 deletions deps/wifi-mw-core.lib
@@ -0,0 +1 @@
https://github.com/cypresssemiconductorco/wifi-mw-core/#latest-v3.X
24 changes: 15 additions & 9 deletions docs/api_reference_manual/html/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions source/cy_mqtt_api.c
Expand Up @@ -869,7 +869,7 @@ cy_rslt_t cy_mqtt_init( void )
{
cy_rslt_t result = CY_RSLT_SUCCESS;

if( (mqtt_lib_init_status == true) )
if( mqtt_lib_init_status == true )
{
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_INFO, "\nMQTT library is already initialized. Number of MQTT client instance : [%d] \n", mqtt_handle_count );
return result;
Expand Down Expand Up @@ -1575,7 +1575,7 @@ cy_rslt_t cy_mqtt_subscribe( cy_mqtt_t mqtt_handle, cy_mqtt_subscribe_info_t *su
MQTTSubscribeInfo_t *sub_list = NULL;
uint32_t timeout = 0;

if( (mqtt_handle == NULL) || (sub_info == NULL) || (sub_count < 1) || (sub_count > CY_MQTT_MAX_OUTGOING_SUBSCRIBES) )
if( (mqtt_handle == NULL) || (sub_info == NULL) || (sub_count < 1) )
{
cy_mqtt_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "\nBad arguments to cy_mqtt_subscribe()..!\n" );
return CY_RSLT_MODULE_MQTT_BADARG;
Expand Down
2 changes: 1 addition & 1 deletion version.txt
@@ -1 +1 @@
3.1.0.678
3.1.1.830

0 comments on commit 0f60b52

Please sign in to comment.