diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 5357fb2..de4e91f 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -890,6 +890,18 @@ uint8_t Adafruit_MQTT::disconnectPacket(uint8_t *packet) { return 2; } +uint Adafruit_MQTT::getSubscriptionCount() +{ + uint count = 0; + + for (int i = 0; i < MAXSUBSCRIPTIONS; i++) { + if (subscriptions[i]) + count++; + } + + return count; +} + // Adafruit_MQTT_Publish Definition //////////////////////////////////////////// Adafruit_MQTT_Publish::Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver, diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 1bfac20..f29a98b 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -218,6 +218,9 @@ public: // Ping the server to ensure the connection is still alive. bool ping(uint8_t n = 1); + // Count the number of registrered Adafruit_MQTT_Subscribe + uint getSubscriptionCount(); + protected: // Interface that subclasses need to implement: