diff options
author | Varun Reddy | 2017-10-12 12:56:57 -0500 |
---|---|---|
committer | Varun Reddy | 2017-10-12 12:56:57 -0500 |
commit | 9b84c7bcc04a7e758c0884c230c627d45ffa3906 (patch) | |
tree | 5de40548d2a6285f285b782a4fb8a15d8e84b2d1 | |
parent | b5fc155bf6276808db5c6513daff4b764aa3df4a (diff) | |
download | aws-iot-device-sdk-embedded-c-9b84c7bcc04a7e758c0884c230c627d45ffa3906.tar.gz aws-iot-device-sdk-embedded-c-9b84c7bcc04a7e758c0884c230c627d45ffa3906.tar.xz aws-iot-device-sdk-embedded-c-9b84c7bcc04a7e758c0884c230c627d45ffa3906.zip |
Wait for all messages to be received in subscribe publish sample
Fixes #73
-rw-r--r-- | samples/linux/subscribe_publish_sample/subscribe_publish_sample.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c b/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c index 4f92645..6f952b8 100644 --- a/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c +++ b/samples/linux/subscribe_publish_sample/subscribe_publish_sample.c | |||
@@ -240,6 +240,10 @@ int main(int argc, char **argv) { | |||
240 | publishCount--; | 240 | publishCount--; |
241 | } | 241 | } |
242 | 242 | ||
243 | if(publishCount == 0) { | ||
244 | break; | ||
245 | } | ||
246 | |||
243 | sprintf(cPayload, "%s : %d ", "hello from SDK QOS1", i++); | 247 | sprintf(cPayload, "%s : %d ", "hello from SDK QOS1", i++); |
244 | paramsQOS1.payloadLen = strlen(cPayload); | 248 | paramsQOS1.payloadLen = strlen(cPayload); |
245 | rc = aws_iot_mqtt_publish(&client, "sdkTest/sub", 11, ¶msQOS1); | 249 | rc = aws_iot_mqtt_publish(&client, "sdkTest/sub", 11, ¶msQOS1); |
@@ -252,6 +256,9 @@ int main(int argc, char **argv) { | |||
252 | } | 256 | } |
253 | } | 257 | } |
254 | 258 | ||
259 | // Wait for all the messages to be received | ||
260 | aws_iot_mqtt_yield(&client, 100); | ||
261 | |||
255 | if(SUCCESS != rc) { | 262 | if(SUCCESS != rc) { |
256 | IOT_ERROR("An error occurred in the loop.\n"); | 263 | IOT_ERROR("An error occurred in the loop.\n"); |
257 | } else { | 264 | } else { |