From 3e24eb8af13fc1c882b3e46a8554bb45bf7651e8 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Mon, 27 Jan 2020 12:44:50 -0800 Subject: [PATCH] samples: net: mqtt_publisher: handle EAGAIN from mqtt_live() Now that mqtt_live() can send an EAGAIN message meaning: no ping was generated, let's handle that in process_mqtt_and_sleep() by skipping the call to mqtt_input() since no data will be expected. Signed-off-by: Michael Scott --- samples/net/mqtt_publisher/src/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/net/mqtt_publisher/src/main.c b/samples/net/mqtt_publisher/src/main.c index eb0590bcce4..5357b1a3844 100644 --- a/samples/net/mqtt_publisher/src/main.c +++ b/samples/net/mqtt_publisher/src/main.c @@ -382,15 +382,15 @@ static int process_mqtt_and_sleep(struct mqtt_client *client, int timeout) wait(remaining); rc = mqtt_live(client); - if (rc != 0) { + if (rc != 0 && rc != -EAGAIN) { PRINT_RESULT("mqtt_live", rc); return rc; - } - - rc = mqtt_input(client); - if (rc != 0) { - PRINT_RESULT("mqtt_input", rc); - return rc; + } else if (rc == 0) { + rc = mqtt_input(client); + if (rc != 0) { + PRINT_RESULT("mqtt_input", rc); + return rc; + } } remaining = timeout + start_time - k_uptime_get();