#include "Adafruit_MQTT.h" #include "Adafruit_MQTT_CC3000.h" #include Adafruit_MQTT_CC3000::Adafruit_MQTT_CC3000(Adafruit_CC3000 *cc3k, const char *server, uint16_t port, const char *cid, const char *user, const char *pass) : Adafruit_MQTT(server, port, cid, user, pass), cc3000(cc3k) { // nothin doin } int8_t Adafruit_MQTT_CC3000::connect(void) { uint32_t ip = 0; Watchdog.reset(); // look up IP address if (serverip == 0) { // Try looking up the website's IP address using CC3K's built in getHostByName strcpy_P((char *)buffer, servername); Serial.print((char *)buffer); Serial.print(F(" -> ")); uint8_t dnsretries = 5; Watchdog.reset(); while (ip == 0) { if (! cc3000->getHostByName((char *)buffer, &ip)) { Serial.println(F("Couldn't resolve!")); dnsretries--; Watchdog.reset(); } //Serial.println("OK"); Serial.println(ip, HEX); if (!dnsretries) return -1; delay(500); } serverip = ip; cc3000->printIPdotsRev(serverip); Serial.println(); } Watchdog.reset(); // connect to server Serial.println(F("Connecting to TCP")); mqttclient = cc3000->connectTCP(serverip, portnum); uint8_t len = connectPacket(buffer); Serial.println(F("MQTT connection packet:")); for (uint8_t i=0; i 0)) { Serial.print('.'); while (mqttclient.available()) { Serial.print('!'); char c = mqttclient.read(); timeout = t; // reset the timeout buffer[len] = c; //Serial.print((uint8_t)c,HEX); len++; if (len == maxlen) { // we read all we want, bail Serial.print(F("Read packet:\t")); for (uint8_t i=0; i 0) { Serial.println(F("Reply:")); len = readPacket(buffer, 4, PUBLISH_TIMEOUT_MS); for (uint8_t i=0; i