Updated to the Arduino-1.0 API
This commit is contained in:
parent
fb5f8de2a4
commit
4ad0d5f4ac
@ -1,6 +1,6 @@
|
|||||||
1.7
|
1.7
|
||||||
* Improved keepalive handling
|
* Improved keepalive handling
|
||||||
|
* Updated to the Arduino-1.0 API
|
||||||
1.6
|
1.6
|
||||||
* Added the ability to publish a retained message
|
* Added the ability to publish a retained message
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
PubSubClient::PubSubClient() : _client(0) {
|
PubSubClient::PubSubClient() : _client() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, void (*callback)(char*,uint8_t*,int)) : _client(ip,port) {
|
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, void (*callback)(char*,uint8_t*,int)) : _client() {
|
||||||
this->callback = callback;
|
this->callback = callback;
|
||||||
|
this->ip = ip;
|
||||||
|
this->port = port;
|
||||||
}
|
}
|
||||||
int PubSubClient::connect(char *id) {
|
int PubSubClient::connect(char *id) {
|
||||||
return connect(id,0,0,0,0);
|
return connect(id,0,0,0,0);
|
||||||
@ -20,7 +22,7 @@ int PubSubClient::connect(char *id) {
|
|||||||
|
|
||||||
int PubSubClient::connect(char *id, char* willTopic, uint8_t willQos, uint8_t willRetain, char* willMessage) {
|
int PubSubClient::connect(char *id, char* willTopic, uint8_t willQos, uint8_t willRetain, char* willMessage) {
|
||||||
if (!connected()) {
|
if (!connected()) {
|
||||||
if (_client.connect()) {
|
if (_client.connect(this->ip, this->port)) {
|
||||||
nextMsgId = 1;
|
nextMsgId = 1;
|
||||||
uint8_t d[9] = {0x00,0x06,'M','Q','I','s','d','p',MQTTPROTOCOLVERSION};
|
uint8_t d[9] = {0x00,0x06,'M','Q','I','s','d','p',MQTTPROTOCOLVERSION};
|
||||||
uint8_t length = 0;
|
uint8_t length = 0;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#ifndef PubSubClient_h
|
#ifndef PubSubClient_h
|
||||||
#define PubSubClient_h
|
#define PubSubClient_h
|
||||||
|
|
||||||
|
#include "Ethernet.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
|
|
||||||
#define MAX_PACKET_SIZE 128
|
#define MAX_PACKET_SIZE 128
|
||||||
@ -43,6 +44,8 @@ private:
|
|||||||
uint8_t readByte();
|
uint8_t readByte();
|
||||||
int write(uint8_t header, uint8_t* buf, uint8_t length);
|
int write(uint8_t header, uint8_t* buf, uint8_t length);
|
||||||
uint8_t writeString(char* string, uint8_t* buf, uint8_t pos);
|
uint8_t writeString(char* string, uint8_t* buf, uint8_t pos);
|
||||||
|
uint8_t *ip;
|
||||||
|
uint16_t port;
|
||||||
public:
|
public:
|
||||||
PubSubClient();
|
PubSubClient();
|
||||||
PubSubClient(uint8_t *, uint16_t, void(*)(char*,uint8_t*,int));
|
PubSubClient(uint8_t *, uint16_t, void(*)(char*,uint8_t*,int));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user