void reconnect() { // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); if (client.connect("arduinoClient")) { Serial.println("connected"); client.publish("/info/login/","{'Deivceid'}"); client.subscribe("/command/#"); } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } }
void setup() { // put your setup code here, to run once: //Initialize serial and wait for port to open: Serial.begin(9600); //while (!Serial) { //; // wait for serial port to connect. Needed for Leonardo only // } Bridge.begin(); // initialize digital pin 13 as an output. pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, HIGH);
留言列表