Skip to content

Commit

Permalink
Merge pull request #1 from imbeacon/master
Browse files Browse the repository at this point in the history
Added std::function support for non ESP boards.
  • Loading branch information
imbeacon authored Feb 21, 2023
2 parents 2d228f2 + e49f361 commit 0a6ee1e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/PubSubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@
// Maximum size of fixed header and variable length size header
#define MQTT_MAX_HEADER_SIZE 5

#if defined(ESP8266) || defined(ESP32)
#include <functional>
#define MQTT_CALLBACK_SIGNATURE std::function<void(char*, uint8_t*, unsigned int)> callback
#else
#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int)
#endif
# ifdef __has_include
# if __has_include(<functional>)
# include <functional>
# define MQTT_CALLBACK_SIGNATURE std::function<void(char*, uint8_t*, unsigned int)> callback
# else
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int)
# endif
# else
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int)
# endif

#define CHECK_STRING_LENGTH(l,s) if (l+2+strnlen(s, this->bufferSize) > this->bufferSize) {_client->stop();return false;}

Expand Down

0 comments on commit 0a6ee1e

Please sign in to comment.