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
Missing Publish flags in MQTT library #480
Comments
Removed number for qos in 'publish' - now needs a module. This was undocumented, and not the same as the MQTT NPM module Removed automatic conversion of number to qos for options in subscribe (undocumented, not same as MQTT module) Removed 'callback' from subscribe. It's undocumented, useless, and DOESN'T do what the MQTT NPM module does, which would cause confusion
Ok, just added. Can you check it out and see if it works?
|
Thanks! It certainly looks like it should. I'll give it a go tonight, hopefully. This would be a breaking change for anyone currently passing |
Thanks - I generally try to avoid breaking changes, but in this case:
|
OK. Well, it's fine by me : ) I'm not sure there's a lot you can do to make that module smaller, is there? It looks like it implements the full spec. I can't see there's much you could do to make it smaller, unless you removed features or made micro-optimisations to the way the code is written. |
Hmm... I'm getting an error message. I don't seem to be able to copy it out of the IDE though...
|
Presumably it isn't
I can't see another example of where you've had to do that, but I think you should be able to do:
or
|
Yeah, both of those options work. I'll do a PR. |
Just as hint, there is tinyMQTT module by Olli Phillips |
@jjok perfect - thanks for that PR! I think a lot of modules to use either the local var, or bind - there's not one way we use in particular. @olliephillips are you interested in getting that TinyMQTT module on the Espruino site? I'm happy to add it, and IMO it'd make a lot of sense. |
Thanks. I hadn't seen that. Although, it doesn't look like it has full Maybe I'll open a ticket there too... 🤔 |
Thanks @gfwilliams. The |
Thanks! I'll update the version on the website with this soon. |
@gfwilliams If you think it would add value, absolutely. @jjok pretty sure retain is the default yes |
@olliephillips great - thanks! Just added it - http://espruino.com/tinyMQTT A bit of a thread hijack, but was there a reason that you didn't define |
@gfwilliams honestly? probably my inexperience with js. I recall the global was contentious at the time I was working on it, but nobody suggested a different approach. I seem to recall the global helped me make the module smaller than it was. If there's a better way that reduces size again I'm happy to learn about it - and I'll bow to your experience with js for sure :) |
Also not related to this thread...
@gfwilliams Should you be able to copy text out of the left pane of the IDE? It would be pretty useful for copying out error messages. |
I never came across the variable before as a way of saving space, but it's really neat. The change to module scope was just:
but you wrote the module a while back so maybe it didn't work in Espruino then? Not sure :) Just a FYI - I was frustrated that the whole
@jjok yes - just click and drag. When you stop the drag then it copies. It's a bit odd but it was done that way because Ctrl-C is used to break out of running code/clear the line. |
Ahh. Thanks. : ) |
@gfwilliams I'll look at that and likely change. What minifier do you use, I was using the closure compiler? Also with the docs on Espruino for tinyMQTT, will you pick up changes in say the repo README and reflect on espruino.com, or should I be mindful of this, and update the docs in this repo should the API ever change? |
I was just using closure with simple minification. I wrap in I'm afraid there's nothing fancy going on with the new page - so if there are any new changes they'll need to be manually mirrored in https://github.com/espruino/EspruinoDocs/blob/master/modules/tinyMQTT.md It's an interesting thought - I think if I got to the stage where there were a lot of Espruino modules being brought in from their own repos I'd come up with some kind of script, but as far as I remember yours is the only one at the moment. |
Just tested. Why that and adding the closure helps minification is certainly counter-intuitive to me, but it definitely works! Almost 20 more jsvars freed for application code. I'll revise the module to reflect. |
Well Gordon it works perfect from the beginning;-). Just did some small changes to allow receiving 256byte and my latest version can even run from storage after quoting at to sections: first and second. Hi @olliephillips, I got some mqtt scenarios and can offer to run them for a couple of days, let me know if you like me to jump in. |
Hi @MaBecker, thanks, that would be good! I've run the module locally tonight and my application seems good - but I'm only publishing. I'll get the revisions into a new branch and you can test away! You'll have to tell me more about running the module from storage too, that's not something I've considered. Hope you are well! |
Revisions are here @MaBecker https://github.com/olliephillips/tinyMQTT/blob/minify/tinyMQTT.min.js |
Hi. I'd like to publish an MQTT packet that has the
retain
flag set, but it looks like onlyqos
is currently implemented.It would be great to add the retain and DUP flags. I'll see if I can do it myself.
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038
The text was updated successfully, but these errors were encountered: