Skip to content

Commit 0c4f64b

Browse files
Documentation fixes and additions (#373)
### core_mqtt.h: - fix MQTT_InitRetransmits example (remove phantom `publishClearAllCallback` so example matches the 3-callback signature); - fix MQTT_InitStatefulQoS docstring (@p pBuffer -> @p pAckPropsBuf); - Complete the truncated MQTTStatusNotConnected return-value sentence in `MQTT_CheckConnectStatus`. - Replace C99 compound literals (&(uint8_t){ MQTT_PACKET_TYPE_* }) in all doc examples with the C90-compatible MQTT_PROP_VALIDATE_* macros across core_mqtt.h (5), core_mqtt_serializer.h (1), MigrationGuide.md (26), and MQTTv5Guide.md (9). The one PUBREL case, which has no matching MQTT_PROP_VALIDATE_* macro, uses MQTT_PROP_NO_VALIDATE. ### README.md: - Add Thread Safety section documenting the MQTT_PRE_STATE_UPDATE_HOOK / MQTT_POST_STATE_UPDATE_HOOK extension points, with a non-recursive FreeRTOS mutex example (verified: the library does not re-enter a hook-protected region). ### core_mqtt_serializer.h: - Add an explanatory comment block above the MQTT_PACKET_TYPE_*_VAL file-scope statics explaining why they exist and why the MISRA C:2012 Rule 2.2 / 2.8 deviations are accepted (macros cannot be addressed, MQTT_PROP_VALIDATE_* needs a typed const uint8_t *). - Add source/include/core_mqtt_config_template.h: a commented-out starter template users can copy as core_mqtt_config.h, covering every tunable documented in core_mqtt_config_defaults.h plus the thread-safety hooks.
1 parent 04845c6 commit 0c4f64b

6 files changed

Lines changed: 265 additions & 47 deletions

File tree

MQTTv5Guide.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ status = MQTTPropertyBuilder_Init(&propBuilder, propBuffer, sizeof(propBuffer));
310310
// Add session expiry
311311
uint32_t sessionExpiry = 3600; // 1 hour
312312
status = MQTTPropAdd_SessionExpiry(&propBuilder, sessionExpiry,
313-
&(uint8_t){MQTT_PACKET_TYPE_CONNECT});
313+
MQTT_PROP_VALIDATE_CONNECT);
314314

315315
// Add user property
316316
MQTTUserProperty_t userProp = {
@@ -320,7 +320,7 @@ MQTTUserProperty_t userProp = {
320320
.valueLength = strlen("sensor-001")
321321
};
322322
status = MQTTPropAdd_UserProp(&propBuilder, &userProp,
323-
&(uint8_t){MQTT_PACKET_TYPE_CONNECT});
323+
MQTT_PROP_VALIDATE_CONNECT);
324324
```
325325

326326
3. **Pass the property builder to API functions:**
@@ -532,7 +532,7 @@ MQTTPropertyBuilder_Init(&pubProps, pubPropsBuf, sizeof(pubPropsBuf));
532532

533533
uint16_t topicAlias = 1;
534534
MQTTPropAdd_TopicAlias(&pubProps, topicAlias,
535-
&(uint8_t){MQTT_PACKET_TYPE_PUBLISH});
535+
MQTT_PROP_VALIDATE_PUBLISH);
536536

537537
MQTTPublishInfo_t publishInfo = {
538538
.qos = MQTTQoS1,
@@ -560,10 +560,10 @@ MQTTPropertyBuilder_Init(&pubProps, pubPropsBuf, sizeof(pubPropsBuf));
560560
561561
MQTTPropAdd_ResponseTopic(&pubProps, "response/topic",
562562
strlen("response/topic"),
563-
&(uint8_t){MQTT_PACKET_TYPE_PUBLISH});
563+
MQTT_PROP_VALIDATE_PUBLISH);
564564
565565
MQTTPropAdd_CorrelationData(&pubProps, "req-123", strlen("req-123"),
566-
&(uint8_t){MQTT_PACKET_TYPE_PUBLISH});
566+
MQTT_PROP_VALIDATE_PUBLISH);
567567
568568
MQTT_Publish(&context, &publishInfo, packetId, &pubProps);
569569
@@ -618,7 +618,7 @@ MQTTPropertyBuilder_Init(&connectProps, connectPropsBuf, sizeof(connectPropsBuf)
618618
// Set session expiry to 1 hour
619619
uint32_t sessionExpiry = 3600;
620620
MQTTPropAdd_SessionExpiry(&connectProps, sessionExpiry,
621-
&(uint8_t){MQTT_PACKET_TYPE_CONNECT});
621+
MQTT_PROP_VALIDATE_CONNECT);
622622
623623
// Connect with session expiry
624624
MQTT_Connect(&context, &connectInfo, NULL, 1000, &sessionPresent,
@@ -640,7 +640,7 @@ MQTTUserProperty_t deviceId = {
640640
.valueLength = strlen("sensor-001")
641641
};
642642
MQTTPropAdd_UserProp(&pubProps, &deviceId,
643-
&(uint8_t){MQTT_PACKET_TYPE_PUBLISH});
643+
MQTT_PROP_VALIDATE_PUBLISH);
644644

645645
MQTTUserProperty_t timestamp = {
646646
.pKey = "timestamp",
@@ -649,7 +649,7 @@ MQTTUserProperty_t timestamp = {
649649
.valueLength = strlen("2024-01-23T10:30:00Z")
650650
};
651651
MQTTPropAdd_UserProp(&pubProps, &timestamp,
652-
&(uint8_t){MQTT_PACKET_TYPE_PUBLISH});
652+
MQTT_PROP_VALIDATE_PUBLISH);
653653

654654
MQTT_Publish(&context, &publishInfo, packetId, &pubProps);
655655
```
@@ -664,7 +664,7 @@ MQTTPropertyBuilder_Init(&disconnectProps, disconnectPropsBuf,
664664
665665
MQTTPropAdd_ReasonString(&disconnectProps, "Shutting down for maintenance",
666666
strlen("Shutting down for maintenance"),
667-
&(uint8_t){MQTT_PACKET_TYPE_DISCONNECT});
667+
MQTT_PROP_VALIDATE_DISCONNECT);
668668
669669
MQTTSuccessFailReasonCode_t reason = MQTT_REASON_DISCONNECT_NORMAL_DISCONNECTION;
670670
MQTT_Disconnect(&context, &disconnectProps, &reason);

