   uint8_t identity[6] = {'P', 'h', 'o', 't', 'o', 'n'};
   dealer.setIdentity(identity, 6);
 
-  int tries = 0;
-  while (!dealer.ready()) {
-    Serial.println("Not ready yet.");
-    if (++tries > 5) {
-      end();
-    }
-    delay(1000);
-    dealer.update();
-  }
+  waitUntilReady(dealer);
 
   {
     uint8_t data[5] = {'H', 'e', 'l', 'l', 'o'};


SYSTEM_MODE(MANUAL);

void setup() {
  WiFi.on();
  WiFi.connect();
  waitUntil(WiFi.ready);
  Particle.process();

  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  ZMTPSocket dealer(DEALER);

  // uint8_t address[4] = { 192, 168, 29, 198 };
  uint8_t address[4] = {172, 20, 10, 3};
  Serial.printf("Connecting to: %i.%i.%i.%i\n", address[0], address[1],
                address[2], address[3]);
  dealer.connect(address, 1234);

    router.send(frame);
    zmtp_frame_destroy(&frame);
  }
}

void setup() {
  enableWiFi();

  // uint8_t address[4] = { 192, 168, 29, 198 };
  uint8_t address[4] = {172, 20, 10, 3};
  runDealerTest(address);
  runRouterTest();

  // Allow time for network to catch up before we hard disconnect.
  delay(1000);

  end();
