From 5d101b8a7b0d329cee80e2599854578d311cd657 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 24 Jul 2015 11:29:22 +0200 Subject: [PATCH] Allow passing __FlashStringHelper* in addition to char* everywhere Arduino supplies the F() macro that allows easily putting strings in PROGMEM and marking them with a custom type. Essentially, a __FlashStringHelper* is just the same char*, but cast to a different type, which allows for example Serial.print() to automatically handle both PROGMEM and normal strings. By letting this library accept __FlashStringHelper* as well, you can use easily use the F() macro and reduce the chance of mixing up normal and PROGMEM pointers. --- Adafruit_MQTT.cpp | 28 ++++++++++++++++++++++++++++ Adafruit_MQTT.h | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 443fc69..5558a65 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -83,6 +83,20 @@ Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port, const char *cid, } } +Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server, uint16_t port, const __FlashStringHelper *cid, + const __FlashStringHelper *user, const __FlashStringHelper *pass) { + servername = (const char *)server; + portnum = port; + clientid = (const char *)cid; + username = (const char *)user; + password = (const char *)pass; + + for (uint8_t i=0; i