From 4f295e20796717237be9b6be0c1634dfbabccd96 Mon Sep 17 00:00:00 2001 From: Yaohai Zheng Date: Tue, 6 Dec 2016 21:41:22 +0800 Subject: [PATCH] Fix issues on esp8266 arch for mqtt. --- src/sdk/iothubtransport_mqtt_common.c | 7 +++++-- src/sdk/jsondecoder.c | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sdk/iothubtransport_mqtt_common.c b/src/sdk/iothubtransport_mqtt_common.c index 43bd4be..bda261b 100644 --- a/src/sdk/iothubtransport_mqtt_common.c +++ b/src/sdk/iothubtransport_mqtt_common.c @@ -679,6 +679,9 @@ static int parse_device_twin_topic_info(const char* resp_topic, bool* patch_msg, return result; } + +#define TOUPPER(c) (((c>='a') && (c<='z'))?c-'a'+'A':c) + static IOTHUB_IDENTITY_TYPE retrieve_topic_type(const char* topic_resp) { IOTHUB_IDENTITY_TYPE type; @@ -710,7 +713,7 @@ static IOTHUB_IDENTITY_TYPE retrieve_topic_type(const char* topic_resp) { break; } - else if (toupper(TOPIC_DEVICE_TWIN_PREFIX[index]) != toupper(topic_resp[index])) + else if (TOUPPER(TOPIC_DEVICE_TWIN_PREFIX[index]) != TOUPPER(topic_resp[index])) { search_device_twin = false; } @@ -728,7 +731,7 @@ static IOTHUB_IDENTITY_TYPE retrieve_topic_type(const char* topic_resp) { break; } - else if (toupper(TOPIC_DEVICE_METHOD_PREFIX[index]) != toupper(topic_resp[index])) + else if (TOUPPER(TOPIC_DEVICE_METHOD_PREFIX[index]) != TOUPPER(topic_resp[index])) { search_device_method = false; } diff --git a/src/sdk/jsondecoder.c b/src/sdk/jsondecoder.c index 4917f0d..f723e70 100644 --- a/src/sdk/jsondecoder.c +++ b/src/sdk/jsondecoder.c @@ -112,6 +112,8 @@ static JSON_DECODER_RESULT ParseString(PARSER_STATE* parserState, char** stringB return result; } +#define ISDIGIT(c) (((c>='0') && (c<='9'))?1:0) + static JSON_DECODER_RESULT ParseNumber(PARSER_STATE* parserState) { JSON_DECODER_RESULT result = JSON_DECODER_OK; @@ -126,7 +128,7 @@ static JSON_DECODER_RESULT ParseNumber(PARSER_STATE* parserState) while (*(parserState->json) != '\0') { /* Codes_SRS_JSON_DECODER_99_044:[ Octal and hex forms are not allowed.] */ - if (isdigit(*(parserState->json))) + if (ISDIGIT(*(parserState->json))) { digitCount++; /* simply continue */ @@ -158,7 +160,7 @@ static JSON_DECODER_RESULT ParseNumber(PARSER_STATE* parserState) while (*(parserState->json) != '\0') { /* Codes_SRS_JSON_DECODER_99_044:[ Octal and hex forms are not allowed.] */ - if (isdigit(*(parserState->json))) + if (ISDIGIT(*(parserState->json))) { digitCount++; /* simply continue */ @@ -195,7 +197,7 @@ static JSON_DECODER_RESULT ParseNumber(PARSER_STATE* parserState) while (*(parserState->json) != '\0') { /* Codes_SRS_JSON_DECODER_99_044:[ Octal and hex forms are not allowed.] */ - if (isdigit(*(parserState->json))) + if (ISDIGIT(*(parserState->json))) { digitCount++; /* simply continue */ @@ -263,7 +265,7 @@ static JSON_DECODER_RESULT ParseValue(PARSER_STATE* parserState, MULTITREE_HANDL } else if ( ( - isdigit(*(parserState->json)) + ISDIGIT(*(parserState->json)) ) || (*(parserState->json) == '-')) {