mirror of
https://github.com/FreeRTOS/coreMQTT
synced 2025-05-14 14:19:42 +08:00

* Update ci.yml (#197) * Update ci.yml * Add main branch in the CI YAML * Add cancel callback API (#196) * Add cancel callback command * Update the function name * Fix formatting * Update memory estimates * Add State to MQTT_ProcessLoop so that it can be called in a non-blocking manner (#198) * Add stateful process-loop function * Add extra checks; fix bugs and add description of functions * Add index based stateful processloop * Clean up * Renamed functions to make them more coherent with their function * Remove unused function declarations * Fixed failing CI checks from previous commits except unit-test * Fixed spell check and updated size-table * Fix CBMC proofs * Empty-Commit to trigger CBMC proofs * Fix loop unwinding values in the Makefile * Add upper bound on the buffer size of MQTT * Increase minimum limit on buffer size to >0 * Add upper bound on the size of the buffer as well * CBMC: Add memmove stub to accelerate coverage The commit adds a stub for memmove accelerate CBMC coverage calculation. Without this stub, coverage for `MQTT_ProcessLoop` and `MQTT_ReceiveLoop` fails to converge (gets stuck generating the SAT formula for the memmove in `receiveSingleIteration`). This stub checks that src and dst are nonnull pointers and havocs dst. * Fix formatting Co-authored-by: Aniruddha Kanhere <ubuntu@ip-172-31-25-12.us-west-2.compute.internal> Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com> * Remove the use of common buffer (#199) * Make publish use internal buffers * Fix comment about packet ID * Try a different approach for ping and disconnect * Use writev and flush in conjuction with send * Update the publish method to use vectors * Add vectored IO to all functions * Fix formatting * Reduce complexity score * Fix spell check and complexity score * Fix breaking build * Add doxygen comments * Fix doxygen part 2 * Doxygen fix part 3 * Fix doxygen part 4 * Fix some checks * Fix memory tables * Fix some small errors * Fix compiler warnings and breaking CI checks from previous commit * Fix spell check and doxygen * Fix a couple of CBMC proofs * Fix ping and publish proofs * Update the function name * Fix more CBMC proofs * Fix MQTT Connect proof * Add unwinding loops * Fix last CBMC proof * Fix formatting * Update the Subscribe and Unsubscribe functions * Fix formatting and doxygen checks * Fix broken CBMC proofs * Fix memory statistic table * Revert changes from serializer source * update comments to clarify write requirements * Add a note for write function pointer * Fix spell check * Update changelog (#202) * Update MQTT logging so that log levels of the library do not leak (#205) * Replace publish state arrays with pointers Added an MQTT_InIt function for QoS > 0 publishes Fixed functions which were dealing with state arrays * Fix CI checks and clean up * Fix CBMC proofs * Fix sub and unsub CBMC proofs * Fix remaining proofs * Fix remaining CI checks * Fix spell check * Minor typo fix (#209) * Update core_mqtt.h (#208) * Update core_mqtt.h * Update core_mqtt.h Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Update documentation and Doxygen comments in the source (#206) * Update comments of the MQTT_InIt function * Updating documentation of more of functions * Fix formatting and spell check * Update core_mqtt.h * Add hooks to the source code (#200) * Add mutex hooks * Clean up of code * Add doxygen comments and fix spell check * Fix LogError call * Fix formatting and memory table * Fix dereference failure * Update the hook names * Fix broken builds * Update the macros and variables * Reword the briefs of hooks and uncrustify * Fir formatting * Protect get packet ID * Fix formatting * Fix Unit tests (#212) * Fix Unit tests * Update unit tests after new changes * Fix more UT * add dummy calls to the transport * fix build error * Remove usused variables * Remove unsused variables * Remove usused variables * Unsued parameter * Fix ut failure * Fix uninitialized unit test variables * Fix ut expectation * Fix unit-tests * Fix unit test uninitialized variable * increase unit test coverage * increase unit test coverage * Fix unit test build * State coverage 100% * Serializer 100% coverage * 100% UT coverage * Fix formatting * Fix size table * Address PR comments Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Remove unnecessary ternaries (#211) Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Fix misra deviations (#213) * MISRA compliance update 1 * Fix MISRA errors * Zero MISRA violations; 13 suppressed * Fix CI checks * Update MISRA.md * Remove deviations * Fix MISRA.md file * Fix bug - wasn't incrementing vector length properly. * Remove unwanted files * Update comment to clarify the control flow of UT * Remove 'dev' branch from the CI checks * Update horrid threshold = 10 Co-authored-by: Aniruddha Kanhere <ubuntu@ip-172-31-25-12.us-west-2.compute.internal> Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> Co-authored-by: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Co-authored-by: Archit Gupta <71798289+archigup@users.noreply.github.com>
76 lines
3.3 KiB
Plaintext
76 lines
3.3 KiB
Plaintext
/**
|
|
@page mqtt_porting Porting Guide
|
|
@brief Guide for porting MQTT to a new platform.
|
|
|
|
A port to a new platform must provide the following components:
|
|
1. [Configuration Macros](@ref mqtt_porting_config)
|
|
2. [Transport Interface](@ref mqtt_porting_transport)
|
|
3. [Time Function](@ref mqtt_porting_time)
|
|
|
|
@section mqtt_porting_config Configuration Macros
|
|
@brief Settings that must be set as macros in the config header `core_mqtt_config.h`, or passed in as compiler options.
|
|
|
|
@note If a custom configuration header `core_mqtt_config.h` is not provided, then the @ref MQTT_DO_NOT_USE_CUSTOM_CONFIG macro must be defined.
|
|
|
|
@see [Configurations](@ref core_mqtt_config)
|
|
|
|
The following macros can be configured for the managed MQTT library:
|
|
- @ref MQTT_PINGRESP_TIMEOUT_MS <br>
|
|
- @ref MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT
|
|
|
|
In addition, the following logging macros are used throughout the library:
|
|
- @ref LogError
|
|
- @ref LogWarn
|
|
- @ref LogInfo
|
|
- @ref LogDebug
|
|
|
|
@section mqtt_porting_transport Transport Interface
|
|
@brief The MQTT library relies on an underlying transport interface API that must be implemented
|
|
in order to send and receive packets on a network.
|
|
|
|
@see [Transport Interface](@ref mqtt_transport_interface)
|
|
|
|
The transport interface API used by MQTT is defined in @ref transport_interface.h.
|
|
A port must implement functions corresponding to the following functions pointers:
|
|
- [Transport Receive](@ref TransportRecv_t): A function to receive bytes from a network.
|
|
@code
|
|
int32_t (* TransportRecv_t )(
|
|
NetworkContext_t * pNetworkContext, void * pBuffer, size_t bytesToRecv
|
|
);
|
|
@endcode
|
|
- [Transport Send](@ref TransportSend_t): A function to send bytes over a network.
|
|
@code
|
|
int32_t (* TransportSend_t )(
|
|
NetworkContext_t * pNetworkContext, const void * pBuffer, size_t bytesToSend
|
|
);
|
|
@endcode
|
|
|
|
The above two functions take in a pointer to a @ref NetworkContext_t, the typename of a
|
|
`struct NetworkContext`. The NetworkContext struct must also be defined by the port, and
|
|
ought to contain any information necessary to send and receive data with the @ref TransportSend_t
|
|
and @ref TransportRecv_t implementations, respectively:
|
|
@code
|
|
struct NetworkContext {
|
|
// Fields necessary for the transport implementations, e.g. a TCP socket descriptor.
|
|
};
|
|
@endcode
|
|
|
|
@section mqtt_porting_time Time Function
|
|
@brief The MQTT library relies on a function to generate millisecond timestamps, for the
|
|
purpose of calculating durations and timeouts, as well as maintaining the keep-alive mechanism
|
|
of the MQTT protocol.
|
|
|
|
@see @ref MQTTGetCurrentTimeFunc_t
|
|
|
|
Platforms must supply a function capable of generating 32 bit timestamps of millisecond resolution.
|
|
These timestamps need not correspond with any real world clock; the only requirement is that the
|
|
difference between two timestamps must be an accurate representation of the duration between them,
|
|
in milliseconds.
|
|
|
|
@note Should the platform be incapable of providing millisecond timestamps, the port may instead
|
|
provide a function that always returns 0, or a strictly non-decreasing sequence. In this case, the
|
|
timeout values in all library calls to @ref MQTT_Connect, @ref MQTT_ProcessLoop, or @ref MQTT_ReceiveLoop
|
|
MUST be set to 0, resulting in loop functions running for a single iteration, and @ref MQTT_Connect
|
|
relying on @ref MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT to receive the CONNACK packet.
|
|
*/
|