Wish MQTT Enhancement - Include BeginPublish,EndPublish,Write methods

Discussion in 'B4R Bugs & Wishlist' started by miker2069, Oct 13, 2019.

Similar threads

B4A Tutorial [B4X] MQTT - Connect & Reconnect
B4R Library RDC based on MQTT
B4R Tutorial MQTT
B4A Tutorial [B4X] MQTT Chat Room
B4R Tutorial ESP Configurator based on B4RSerializator
  1. miker2069

    miker2069 Active Member Licensed User

    The B4R rMQTT library is based on the well known Arduino PubSubClient library written by Nick O'Leary. It's a subset of this library - with the most important/used methods wrapped. I do have a scenario that requires some of the additional methods to be wrapped as well. Specifically:
    I think these are very useful for sending chunks of large payload to MQTT. One easy to understand use case is sending an image byte payload to MQTT. I do this in B4i, B4J all the time and it works great. If I have an image stored in SPIFFS, SD Card, or even if I am downloading the image via HTTP - it's necessary to be able to chunk and stream the payload to the MQTT broker using write(payload,length).

    In fact the last scenario is exactly what I'm looking to accomplish. On my esp8266 sketch, I'm downloading a jpeg snapshot via HTTP from an IP Camera and temporarily storing it in SPIFFS (the image I don't think would be more than 200KB (in reality it's a max of 120KB). I want to publish the image bytes to an MQTT topic so the receiver (B4J, B4i, etc.) can receive the image and display it.

    The advantage of this is that the broker should be able to queue up the chunks and when the EndPublish is receive notify the subscribers as normal - it's then business as usual on the receiving side.

    The advantages of this are great - I can have a small esp8266 or esp32 device that's connected to an MQTT broker on the internet (like cloudmqtt or my own broker at a VPS) that pulls images (or anything else) from devices on a local network and publishes it. My receivers don't need direct access to the cameras (no firewalls to worry about) and everything is very secure.

    Hopefully I've built the case for this :) - I don't thin kit would be to terribly difficult to add this.
    rwblinn, inakigarm and janderkan like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    rMQTT v1.40 is attached. It is based on the latest version of PubSubClient and it adds support for chunk based publishes:
    Dim buffer(5As Byte
    For i = 1 To 100 Step 5
    0) = i
    1) = i + 1
    2) = i + 2
    3) = i + 3
    4) = i + 4
    Library will also be included in B4R v3.00 which will be released later this week.

    Attached Files:

  3. miker2069

    miker2069 Active Member Licensed User

    Awesome - SOOOOOO EXCITED! :) :) :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice