remove defaults from mqtt constructors

This commit is contained in:
Todd Treece 2015-10-22 10:09:16 -04:00
parent 371b16bfab
commit 2aed9ae737
5 changed files with 93 additions and 36 deletions

View File

@ -70,9 +70,11 @@ static uint8_t *stringprint_P(uint8_t *p, const char *s, uint16_t maxlen=0) {
// Adafruit_MQTT Definition ////////////////////////////////////////////////////
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port,
const char *user, const char *pass,
const char *cid) {
Adafruit_MQTT::Adafruit_MQTT(const char *server,
uint16_t port,
const char *cid,
const char *user,
const char *pass) {
servername = server;
portnum = port;
clientid = cid;
@ -85,13 +87,14 @@ Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port,
}
packet_id_counter = 0;
}
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
uint16_t port,
const __FlashStringHelper *cid,
const __FlashStringHelper *user,
const __FlashStringHelper *pass,
const __FlashStringHelper *cid) {
const __FlashStringHelper *pass) {
servername = (const char *)server;
portnum = port;
@ -105,6 +108,46 @@ Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
}
packet_id_counter = 0;
}
Adafruit_MQTT::Adafruit_MQTT(const char *server,
uint16_t port,
const char *user,
const char *pass) {
servername = server;
portnum = port;
clientid = "";
username = user;
password = pass;
// reset subscriptions
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
subscriptions[i] = 0;
}
packet_id_counter = 0;
}
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
uint16_t port,
const __FlashStringHelper *user,
const __FlashStringHelper *pass) {
servername = (const char *)server;
portnum = port;
clientid = "";
username = (const char *)user;
password = (const char *)pass;
// reset subscriptions
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
subscriptions[i] = 0;
}
packet_id_counter = 0;
}
int8_t Adafruit_MQTT::connect() {

View File

@ -100,16 +100,24 @@ class Adafruit_MQTT_Subscribe; // forward decl
class Adafruit_MQTT {
public:
Adafruit_MQTT(const char *server = "io.adafruit.com",
uint16_t port = 1883,
const char *user = "",
const char *pass = "",
const char *cid = "");
Adafruit_MQTT(const __FlashStringHelper *server = 0,
uint16_t port = 1883,
const __FlashStringHelper *user = 0,
const __FlashStringHelper *pass = 0,
const __FlashStringHelper *cid = 0);
Adafruit_MQTT(const char *server,
uint16_t port,
const char *cid,
const char *user,
const char *pass);
Adafruit_MQTT(const __FlashStringHelper *server,
uint16_t port,
const __FlashStringHelper *cid,
const __FlashStringHelper *user,
const __FlashStringHelper *pass);
Adafruit_MQTT(const char *server,
uint16_t port,
const char *user,
const char *pass);
Adafruit_MQTT(const __FlashStringHelper *server,
uint16_t port,
const __FlashStringHelper *user,
const __FlashStringHelper *pass);
virtual ~Adafruit_MQTT() {}
// Connect to the MQTT server. Returns 0 on success, otherwise an error code

View File

@ -37,13 +37,15 @@
// in the compilation of the library).
class Adafruit_MQTT_CC3000 : public Adafruit_MQTT {
public:
Adafruit_MQTT_CC3000(Adafruit_CC3000 *cc3k,
const char *server = "io.adafruit.com",
uint16_t port = 1883,
const char *user = "",
const char *pass = "",
const char *cid = ""):
Adafruit_MQTT(server, port, user, pass, cid),
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)
{}
Adafruit_MQTT_CC3000(Adafruit_CC3000 *cc3k, const char *server, uint16_t port,
const char *user, const char *pass):
Adafruit_MQTT(server, port, user, pass),
cc3000(cc3k)
{}

View File

@ -35,13 +35,15 @@
// and even other platforms like ESP8266.
class Adafruit_MQTT_Client : public Adafruit_MQTT {
public:
Adafruit_MQTT_Client(Client *client,
const char *server = "io.adafruit.com",
uint16_t port = 1883,
const char *user = "",
const char *pass = "",
const char *cid = ""):
Adafruit_MQTT(server, port, user, pass, cid),
Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port,
const char *cid, const char *user, const char *pass):
Adafruit_MQTT(server, port, cid, user, pass),
client(client)
{}
Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port,
const char *user, const char *pass):
Adafruit_MQTT(server, port, user, pass),
client(client)
{}

View File

@ -35,13 +35,15 @@
// in the compilation of the library).
class Adafruit_MQTT_FONA : public Adafruit_MQTT {
public:
Adafruit_MQTT_FONA(Adafruit_FONA *f,
const char *server = "io.adafruit.com",
uint16_t port = 1883,
const char *user = "",
const char *pass = "",
const char *cid = ""):
Adafruit_MQTT(server, port, user, pass, cid),
Adafruit_MQTT_FONA(Adafruit_FONA *f, const char *server, uint16_t port,
const char *cid, const char *user, const char *pass):
Adafruit_MQTT(server, port, cid, user, pass),
fona(f)
{}
Adafruit_MQTT_FONA(Adafruit_FONA *f, const char *server, uint16_t port,
const char *user, const char *pass):
Adafruit_MQTT(server, port, user, pass),
fona(f)
{}