MigrationGuide.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static bool eventCallback(
407407
/* PUBREC is not a terminating packet — the library will send PUBREL next.
408408
* pReasonCode and pSendPropsBuffer are valid here. */
409409
*pReasonCode = MQTT_REASON_PUBREL_SUCCESS;
410-
MQTTPropAdd_ReasonString( pSendPropsBuffer, "Success", 7, &(uint8_t){ MQTT_PACKET_TYPE_PUBREL } );
410+
MQTTPropAdd_ReasonString( pSendPropsBuffer, "Success", 7, MQTT_PROP_NO_VALIDATE );
411411
}
412412
else
413413
{
@@ -613,7 +613,7 @@ size bufLength = sizeof(buf);
613613
MQTTPropertyBuilder_Init(&connectionProperties, buf, bufLength) ;
614614
615615
uint32_t sessionExpiryInterval = 100 ; // 100ms
616-
MQTTPropAdd_SessionExpiry(&connectionProperties, sessionExpiryInterval, &(uint8_t){ MQTT_PACKET_TYPE_CONNECT } );
616+
MQTTPropAdd_SessionExpiry(&connectionProperties, sessionExpiryInterval, MQTT_PROP_VALIDATE_CONNECT );
617617
618618
// Can also use the will properties in a similar way.
619619
@@ -713,7 +713,7 @@ MQTTPropertyBuilder_Init(&propertyBuilder,
713713
sizeof(propertyBuffer));
714714

715715
// Add subscription identifier property
716-
MQTTPropAdd_SubscriptionId(&propertyBuilder, 1, &(uint8_t){ MQTT_PACKET_TYPE_SUBSCRIBE } );
716+
MQTTPropAdd_SubscriptionId(&propertyBuilder, 1, MQTT_PROP_VALIDATE_SUBSCRIBE );
717717

718718
status = MQTT_Subscribe(&mqttContext,
719719
subscriptionList,
@@ -810,8 +810,8 @@ MQTTPropertyBuilder_Init(&propertyBuilder,
810810
sizeof(propertyBuffer));
811811

812812
// Add publish properties
813-
MQTTPropAdd_PayloadFormat(&propertyBuilder, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
814-
MQTTPropAdd_TopicAlias(&propertyBuilder, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
813+
MQTTPropAdd_PayloadFormat(&propertyBuilder, 1, MQTT_PROP_VALIDATE_PUBLISH );
814+
MQTTPropAdd_TopicAlias(&propertyBuilder, 1, MQTT_PROP_VALIDATE_PUBLISH );
815815

816816
status = MQTT_Publish(&mqttContext,
817817
&publishInfo,
@@ -913,7 +913,7 @@ MQTTUserProperty_t userProperty = {
913913
.pValue = "value",
914914
.valueLength = strlen("value")
915915
};
916-
MQTTPropAdd_UserProp(&propertyBuilder, &userProperty, &(uint8_t){ MQTT_PACKET_TYPE_UNSUBSCRIBE } );
916+
MQTTPropAdd_UserProp(&propertyBuilder, &userProperty, MQTT_PROP_VALIDATE_UNSUBSCRIBE );
917917

918918
status = MQTT_Unsubscribe(&mqttContext,
919919
unsubscribeList,
@@ -983,7 +983,7 @@ MQTTPropertyBuilder_Init(&propertyBuilder,
983983
MQTTPropAdd_ReasonString(&propertyBuilder,
984984
"Normal shutdown",
985985
strlen("Normal shutdown"),
986-
&(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT });
986+
MQTT_PROP_VALIDATE_DISCONNECT);
987987

988988
MQTTSuccessFailReasonCode_t reason = MQTT_REASON_DISCONNECT_NORMAL_DISCONNECTION;
989989
status = MQTT_Disconnect(&mqttContext,
@@ -1083,7 +1083,7 @@ MQTTPropertyBuilder_Init(&willProperties,
10831083
sizeof(willPropBuffer));
10841084

10851085
// Add properties as needed
1086-
MQTTPropAdd_SessionExpiry(&connectionProperties, 3600, &(uint8_t){ MQTT_PACKET_TYPE_CONNECT } );
1086+
MQTTPropAdd_SessionExpiry(&connectionProperties, 3600, MQTT_PROP_VALIDATE_CONNECT );
10871087
MQTTPropAdd_WillDelayInterval(&willProperties, 60, NULL );
10881088

10891089
status = MQTT_GetConnectPacketSize(&connectInfo,
@@ -1179,8 +1179,8 @@ MQTTPropertyBuilder_Init(&publishProperties,
11791179
sizeof(propBuffer));
11801180

11811181
// Add publish properties
1182-
MQTTPropAdd_TopicAlias(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1183-
MQTTPropAdd_PayloadFormat(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1182+
MQTTPropAdd_TopicAlias(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
1183+
MQTTPropAdd_PayloadFormat(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
11841184

11851185
// Get max packet size from CONNACK properties
11861186
uint32_t serverMaxPacketSize = pContext->connectionProperties.serverMaxPacketSize; // Value from server
@@ -1274,7 +1274,7 @@ MQTTPropertyBuilder_Init(&subscribeProperties,
12741274
sizeof(propBuffer));
12751275

12761276
// Add subscription identifier
1277-
MQTTPropAdd_SubscriptionId(&subscribeProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_SUBSCRIBE } );
1277+
MQTTPropAdd_SubscriptionId(&subscribeProperties, 1, MQTT_PROP_VALIDATE_SUBSCRIBE );
12781278

12791279
// Get max packet size from CONNACK properties
12801280
uint32_t serverMaxPacketSize = pContext->connectionProperties.serverMaxPacketSize; // value from server
@@ -1377,7 +1377,7 @@ MQTTUserProperty_t userProperty = {
13771377
.pValue = "value",
13781378
.valueLength = strlen("value")
13791379
};
1380-
MQTTPropAdd_UserProp(&unsubscribeProperties, &userProperty, &(uint8_t){ MQTT_PACKET_TYPE_UNSUBSCRIBE } );
1380+
MQTTPropAdd_UserProp(&unsubscribeProperties, &userProperty, MQTT_PROP_VALIDATE_UNSUBSCRIBE );
13811381

13821382
// Get max packet size from CONNACK properties
13831383
uint32_t serverMaxPacketSize = pContext->connectionProperties.serverMaxPacketSize; // Value from server
@@ -1455,11 +1455,11 @@ MQTTPropertyBuilder_Init(&disconnectProperties,
14551455
sizeof(propBuffer));
14561456

14571457
// Add disconnect properties
1458-
MQTTPropAdd_SessionExpiry(&disconnectProperties, 0, &(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT } );
1458+
MQTTPropAdd_SessionExpiry(&disconnectProperties, 0, MQTT_PROP_VALIDATE_DISCONNECT );
14591459
MQTTPropAdd_ReasonString(&disconnectProperties,
14601460
"Normal shutdown",
14611461
strlen("Normal shutdown"),
1462-
&(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT } );
1462+
MQTT_PROP_VALIDATE_DISCONNECT );
14631463

14641464
MQTTSuccessFailReasonCode_t reason = MQTT_REASON_DISCONNECT_NORMAL_DISCONNECTION;
14651465
status = MQTT_GetDisconnectPacketSize(&disconnectProperties,
@@ -1587,8 +1587,8 @@ MQTTPropertyBuilder_Init(&willProperties,
15871587
sizeof(willPropBuffer));
15881588

15891589
// Add connect properties
1590-
MQTTPropAdd_SessionExpiry(&connectionProperties, 3600, &(uint8_t){ MQTT_PACKET_TYPE_CONNECT } );
1591-
MQTTPropAdd_MaxPacketSize(&connectionProperties, 1024, &(uint8_t){ MQTT_PACKET_TYPE_CONNECT } );
1590+
MQTTPropAdd_SessionExpiry(&connectionProperties, 3600, MQTT_PROP_VALIDATE_CONNECT );
1591+
MQTTPropAdd_MaxPacketSize(&connectionProperties, 1024, MQTT_PROP_VALIDATE_CONNECT );
15921592

15931593
// Add will properties if using will message
15941594
MQTTPropAdd_WillDelayInterval(&willProperties, 60, NULL );
@@ -1723,9 +1723,9 @@ MQTTPropertyBuilder_Init(&publishProperties,
17231723
sizeof(propBuffer));
17241724

17251725
// Add publish properties
1726-
MQTTPropAdd_PayloadFormat(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1727-
MQTTPropAdd_TopicAlias(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1728-
MQTTPropAdd_MessageExpiry(&publishProperties, 3600, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1726+
MQTTPropAdd_PayloadFormat(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
1727+
MQTTPropAdd_TopicAlias(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
1728+
MQTTPropAdd_MessageExpiry(&publishProperties, 3600, MQTT_PROP_VALIDATE_PUBLISH );
17291729

17301730
// Get remaining length first
17311731
status = MQTT_GetPublishPacketSize(&publishInfo,
@@ -1863,9 +1863,9 @@ MQTTPropertyBuilder_Init(&publishProperties,
18631863
sizeof(propBuffer));
18641864

18651865
// Add publish properties
1866-
MQTTPropAdd_PayloadFormat(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1867-
MQTTPropAdd_TopicAlias(&publishProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1868-
MQTTPropAdd_MessageExpiry(&publishProperties, 3600, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH } );
1866+
MQTTPropAdd_PayloadFormat(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
1867+
MQTTPropAdd_TopicAlias(&publishProperties, 1, MQTT_PROP_VALIDATE_PUBLISH );
1868+
MQTTPropAdd_MessageExpiry(&publishProperties, 3600, MQTT_PROP_VALIDATE_PUBLISH );
18691869

18701870
// Get remaining length first
18711871
status = MQTT_GetPublishPacketSize(&publishInfo,
@@ -2003,7 +2003,7 @@ MQTTPropertyBuilder_Init(&subscribeProperties,
20032003
sizeof(propBuffer));
20042004

20052005
// Add subscription identifier
2006-
MQTTPropAdd_SubscriptionId(&subscribeProperties, 1, &(uint8_t){ MQTT_PACKET_TYPE_SUBSCRIBE } );
2006+
MQTTPropAdd_SubscriptionId(&subscribeProperties, 1, MQTT_PROP_VALIDATE_SUBSCRIBE );
20072007

20082008
// Get remaining length first
20092009
status = MQTT_GetSubscribePacketSize(subscriptionList,
@@ -2141,7 +2141,7 @@ MQTTUserProperty_t userProperty = {
21412141
.pValue = "value",
21422142
.valueLength = strlen("value")
21432143
};
2144-
MQTTPropAdd_UserProp(&unsubscribeProperties, &userProperty, &(uint8_t){ MQTT_PACKET_TYPE_UNSUBSCRIBE } );
2144+
MQTTPropAdd_UserProp(&unsubscribeProperties, &userProperty, MQTT_PROP_VALIDATE_UNSUBSCRIBE );
21452145

21462146
// Get remaining length first
21472147
status = MQTT_GetUnsubscribePacketSize(subscriptionList,
@@ -2242,11 +2242,11 @@ MQTTPropertyBuilder_Init(&disconnectProperties,
22422242
sizeof(propBuffer));
22432243

22442244
// Add disconnect properties
2245-
MQTTPropAdd_SessionExpiry(&disconnectProperties, 0, &(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT } );
2245+
MQTTPropAdd_SessionExpiry(&disconnectProperties, 0, MQTT_PROP_VALIDATE_DISCONNECT );
22462246
MQTTPropAdd_ReasonString(&disconnectProperties,
22472247
"Normal shutdown",
22482248
strlen("Normal shutdown"),
2249-
&(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT } );
2249+
MQTT_PROP_VALIDATE_DISCONNECT );
22502250

22512251
// Get remaining length first
22522252
MQTTSuccessFailReasonCode_t reason = MQTT_REASON_DISCONNECT_NORMAL_DISCONNECTION;

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,61 @@ connectInfo.userNameLength = USERNAME_STRING_LENGTH;
105105
mqttStatus = MQTT_Connect( pMqttContext, &connectInfo, NULL, CONNACK_RECV_TIMEOUT_MS, pSessionPresent, NULL, NULL );
106106
```
107107

108+
## Thread Safety
109+
110+
coreMQTT is a single-threaded protocol engine: a given `MQTTContext_t` is
111+
**not** safe to use concurrently from multiple threads. The `MQTT_ProcessLoop`,
112+
`MQTT_ReceiveLoop`, and publish/subscribe APIs all read and mutate fields in
113+
the context (timestamps, state records, in-flight packet IDs, etc.) without
114+
internal locking.
115+
116+
If your application calls coreMQTT APIs from more than one thread — for
117+
example, an MQTT receive loop in one task and application-originated
118+
`MQTT_Publish` calls from another — you must serialize access to the context
119+
yourself. The library provides two extension points for that purpose:
120+
121+
- `MQTT_PRE_STATE_UPDATE_HOOK( pContext )` — invoked immediately before the
122+
library reads or writes shared context state.
123+
- `MQTT_POST_STATE_UPDATE_HOOK( pContext )` — invoked immediately after the
124+
corresponding read or write completes.
125+
126+
Both macros expand to nothing by default. Define them in your
127+
`core_mqtt_config.h` (or via the compiler command line) to acquire and release
128+
a mutex that protects the context. Sketch for FreeRTOS:
129+
130+
```c
131+
/* In core_mqtt_config.h */
132+
#include "FreeRTOS.h"
133+
#include "semphr.h"
134+
135+
/* Application provides one mutex per MQTT context and stores a pointer to it
136+
* reachable from the context — for example, inside the NetworkContext or a
137+
* parallel lookup table keyed by pContext. */
138+
extern SemaphoreHandle_t getMutexForContext( const MQTTContext_t * pContext );
139+
140+
#define MQTT_PRE_STATE_UPDATE_HOOK( pContext ) \
141+
( void ) xSemaphoreTake( getMutexForContext( pContext ), portMAX_DELAY )
142+
143+
#define MQTT_POST_STATE_UPDATE_HOOK( pContext ) \
144+
( void ) xSemaphoreGive( getMutexForContext( pContext ) )
145+
```
146+
147+
Notes:
148+
149+
- The library calls the hooks in matched pre/post pairs around individual
150+
state accesses; it does not re-enter a hook-protected region from inside
151+
another one, so a non-recursive mutex is sufficient. A recursive mutex
152+
also works if you prefer one for defense in depth.
153+
- The hooks surround individual state accesses, not whole API calls. If you
154+
also need atomicity across a full `MQTT_Publish` invocation from the
155+
application's point of view, take a second application-level lock around
156+
the API call.
157+
- On a single-threaded system (for example, cooperative scheduling with one
158+
task owning the MQTT stack), leave the hooks undefined.
159+
- The transport `send` / `recv` callbacks are not called from inside the
160+
hooks, so your transport implementation does not need to be reentrant with
161+
respect to the mutex.
162+
108163
## Upgrading to v5.0.0
109164
110165
coreMQTT v5.0.0 adds MQTT v5.0 protocol support with breaking API changes.

source/include/core_mqtt.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ MQTTStatus_t MQTT_Init( MQTTContext_t * pContext,
520520
* @param[in] incomingPublishCount Maximum number of records which can be kept in the memory
521521
* pointed to by @p pIncomingPublishRecords.
522522
* @param[in] pAckPropsBuf Pointer to memory which will be used to store properties of outgoing publish-ACKS.
523-
* @param[in] ackPropsBufLength Length of the buffer pointed to by @p pBuffer.
523+
* @param[in] ackPropsBufLength Length of the buffer pointed to by @p pAckPropsBuf.
524524
* @return #MQTTBadParameter if invalid parameters are passed;<br>
525525
* #MQTTSuccess otherwise.<br>
526526
*
@@ -637,8 +637,6 @@ MQTTStatus_t MQTT_InitStatefulQoS( MQTTContext_t * pContext,
637637
* // User defined callback used to clear a particular copied publish packet
638638
* bool publishClearCallback(struct MQTTContext* pContext,
639639
* uint16_t packetId);
640-
* // User defined callback used to clear all copied publish packets
641-
* bool publishClearAllCallback(struct MQTTContext* pContext);
642640
*
643641
* MQTTContext_t mqttContext;
644642
* TransportInterface_t transport;
@@ -678,8 +676,7 @@ MQTTStatus_t MQTT_InitStatefulQoS( MQTTContext_t * pContext,
678676
* {
679677
* status = MQTT_InitRetransmits( &mqttContext, publishStoreCallback,
680678
* publishRetrieveCallback,
681-
* publishClearCallback,
682-
* publishClearAllCallback );
679+
* publishClearCallback );
683680
*
684681
* // Now unacked Publishes can be resent on an unclean session resumption.
685682
* }
@@ -700,7 +697,7 @@ MQTTStatus_t MQTT_InitRetransmits( MQTTContext_t * pContext,
700697
*
701698
* @return #MQTTBadParameter if invalid parameters are passed;
702699
* #MQTTStatusConnected if the MQTT connection is established with the broker.
703-
* #MQTTStatusNotConnected if the MQTT connection is broker.
700+
* #MQTTStatusNotConnected if the MQTT connection is not established with the broker.
704701
* #MQTTStatusDisconnectPending if Transport Interface has failed and MQTT connection needs to be closed.
705702
*
706703
* <b>Example</b>
@@ -840,7 +837,7 @@ MQTTStatus_t MQTT_CheckConnectStatus( const MQTTContext_t * pContext );
840837
*
841838
* // Set a property in the connectPropsBuilder
842839
* uint32_t maxPacketSize = 100 ;
843-
* status = MQTTPropAdd_MaxPacketSize(&connectPropsBuilder, maxPacketSize, &(uint8_t){ MQTT_PACKET_TYPE_CONNECT });
840+
* status = MQTTPropAdd_MaxPacketSize(&connectPropsBuilder, maxPacketSize, MQTT_PROP_VALIDATE_CONNECT);
844841
*
845842
* // The last will and testament is optional, it will be published by the broker
846843
* // should this client disconnect without sending a DISCONNECT packet.
@@ -930,7 +927,7 @@ MQTTStatus_t MQTT_Connect( MQTTContext_t * pContext,
930927
* size_t propertyBufferLength = sizeof( propertyBuffer );
931928
* status = MQTTPropertyBuilder_Init( &propertyBuilder, propertyBuffer, propertyBufferLength );
932929
*
933-
* status = MQTTPropAdd_SubscriptionId(&propertyBuilder, 1, &(uint8_t){ MQTT_PACKET_TYPE_SUBSCRIBE });
930+
* status = MQTTPropAdd_SubscriptionId(&propertyBuilder, 1, MQTT_PROP_VALIDATE_SUBSCRIBE);
934931
*
935932
* // Obtain a new packet id for the subscription.
936933
* packetId = MQTT_GetPacketId( pContext );
@@ -1011,7 +1008,7 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext,
10111008
* status = MQTTPropertyBuilder_Init( &propertyBuilder, propertyBuffer, propertyBufferLength );
10121009
*
10131010
* // Set a property in the propertyBuilder
1014-
* status = MQTTPropAdd_PayloadFormat( &propertyBuilder, 1, &(uint8_t){ MQTT_PACKET_TYPE_PUBLISH });
1011+
* status = MQTTPropAdd_PayloadFormat( &propertyBuilder, 1, MQTT_PROP_VALIDATE_PUBLISH);
10151012
*
10161013
* // Packet ID is needed for QoS > 0.
10171014
* packetId = MQTT_GetPacketId( pContext );
@@ -1130,7 +1127,7 @@ MQTTStatus_t MQTT_Ping( MQTTContext_t * pContext );
11301127
* userProperty.pValue = "value";
11311128
* userProperty.valueLength = strlen( userProperty.pValue );
11321129
*
1133-
* status = MQTTPropAdd_UserProp( &propertyBuilder, &userProperty, &(uint8_t){ MQTT_PACKET_TYPE_UNSUBSCRIBE });
1130+
* status = MQTTPropAdd_UserProp( &propertyBuilder, &userProperty, MQTT_PROP_VALIDATE_UNSUBSCRIBE);
11341131
*
11351132
* status = MQTT_Unsubscribe( pContext, &unsubscribeList[ 0 ], NUMBER_OF_SUBSCRIPTIONS, packetId, &propertyBuilder );
11361133
*
@@ -1184,7 +1181,7 @@ MQTTStatus_t MQTT_Unsubscribe( MQTTContext_t * pContext,
11841181
* status = MQTTPropertyBuilder_Init( &propertyBuilder, propertyBuffer, propertyBufferLength );
11851182
*
11861183
* // Set a property in the propertyBuilder
1187-
* status = MQTTPropAdd_ReasonString( &propertyBuilder, "Disconnecting", 13, &(uint8_t){ MQTT_PACKET_TYPE_DISCONNECT });
1184+
* status = MQTTPropAdd_ReasonString( &propertyBuilder, "Disconnecting", 13, MQTT_PROP_VALIDATE_DISCONNECT);
11881185
*
11891186
* MQTTSuccessFailReasonCode_t reason = MQTT_REASON_DISCONNECT_NORMAL_DISCONNECTION;
11901187
* status = MQTT_Disconnect( pContext, &propertyBuilder, &reason );

0 commit comments

Comments
 (0)