diff --git a/src/emq_client.cpp b/src/emq_client.cpp index 25940d7..d52511d 100644 --- a/src/emq_client.cpp +++ b/src/emq_client.cpp @@ -46,7 +46,7 @@ extern int g_mqtt_port; // private variable definitions static bool force_disconnected = false; -static PubSubClient* emqx_client = NULL; +static PubSubClient* emqx_client = nullptr; // private function declarations @@ -55,7 +55,7 @@ static PubSubClient* emqx_client = NULL; int connectToEMQXBroker(PubSubClient &mqtt_client) { int retry_times = 0; - if (NULL == emqx_client) { + if (nullptr == emqx_client) { emqx_client = &mqtt_client; } emqx_client->setServer(g_mqtt_server.c_str(), g_mqtt_port); diff --git a/src/iot_hub.cpp b/src/iot_hub.cpp index 8dcb697..9fbc7db 100644 --- a/src/iot_hub.cpp +++ b/src/iot_hub.cpp @@ -166,7 +166,7 @@ void checkIot() { void iotCallback(char *topic, uint8_t *data, uint32_t length) { INFOF("Downstream message received, topic = %s, length = %d\n", topic, length); - if (NULL != g_downstream_topic.c_str() && 0 == strcmp(topic, g_downstream_topic.c_str())) { + if (nullptr != g_downstream_topic.c_str() && 0 == strcmp(topic, g_downstream_topic.c_str())) { handleIrisKitMessage((const char*) data, length); } } \ No newline at end of file diff --git a/src/iris_client.cpp b/src/iris_client.cpp index 2a6f3d7..662ee99 100644 --- a/src/iris_client.cpp +++ b/src/iris_client.cpp @@ -92,7 +92,7 @@ event_handler_t event_handler_table[] = { // public function definitions int getIRISKitVersion(char *buffer, int buffer_size) { - if (NULL == buffer) { + if (nullptr == buffer) { return -1; } memset(buffer, 0, buffer_size); @@ -123,7 +123,7 @@ int authIrisKit(String credential_token, http_error_t http_ret = HTTP_ERROR_GENERIC; - if (NULL != strstr(iris_server_address, "http://")) { + if (nullptr != strstr(iris_server_address, "http://")) { protocol_prefix = true; } if (protocol_prefix) { @@ -185,7 +185,7 @@ bool downloadBin(int remote_id) { String download_bin_url; http_error_t http_ret = HTTP_ERROR_GENERIC; - if (NULL != strstr(iris_server_address, "http://")) { + if (nullptr != strstr(iris_server_address, "http://")) { protocol_prefix = true; } if (protocol_prefix) { @@ -223,7 +223,7 @@ void sendIrisKitHeartBeat() { void handleIrisKitMessage(const char* data, int length) { int ret = 0; char* payload = (char*) malloc(length + 1); - if (NULL != payload) { + if (nullptr != payload) { strncpy(payload, data, length); payload[length] = '\0'; INFOF("--> %s\n", payload); @@ -238,7 +238,7 @@ void handleIrisKitMessage(const char* data, int length) { } } - if (NULL != payload) { + if (nullptr != payload) { free(payload); } } diff --git a/src/iris_kit.cpp b/src/iris_kit.cpp index 72a6cbc..5f2b8f0 100644 --- a/src/iris_kit.cpp +++ b/src/iris_kit.cpp @@ -113,11 +113,11 @@ void setup() { INFOF("Password is empty ? %s\n", iris_kit_settings.password.isEmpty() ? "yes" : "no"); } if (!iris_kit_settings.credential_token.isEmpty() && - !iris_kit_settings.credential_token.equalsIgnoreCase("NULL") && + !iris_kit_settings.credential_token.equalsIgnoreCase("nullptr") && !iris_kit_settings.server_address.isEmpty() && - !iris_kit_settings.server_address.equalsIgnoreCase("NULL") && + !iris_kit_settings.server_address.equalsIgnoreCase("nullptr") && !iris_kit_settings.password.isEmpty() && - !iris_kit_settings.password.equalsIgnoreCase("NULL")) { + !iris_kit_settings.password.equalsIgnoreCase("nullptr")) { iris_kit_settings_loaded = true; } @@ -210,7 +210,7 @@ void setup() { loadIRPin(send_pin, recv_pin); // prepare MQTT connection params - if (NULL != strstr(iris_server_address, "iris.irext.net")) { + if (nullptr != strstr(iris_server_address, "iris.irext.net")) { g_mqtt_server = String(MQTT_HOST_REL); g_runtime_env = RUNTIME_RELEASE; } else { diff --git a/src/utils.cpp b/src/utils.cpp index e78a66a..c9ed3f4 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -32,31 +32,31 @@ MD5Builder md5_builder; int split_string(const String source, char* parts[], const char* delimiter) { - char* pch = NULL; - char* copy = NULL; - char* tmp = NULL; + char* pch = nullptr; + char* copy = nullptr; + char* tmp = nullptr; int i = 0; copy = strdup(source.c_str()); - if (NULL == copy) { + if (nullptr == copy) { goto exit; } pch = strtok(copy, delimiter); tmp = strdup(pch); - if (NULL == tmp) { + if (nullptr == tmp) { goto exit; } parts[i++] = tmp; while (pch) { - pch = strtok(NULL, delimiter); - if (NULL == pch) break; + pch = strtok(nullptr, delimiter); + if (nullptr == pch) break; tmp = strdup(pch); - if (NULL == tmp) { + if (nullptr == tmp) { goto exit; }