Merge pull request #179 from cmumford/fix-protected
Corrected client public/private methods.
This commit is contained in:
commit
569c83af8c
@ -41,11 +41,14 @@ public:
|
|||||||
const char *user = "", const char *pass = "")
|
const char *user = "", const char *pass = "")
|
||||||
: Adafruit_MQTT(server, port, user, pass), client(client) {}
|
: Adafruit_MQTT(server, port, user, pass), client(client) {}
|
||||||
|
|
||||||
bool connectServer();
|
bool connected() override;
|
||||||
bool disconnectServer();
|
|
||||||
bool connected();
|
protected:
|
||||||
uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, int16_t timeout);
|
bool connectServer() override;
|
||||||
bool sendPacket(uint8_t *buffer, uint16_t len);
|
bool disconnectServer() override;
|
||||||
|
uint16_t readPacket(uint8_t *buffer, uint16_t maxlen,
|
||||||
|
int16_t timeout) override;
|
||||||
|
bool sendPacket(uint8_t *buffer, uint16_t len) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Client *client;
|
Client *client;
|
||||||
|
@ -42,7 +42,13 @@ public:
|
|||||||
const char *user = "", const char *pass = "")
|
const char *user = "", const char *pass = "")
|
||||||
: Adafruit_MQTT(server, port, user, pass), fona(f) {}
|
: Adafruit_MQTT(server, port, user, pass), fona(f) {}
|
||||||
|
|
||||||
bool connectServer() {
|
bool connected() {
|
||||||
|
// Return true if connected, false if not connected.
|
||||||
|
return fona->TCPconnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool connectServer() override {
|
||||||
char server[40];
|
char server[40];
|
||||||
strncpy(server, servername, 40);
|
strncpy(server, servername, 40);
|
||||||
#ifdef ADAFRUIT_SLEEPYDOG_H
|
#ifdef ADAFRUIT_SLEEPYDOG_H
|
||||||
@ -54,14 +60,10 @@ public:
|
|||||||
return fona->TCPconnect(server, portnum);
|
return fona->TCPconnect(server, portnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disconnectServer() { return fona->TCPclose(); }
|
bool disconnectServer() override { return fona->TCPclose(); }
|
||||||
|
|
||||||
bool connected() {
|
uint16_t readPacket(uint8_t *buffer, uint16_t maxlen,
|
||||||
// Return true if connected, false if not connected.
|
int16_t timeout) override {
|
||||||
return fona->TCPconnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, int16_t timeout) {
|
|
||||||
uint8_t *buffp = buffer;
|
uint8_t *buffp = buffer;
|
||||||
DEBUG_PRINTLN(F("Reading data.."));
|
DEBUG_PRINTLN(F("Reading data.."));
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ public:
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sendPacket(uint8_t *buffer, uint16_t len) {
|
bool sendPacket(uint8_t *buffer, uint16_t len) override {
|
||||||
DEBUG_PRINTLN(F("Writing packet"));
|
DEBUG_PRINTLN(F("Writing packet"));
|
||||||
if (fona->TCPconnected()) {
|
if (fona->TCPconnected()) {
|
||||||
boolean ret = fona->TCPsend((char *)buffer, len);
|
boolean ret = fona->TCPsend((char *)buffer, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user