-
Notifications
You must be signed in to change notification settings - Fork 58
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
UARTService: allow setting of buffer sizes, timeouts, and UUID #37
Comments
Would be useful if the default value of the timeout(s) could be specifically mentioned in the documentation too. |
@tannewt: I started to work on this, but encountered a problem. The class UARTService(Service):
# ...
uuid = VendorUUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")
_server_tx = StreamOut(uuid=VendorUUID("6E400003-B5A3-F393-E0A9-E50E24DCCA9E"),
timeout=1.0, buffer_size=64)
_server_rx = StreamIn(uuid=VendorUUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E"),
timeout=1.0, buffer_size=64) I initially made them instance variables, without thinking much, but then the binding doesn't happen. How can we set up customized versions for an instance so the users can set the timeouts and buffer sizes? |
I think the easiest way would be to make them mutable after the init of CharacteristicBuffer. Once you have that, then you can set them in the init after calling super().init() which will do the binding. |
But since there's a single instance of each, if there's more than one UARTService, wouldn't they step on each other if they want different values for |
Or, do you mean change the properties of the Is this inherent due to the descriptor protocol? Could the binding be restructured to use instances instead? I'm worried there might be future cases where we can't make some aspect of a service mutable later. |
There is a single instance of each StreamIn and StreamOut but they shadow themselves with either CharacteristicBuffer or BoundWriteStream for each service that is instantiated. The timeout and buffer sizes could be removed from StreamIn/Out completely. They could be set on the service instance before calling I thought about using instances for attribute objects but opted for binding descriptors so that the service definition was consistent for all attributes. |
Any rough ETA on this? I was using a longer timeout in a simple "protocol" and need to know whether to recode this or wait. I don't mind either way, btw. It's ultimately for an Adafruit Learn Guide which I was hoping to finish up by 20th. |
@tannewt Is this part of your addition of other kinds of buffers, or should it be done independently? |
I don't have a pending change for this. PacketBuffer is independent at the moment. |
Would it be possible to do the same thing for the uuid? |
@dglaude I just changed the title. Is this for the so-called "Transparent UART" service, with service UUID |
The UUID of the gadget I use is Apparently it is very common for old protocol that used to be build on Bluetooth SPP (Serial Port Profile) and have evolved to BTLE where there is no real standard way to do serial communication. I did exactly as you did for the Oximeter, but I would be happy to deduplicate the code. The rest of the protocol are messages terminated by a semicolon, so I'll try to make a readline that do end on that rather than newline character. |
It turns out setting the buffer size is not something that would be specified by the user, but instead needs to be MTU-3 for the current connection. That is how the buffer sizes are handled in other implementations of NUS. See #203. Setting the timeouts and allowing different UUID's still makes sense. |
Add optional args to constructor to allow setting buffer sizes and timeouts for
StreamOut
andStreamIn
objects.The text was updated successfully, but these errors were encountered: