1
0
mirror of https://github.com/FreeRTOS/coreMQTT synced 2025-06-02 13:53:40 +08:00

52 Commits

Author SHA1 Message Date
Archit Gupta
b313f0bdbb
Remove config header include in coreMQTT headers (#189)
core_mqtt.h and other coreMQTT headers pull in core_mqtt_config.h and core_mqtt_config_defaults.h.
core_mqtt_config_defaults.h defines empty logging macros. This means every application that uses coreMQTT needs to be careful to set up the logging stack before including core_mqtt.h or they may mysteriously not have logging output.

The logging setup should be in each compilation object, not set up in headers. This moves the inclusion of default logging macros from the headers to the library c files.

This fixes the issue with the logging macros for customers who do not set the logging macros in their core_mqtt_config.h. However, those who do enable logging for coreMQTT will still have their coreMQTT logging setup in all their c files using coreMQTT.
2022-03-18 15:24:01 -07:00
Archit Gupta
76eb955b8c
Fix typo (#188) 2022-01-07 13:56:18 -08:00
Archit Gupta
424ebd3f82
Clear all fields of MQTTPubAckInfo_t when invalidating (#187) 2022-01-07 12:51:57 -08:00
Muneeb Ahmed
785f2f2117
Update version to 1.2.0 (#179) 2021-11-11 12:17:38 -08:00
johnrhen
0f244d4454
Fix inconsistent log levels (#175)
* Change logging level on CONNACK from 'Info' to 'Debug' to reflect CONNECT

* Changed Debug logging to Error logging where MQTTBadResponse is set

* Fix formatting

* Update source/core_mqtt_serializer.c

Co-authored-by: Archit Gupta <71798289+archigup@users.noreply.github.com>

* Change LogInfo to LogDebug on line 958 to mirror line 970

* Fix comments with inconsistent byte indexes

Co-authored-by: Hendrickson <johnrhen@88665a3d649f.ant.amazon.com>
Co-authored-by: Archit Gupta <71798289+archigup@users.noreply.github.com>
2021-09-30 09:49:54 -07:00
Joey Degges
c42daa1b82
Handle all enum values in switches (#174)
Non-functional change to handle all enum values for MQTTPublishState_t
and MQTTQoS_t in switch statements. This allows users to compile with
-Werror=switch-enum.
2021-09-24 19:01:13 -04:00
Muneeb Ahmed
51c8067bff
Update version and add C++ guards (#168)
* Update version numbers

* Update CHANGELOG.md

* Add guards for C++ linkage

* Link to Memory estimates markdown from README

* Make possible to override CMake C Standard for tests
2021-07-22 16:49:59 -07:00
Archit Aggarwal
a108af5297
Remove debug log that can be problematic for non-blocking transport implementations (#167)
The debug-level log that is printed on not receiving any data from the network (when the first byte of an MQTT packet is attempted for reading) can be problematic when the transport interface TransportInterfaceRecv_t function is implemented in non-blocking behavior.

The problem it will cause is overwhelming logging of the message when MQTT_ProcessLoop API is called with a non-zero timeout (or the API is called multiple times with zero timeout but within a loop until some data is achieved). Due to over-logging of this message, the DEBUG logging level configured build of the coreMQTT library will be non-valuable.

This PR removes the problematic log statement.
2021-07-16 16:28:30 -07:00
Muneeb Ahmed
d39236e732
Add check for 0 packet ID for subacks (#159)
* Add check for 0 packet ID for subacks

* Sort lexicon.txt
2021-07-07 20:11:00 -07:00
Muneeb Ahmed
6b222a7c51
Fix keep alive interval check (#163)
* Fix keep alive checking interval

* Update default ping response timeout to a more reasonable value

* Update changelog

* Update doc for MQTT_PINGRESP_TIMEOUT_MS
2021-07-01 10:13:11 -07:00
Archit Aggarwal
363a2fbca2
Update CHANGELOG and file versioning for upcoming release (#153) 2021-02-25 13:56:58 -08:00
David Chalco
1a201a1fe6
Example code - fix incorrect struct member (#150) 2021-01-19 13:26:07 -08:00
Muneeb Ahmed
096ec21c55
Check for empty topic filters in subscribes (#139)
* Validate each topic filter in a subscribe or unsubscribe packet is of nonzero length
2020-12-11 01:26:18 -08:00
Archit Aggarwal
c7a2c898b3
Update API documentation of transport send/recv functions (#136)
Update API of the transport interface functions for the following:

* Transport recv() should NOT block when requested to read a single byte. It MAY block for the underlying socket timeout when requested to read n > 1 bytes.
* Transport send() should NOT return an error when the send fails because of a full TX buffer of the underlying network stack, so that the calling library can retry the send operation.
2020-12-09 22:25:48 -08:00
SarenaAWS
cf7406a98c
Add the current version as a macro to the library. (#135)
So that the version can be used in metrics collection and anywhere else it is needed.
2020-12-09 17:25:50 -08:00
SarenaAWS
d96960ec8d
Update v1.0.1 to v1.1.0 and 202011.00 to 202012.00 for memory estimates link. (#131) 2020-12-09 11:33:30 -08:00
Archit Aggarwal
9ef7fe91c1
Add doc that keep-alive is unsupported with dummy timer (#132)
Update API doc to mention that the keep-alive mechanism is not supported by MQTT_ProcessLoop API when a dummy timer function that always returns zero is supplied to the library.
2020-12-09 10:57:07 -08:00
Muneeb Ahmed
fdfb78df4b
Remove references to MQTT from readme headers (#130)
* Remove references to MQTT from readme headers

* Move parenthesis
2020-12-08 21:42:13 -08:00
Archit Aggarwal
037a2510c6
doc: add info to set timeout configs to zero when timer is dummy (#128) 2020-12-08 15:29:18 -08:00
Archit Aggarwal
510a3f6eca
Update APIs to detect partial sends as failures (#127)
* Fix issue of data recv being interrupted

* Rename elapsedTimeMs variable to its express its new meaning

* Use configuration const for recvExact timeout

* Remove timeout check from discardPacket and address CI check failures

* Fix more CI check failures

* Remove another unused local variable

* Re-instate timeout in discard to reduce scope of changes

* Remove unused variable again

* Fix failing unit test

* Rename new config macro, and attempt to fix CBMC failures

* Doc: Improvement suggestions from code review

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>

* Fix quality check failures

* Add test case to check partial network reads with zero timeout duration for ProcessLoop

* style: Improving naming

* Address complexity failure

* Address comments

* Doc: Add blocking time equation of Receive/ProcessLoop functions in their API doc

* Improvement in API doc

* Set MQTT_RECV_POLLING_TIMEOUT_MS so that recvExact runs in one iteration always for cbmc.

* doc: Add information about zero return value for Transport_Recv_t

* fix: prevent possibility of infinite loop in timeout logic of ProcessLoop

* style: Minor changes

* hygiene: minor name fix

* fix: Possibility of infinite loop in sendPacket

* Add the new configuration to doxygen

* test: Add mock transport send function that always returns zero

* fix: Issues in sendPacket and sendPublish

* test: add test for sendPacket timeout

* Update Timer Overflow test

* test: temporarily comment out unused variable

* test: fix the timer overflow test

* Address review comments

* style: make log messages concise

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>

* Update call sites of sendPacket to treat partial sends as failure

* test: Add send timeout coverage for APIs calling sendPacket

* test: Add coverage for send timeout in APIs calling sendPacket

* test: review feedback

* ci: address spell check error

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
Co-authored-by: Sarena Meas <sarem@amazon.com>
2020-12-07 16:02:39 -08:00
Archit Aggarwal
0a2172b896
Fixes in internal logic of sending packets (#124)
* Fix issue of data recv being interrupted

* Rename elapsedTimeMs variable to its express its new meaning

* Use configuration const for recvExact timeout

* Remove timeout check from discardPacket and address CI check failures

* Fix more CI check failures

* Remove another unused local variable

* Re-instate timeout in discard to reduce scope of changes

* Remove unused variable again

* Fix failing unit test

* Rename new config macro, and attempt to fix CBMC failures

* Doc: Improvement suggestions from code review

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>

* Fix quality check failures

* Add test case to check partial network reads with zero timeout duration for ProcessLoop

* style: Improving naming

* Address complexity failure

* Address comments

* Doc: Add blocking time equation of Receive/ProcessLoop functions in their API doc

* Improvement in API doc

* Set MQTT_RECV_POLLING_TIMEOUT_MS so that recvExact runs in one iteration always for cbmc.

* doc: Add information about zero return value for Transport_Recv_t

* fix: prevent possibility of infinite loop in timeout logic of ProcessLoop

* style: Minor changes

* hygiene: minor name fix

* fix: Possibility of infinite loop in sendPacket

* Add the new configuration to doxygen

* test: Add mock transport send function that always returns zero

* fix: Issues in sendPacket and sendPublish

* test: add test for sendPacket timeout

* Update Timer Overflow test

* test: temporarily comment out unused variable

* test: fix the timer overflow test

* Address review comments

* style: make log messages concise

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
Co-authored-by: Sarena Meas <sarem@amazon.com>
2020-12-07 10:37:26 -08:00
Oscar Michael Abrina
4f7d1b9f9e
Enable debug logging in unit-test build and fix logging compilation error (#125)
- Update core_mqtt_config.h to specify logging level as LOG_NONE
- Update GA to set logging level as LOG_DEBUG
- Fix compile error in LogDebug of recvExact
2020-12-06 18:09:58 -08:00
Archit Aggarwal
b581fc4172
Bugfix: Fix interrupted network read operation (#120)
### Problem

The `MQTT_ProcessLoop` and `MQTT_ReceiveLoop` read incoming MQTT packet payload over the network by calling the `recvExact` function. The `recvExact` function can be called multiple times to read the expected number of bytes for the MQTT packet but it also implements a timeout functionality of receiving the expected number of payload within the timeout value passed to the function.
This causes problems when the `Transport_Recv` call returns less than requested number of bytes, and there is a timeout (for example, when calling `MQTT_ProcessLoop` with 0ms duration) which causes the function to assume failure instead of reading the remaining payload of the MQTT packet by calling `Transport_Recv` again. Thus, in such cases, the MQTT connection is severed prematurely even though there is a high probability of receiving the remaining bytes of the MQTT packet over the network.

### Solution
Instead of implementing a timeout on the entire duration of receiving the expected number of remaining MQTT packet bytes in `recvExact`, the use of timeout is being changed to be relevant only on the total time of receiving 0 bytes over the network over multiple calls to `Transport_Recv`.
As this modified meaning of the timeout duration is now unrelated to the timeout duration that the `MQTT_ProcessLoop` or `MQTT_ReceiveLoop` functions are called, a new configuration constant for the `recvExact` timeout value, `MQTT_RECV_POLLING_TIMEOUT_MS`, has been added to the library which will carry a default value of 10ms. 

Co-authored-by: Sarena Meas <sarem@amazon.com>
2020-12-04 19:49:40 -08:00
Muneeb Ahmed
73472634c6
Use stdbool.h always(#118)
* Add custom stdbool.readme file

* Add custom stdint.readme file

* Add GitHub Action to test .readme headers

* Tested GA by pushing an invalid file
2020-12-04 10:26:49 -08:00
Oscar Michael Abrina
8de05fa001
Fix typo in MQTT_Unsubscribe code example (#122)
This fixes a typo in the code example that was raised in issue #119
2020-12-04 10:00:31 -08:00
Muneeb Ahmed
ca492a40f0
Fix incorrect size compiler warning (#116) 2020-12-01 19:17:48 -08:00
Muneeb Ahmed
e1b81ae409
Remove %.*s format specifier from logs (#117) 2020-12-01 18:16:53 -08:00
Oscar Michael Abrina
de4edcd578
Cast variable type based on format identifier (#113)
Update logs to only ever use base format specifiers and cast to the standard C type to minimize compilation warnings.
2020-11-24 14:34:28 -08:00
SarenaAWS
4b8674a806
Update all references from master to main. (#110) 2020-11-18 12:27:01 -08:00
SarenaAWS
66a35e4213
Update version v1.0.0 to v1.0.1. (#97) 2020-11-02 12:11:10 -08:00
Muneeb Ahmed
1bb7a23f5c
Align wording of Init with porting guide (#95)
* Align wording of Init with porting guide

* Also add notes for connect, processloop, and receiveloop
2020-10-30 11:30:00 -07:00
SarenaAWS
93c15bdab8
Move transport_interface.h from portable/ to interface/ (#91)
* Move transport_interface.h to interface/ folder.

* Replace all paths to portable with interface.
2020-10-28 14:53:06 -07:00
Oscar Michael Abrina
7f0478d13a
Remove const qualifier from send/recv in transport interface (#86)
This follows changes from FreeRTOS/FreeRTOS@398abba. The const qualifier is removed from send/recv because there are transport implementations that require a member of the network context to be modified such as in the case of mbedtls.
2020-10-21 11:12:28 -07:00
Oscar Michael Abrina
c0fadc4339
Resend PUBACK and PUBREC irrespective of the DUP flag (#83)
This updates the coreMQTT library so as to resend a PUBACK and PUBREC for an incoming duplicate publish packet, irrespective of the broker setting the DUP flag.
2020-10-07 13:47:33 -07:00
Muneeb Ahmed
38f24af76c
Set NULL payloads and fix unit test (#71)
* Set publish payload to NULL when zero length

* Add unit test for zero length payload

* Fix unit tests for deserialize publish

* Rename setupWillInfo to setupPublishInfo

* Remove void * from memset
2020-09-18 17:40:33 -07:00
Archit Aggarwal
227c31e53e
Update versioning case (#66) 2020-09-16 11:36:03 -07:00
Oscar Michael Abrina
0e1f5fb728
Add version number and missing @file tags (#53)
* Add version numbers

* Add missing @file tags

* Update lexicon.txt

* Update @brief tag for MQTT cbmc state

Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com>
2020-09-14 16:54:24 -07:00
abhidixi11
9e62b8daac
Session present flag fix. (#56)
Update deserializeConnack private function to set output parameter flag when session present bit is not set in CONNACK response
2020-09-12 13:12:28 -07:00
SarenaAWS
e8f8c5394c
Update the transport_interface for multiple page and section definition warnings in the CSDK hub (#46) 2020-09-10 16:31:37 -07:00
SarenaAWS
76cd50a135
Add documentation for MQTT_DO_NOT_USE_CUSTOM_CONFIG (#42)
Co-authored-by: Archit Aggarwal <architag@amazon.com>
2020-09-09 13:22:02 -07:00
SarenaAWS
ea7d08f9bd
Move lexicon.txt to the top level. (#41) 2020-09-09 09:16:19 -07:00
Archit Aggarwal
9fc6f76b6d
Hygiene update of logging interface macro docs in config defaults (#33) 2020-09-08 14:51:17 -07:00
SarenaAWS
6631dde60d
Add doxygen docs to transport_interface.h (#40) 2020-09-08 12:49:53 -07:00
Archit Aggarwal
d410251813
Add config to allow MQTT build without custom config (#22) 2020-09-04 13:33:54 -07:00
Archit Aggarwal
d355bfa259
Re-brand lightweight MQTT as MQTT serializer (#29)
Rename all instance of "lightweight" MQTT with "serializer" in files and documentation
2020-09-03 14:56:32 -07:00
Muneeb Ahmed
e914df6d22
Fix MISRA 10.3 violation (#31)
* Change a UL to a U for a uint32_t
2020-09-03 11:26:14 -07:00
Archit Aggarwal
d0cc7ba5b3
Add spell check support to repository (#21)
* Add spell check scripts under tools/spell
* Break lexicon file into specific files for source/ and test/unit-test directories
2020-09-01 16:17:53 -07:00
Muneeb Ahmed
f0a8b3c1b3
Fix doxygen build due to renamed files (#20)
* Fix doxygen build due to renamed files

* ci: combine doxygen stderr into stdout
2020-09-01 12:25:24 -07:00
Muneeb Ahmed
54b54e78ad
Add define guards and change spellings (#15)
* Add checks for definition of false and true

* Prefer American spellings for optimize and acknowledgment
2020-08-31 14:51:21 -07:00
Muneeb Ahmed
b6bf2005ca
Fix bug that may sometimes disable keep alive (#7)
* Reset the waitingForPingResp flag in every MQTT_Connect
2020-08-31 12:45:46 -07:00