简体   繁体   中英

AWS IOT BasicPubSub Arduino Yun Example gives Generic Error & Yield Error when delay is set to 10,000

I downloaded the Arduino Yun SDK from Github & installed as per the given instructions. I ran the example BasicPubSub & it runs successfully & I see messages arriving on MQTT Client subscription topic every second. That's amazing!

But I don't see my device connection on resources tab. It still says, 'Last update = No state'. Why is it so?

I need to send messages once per 10 seconds. I change the delay in the BasicPubSub loop to delay(10000). But now, only the first message is received in the topic & the serial monitor says, '-1 Publish Failed; -35 Yield Failed'

Is there a problem with the connection. If it is so, why is the first message delivered but not the others. What can I do to solve the problem?

Thanks

I had the same issue and I found that you need to call the yield function more frequently for Arduino to stay connected. So your should do something like this if you want to delay more than 10 secs:

int uploadInterval = 60;   // Delay time (SECOND) for each loop iterarion
for (int i = 0; i < uploadInterval; i++) {
  if ((rc = myClient.yield()) != 0) {
    Serial.println("Yield failed!");
    Serial.println(rc);
  }
  delay(1000);
}

From the AWS Arduino SDK webpage about yield function: "Users should call this function frequently to receive new messages and free subscribe slots for new subscribes, especially for shadow thing requests."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM