Skip to content

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

Merged
merged 1 commit into from
Apr 8, 2021
Merged

Conversation

makermelissa
Copy link
Collaborator

This adds the on_mqtt_unsubscribe event. It also adds error handling for the publish command to handle an error @jedgarpark was running into:

File “code.py”, line 78, in <module>
  File “adafruit_io/adafruit_io.py”, line 413, in publish
  File “adafruit_minimqtt/adafruit_minimqtt.py”, line 618, in publish
OSError: [Errno 104] ECONNRESET

@makermelissa makermelissa requested a review from a team April 8, 2021 17:48
@ladyada ladyada requested a review from brentru April 8, 2021 17:49
@@ -120,6 +120,14 @@ def mqtt_loop(self):
except MQTT.MMQTTException as err:
print("MMQTTException: {0}".format(err))

def mqtt_publish(self, *args, **kwargs):
Copy link
Member

@brentru brentru Apr 8, 2021

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?

Copy link
Collaborator Author

@makermelissa makermelissa Apr 8, 2021

Choose a reason for hiding this comment

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

Copy link
Member

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).

Copy link
Member

@brentru brentru Apr 8, 2021

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.

Copy link
Collaborator Author

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.

@makermelissa makermelissa requested a review from brentru April 8, 2021 19:38
@makermelissa makermelissa merged commit 10025c6 into adafruit:main Apr 8, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 9, 2021
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 "
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.

2 participants