From 7886b7243c348dbf26fb7eb0d082ba5d29cca3e0 Mon Sep 17 00:00:00 2001 From: ladyada Date: Tue, 9 Aug 2016 21:12:49 -0400 Subject: [PATCH] simplify Client --- Adafruit_MQTT_Client.cpp | 2 +- examples/mqtt_ethernet/mqtt_ethernet.ino | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Adafruit_MQTT_Client.cpp b/Adafruit_MQTT_Client.cpp index bf13b61..abcfdbd 100644 --- a/Adafruit_MQTT_Client.cpp +++ b/Adafruit_MQTT_Client.cpp @@ -25,7 +25,7 @@ bool Adafruit_MQTT_Client::connectServer() { // Grab server name from flash and copy to buffer for name resolution. memset(buffer, 0, sizeof(buffer)); - strcpy_P((char *)buffer, servername); + strcpy((char *)buffer, servername); DEBUG_PRINT(F("Connecting to: ")); DEBUG_PRINTLN((char *)buffer); // Connect and check for success (0 result). int r = client->connect((char *)buffer, portnum); diff --git a/examples/mqtt_ethernet/mqtt_ethernet.ino b/examples/mqtt_ethernet/mqtt_ethernet.ino index ecb1a24..a156705 100644 --- a/examples/mqtt_ethernet/mqtt_ethernet.ino +++ b/examples/mqtt_ethernet/mqtt_ethernet.ino @@ -41,17 +41,7 @@ byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //Set up the ethernet client EthernetClient client; -// Store the MQTT server, client ID, username, and password in flash memory. -// This is required for using the Adafruit MQTT library. -const char MQTT_SERVER[] PROGMEM = AIO_SERVER; -// Set a unique MQTT client ID using the AIO key + the date and time the sketch -// was compiled (so this should be unique across multiple devices for a user, -// alternatively you can manually set this to a GUID or other random value). -const char MQTT_CLIENTID[] PROGMEM = __TIME__ AIO_USERNAME; -const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME; -const char MQTT_PASSWORD[] PROGMEM = AIO_KEY; - -Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD); +Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); // You don't need to change anything below this line! #define halt(s) { Serial.println(F( s )); while(1); } @@ -61,12 +51,10 @@ Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, M // Setup a feed called 'photocell' for publishing. // Notice MQTT paths for AIO follow the form: /feeds/ -const char PHOTOCELL_FEED[] PROGMEM = AIO_USERNAME "/feeds/photocell"; -Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED); +Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell"); // Setup a feed called 'onoff' for subscribing to changes. -const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff"; -Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED); +Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff"); /*************************** Sketch Code ************************************/