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::Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
|
||||
const char *user, const char *pass) {
|
||||
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port,
|
||||
const char *user, const char *pass,
|
||||
const char *cid) {
|
||||
servername = server;
|
||||
portnum = port;
|
||||
clientid = cid;
|
||||
username = user;
|
||||
password = pass;
|
||||
|
||||
// reset subscriptions
|
||||
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
||||
subscriptions[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server, uint16_t port, const __FlashStringHelper *cid,
|
||||
const __FlashStringHelper *user, const __FlashStringHelper *pass) {
|
||||
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
|
||||
uint16_t port,
|
||||
const __FlashStringHelper *user,
|
||||
const __FlashStringHelper *pass,
|
||||
const __FlashStringHelper *cid) {
|
||||
|
||||
servername = (const char *)server;
|
||||
portnum = port;
|
||||
clientid = (const char *)cid;
|
||||
username = (const char *)user;
|
||||
password = (const char *)pass;
|
||||
|
||||
// reset subscriptions
|
||||
for (uint8_t i=0; i<MAXSUBSCRIPTIONS; i++) {
|
||||
subscriptions[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int8_t Adafruit_MQTT::connect() {
|
||||
@ -519,7 +528,6 @@ uint8_t Adafruit_MQTT::disconnectPacket(uint8_t *packet) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
// Adafruit_MQTT_Publish Definition ////////////////////////////////////////////
|
||||
|
||||
Adafruit_MQTT_Publish::Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver,
|
||||
|
@ -99,10 +99,16 @@ class Adafruit_MQTT_Subscribe; // forward decl
|
||||
|
||||
class Adafruit_MQTT {
|
||||
public:
|
||||
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 = "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);
|
||||
virtual ~Adafruit_MQTT() {}
|
||||
|
||||
// Connect to the MQTT server. Returns 0 on success, otherwise an error code
|
||||
|
Loading…
Reference in New Issue
Block a user