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
MQTT protocol over bluetooth #15
Conversation
This change was needed to separate the MQTT protocoll from the underlying leyer
adafruit_minimqtt.py
Outdated
@@ -46,7 +46,7 @@ | |||
from micropython import const | |||
import adafruit_logging as logging | |||
|
|||
__version__ = "0.0.0-auto.0" | |||
__version__ = "0.1.0-auto.0" |
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.
Leave this as-is. The build scripts replace it with the git tag.
OK. It's ready to push. |
Hi @Tasm-Devil - Travis is failing here: https://travis-ci.com/adafruit/Adafruit_CircuitPython_MiniMQTT/builds/142054500#L299 Once this check passes, I'll review the PR. |
Can you point to the code? I can't see the bug. |
@Tasm-Devil There are a few PyLint errors with the code. These aren't bugs, they are syntax issues. For example, on Line 301 of the attached URL: https://travis-ci.com/adafruit/Adafruit_CircuitPython_MiniMQTT/builds/142054500#L2301
On line 124 of the Please work through each error until they're resolved. Then, re-commit your code. We have a guide/reference for this on the Adafruit Learning System: https://learn.adafruit.com/improve-your-code-with-pylint/pylint-errors#working-through-pylint-errors-5-5 |
fixed |
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.
Please do not change .pylintrc
.
Instead, please fix the errors thrown by pylint or add a line to disable pylint checking (# pylint: disable=some-message,another-one
) above the line which you feel is erroneous. I'll review the lines and provide feedback.
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.
This change of the pylintrc was not intened. Sorry.
@Tasm-Devil what hardware and code did you use to test this class? |
I tested it on the Feather nrf52840. The Software was my BLE2WebService site, you can find here: https://github.com/Tasm-Devil/BLE2WebService |
Ok, will test with a CLUE board. |
Nice. I'd like to get my hands on one 🙂 |
Ok, where is If you made this module, please submit a pull request for it to the Adafruit_CircuitPython_BLE library (https://github.com/adafruit/Adafruit_CircuitPython_BLE). I feel it should be located there, ESP32SPI isn't part of MiniMQTT. |
Why do you need MQTTOverWifi and MQTTOverBluetooth classes? Can you encapsulate the wifi and bluetooth details so that the MQTT stuff doesn't need to know about it? |
@Bentru The socket is borrowed from here: adafruit_esp32spi/adafruit_esp32spi_socket.py |
I need those two subclasses because they use different interfaces. I think, that the parent-class should only do the MQTT-stuff and the children-classes worry about the two interfaces and how to establish a network connection. You can see the differences in the constructors of these subclasses. How should we proceed now? |
@brentru I think a new BLE_Socket library would be best. We'll want to move all of the Wifi stuff out of here as well and into the ESP32SPI socket. MQTT shouldn't need to worry about the transport details at all. |
Sounds very good to me. This is how it should be done. |
@Tasm-Devil Are you still working on this? We have made some changes to the library that will now require you to update this PR to resolve merge conflicts. Please let us know if you need assistance with that. |
Yes, I will update everything. But I will create a new Pull request when I am ready. |
@brentru I'm looking at your revision of the MQTT class. I think you unfortunately made the same assumption regarding the interface that my interface cannot fulfill and why I had to create two subclasses. You think of the interface class of adafruit_wiznet5k.py or adafruit_esp32spi.py This means that because of lines 123 and 240 my plan to use this class via WebSocket over Bluetooth fails. |
I think it's ready to merge now. Althought the 64B Buffer size of the Bluetooth Service class is quite small for more than one subscripted message, it works like a charm. Thanks to bentru for cleaning up that class. |
@brentru and @tannewt could you take a look a this, I could work out with @Tasm-Devil the merge conflict in case this is good for you folks. Thanks |
I'd like to see it use the new socketpool/socket model. I think this library has been switched over. It feels like this could be a separate library too. What needs to be on the other end of the BLE connection? It seems weird to me that it uses a UART service. |
I agree with Scott w.r.t updating + making it a sep library if anyone wants to take it on...but, The more I think about it, I am confused about this PR... The MQTT 3.1.1 protocol (which this library follows) transports over TCP/IP, but does not specify BLE as a transport [MQTT Specification, 4:2 Network Connections]:
A different MQTT specification, MQTT-SN, defines a "virtual connection" which could be used with BLE. That would be another CircuitPython library, though. |
@Tasm-Devil Let me know what yo think. But as we see it this would need to be in another library. let me know thanks |
The example is up to date now. The many changes done in the last year are so good, that my little example works very good with this refactored MQTT Library. I wouldn't put the adafruit_ble_socket.py in another library because it's only a little helper socket class which I consider as a quick fix for this special example. But the adafruit_ble_socket.py has to be in the lib folder currently. |
This is on the other side of the Bluetooth Connection. It will open an Secure Websocket to the broker. I want to use it in my class to inspect MQTT-Messages on the fly. The Page needs a little work but its cool to see the MQTT-Packages and try to understand them by reading the RFC. |
Closing this for now. My understanding reading this chain is that we would want this functionality introduced in a separate library. @Tasm-Devil if you're interested in working on it still you could move the bluetooth implementation into it's own repo and we could add it to the community bundle if you like. If you do want to do that and need help you can ping me here or join the discord. |
With this commit, the MQTT class now also supports Bluetooth. I wrote a new socket class based on Adafruit_CircuitPython_ESP32SPI. There is also an example. I split the MQTT class somewhat so that there is a clear separation between MQTT and the underlying protocol.
I hope this work will be useful to others.
Warm greetings from Germany.