You've already forked Adafruit_MQTT_Library
mirror of
https://github.com/adafruit/Adafruit_MQTT_Library.git
synced 2025-07-27 15:01:49 +03:00
Refactor Adafruit_MQTT to have a simple interface for packet sending & receiving that subclasses implement.
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
#ifndef _ADAFRUIT_MQTT_CC3000_H_
|
||||
#define _ADAFRUIT_MQTT_CC3000_H_
|
||||
|
||||
|
||||
#include "Adafruit_MQTT.h"
|
||||
#include "Adafruit_MQTT_CC3000.h"
|
||||
#include <Adafruit_CC3000.h>
|
||||
#include "Adafruit_MQTT.h"
|
||||
|
||||
// delay in ms between calls of available()
|
||||
#define MQTT_CC3000_INTERAVAILDELAY 10
|
||||
@ -12,19 +10,20 @@
|
||||
|
||||
class Adafruit_MQTT_CC3000 : public Adafruit_MQTT {
|
||||
public:
|
||||
Adafruit_MQTT_CC3000(Adafruit_CC3000 *cc3k, const char *server, uint16_t port, const char *cid, const char *user, const char *pass);
|
||||
int8_t connect(void);
|
||||
uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout, boolean checkForValidPubPacket = false);
|
||||
int32_t close(void);
|
||||
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)
|
||||
{}
|
||||
|
||||
boolean publish(const char *topic, char *payload, uint8_t qos);
|
||||
boolean ping(uint8_t time);
|
||||
|
||||
boolean subscribe(Adafruit_MQTT_Subscribe *sub);
|
||||
|
||||
Adafruit_MQTT_Subscribe *readSubscription(int16_t timeout=0);
|
||||
bool connectServer();
|
||||
bool disconnect();
|
||||
uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout,
|
||||
bool checkForValidPubPacket = false);
|
||||
bool sendPacket(uint8_t *buffer, uint8_t len);
|
||||
|
||||
private:
|
||||
uint32_t serverip;
|
||||
Adafruit_CC3000 *cc3000;
|
||||
Adafruit_CC3000_Client mqttclient;
|
||||
};
|
||||
|
Reference in New Issue
Block a user