Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subscription packet callbacks not executing within processPacketsUntil() #215

Merged
merged 6 commits into from
Nov 1, 2022

Conversation

brentru
Copy link
Member

@brentru brentru commented Oct 28, 2022

Callback functions within subscription packets are currently not processed if processPacketsUntil() receives a subscription packet. While processPacketsUntil() does call handleSubscriptionPacket(), handleSubscriptionPacket() fills the Adafruit_Subscription object but does not call the callbacks as mentioned in its docstring ("// Handle any data coming in for subscriptions and fires them off to the appropriate callback") nor does it mark the subscription message as "read" (implemented in #195).

This causes any subscription packet picked up during processPacketsUntil()'s period (called by a ping() or publish()) to never execute its callback method.

This pull request:

  • Adds a new method, processSubscriptionPacket which executes a subscription packet's associated callback and marks the message as "read"
  • Refactors processPackets and processPacketsUntil to use processSubscriptionPacket

This was tested against the Adafruit IO WipperSnapper library's synchronization function and was OK for: 5x servos re-syncing, 2x DS18x components syncing, 2x i2c devices + servo + 2x dsx + 1x pin component syncing

ping @ladyada for review

Copy link

@lorennorman lorennorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 great work finding this!!!

Adafruit_MQTT.cpp Show resolved Hide resolved
library.properties Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants