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

feat: add support for binary messages #97

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

alvarowolfx
Copy link
Contributor

@alvarowolfx alvarowolfx commented Jan 7, 2022

I'm creating a basic client library to use with Golioth Platform. We recently added a new gateway to support MQTT devices and that allows us to add support to CircuitPython.

But while developing the client, we had issues with one of our services meant for Over the Air Updates, which serves not only for the main device firmware, but you can send any arbitrary artifact ( like images/bitmap in my testing here). Currently, this MQTT library tries to convert all messages to a Unicode string, which unfortunately fails for binary data. Reference to where it fails: https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT/blob/main/adafruit_minimqtt/adafruit_minimqtt.py#L843

So what I'm proposing here is to add an optional parameter called use_binary, that would allow users to use the MQTT client in binary mode and return the raw bytearray message. Them is up to the user to convert to a string as needed.

adafruit_minimqtt/adafruit_minimqtt.py Outdated Show resolved Hide resolved
adafruit_minimqtt/adafruit_minimqtt.py Show resolved Hide resolved
@alvarowolfx alvarowolfx force-pushed the feat/add-binary-support branch from f05b92d to efe8b4b Compare January 11, 2022 13:35
@alvarowolfx alvarowolfx force-pushed the feat/add-binary-support branch from efe8b4b to 1bdaca8 Compare January 11, 2022 13:46
@alvarowolfx alvarowolfx requested a review from brentru January 11, 2022 14:00
@brentru brentru merged commit c068e50 into adafruit:main Jan 11, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 19, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_DRV2605 to 1.2.1 from 1.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DRV2605#30 from tekktrik/doc/fix-code-block

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.6.0 from 3.5.14:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#150 from tekktrik/feature/configurable-eol
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#151 from tekktrik/feature/add-recvinto
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#152 from tekktrik/hotfix/fix-docs
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#149 from tekktrik/doc/add-missing-to-api

Updating https://github.com/adafruit/Adafruit_CircuitPython_FRAM to 1.3.13 from 1.3.12:
  > Merge pull request adafruit/Adafruit_CircuitPython_FRAM#33 from tekktrik/doc/update-documentation

Updating https://github.com/adafruit/Adafruit_CircuitPython_HT16K33 to 4.2.0 from 4.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#88 from jposada202020/including_animation_class

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 6.2.0 from 6.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#120 from FoamyGuy/force_content_type

Updating https://github.com/adafruit/Adafruit_CircuitPython_CursorControl to 2.5.2 from 2.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_CursorControl#32 from FoamyGuy/alt_click

Updating https://github.com/adafruit/Adafruit_CircuitPython_FunHouse to 2.1.10 from 2.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#33 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_FunHouse#31 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.2.0 from 5.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#97 from goliothlabs/feat/add-binary-support

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.6.0 from 0.5.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#29 from jepler/program-object
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this pull request Sep 18, 2022
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