support anon auth & generated client id in constructor
This commit is contained in:
parent
aa6db4d5f5
commit
b48265faed
@ -70,30 +70,39 @@ static uint8_t *stringprint_P(uint8_t *p, const char *s, uint16_t maxlen=0) {
|
|||||||
|
|
||||||
// Adafruit_MQTT Definition ////////////////////////////////////////////////////
|
// Adafruit_MQTT Definition ////////////////////////////////////////////////////
|
||||||
|
|
||||||
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
|
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port,
|
||||||
const char *user, const char *pass) {
|
const char *user, const char *pass,
|
||||||
|
const char *cid) {
|
||||||
servername = server;
|
servername = server;
|
||||||
portnum = port;
|
portnum = port;
|
||||||
clientid = cid;
|
clientid = cid;
|
||||||
username = user;
|
username = user;
|
||||||
password = pass;
|
password = pass;
|
||||||
|
|
||||||
|
// reset subscriptions
|
||||||
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
||||||
subscriptions[i] = 0;
|
subscriptions[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server, uint16_t port, const __FlashStringHelper *cid,
|
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
|
||||||
const __FlashStringHelper *user, const __FlashStringHelper *pass) {
|
uint16_t port,
|
||||||
|
const __FlashStringHelper *user,
|
||||||
|
const __FlashStringHelper *pass,
|
||||||
|
const __FlashStringHelper *cid) {
|
||||||
|
|
||||||
servername = (const char *)server;
|
servername = (const char *)server;
|
||||||
portnum = port;
|
portnum = port;
|
||||||
clientid = (const char *)cid;
|
clientid = (const char *)cid;
|
||||||
username = (const char *)user;
|
username = (const char *)user;
|
||||||
password = (const char *)pass;
|
password = (const char *)pass;
|
||||||
|
|
||||||
|
// reset subscriptions
|
||||||
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
||||||
subscriptions[i] = 0;
|
subscriptions[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Adafruit_MQTT::connect() {
|
int8_t Adafruit_MQTT::connect() {
|
||||||
@ -519,7 +528,6 @@ uint8_t Adafruit_MQTT::disconnectPacket(uint8_t *packet) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Adafruit_MQTT_Publish Definition ////////////////////////////////////////////
|
// Adafruit_MQTT_Publish Definition ////////////////////////////////////////////
|
||||||
|
|
||||||
Adafruit_MQTT_Publish::Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver,
|
Adafruit_MQTT_Publish::Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver,
|
||||||
|
@ -99,10 +99,16 @@ class Adafruit_MQTT_Subscribe; // forward decl
|
|||||||
|
|
||||||
class Adafruit_MQTT {
|
class Adafruit_MQTT {
|
||||||
public:
|
public:
|
||||||
Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
|
Adafruit_MQTT(const char *server = "io.adafruit.com",
|
||||||
const char *user, const char *pass);
|
uint16_t port = 1883,
|
||||||
Adafruit_MQTT(const __FlashStringHelper *server, uint16_t port, const __FlashStringHelper *cid,
|
const char *user = "",
|
||||||
const __FlashStringHelper *user, const __FlashStringHelper *pass);
|
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);
|
||||||
virtual ~Adafruit_MQTT() {}
|
virtual ~Adafruit_MQTT() {}
|
||||||
|
|
||||||
// Connect to the MQTT server. Returns 0 on success, otherwise an error code
|
// Connect to the MQTT server. Returns 0 on success, otherwise an error code
|
||||||
|
Loading…
Reference in New Issue
Block a user