From 21b75a2c4aad100a3fc2cb1f04e6a9b147d69a3d Mon Sep 17 00:00:00 2001 From: Tom Cook Date: Tue, 26 Jan 2016 09:50:27 +0000 Subject: [PATCH 1/3] Changed callback type. --- src/PubSubClient.cpp | 2 +- src/PubSubClient.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index 5c02339..3620057 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -570,7 +570,7 @@ PubSubClient& PubSubClient::setServer(const char * domain, uint16_t port) { return *this; } -PubSubClient& PubSubClient::setCallback(void(*callback)(char*,uint8_t*,unsigned int)){ +PubSubClient& PubSubClient::setCallback(MQTT_CALLBACK_SIGNATURE) { this->callback = callback; return *this; } diff --git a/src/PubSubClient.h b/src/PubSubClient.h index fc72c76..d2cc61c 100755 --- a/src/PubSubClient.h +++ b/src/PubSubClient.h @@ -11,6 +11,7 @@ #include "IPAddress.h" #include "Client.h" #include "Stream.h" +#include #define MQTT_VERSION_3_1 3 #define MQTT_VERSION_3_1_1 4 @@ -65,7 +66,7 @@ #define MQTTQOS1 (1 << 1) #define MQTTQOS2 (2 << 1) -#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*,uint8_t*,unsigned int) +#define MQTT_CALLBACK_SIGNATURE std::function callback class PubSubClient { private: From 98a9c296f6d469a9b6221eb2e29655610b4d7583 Mon Sep 17 00:00:00 2001 From: Tom Cook Date: Wed, 27 Jan 2016 12:39:43 +0000 Subject: [PATCH 2/3] Made use of std::function ESP8266-specific. --- src/PubSubClient.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PubSubClient.h b/src/PubSubClient.h index d2cc61c..073a759 100755 --- a/src/PubSubClient.h +++ b/src/PubSubClient.h @@ -66,7 +66,11 @@ #define MQTTQOS1 (1 << 1) #define MQTTQOS2 (2 << 1) +#ifdef ESP8266 #define MQTT_CALLBACK_SIGNATURE std::function callback +#else +#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, uint32_t) +#endif class PubSubClient { private: From 67eba6dad42071a23ff30cc03993af05981d097d Mon Sep 17 00:00:00 2001 From: Tom Cook Date: Wed, 27 Jan 2016 12:41:50 +0000 Subject: [PATCH 3/3] Moved #include of --- src/PubSubClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PubSubClient.h b/src/PubSubClient.h index 073a759..c41f03f 100755 --- a/src/PubSubClient.h +++ b/src/PubSubClient.h @@ -11,7 +11,6 @@ #include "IPAddress.h" #include "Client.h" #include "Stream.h" -#include #define MQTT_VERSION_3_1 3 #define MQTT_VERSION_3_1_1 4 @@ -67,6 +66,7 @@ #define MQTTQOS2 (2 << 1) #ifdef ESP8266 +#include #define MQTT_CALLBACK_SIGNATURE std::function callback #else #define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, uint32_t)