If the CDC receive buffer was full and some code read less than 64 bytes
(wMaxTransferSize), the CDC code would submit an OUT transfer with N<64
bytes length to fill the buffer back up.
However if the host had more than N bytes to send then it would still send
the full 64 bytes (correctly) in the transfer. The remaining (64-N) bytes
would be lost.
Adds the restriction that CDCInterface rxbuf has to be at least 64 bytes.
Fixes issue #885.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Storing references to tasks is required by CPython, and enforced by Ruff
RUF006. In this case it's also reasonable to cancel these tasks once the
test is finished.
Signed-off-by: Damien George <damien@micropython.org>
This changes almost all uses of "u-module" to just "module" for the
following built-in modules:
- binascii
- collections
- errno
- io
- json
- socket
- struct
- sys
- time
There are some remaining uses of "u-module" naming, for the cases where the
built-in module is extended in Python, eg `python-stdlib/os` uses `uos`.
Also, there are remaining uses of `utime` when non-standard (compared to
CPython) functions are used, like `utime.ticks_ms()`.
Signed-off-by: Damien George <damien@micropython.org>
Testing shows that the first two writes always go through and the rest are
dropped, so update the .exp file to match that.
Signed-off-by: Damien George <damien@micropython.org>
This tests both encoding and decoding multiple 16-bit and 32-bit services
within the one advertising field.
Signed-off-by: Damien George <damien@micropython.org>
Fixes are needed to support the cases of:
- There may be more than one UUID per advertising field.
- The UUID advertising field may be empty (no UUIDs).
- Constructing 32-bit `bluetooth.UUID()` entities, which must be done by
passing in a 4-byte bytes object, not an integer.
Signed-off-by: Damien George <damien@micropython.org>
When multiple UUIDs of the same size are advertised, they should all be
listed in a single LTV. Supplement to the Bluetooth Core Specification,
Part A, §1.1.1: "A packet or data block shall not contain more than one
instance for each Service UUID data size."
When aioble construct the advertisement data, it is creating a new data
block for each UUID that contains only that single UUID. Rather than,
e.g., a single 16-bit UUID block with a list of multiple UUIDs.
Not only is this against the specification, it wastes two bytes of limited
advertisement space per UUID beyond the first for the repeated data block
length and type fields.
Fix this by grouping each UUID size together.
Signed-off-by: Trent Piepho <tpiepho@gmail.com>
The value for the `timeout_ms` optional argument to
`DeviceConnection.disconnected()` async method is changed from 60000 to
None. This way users awaiting a device disconnection using `await
connection.disconnected()` won't be surprised by a 1 minute timeout.
Only read from the temp characteristic if the connection is still active.
Improves the example by avoiding a TypeError exception if/when the sensor
disconnects.
This sets the disconnected timeout to None, so that the peripheral waits
forever for the client to disconnect. Previously the peripheral would
abort the connection after 60 seconds (because that's the default timeout).
Signed-off-by: Stephen More <stephen.more@gmail.com>
This ensures that the peripheral notifies subscribed clients when the
characteristic is written to.
Signed-off-by: Stephen More <stephen.more@gmail.com>
Mostly small cleanups to put each top-level import on its own line. But
explicitly disable the lint for examples/tests which insert the current
directory into the path before importing.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Most of these look like they were used for print debugging and then kept in
when the print statements were removed or commented.
Some look like missing or incomplete functionality, these have been marked
with comments where possible.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
These packages build on top of machine.USBDevice() to provide high level
and flexible support for implementing USB devices in Python code.
Additional credits, as per included copyright notices:
- CDC support based on initial implementation by @hoihu with fixes by
@linted.
- MIDI support based on initial implementation by @paulhamsh.
- HID keypad example based on work by @turmoni.
- Everyone who tested and provided feedback on early versions of these
packages.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Changes are cosmetic - and maybe very minor code size - but not functional.
_reg_read() was calling struct.packinto() with an incorrect number of
arguments but it seems like MicroPython didn't mind, as result is correct
for both versions.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
If send completes before the first call to poll_send(), the driver could
get stuck in _sync_wait(). This had much less impact before rp2 port went
tickless, as _sync_wait(will_irq=True) calls machine.idle() which may not
wake very frequently on a tickless port.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
According to the docs, only freq_khz was needed for working output.
However:
- Without output_power setting, no output from SX1262 antenna (theory:
output routed to the SX1261 antenna).
- SF,BW,etc. settings were different from the SX127x power on defaults, so
modems with an identical configuration were unable to communicate.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
MicroPython now supplies SSL/TLS functionality in a new built-in `tls`
module. The `ssl` module is now implemented purely in Python, in this
repository. Other libraries are updated to work with this scheme.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
There don't seem to be any MQTT implementations that expect an empty
username (instead of the field missing), so the check for unused `user` can
be simplified.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
Allows modifying current line, adding/deleting characters in the middle
etc. Includes home/end keys to move to start/end of current line.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This is the last remaining use of the "options" feature. Nothing in the
main repo which `require()`'s this package sets it.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
- Add config for [tool.ruff.format] to pyproject.toml.
- Update pre-commit to run both ruff and ruff-format.
- Update a small number of files that change with ruff's rules.
- Update CI.
- Simplify codeformat.py just forward directly to "ruff format"
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Previously a BufferedCharacteristic could only be read by the client, where
it should have been writeable. This makes it support all ops (read / write
/ write-with-response, etc).
Adds a test to check the max_len and append functionality of
BufferedCharacteristic.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
In micropython/micropython#11239 we added support for passing data to
gatts_indicate (to make it match gatts_notify).
This adds the same to aioble.
Also update the documentation to mention this (and fix some mistakes and
add a few more examples).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
- If no reset pin was set, calling standby() in the constructor
would enable the TCXO (XOSC) before the timeout was correctly set.
- This manifested as a BUSY timeout on the STM32WL5, first time after power
on reset.
- Clean up the general handling of BUSY timeouts, but also add some safety
margin to the base timeout just in case (not an issue, is only a stop-gap
to prevent the modem blocking indefinitely.)
Signed-off-by: Angus Gratton <angus@redyak.com.au>
For unknown reason, power output in this configuration is lower than it
should be (including when compared to the STM32Cube C libraries running on
the same board.
Suspect either the Nucleo board antenna switch or the power amplifier
registers are being set wrong, but the actual root cause remains elusive...
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Support depends on hardware support in MicroPython.
Also includes some tweaks in the SX126x base class, to deal with slightly
different platform configuration on STM32WL55, longer timeouts, tx_ant
options, etc.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
As-written this code is unreachable (return statement two line above),
so this change is really just to make the linter happy.
Found by Ruff checking F821.
Signed-off-by: Angus Gratton <angus@redyak.com.au>