Giter Club home page Giter Club logo

coremqtt's Introduction

coreMQTT Client Library

API Documentation Pages for current and previous releases of this library can be found here

This repository contains the coreMQTT library that has been optimized for a low memory footprint. The coreMQTT library is compliant with the MQTT 3.1.1 standard. It has no dependencies on any additional libraries other than the standard C library, a customer-implemented network transport interface, and optionally a user-implemented platform time function. This library is distributed under the MIT Open Source License.

This library has gone through code quality checks including verification that no function has a GNU Complexity score over 8, and checks against deviations from mandatory rules in the MISRA coding standard. Deviations from the MISRA C:2012 guidelines are documented under MISRA Deviations. This library has also undergone both static code analysis from Coverity static analysis, and validation of memory safety through the CBMC automated reasoning tool.

See memory requirements for this library here.

coreMQTT v2.3.1 source code is part of the FreeRTOS 202406.01 LTS release.

MQTT Config File

The MQTT client library exposes build configuration macros that are required for building the library. A list of all the configurations and their default values are defined in core_mqtt_config_defaults.h. To provide custom values for the configuration macros, a custom config file named core_mqtt_config.h can be provided by the application to the library.

By default, a core_mqtt_config.h custom config is required to build the library. To disable this requirement and build the library with default configuration values, provide MQTT_DO_NOT_USE_CUSTOM_CONFIG as a compile time preprocessor macro.

Thus, the MQTT library can be built by either:

  • Defining a core_mqtt_config.h file in the application, and adding it to the include directories list of the library OR
  • Defining the MQTT_DO_NOT_USE_CUSTOM_CONFIG preprocessor macro for the library build.

Sending metrics to AWS IoT

When establishing a connection with AWS IoT, users can optionally report the Operating System, Hardware Platform and MQTT client version information of their device to AWS. This information can help AWS IoT provide faster issue resolution and technical support. If users want to report this information, they can send a specially formatted string (see below) in the username field of the MQTT CONNECT packet.

Format

The format of the username string with metrics is:

<Actual_Username>?SDK=<OS_Name>&Version=<OS_Version>&Platform=<Hardware_Platform>&MQTTLib=<MQTT_Library_name>@<MQTT_Library_version>

Where

  • <Actual_Username> is the actual username used for authentication, if username and password are used for authentication. When username and password based authentication is not used, this is an empty value.
  • <OS_Name> is the Operating System the application is running on (e.g. FreeRTOS)
  • <OS_Version> is the version number of the Operating System (e.g. V10.4.3)
  • <Hardware_Platform> is the Hardware Platform the application is running on (e.g. WinSim)
  • <MQTT_Library_name> is the MQTT Client library being used (e.g. coreMQTT)
  • <MQTT_Library_version> is the version of the MQTT Client library being used (e.g. 1.0.2)

Example

  • Actual_Username = “iotuser”, OS_Name = FreeRTOS, OS_Version = V10.4.3, Hardware_Platform_Name = WinSim, MQTT_Library_Name = coremqtt, MQTT_Library_version = 2.3.0. If username is not used, then “iotuser” can be removed.
/* Username string:
 * iotuser?SDK=FreeRTOS&Version=v10.4.3&Platform=WinSim&[email protected]
 */

#define OS_NAME                   "FreeRTOS"
#define OS_VERSION                "V10.4.3"
#define HARDWARE_PLATFORM_NAME    "WinSim"
#define MQTT_LIB                  "[email protected]"

#define USERNAME_STRING           "iotuser?SDK=" OS_NAME "&Version=" OS_VERSION "&Platform=" HARDWARE_PLATFORM_NAME "&MQTTLib=" MQTT_LIB
#define USERNAME_STRING_LENGTH    ( ( uint16_t ) ( sizeof( USERNAME_STRING ) - 1 ) )

MQTTConnectInfo_t connectInfo;
connectInfo.pUserName = USERNAME_STRING;
connectInfo.userNameLength = USERNAME_STRING_LENGTH;
mqttStatus = MQTT_Connect( pMqttContext, &connectInfo, NULL, CONNACK_RECV_TIMEOUT_MS, pSessionPresent );

Upgrading to v2.0.0 and above

With coreMQTT versions >=v2.0.0, there are breaking changes. Please refer to the coreMQTT version >=v2.0.0 Migration Guide.

Building the Library

The mqttFilePaths.cmake file contains the information of all source files and the header include path required to build the MQTT library.

Additionally, the MQTT library requires two header files that are not part of the ISO C90 standard library, stdbool.h and stdint.h. For compilers that do not provide these header files, the source/include directory contains the files stdbool.readme and stdint.readme, which can be renamed to stdbool.h and stdint.h, respectively, to provide the type definitions required by MQTT.

As mentioned in the previous section, either a custom config file (i.e. core_mqtt_config.h) OR MQTT_DO_NOT_USE_CUSTOM_CONFIG macro needs to be provided to build the MQTT library.

For a CMake example of building the MQTT library with the mqttFilePaths.cmake file, refer to the coverity_analysis library target in test/CMakeLists.txt file.

Building Unit Tests

Checkout CMock Submodule

By default, the submodules in this repository are configured with update=none in .gitmodules to avoid increasing clone time and disk space usage of other repositories (like amazon-freertos that submodules this repository).

To build unit tests, the submodule dependency of CMock is required. Use the following command to clone the submodule:

git submodule update --checkout --init --recursive test/unit-test/CMock

Platform Prerequisites

  • Docker

or the following:

  • For running unit tests
    • C90 compiler like gcc
    • CMake 3.13.0 or later
    • Ruby 2.0.0 or later is additionally required for the CMock test framework (that we use).
  • For running the coverage target, gcov and lcov are additionally required.

Steps to build Unit Tests

  1. If using docker, launch the container:

    1. docker build -t coremqtt .
    2. docker run -it -v "$PWD":/workspaces/coreMQTT -w /workspaces/coreMQTT coremqtt
  2. Go to the root directory of this repository. (Make sure that the CMock submodule is cloned as described above)

  3. Run the cmake command: cmake -S test -B build

  4. Run this command to build the library and unit tests: make -C build all

  5. The generated test executables will be present in build/bin/tests folder.

  6. Run cd build && ctest to execute all tests and view the test run summary.

CBMC

To learn more about CBMC and proofs specifically, review the training material here.

The test/cbmc/proofs directory contains CBMC proofs.

In order to run these proofs you will need to install CBMC and other tools by following the instructions here.

Reference examples

Please refer to the demos of the MQTT client library in the following locations for reference examples on POSIX and FreeRTOS platforms:

Platform Location Transport Interface Implementation
POSIX AWS IoT Device SDK for Embedded C POSIX sockets for TCP/IP and OpenSSL for TLS stack
FreeRTOS FreeRTOS/FreeRTOS FreeRTOS+TCP for TCP/IP and mbedTLS for TLS stack
FreeRTOS FreeRTOS AWS Reference Integrations Based on Secure Sockets Abstraction

Documentation

Existing Documentation

For pre-generated documentation, please see the documentation linked in the locations below:

Location
AWS IoT Device SDK for Embedded C
API Reference

Note that the latest included version of coreMQTT may differ across repositories.

Generating Documentation

The Doxygen references were created using Doxygen version 1.9.2. To generate the Doxygen pages, please run the following command from the root of this repository:

doxygen docs/doxygen/config.doxyfile

Contributing

See CONTRIBUTING.md for information on contributing.

coremqtt's People

Contributors

abhidixi11 avatar adam-scislowicz avatar aggarw13 avatar angelonakos avatar aniruddhakanhere avatar archigup avatar bradleysmith23 avatar chinglee-iot avatar dcgaws avatar fbbotero-aws avatar feliperodri avatar gkwicker avatar gordonwang0 avatar jasonpcarroll avatar johnrhen avatar karkhaz avatar kstribrnamzn avatar leegeth avatar markrtuttle avatar muneebahmed10 avatar nateglims avatar nrdg42 avatar ronakfof avatar saidrhs avatar sarenameas avatar skptak avatar sukhmanm avatar tony-josi-aws avatar yngki avatar yourslab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coremqtt's Issues

Compile error for comparison of integer expressions of different signedness

../../../../lib/mqtt_client/coreMQTT/source/core_mqtt.c: In function 'sendConnectWithoutCopy':

../../../../lib/mqtt_client/coreMQTT/source/core_mqtt.c:2220:50: error: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]

     assert( ( pIndex - connectPacketHeader ) <= sizeof( connectPacketHeader ) );

LIMIT ON INCOMING MESSAGE SIZE/LENGTH

Is there any limit of incoming messaged to mqtt. I am facing an issue where i am able to receive short message from Aws iot shadow, but when the shadow document has lots of fields(nesting) i am not able to receive the message.

Log functions cause compiler warnings

Hi everybody,

First of all very good job with the new version, the quality seems to be improved massively. I hope this will be the last major version I will be porting :)

I am porting the SDK to Mbed OS, and realized that the log functions cause compiler warnings. My GCC ARM version is 9 2020-q2-update.

There might be some I missed, but here is the what I caught:

[Warning] core_mqtt.c@608,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@623,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@623,25: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@635,21: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
[Warning] core_mqtt.c@717,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@734,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@734,25: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@786,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@813,21: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
[Warning] core_mqtt.c@854,24: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@859,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@949,25: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1388,21: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1406,29: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1775,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1866,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2001,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2061,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2111,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]

MQTT Subscribing for published data (Payload)

Hi,
I have a query , after using the AWS library can i get the data which i have sent to AWS IOT core using MQTT?

Lets say i sent {"Temp":80} now as soon as sent the data , i want to receive once it got published using MQTT.

Assert fails on empty string

I'm trying to port my code from v1.2.0 to v2.1.0, which is integrated into the coreMQTT-Agent. However, I have come across an unexpected assertion firing which was not present in previous v1.2.0. Upon analyzing the code, I discovered that the problem also exists in v2.1.1 too.

assert( ( length != 0U ) == ( string != NULL ) );

In my code I am trying to connect to a test broker that does not require a login and password. That's why I pass empty strings as "" and not NULL. strlen of the empty string returns 0, so this assertion fires: I have a valid string that is not NULL, but its length is 0.

Workaround of this problem can be achieved by passing a pointer to NULL instead of the empty string "". But still I think this case should not be handled as fatal error.

Problem of unnecessary waiting time for reception

I use the FreeRTOS-LTS 2022210.01.
I realized that CoreMQTT had a idle period every data paket of OTA when I do OTA of FreeRTOS.

I doesn't happen when I use previsou version of LTS of FreeRTOS of CoreMQTT ver 1.

It affects the period of OTA because the wast idle time in here.
Below figure is the waveform I got do the OTA using FreeRTOS v202210.01 with CoreMQTT v2.
As you can see the idle period is here at the end of OTA packets.

image

I checked why this issue is happned, then the below code is requested the Receive API not to check the total packet size.
Then, the Receive API is waiting until timeout, because the recevied packet size is smaller than the upper API requested.

recvBytes = pContext->transportInterface.recv( pContext->transportInterface.pNetworkContext,

CoreMQTT receive API says the a byte recevie doesn't block. So we have implemeted it.
But V2 of CoreMQTT happened avobe issue.

https://freertos.github.io/coreMQTT/v2.1.1/group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167

image

Handle QoS2 messages when the library loses state - store state in NVM

It is a very narow corner case but stil it breaks the client and renders it unusable.

  1. coreMQTT client is running on an embedded device, it subscribed to a topic with QoS2.
  2. The issue happens when a message is received and then the device reboots (for unrelated to coreMQTT reasons).
  3. When it boots again and re-connects to the broker it immidiately receives MQTT_PACKET_TYPE_PUBREL but since the device was rebooted the library has no knowleadge of the packet it received before, outgoingPublishRecords is empty and MQTT_ProcessLoop returns MQTTBadResponse.

Q: How would you suggest to handle a situation like this? There are no public functions in the library to get the failed packet id and to get access to outgoingPublishRecords structure that one could simply inject a record with id and MQTT_PACKET_TYPE_PUBCOMP type to let go that record. In the corner case like this I guess it's ok to lose the record since not much you can do if device reboots.

No ack found for packet id

After a running for a long time, these messages accumulate:

I (146451442) network: Attempting to connect to MQTT
I (146450881) hmqtt: Connected to MQTT.
I (146450882) hmqtt: Session present.
E (146450882) coreMQTT: No ack found for packet id 15788.
E (146450886) coreMQTT: No ack found for packet id 16425.
E (146450893) coreMQTT: No ack found for packet id 60272.
E (146450899) coreMQTT: No ack found for packet id 26707.
E (146450905) coreMQTT: No ack found for packet id 28396.
E (146450912) coreMQTT: No ack found for packet id 49384.
E (146450918) coreMQTT: No ack found for packet id 49987.
E (146450925) coreMQTT: No ack found for packet id 62338.
E (146450931) coreMQTT: No ack found for packet id 43880.
E (146450938) coreMQTT: No ack found for packet id 34763.
I (146450944) hmqtt: Session resumed.
I (146451992) network: ConnectToMQTT succeeded
I (146450954) hmqtt: Waiting for network to be ready...
I (146450960) network: Subscribing to MQTT topics ...

This only happens on some devices, some of the time.
What is the cause of this issue? Is it due to maintaining the session across reconnects?

I am using coreMQTT v2.1.1 and coreMQTT-Agent V1.2

Support for MQTT v5.x

The AWS MQTT broker supports MQTT v5.x. To make the most out of integration of devices to AWS MQTT broker using MQTT v5.x, the coreMQTT library needs an update as it currently is compliant to MQTT v3.x
Could this update be considered ?

Thank you.

Fix topic name parsing

The value of the topic name variable is taking the value of the topic name + payload
The error is in the line 1448

Example:

  • TopicName --> $aws/things/test/jobs/start-next/accepted{"clientToken":"test","timestamp":1712955349}

Must be

  • TopicName --> $aws/things/test/jobs/start-next/accepted

PING message interval is not handled properly

It looks like there is a bug in the line core_mqtt.c:1383

        if( ( timeElapsed != 0U ) && ( timeElapsed >= PACKET_RX_TIMEOUT_MS ) )

By default PACKET_RX_TIMEOUT_MS is 30 seconds but PING message is sent every time the Loop function is invoked because timeElapsed is always equal to now when pContext->lastPacketRxTime is 0

The fix I did is this one but I am not sure how it might effect other parts of the code:

        static uint32_t calculateElapsedTime( uint32_t later, uint32_t start )
        {
            return start ? later - start : 0;
        }

I haven't checked other conditions related to invoking MQTT_Ping( pContext );

Documentation - Commented Code Examples

The example code showing how to use MQTT_Init needs to be fixed. From example snippet

MQTTContext_t mqttContext;
TransportInterface_t transport;
MQTTFixedBuffer_t fixedBuffer;
uint8_t buffer[ 1024 ];

// Clear context.
memset( ( void * ) &mqttContext, 0x00, sizeof( MQTTContext_t ) );

// Set transport interface members.
transport.pNetworkInterface = &someNetworkInterface;

transport.pNetworkInterface does not exist. See below.
From coreMQTT/source/interface/transport_interface.h:

typedef struct TransportInterface
{
    TransportRecv_t recv;               /**< Transport receive interface. */
    TransportSend_t send;               /**< Transport send interface. */
    NetworkContext_t * pNetworkContext; /**< Implementation-defined network context. */
} TransportInterface_t;

coreMQTT State Access Audit

Description

CoreMQTT likely relies upon state - state which may be accessible across FreeRTOS tasks. We want to verify CoreMQTT is task/thread safe by ensuring that state access across FreeRTOS tasks is done so behind a synchronization mechanism.

Help is wanted to audit the repository for state which can be used outside of the MQTT task/thread.

This work is being tracked by the FreeRTOS team however it may not be prioritized for some time. Your help in identifying problem state variables/structures will help us in correcting these issues faster. As always, if you are able to fix the issue, we appreciate the help and will gladly look at your PR.

Related Issues

Wifi Disconnection Handling

I currently have a task that handles all coreMQTT access for thread safety which I wrote before I learned of coreMQTT agent. I have a another task that establishes the TLS connection and passes requests for subs, pubs, unsubs, etc. It's been working well in almost all aspect except for when an unexpected disconnection occurs.

When the wifi disconnection happens, I end the connection establishing task. Before ending this task I clean everything up (free memory, disconnect calls, etc). I restart this same task, but the problem a successful connection seems to take a long time (very infrequently) or never at all (most of the time).

So is there a guide on how a reconnection should happen on unexpected network disconnection? I know this question isn't directly related to coreMQTT itself, but I think I've exhausted all the resources available to me. Thank you.

Log functions cause compiler warnings

Hi everybody,

First of all very good job with the new version, the quality seems to be improved massively. I hope this will be the last major version I will be porting :)

I am porting the SDK to Mbed OS, and realized that the log functions cause compiler warnings. My GCC ARM version is 9 2020-q2-update.

There might be some I missed, but here is the what I caught:

[Warning] core_mqtt.c@608,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@623,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@623,25: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@635,21: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
[Warning] core_mqtt.c@717,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@734,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@734,25: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@786,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@813,21: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
[Warning] core_mqtt.c@854,24: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@859,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@949,25: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1388,21: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1406,29: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1775,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@1866,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2001,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2061,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
[Warning] core_mqtt.c@2111,25: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]

Hardfault issue

sendResult = pContext->transportInterface.writev( pContext->transportInterface.pNetworkContext,

when writev function doed not implement due to the stack being painted to the value a5, the function is called at the address a5a5a5a5, which leads to HardFault

What happens when the monotonic clock overflows?

The monotonic clock uses a 32-bit integer in milliseconds and so will overflow in just under 50 days. It does not have a per-connection epoch, so the integrator is required to use something like from boot or from first connection. After 50 days, it will overflow. Does the library handle this (in which case, can it be documented)? Is there some way of resetting the epoch? Failing that, is it possible to have an option to use 64-bit timestamps?

sendBuffer may fail because of tick timer rollover

In core_mqtt.c, sendBuffer a timeout value is calculated by reading the current time and adding some timeout to that value.

timeoutMs = pContext->getTime() + MQTT_SEND_TIMEOUT_MS;

Take the case where current time is very close to, but not yet rolled over. We then add some timeout value causing a rollover on the timeoutMs variable.

We then check if the current time is greater than or equal to the timeout time

if( pContext->getTime() >= timeoutMs )

This check will erroneously fail.

For Example:

current time = 4294957296
timeoutMs = current time + 20000 = 20000

*continue executing*

Current Time = current time + ΔT where ΔT is less than 2^32 - current time 

currentTime >= timeoutMs = true until current time rolls over.

undefined reference to `main' in building phase

When building coreMQTT in Ubuntu 23.10 I get this error:

raphy@raohy:~/libpeer/dependencies/coreMQTT$ gcc -I source/include/ -DMQTT_DO_NOT_USE_CUSTOM_CONFIG -I source/interface/ source/core_mqtt.c source/core_mqtt_state.c source/core_mqtt_serializer.c -o coreMQTT
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

What am I doing wrong? How make it work?

MQTT_Connect is a blocking call

Dear

I am using coreMQTT in an event based embedded architecture and I faced problems with the function MQTT_Connect as it's a blocking function, waiting on the connack message. Due to this blocking behaviour, I never get to the point of processing a TCP receive event which is preventing the connack message to be received.

Why is this function implemented to be blocking?

PS. I currently patched the coreMQTT library to avoid this blocking behaviour. I am willing to share this.

No new tagged version release for over a year

Hi,
I'm wondering why there hasn't been an official release in over a year? We took v2.1.1 considering it was stable, but when the all the fixes going for keep alive handling going to be merged into an official release? Some of these things have been fixed for quite some time!
Thank you!

MQTTEventCallback_t doesn't have user data parameter

A user callback is supposed to have user data passed in, right?

typedef void (* MQTTEventCallback_t )( struct MQTTContext * pContext,
                                       struct MQTTPacketInfo * pPacketInfo,
                                       struct MQTTDeserializedInfo * pDeserializedInfo );

There is no way to use user context inside the callback in this form. How would one pass a class object or container of subscriptions? Global variables or static class members are a very lousy approach.

CROSS COMPILATION

Can anyone tell me the cross compilation instructions for the Library?

Continuously send `PINGREQ` after `PACKET_T(R)X_TIMEOUT_MS`

Hi. I am developing an MQTT client based on coreMQTT-Agent v1.2.0 including coreMQTT v2.1.0. In the config file, I set PACKET_TX_TIMEOUT_MS and PACKET_RX_TIMEOUT_MS with the same value: 10000 (10 seconds). After starting my MQTT task, connecting to the broker and normal messaging, after 10 seconds with a polling interval of 200ms of the recv callback from the transport interface, continuous MQTT_Ping() spam begins. It never ends even if there is an exchange of messages with the broker

image

MQTT v5

Provide support for the new MQTT5 connectivity protocol for all FreeRTOS users. MQTT v5 builds on the MQTT v3.1.1 protocol used by most devices to connect to AWS IoT Core but adding a number of new features. While the most prominent features are impacting large (Industrial) IoT devices allowing them to send multi-megabyte messages (not applicable to the typically constrained FreeRTOS MCU based devices), making the protocol integration available future-proofs FreeRTOS and will strengthen the value proposition of both FreeRTOS and IoT products.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.