 MQTTClient *g_mqtt_client;
 
 uint8_t g_plug_status = 0;
+
+void (*reset)(void) = 0;
+
+uint8_t g_retry_cnt = 0;
+
+void retry_or_reset(uint8_t try_cnt) {
+  if (g_retry_cnt >= try_cnt) {
+    reset();
+  } else {
+    ++g_retry_cnt;
+  }
+}
 
 bool get_ip_port() {
   char *p = strstr(g_url, "tcp://");

    }

    if (!st) {
//      digitalWrite(PIN_NET_STATUS, LOW);
      delete g_mqtt_client;
      delete g_net_client;

void connect_yunba() {
  Serial.println("cn.."); // connecting

  g_retry_cnt = 0;
  while (!g_mqtt_client->connect(g_client_id, g_username, g_password)) {
    Serial.println("..");
    delay(100);
    retry_or_reset(5);
  }

  g_last_check_ms = millis();
