Skip to content

Commit

Permalink
Added warning comment in API to tell users to make sure that the vari…
Browse files Browse the repository at this point in the history
…ables topic name and application data passed to the subscribe API needs to be static in memory (#175)
  • Loading branch information
huguesBouvier authored and Gordon Wang committed May 4, 2018
1 parent 1c25bce commit 07241fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions include/aws_iot_mqtt_client_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ IoT_Error_t aws_iot_mqtt_publish(AWS_IoT_Client *pClient, const char *pTopicName
* Called to send a subscribe message to the broker requesting a subscription
* to an MQTT topic.
* @note Call is blocking. The call returns after the receipt of the SUBACK control packet.
* @warning pTopicName and pApplicationHandlerData need to be static in memory.
*
* @param pClient Reference to the IoT Client
* @param pTopicName Topic Name to publish to
* @param pTopicName Topic Name to publish to. pTopicName needs to be static in memory since
* no malloc are performed by the SDK
* @param topicNameLen Length of the topic name
* @param pApplicationHandler_t Reference to the handler function for this subscription
* @param pApplicationHandlerData Data to be passed as argument to the application handler callback
* @param pApplicationHandlerData Point to data passed to the callback.
* pApplicationHandlerData also needs to be static in memory since no malloc are performed by the SDK
*
* @return An IoT Error Type defining successful/failed subscription
*/
Expand Down
12 changes: 10 additions & 2 deletions src/aws_iot_mqtt_client_subscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,15 @@ static uint32_t _aws_iot_mqtt_get_free_message_handler_index(AWS_IoT_Client *pCl
* subscribe API to perform the operation. Not meant to be called directly as
* it doesn't do validations or client state changes
* @note Call is blocking. The call returns after the receipt of the SUBACK control packet.
* @warning pTopicName and pApplicationHandlerData need to be static in memory.
*
* @param pClient Reference to the IoT Client
* @param pTopicName Topic Name to publish to
* @param pTopicName Topic Name to publish to. pTopicName needs to be static in memory since
* no malloc are performed by the SDK
* @param topicNameLen Length of the topic name
* @param pApplicationHandler_t Reference to the handler function for this subscription
* @param pApplicationHandlerData Point to data passed to the callback.
* pApplicationHandlerData also needs to be static in memory since no malloc are performed by the SDK
*
* @return An IoT Error Type defining successful/failed subscription
*/
Expand Down Expand Up @@ -277,11 +281,15 @@ static IoT_Error_t _aws_iot_mqtt_internal_subscribe(AWS_IoT_Client *pClient, con
* calls the internal subscribe above to perform the actual operation.
* It is also responsible for client state changes
* @note Call is blocking. The call returns after the receipt of the SUBACK control packet.
* @warning pTopicName and pApplicationHandlerData need to be static in memory.
*
* @param pClient Reference to the IoT Client
* @param pTopicName Topic Name to publish to
* @param pTopicName Topic Name to publish to. pTopicName needs to be static in memory since
* no malloc are performed by the SDK
* @param topicNameLen Length of the topic name
* @param pApplicationHandler_t Reference to the handler function for this subscription
* @param pApplicationHandlerData Point to data passed to the callback.
* pApplicationHandlerData also needs to be static in memory since no malloc are performed by the SDK
*
* @return An IoT Error Type defining successful/failed subscription
*/
Expand Down
1 change: 1 addition & 0 deletions src/aws_iot_mqtt_client_unsubscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static IoT_Error_t _aws_iot_mqtt_internal_unsubscribe(AWS_IoT_Client *pClient, c
if(pClient->clientData.messageHandlers[i].topicName != NULL &&
(strcmp(pClient->clientData.messageHandlers[i].topicName, pTopicFilter) == 0)) {
subscriptionExists = true;
break;
}
}

Expand Down

0 comments on commit 07241fb

Please sign in to comment.