1
0
mirror of https://github.com/FreeRTOS/coreMQTT synced 2025-06-29 15:16:46 +08:00

446 Commits

Author SHA1 Message Date
SarenaAWS
5634426244 Doxygen templates and instructions for writing docs for a new library (#1150)
* Add doxygen templates and instructions for writing docs for a new library.
* Make some fixes to the MQTT library doxygen.
2020-08-25 23:23:35 -07:00
SarenaAWS
ef2a080052 Doxygen for MQTT API Only (#1149)
* MQTT API doxygen documentation and supporting files.

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
2020-08-24 15:53:59 -07:00
Archit Aggarwal
4fb7f3c24f Add 3 test cases for full branch coverage of MatchTopic (#1156) 2020-08-24 15:02:00 -07:00
Muneeb Ahmed
0884ff0f4d Clear old records for clean sessions (#1148)
* Clear state records when a CONNACK's session present flag is false

Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com>
2020-08-24 13:33:45 -07:00
Muneeb Ahmed
ff63b3342e Add code examples for new and state API functions (#1146)
* Add code examples for MQTT_PublishToResend, MQTT_MatchTopic, and MQTT_GetSubAckStatusCodes

Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com>
2020-08-24 12:57:34 -07:00
Archit Aggarwal
814e73948b Add #error statements for CLIENT_CERT_PATH and CLIENT_PRIVATE_KEY_PATH macros (#1155) 2020-08-24 11:56:25 -07:00
Muneeb Ahmed
05b141658a Change state status code and increase coverage (#1140)
* Change a status code in MQTT_UpdateStateAck to MQTTBadParameter when a record is not found

* Add some unit tests to increase code coverage
2020-08-21 16:31:56 -07:00
Archit Aggarwal
afc448615c Fix flaky behavior of LWT test (#1147) 2020-08-20 17:25:04 -07:00
Archit Aggarwal
9614fd8b9d [PR from CLI tool] Add MQTT demo for connection sharing with subscription manager (#1098) 2020-08-20 15:53:17 -07:00
Archit Aggarwal
b8b79b783d Proof for MQTT_MatchTopic API (#1137) 2020-08-20 13:06:20 -07:00
Muneeb Ahmed
8741986353 Add doxygen code examples for mqtt_lightweight.h (#1135)
* Add doxygen code examples for mqtt_lightweight.h

* Comment fixes in mqtt.h

Co-authored-by: SarenaAWS <6563840+sarenameas@users.noreply.github.com>
2020-08-18 16:57:16 -07:00
Archit Aggarwal
2799ee65da [PR from CLI tool]
Add utility for MQTT topic filter and topic matching to library (#1119)

* Add topic matching utility to MQTT API

* Add thorough unit tests for topic matching utility

* Fix failing ExactMatch unit test

* Add topic matching parameter names to mqtt/lexicon.txt

* Fixes caught in code review

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

* Remove problematic assert in matchWildcardsSpecialCases and make hygiene parameter re-ordering changes

* Add another param name to mqtt/lexicon.txt

* Update topic matching to support corner case of matching topic filter ending with "/#" with topic name ending with "/"

* Remove duplicate word entry in mqtt/lexicon.txt

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

* Fix bugs in topic matching algorithm that allowed matching when wildcards are not preceding with '/'

* Slight style change for improved readability to matchWildcards function

* Re-add param names to mqtt/lexicon.txt that were removed in merge conflict resolution

* Rename private function for better expressivity

* Revert "Rename private function for better expressivity"

This reverts commit fe22642a4d723342dbb4c37f2df28c7aea9df0ca.

* Hygiene changes for better readability

* Add more cases to unit tests

* Hygiene changes for invoking matchEndWildcardsSpecialCases function

* More hygiene refactors from review comments

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

* Separate Match and no-match test case sets for # willdcard

* Remove extraneous param docstring for private function

* Add note to MatchTopic API about assumption and behavior of function

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
2020-08-18 15:38:02 -07:00
Archit Aggarwal
aa36fb1082 Fix MQTT_GetSubAckStatusCodes API, and add CBMC proof for it (#1132)
* Add CBMC proof for MQTT_GetSubAckStatusCodes function
* Fix parameter type in API signature found by CBMC proof
2020-08-18 15:21:30 -07:00
SarenaAWS
c772b2214f Fix doxygen warnings in MQTT Library documentation (#1122)
Ignore private functions in mqtt_state.h and .c
2020-08-18 12:24:01 -07:00
Archit Aggarwal
959515328b Hygiene changes in MQTT demos and tests (#1128)
* Upgrade MQTT integration test to use mutual auth, and update its build setup to use CMake cache variables for credentials

* Fix build warning from logging

* Remove references to test.mosquitto.org from demos
2020-08-18 11:21:58 -07:00
Muneeb Ahmed
86dad4faaf Add doxygen code examples for mqtt.h (#1123)
* Add code examples for mqtt.h
2020-08-14 10:44:45 -07:00
Oscar Michael Abrina
d31e39dd5e Download certs into demos/certificates with an option to disable downloading (#1126)
* Add option to turn off downloading of certificates and create demos/certificates directory

* Remove Mosquitto certificate from list of certs to download

* Address PR comments

* Add CMake command line options to use for configuring demos

* Update README.md to contain extra flag for ROOT_CA_CERT_PATH

* Set prefix to PWD if any path flags are relative
2020-08-14 09:39:39 -07:00
SarenaAWS
250d32d0a7 Add cbmc pointer primitive check flag and mqtt_lightweight.c small refactor (#1120)
* Update proof templates, add proof flag --pointer-primitive-check

* Fix overflow in MQTT_SerializeSubscribe, MQTT_SerializeUnsubscribe, MQTT_SerializePublish, and MQTT_SerializePublishHeader.

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
2020-08-14 08:05:02 -07:00
Muneeb Ahmed
504d919814 Add macro for ping response timeout (#1113)
* Add macro to initialize ping response timeout

* Remove pingRespTimeoutMs field from MQTT context

* Add macro to demo configs

* Remove unused MQTT_MAX_QUEUED_PUBLISH_MESSAGES macro
2020-08-13 16:08:32 -07:00
Archit Aggarwal
997cc0e819 [PR from CLI tool] Add new MQTT API for obtaining SUBACK codes (#1108)
* Add new API in lightweight MQTT for extracting payload from SUBACK packet

* Add parameter names of new API to lexicon.txt

* Minor updates

* Update readSubackStatus in lightweight file to use named constants

* Address hygiene comments from review

* Move new API for SUBACK decoding from lightweight to managed layer

* Make minor changes suggested in review comments

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

* Rename API for customer usability and update doc

* Remove new QoS and SUBACK failure macros from lightweight API; Add a new enum for SUBACK status in managed API

* Fix CI build issues

* Adding another word to lexicon.txt for spell check

* Address MISRA violation of type promotion in subtraction logic

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

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
2020-08-12 18:34:55 -07:00
Archit Aggarwal
93dd4aee17 Fix build warnings from logging pointers in MQTT library (#1109) 2020-08-12 14:31:42 -07:00
Archit Aggarwal
1bdc9b7762 Address unused parameter and unused variable warnings (#1117) 2020-08-12 14:27:06 -07:00
Muneeb Ahmed
36a27e6d9b Add doxygen comments, remove unused fields (#1112)
* Add doxygen comments to structs and enums in mqtt.h

* Remove unused publish count parameters in MQTTContext_t
2020-08-11 11:46:24 -07:00
Archit Aggarwal
bed0ba61dd Minor hygiene updates for logging (#1096)
* Log stripped out filename as metadata instead of function name for ISO C adherence
* Make ERROR_LOG as default logging verbosity for MQTT unit tests
2020-08-07 11:39:55 -07:00
Muneeb Ahmed
26a2990384 Return suback when server refuses subscription (#1089)
* Return suback when server refuses subscription

* Add new deserialized struct parameter to callback

* Continue process loop if server refused
2020-08-07 10:53:27 -07:00
Muneeb Ahmed
9fff9d9030 Improve format specifiers in logs (#1097)
* Remove C99 %hhu format specifier

* Add unsigned long to %lu format specifiers

* Log stringified status codes instead of integers
2020-08-07 10:33:37 -07:00
Archit Aggarwal
a26a769fb4 Fix logging call in MQTT, Make hygiene improvement in logging stack (#1095)
* Fix issues with logging across files

* Fix format specifier causing warning
2020-08-04 11:14:39 -07:00
SarenaAWS
c43f4d85f9 CBMC Proofs for MQTT and Some HTTPClient_Send proof updates (#1079)
* Add MQTT proofs:

MQTT_Connect
MQTT_Disconnect Proof
MQTT_Publish
MQTT_Subscribe harness
MQTT_Unsubscribe
MQTT_ReceiveLoop proof

* Add some clarification comments.
2020-08-01 21:17:39 -07:00
Archit Aggarwal
624cab81f5 Integ tests/mqtt retain flag (#1086)
Add integration test for verifying that the MQTT library supports the "retained" PUBLISH message feature
2020-07-31 11:46:18 -07:00
Archit Aggarwal
12337f8c1d Integ tests/more cases of mqtt restore session (#1083)
Add integration tests for:
1) Resending unacked PUBLISH packets (Qos 1 and QoS 2)
2) Receiving duplicate PUBLISH packets (QoS 1 and QoS 2) from the broker in restored session
2020-07-29 10:02:02 -07:00
SarenaAWS
9339eaadfd CBMC Proofs for MQTT_ProcessLoop and MQTT_Ping (#1061)
- Add licenses where missing. 
- Add helpful comments where needed else where.
- Fix MQTT_DeserializeAck proof.
2020-07-28 15:37:49 -07:00
Archit Aggarwal
4fa7af335b Integ tests/mqtt restore session (#1078)
Add integration tests for MQTT session restoration when
1) Unacked PUBREL packets are resent by the client
2) Duplicate PUBREL packets are sent by broker
2020-07-28 14:56:21 -07:00
Archit Aggarwal
5ea624fd0c MQTT Hygiene: Remove "callback" label from getTime function (#1071)
Remove MQTTApplicationCallbacks_t struct from MQTT and add getTime and appCallback as separate members of MQTTContext_t struct
2020-07-28 09:57:46 -07:00
SarenaAWS
6eb8f60839 mqtt.c updates in sendPacket(), asserting on developer bugs, and payload length of zero. (#1082)
* Move assert on bug in the transport rx/tx to after checking for a negative returned. This is done to avoid overflow on the signed to unsigned conversion.
* Delete check for the sendPacket return not equal to the total amount to send. sendPacket() returns only the full amount to send OR a negative return code.
* Check for a payload length of zero for a publish. When the payload length is zero, then the payload buffer is allowed to be NULL. Added unit tests for this case.
2020-07-27 22:02:42 -07:00
SarenaAWS
a5b7d74771 Update mqtt.c send and recv functions to assert on more bytes than expected. (#1073)
Updated missed pFixedBuffer variable name changes.
Add periods in logs where missing.
Add docs to the user callbacks.
Add unit tests where coverage is missing.
Address missing MISRA flags.
2020-07-23 17:28:32 -07:00
Archit Aggarwal
f6f47cbef5 Fix failing MQTT unit test in Release builds (#1069)
* Fix missing network buffer initialization logic causing test case failure
2020-07-22 21:42:19 -07:00
Muneeb Ahmed
962dbd83ca Add system tests for LWT and Keep Alive (#1013)
* Add system tests for LWT and Keep Alive

* Add sleep function to clock.h
2020-07-22 11:51:03 -07:00
markrtuttle
bca363cfa2 Repair loop names mangled by the new cbmc. (#1041)
Co-authored-by: Mark R Tuttle <mrtuttle@amazon.com>
Co-authored-by: SarenaAWS <6563840+sarenameas@users.noreply.github.com>
2020-07-21 17:42:03 -04:00
Navin Soni
ecce7dacb4 Add code for unittest (#1062)
* Add code for unittest

* Fix lexicon.txt

Fix topicfilterlength in lexicon.txt in MQTT to be all lowercase.

* update run targets

* Fix check status

Co-authored-by: SarenaAWS <6563840+sarenameas@users.noreply.github.com>
2020-07-21 13:08:23 -07:00
SarenaAWS
792a83644f Fix straggling lexicon words in mqtt and fixed spelling of retrieve. (#1060) 2020-07-17 15:44:52 -07:00
Muneeb Ahmed
a8acd64b23 Set keep alive interval and update unit tests (#1057)
* Set keep alive interval and update unit tests

* Change error log when no packet is available
2020-07-15 16:58:25 -07:00
SarenaAWS
3d1ba3bb59 MQTT CBMC Proofs (#1052)
CBMC proofs for:

MQTT_SerializeAck()
MQTT_SerializeDisconnect()
MQTT_SerializePingreq()
MQTT_SerializePublish()
MQTT_SerializePublishHeader
MQTT_SerializeSubscribe()
MQTT_SerializeUnsubscribe()
2020-07-15 14:42:47 -07:00
Muneeb Ahmed
c3167da7c8 Initialize variables and add macro for magic num (#1056) 2020-07-14 17:56:14 -07:00
SarenaAWS
ae83c5c006 Add lexicon.txt to demos, libraries, and platform. (#1054)
Add lexicon.txt to demos, platform, libraries/standard/http, libraries/standard/json, and libraries/standard/mqtt.
Fix spelling mistakes where they were found.
Update script to ignore the third_party folder.
Add README.md on how to create a new lexicon.txt.
2020-07-14 11:47:09 -07:00
SarenaAWS
35360bc7cb Fix warnings in http_client.c and mqtt_lightweight.c (#1053)
Deleted commas in the middle of log strings.
Fixed incorrect string modifiers.
2020-07-14 09:54:50 -07:00
SarenaAWS
1709adac58 Add parameter checks and documentation to MQTT Lightweight files (#1044)
* Add unit tests for the parameter checks.
2020-07-10 14:01:33 -07:00
Oscar Michael Abrina
8b48da8f27 Add reconnection logic to all MQTT demos and update to use common transport interface (#1036)
* Get all unit tests to pass

* Update integration tests to common transport interface

* Update OpenSSL send and recv to poll

* Update OpenSSL send and recv

* Update plaintext demo to use common transport interface and removal of warnings

* Get mutual auth demo to compile but not returning successfully

* Remove usage of poll in OpenSSL transport send/recv

* Update based on latest changes to OpenSSL transport recv

* Make certs directory if not exist

* Add reconnection logic to mqtt basic tls demo

* Add reconnection logic to lightweight demo and update transport interface

* Make all demos consistent with each other

* Update CBMC proofs to follow suit

* Remove unnecessary includes

* Add missing time.h include to mqtt_demo_plaintext

* Remove unnecessary cast for network context buffer

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

* Address PR comments

* Refactor Clock_GetTimeMs into clock_posix.c

* Fix accidental replace

* Remove accidentally pushed certificate

* Remove time.h include from mqtt plaintext demo

* Update demos/mqtt/mqtt_demo_lightweight/mqtt_demo_lightweight.c

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

* Update demos/mqtt/mqtt_demo_mutual_auth/mqtt_demo_mutual_auth.c

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

* Update demos/mqtt/mqtt_demo_mutual_auth/mqtt_demo_mutual_auth.c

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

* Update demos/mqtt/mqtt_demo_mutual_auth/mqtt_demo_mutual_auth.c

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

* Address PR comments

* Address PR comments

* Fix error in fixing merge conflict

* Fix redefinition of NetworkContext_t in mqtt_config.h

* Fix PUBREC comment in demos/mqtt/mqtt_demo_basic_tls/mqtt_demo_basic_tls.c

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

* Fix PUBREC comment in demos/mqtt/mqtt_demo_basic_tls/mqtt_demo_basic_tls.c

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

* Address PR comments

* Address PR comments

* Remove test assert for packet type != MQTT_PACKET_TYPE_PINGRESP

* Add back handling of MQTT_PACKET_TYPE_PINGRESP

* Add MQTT_PACKET_TYPE_PINGRESP log for mqtt system test

* Address PR comments

* Update library name of transport_posix

* Address PR comments and add reconnect logic changes

* Update comment in demos

* Remove accidentally pushed cert

* Update demos

* Add missing closing parenthesis

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
2020-07-10 12:19:24 -07:00
SarenaAWS
f4326981e2 CBMC Proofs for MQTT_SerializeConnect and MQTT_DeserializePublish (#1039) 2020-07-08 21:17:21 -07:00
SarenaAWS
ef43cf3091 Add overflow and null parameters checks to MQTT_GetConnectPacketSize and others (#1035)
* Add parameter check for will message payload length in MQTT_GetConnectPacketSize()
* Add documentation about the necessity of MQTT_GetConnectPacketSize()
* Add missing private static function documentation for consistency
* Add documentation about starting over the packet ID at 1.
* Add more parameter checks to MQTT_SerializeConnect()
* Add unit tests for changes.
* Disable logging in the HTTP Client unit tests.
2020-07-06 16:53:32 -07:00
leegeth
b6cd892b86 Fix for PINGRESP Deserializing (#1038)
Allow deserializing of PINGRESP with NULL pointer to remaining data.
2020-07-06 16:46:11 -07:00