Announcement

Collapse
No announcement yet.

gen4-IoD-32T WiFi Display Module - Connection to AWS IoT using MQTT

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I cleaned up the error messages in the connectToMqTT() routine - it show that the client.connect() is returning a false although the returnCode and lastError are successful

    10:32:55.218 -> MQTT connecting
    10:33:05.234 -> failed, returnCode -> Connection Accepted, lastError -> Success < try again in 20 seconds


    Code:
    void connectToMqtt(bool nonBlocking = false)
    {
    
      while (!client.connected())
      {
        yield();
        Serial.print("MQTT connecting ");
        gfx.print("MQTT connecting ");
    
        if (client.connect(THINGNAME))
        {
          Serial.println("connected!");
          gfx.println("connected!");
          if (!client.subscribe(MQTT_SUB_TOPIC))
            lwMQTTErr(client.lastError());
        }
        else
        {
          Serial.println("");
          gfx.println("");
          Serial.print("failed, returnCode -> ");
          gfx.print("failed, returnCode -> ");
          lwMQTTErrConnection(client.returnCode());
          Serial.print(", lastError -> ");
          gfx.print(", lastError -> ");
          lwMQTTErr(client.lastError());
          if (!nonBlocking)
          {
            Serial.println(" < try again in 20 seconds");
            gfx.println(" < try again in 20 seconds");
            client.disconnect();
            for (int i = 0; i < 20; i++)
            {
              Serial.print(".");
              gfx.print(".");
              delay(1000);
              yield();
            }
            Serial.println(".");
            gfx.println(".");
            yield();
          }
          else
          {
            Serial.println(" <");
            gfx.print(" <");
          }
        }
        if (nonBlocking)
          break;
      }
    }

    Comment


    • #17
      Paul,

      As another question - you will notice that I print to the screen using gfx.println() function - when the print hits the bottom of the screen any additional print calls do not appear on the screen, is there an easy way to have it scroll and continue printing?

      Tom
      Last edited by gaspertom; 15th March 2019, 02:13 AM.

      Comment

      Working...
      X