-
Notifications
You must be signed in to change notification settings - Fork 12
Add better MQTT functionality #6
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
Conversation
@@ -120,6 +120,14 @@ def mqtt_loop(self): | |||
except MQTT.MMQTTException as err: | |||
print("MMQTTException: {0}".format(err)) | |||
|
|||
def mqtt_publish(self, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand this method's purpose - is it exposing the MQTT client's publish method and providing error handling? Why not directly call the MQTT client's publish()
through this method, passing in its expected arguments instead of kwargs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, but I did it this way because this works with both mini mqtt and io mqtt and the publish methods have different arguments. See:
https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT/blob/master/adafruit_minimqtt/adafruit_minimqtt.py#L556
and
https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO/blob/master/adafruit_io/adafruit_io.py#L372
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll leave it for now...I disagree with using a "global" function for publishing via two separate libraries, users may get confused between the syntax of providing a feed key and an MQTT topic (differently formatted strings).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we'd have io_publish
and mqtt_publish
to really split it out. Each method would mirror the publish
method to its corresponding library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I was trying to keep the code from growing too big, but may eventually end up going that route.
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.2.6 from 5.2.5: > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#76 from ViennaMike/fix_fusion_modes > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.3.5 from 2.3.4: > Moved a function around > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#28 from jimbobbennett/master > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.4.0 from 1.3.7: > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#42 from FoamyGuy/add_forkawesome_example > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Heart_Rate to 1.1.8 from 1.1.7: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Heart_Rate#13 from adafruit/tannewt-patch-1 > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_iBBQ to 1.2.5 from 1.2.4: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_iBBQ#5 from adafruit/tannewt-patch-1 > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_MIDI to 1.0.5 from 1.0.4: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_MIDI#7 from adafruit/tannewt-patch-1 > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_Debouncer to 1.3.11 from 1.3.10: > Merge pull request adafruit/Adafruit_CircuitPython_Debouncer#27 from adafruit/linting > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.9.1 from 1.9.0: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#33 from makermelissa/main Updating https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing to 1.14.2 from 1.14.1: > Merge pull request adafruit/Adafruit_CircuitPython_FeatherWing#71 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_FunHouse to 1.1.0 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#6 from makermelissa/main > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#5 from makermelissa/main > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#3 from makermelissa/main Updating https://github.com/adafruit/Adafruit_CircuitPython_HID to 4.3.0 from 4.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_HID#63 from JPEWdev/consumer-press-release Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal to 2.2.2 from 2.2.1: > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#71 from makermelissa/master > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_MIDI to 1.3.5 from 1.3.4: > Merge pull request adafruit/Adafruit_CircuitPython_MIDI#32 from jepler/update-simpletest Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.4.0 from 0.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#20 from adafruit/jepler-frequency-too-low > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#17 from gamblor21/mov_operators Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.9.9 from 1.9.8: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#76 from askpatrickw/fix-48 > "Increase duplicate code check threshold "
This adds the on_mqtt_unsubscribe event. It also adds error handling for the publish command to handle an error @jedgarpark was running into: