Guide for porting MQTT to a new platform.
A port to a new platform must provide the following components:
Settings that must be set as macros in the config header core_mqtt_config.h
, or passed in as compiler options.
core_mqtt_config.h
is not provided, then the MQTT_DO_NOT_USE_CUSTOM_CONFIG macro must be defined.The following macros can be configured for the managed MQTT library:
In addition, the following logging macros are used throughout the library:
The MQTT library relies on an underlying transport interface API that must be implemented in order to send and receive packets on a network.
The transport interface API used by MQTT is defined in transport_interface.h. A port must implement functions corresponding to the following functions pointers:
The above two functions take in a pointer to a 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 TransportSend_t and TransportRecv_t implementations, respectively:
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.
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.