   data += String("\"}");
 
   Serial.println(data);
-  client.publish(g_topic, data.c_str());
+  mqtt_client->publish(g_topic, data.c_str());
 }
 
 void messageReceived(String topic, String payload, char *bytes, unsigned int length) {

      }
    }
  }
  Serial.println("e1");
  return false;
}


    }
  }

  Serial.println("es");
  return false;
}

void set_alias(const char *alias) {
  mqtt_client->publish(",yali", alias);
}

void mqtt_connect() {
  Serial.println("cn.."); // connecting
  while (!mqtt_client->connect(client_id, username, password)) {
    Serial.println("..");
    delay(1000);
  }

  Serial.println("co"); // connect ok

//  mqtt_client->subscribe(g_topic);
  set_alias(g_devid);
}

void check_connect() {
  if (millis() - g_last_check_ms > 2000) {
    boolean st = mqtt_client->connected();
//    Serial.println(st);
    if (st != g_net_status) {
      Serial.print("cs:");
      g_net_status = st;
      Serial.println(g_net_status);
    }

    if (!st) {
      mqtt_client->disconnect();
      delete(mqtt_client);
      init_network();
    }
    g_last_check_ms = millis();
  }
