Add method to cound number of subscription

This commit is contained in:
Mathieu Maret 2022-09-10 22:44:01 +02:00
parent af01dcb7da
commit dca344d237
2 changed files with 15 additions and 0 deletions

View File

@ -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,

View File

@ -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: