mirror of
https://github.com/FreeRTOS/coreMQTT
synced 2025-06-04 19:14:18 +08:00
158 lines
12 KiB
HTML
158 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.2"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>coreMQTT: Porting Guide</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(document).ready(function() { init_search(); });
|
|
/* @license-end */
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="style.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">coreMQTT<span id="projectnumber"> v2.0.0</span>
|
|
</div>
|
|
<div id="projectbrief">MQTT 3.1.1 Client Library</div>
|
|
</td>
|
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.svg"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.2 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
|
|
/* @license-end */
|
|
</script>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(document).ready(function(){initNavTree('mqtt_porting.html',''); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div><div class="header">
|
|
<div class="headertitle"><div class="title">Porting Guide </div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p >Guide for porting MQTT to a new platform.</p>
|
|
<p >A port to a new platform must provide the following components:</p><ol type="1">
|
|
<li><a class="el" href="mqtt_porting.html#mqtt_porting_config">Configuration Macros</a></li>
|
|
<li><a class="el" href="mqtt_porting.html#mqtt_porting_transport">Transport Interface</a></li>
|
|
<li><a class="el" href="mqtt_porting.html#mqtt_porting_time">Time Function</a></li>
|
|
</ol>
|
|
<h1><a class="anchor" id="mqtt_porting_config"></a>
|
|
Configuration Macros</h1>
|
|
<p >Settings that must be set as macros in the config header <code>core_mqtt_config.h</code>, or passed in as compiler options.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>If a custom configuration header <code>core_mqtt_config.h</code> is not provided, then the <a class="el" href="core_mqtt_config.html#MQTT_DO_NOT_USE_CUSTOM_CONFIG">MQTT_DO_NOT_USE_CUSTOM_CONFIG</a> macro must be defined.</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="core_mqtt_config.html">Configurations</a></dd></dl>
|
|
<p>The following macros can be configured for the managed MQTT library:</p><ul>
|
|
<li><a class="el" href="core_mqtt_config.html#MQTT_PINGRESP_TIMEOUT_MS">MQTT_PINGRESP_TIMEOUT_MS</a> <br />
|
|
</li>
|
|
<li><a class="el" href="core_mqtt_config.html#MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT">MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT</a></li>
|
|
</ul>
|
|
<p >In addition, the following logging macros are used throughout the library:</p><ul>
|
|
<li><a class="el" href="core__mqtt__default__logging_8h.html#a8d9dbaaa88129137a4c68ba0456a18b1">LogError</a></li>
|
|
<li><a class="el" href="core__mqtt__default__logging_8h.html#a7da92048aaf0cbfcacde9539c98a0e05">LogWarn</a></li>
|
|
<li><a class="el" href="core__mqtt__default__logging_8h.html#a00810b1cb9d2f25d25ce2d4d93815fba">LogInfo</a></li>
|
|
<li><a class="el" href="core__mqtt__default__logging_8h.html#af60e8ffc327d136e5d0d8441ed98c98d">LogDebug</a></li>
|
|
</ul>
|
|
<h1><a class="anchor" id="mqtt_porting_transport"></a>
|
|
Transport Interface</h1>
|
|
<p >The MQTT library relies on an underlying transport interface API that must be implemented in order to send and receive packets on a network.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="mqtt_transport_interface.html">Transport Interface</a></dd></dl>
|
|
<p>The transport interface API used by MQTT is defined in <a class="el" href="transport__interface_8h.html">transport_interface.h</a>. A port must implement functions corresponding to the following functions pointers:</p><ul>
|
|
<li><a class="el" href="group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167">Transport Receive</a>: A function to receive bytes from a network. <div class="fragment"><div class="line">int32_t (* <a class="code hl_typedef" href="group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167">TransportRecv_t</a> )(</div>
|
|
<div class="line"> <a class="code hl_typedef" href="group__mqtt__struct__types.html#ga7769e434e7811caed8cd6fd7f9ec26ec">NetworkContext_t</a> * pNetworkContext, <span class="keywordtype">void</span> * pBuffer, <span class="keywordtype">size_t</span> bytesToRecv</div>
|
|
<div class="line">);</div>
|
|
<div class="ttc" id="agroup__mqtt__callback__types_html_ga227df31d6daf07e5d833537c12130167"><div class="ttname"><a href="group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167">TransportRecv_t</a></div><div class="ttdeci">int32_t(* TransportRecv_t)(NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv)</div><div class="ttdoc">Transport interface for receiving data on the network.</div><div class="ttdef"><b>Definition:</b> transport_interface.h:219</div></div>
|
|
<div class="ttc" id="agroup__mqtt__struct__types_html_ga7769e434e7811caed8cd6fd7f9ec26ec"><div class="ttname"><a href="group__mqtt__struct__types.html#ga7769e434e7811caed8cd6fd7f9ec26ec">NetworkContext_t</a></div><div class="ttdeci">struct NetworkContext NetworkContext_t</div><div class="ttdoc">The NetworkContext is an incomplete type. An implementation of this interface must define struct Netw...</div><div class="ttdef"><b>Definition:</b> transport_interface.h:189</div></div>
|
|
</div><!-- fragment --></li>
|
|
<li><a class="el" href="group__mqtt__callback__types.html#ga2a39853ff952edd715ab07b33ab2a7c5">Transport Send</a>: A function to send bytes over a network. <div class="fragment"><div class="line">int32_t (* <a class="code hl_typedef" href="group__mqtt__callback__types.html#ga2a39853ff952edd715ab07b33ab2a7c5">TransportSend_t</a> )(</div>
|
|
<div class="line"> <a class="code hl_typedef" href="group__mqtt__struct__types.html#ga7769e434e7811caed8cd6fd7f9ec26ec">NetworkContext_t</a> * pNetworkContext, <span class="keyword">const</span> <span class="keywordtype">void</span> * pBuffer, <span class="keywordtype">size_t</span> bytesToSend</div>
|
|
<div class="line">);</div>
|
|
<div class="ttc" id="agroup__mqtt__callback__types_html_ga2a39853ff952edd715ab07b33ab2a7c5"><div class="ttname"><a href="group__mqtt__callback__types.html#ga2a39853ff952edd715ab07b33ab2a7c5">TransportSend_t</a></div><div class="ttdeci">int32_t(* TransportSend_t)(NetworkContext_t *pNetworkContext, const void *pBuffer, size_t bytesToSend)</div><div class="ttdoc">Transport interface for sending data over the network.</div><div class="ttdef"><b>Definition:</b> transport_interface.h:241</div></div>
|
|
</div><!-- fragment --></li>
|
|
</ul>
|
|
<p >The above two functions take in a pointer to a <a class="el" href="group__mqtt__struct__types.html#ga7769e434e7811caed8cd6fd7f9ec26ec">NetworkContext_t</a>, the typename of a <code>struct NetworkContext</code>. The NetworkContext struct must also be defined by the port, and ought to contain any information necessary to send and receive data with the <a class="el" href="group__mqtt__callback__types.html#ga2a39853ff952edd715ab07b33ab2a7c5">TransportSend_t</a> and <a class="el" href="group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167">TransportRecv_t</a> implementations, respectively: </p><div class="fragment"><div class="line"><span class="keyword">struct </span>NetworkContext {</div>
|
|
<div class="line"> <span class="comment">// Fields necessary for the transport implementations, e.g. a TCP socket descriptor.</span></div>
|
|
<div class="line">};</div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="mqtt_porting_time"></a>
|
|
Time Function</h1>
|
|
<p >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.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__mqtt__callback__types.html#gae3bea55b0e49e5208b8c5709a5ea23aa">MQTTGetCurrentTimeFunc_t</a></dd></dl>
|
|
<p>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.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>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 <a class="el" href="core__mqtt_8h.html#aed1e4dc123a8ba79ac569cb17c69bfa0">MQTT_Connect</a>, <a class="el" href="core__mqtt_8h.html#ab95d3d6b3eed98a6184fb2018c5b55d7">MQTT_ProcessLoop</a>, or <a class="el" href="core__mqtt_8h.html#aeb7c37284fcf6f68eb577427a6763fc6">MQTT_ReceiveLoop</a> MUST be set to 0, resulting in loop functions running for a single iteration, and <a class="el" href="core__mqtt_8h.html#aed1e4dc123a8ba79ac569cb17c69bfa0">MQTT_Connect</a> relying on <a class="el" href="core_mqtt_config.html#MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT">MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT</a> to receive the CONNACK packet. </dd></dl>
|
|
</div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|