Jeon byungchul
/
aws-iot-example
this is fork and i will modify for STM32
Fork of AWS-test by
Diff: aws-iot/src/aws_iot_mqtt_client_publish.cpp
- Revision:
- 2:db59f45ad3d3
- Parent:
- 0:cd5404401c2f
--- a/aws-iot/src/aws_iot_mqtt_client_publish.cpp Wed Apr 12 14:09:46 2017 +0200 +++ b/aws-iot/src/aws_iot_mqtt_client_publish.cpp Fri Aug 04 14:06:06 2017 +0900 @@ -47,11 +47,11 @@ * @param stringLen pointer to variable which has the length of the string * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned * @param enddata pointer to the end of the data: do not read beyond - * @return SUCCESS if successful, FAILURE if not + * @return IOT_SUCCESS if successful, IOT_FAILURE if not */ static IoT_Error_t _aws_iot_mqtt_read_string_with_len(char **stringVar, uint16_t *stringLen, unsigned char **pptr, unsigned char *enddata) { - IoT_Error_t rc = FAILURE; + IoT_Error_t rc = IOT_FAILURE; FUNC_ENTRY; /* the first two bytes are the length of the string */ @@ -61,7 +61,7 @@ if(&(*pptr)[*stringLen] <= enddata) { *stringVar = (char *) *pptr; *pptr += *stringLen; - rc = SUCCESS; + rc = IOT_SUCCESS; } } @@ -111,7 +111,7 @@ } rc = aws_iot_mqtt_internal_init_header(&header, PUBLISH, qos, dup, retained); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } aws_iot_mqtt_internal_write_char(&ptr, header.byte); /* write header */ @@ -129,7 +129,7 @@ *pSerializedLen = (uint32_t) (ptr - pTxBuf); - FUNC_EXIT_RC(SUCCESS); + FUNC_EXIT_RC(IOT_SUCCESS); } /** @@ -165,7 +165,7 @@ requestQoS = (PUBREL == msgType) ? QOS1 : QOS0; rc = aws_iot_mqtt_internal_init_header(&header, msgType, requestQoS, dup, 0); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } aws_iot_mqtt_internal_write_char(&ptr, header.byte); /* write header */ @@ -174,7 +174,7 @@ aws_iot_mqtt_internal_write_uint_16(&ptr, packetId); *pSerializedLen = (uint32_t) (ptr - pTxBuf); - FUNC_EXIT_RC(SUCCESS); + FUNC_EXIT_RC(IOT_SUCCESS); } /** @@ -215,31 +215,31 @@ pParams->qos, pParams->isRetained, pParams->id, pTopicName, topicNameLen, (unsigned char *) pParams->payload, pParams->payloadLen, &len); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } /* send the publish packet */ rc = aws_iot_mqtt_internal_send_packet(pClient, len, &timer); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } /* Wait for ack if QoS1 */ if(QOS1 == pParams->qos) { rc = aws_iot_mqtt_internal_wait_for_read(pClient, PUBACK, &timer); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } rc = aws_iot_mqtt_internal_deserialize_ack(&type, &dup, &packet_id, pClient->clientData.readBuf, pClient->clientData.readBufSize); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } } - FUNC_EXIT_RC(SUCCESS); + FUNC_EXIT_RC(IOT_SUCCESS); } /** @@ -280,14 +280,14 @@ } rc = aws_iot_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } pubRc = _aws_iot_mqtt_internal_publish(pClient, pTopicName, topicNameLen, pParams); rc = aws_iot_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS, clientState); - if(SUCCESS == pubRc && SUCCESS != rc) { + if(IOT_SUCCESS == pubRc && IOT_SUCCESS != rc) { pubRc = rc; } @@ -316,7 +316,7 @@ unsigned char *pRxBuf, size_t rxBufLen) { unsigned char *curData = pRxBuf; unsigned char *endData = NULL; - IoT_Error_t rc = FAILURE; + IoT_Error_t rc = IOT_FAILURE; uint32_t decodedLen = 0; uint32_t readBytesLen = 0; MQTTHeader header = {0}; @@ -324,7 +324,7 @@ FUNC_ENTRY; if(NULL == dup || NULL == qos || NULL == retained || NULL == pPacketId) { - FUNC_EXIT_RC(FAILURE); + FUNC_EXIT_RC(IOT_FAILURE); } /* Publish header size is at least four bytes. @@ -339,7 +339,7 @@ header.byte = aws_iot_mqtt_internal_read_char(&curData); if(PUBLISH != header.bits.type) { - FUNC_EXIT_RC(FAILURE); + FUNC_EXIT_RC(IOT_FAILURE); } *dup = header.bits.dup; @@ -348,7 +348,7 @@ /* read remaining length */ rc = aws_iot_mqtt_internal_decode_remaining_length_from_buffer(curData, &decodedLen, &readBytesLen); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); return rc; } @@ -356,9 +356,9 @@ endData = curData + decodedLen; /* do we have enough data to read the protocol version byte? */ - if(SUCCESS != _aws_iot_mqtt_read_string_with_len(pTopicName, topicNameLen, &curData, endData) + if(IOT_SUCCESS != _aws_iot_mqtt_read_string_with_len(pTopicName, topicNameLen, &curData, endData) || (0 > (endData - curData))) { - FUNC_EXIT_RC(FAILURE); + FUNC_EXIT_RC(IOT_FAILURE); } if(QOS0 != *qos) { @@ -368,7 +368,7 @@ *payloadLen = (size_t) (endData - curData); *payload = curData; - FUNC_EXIT_RC(SUCCESS); + FUNC_EXIT_RC(IOT_SUCCESS); } /** @@ -384,7 +384,7 @@ IoT_Error_t aws_iot_mqtt_internal_deserialize_ack(unsigned char *pPacketType, unsigned char *dup, uint16_t *pPacketId, unsigned char *pRxBuf, size_t rxBuflen) { - IoT_Error_t rc = FAILURE; + IoT_Error_t rc = IOT_FAILURE; unsigned char *curdata = pRxBuf; unsigned char *enddata = NULL; uint32_t decodedLen = 0; @@ -409,19 +409,19 @@ /* read remaining length */ rc = aws_iot_mqtt_internal_decode_remaining_length_from_buffer(curdata, &decodedLen, &readBytesLen); - if(SUCCESS != rc) { + if(IOT_SUCCESS != rc) { FUNC_EXIT_RC(rc); } curdata += (readBytesLen); enddata = curdata + decodedLen; if(enddata - curdata < 2) { - FUNC_EXIT_RC(FAILURE); + FUNC_EXIT_RC(IOT_FAILURE); } *pPacketId = aws_iot_mqtt_internal_read_uint16_t(&curdata); - FUNC_EXIT_RC(SUCCESS); + FUNC_EXIT_RC(IOT_SUCCESS); } #ifdef __cplusplus