Wykres commitów

31 Commity (7fcc728db28033fade59ea37fca90d28528a69d1)

Autor SHA1 Wiadomość Data
Christian Clauss 4da6e6f1b2 all: Lint Python code with ruff.
Signed-off-by: Christian Clauss <cclauss@me.com>
2023-07-24 07:51:33 +02:00
Jim Mussared c113611765 aioble: Fix descriptor flag handling.
Removes the workaround for micropython/issues/6864.

Sets the default flags for discovered descriptors to be WRITE,
so that d.write() will implicitly set response=True.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-12 07:04:12 +10:00
Daniel Flanagan 78900afca5 aioble: Add short name support to scan results.
Signed-off-by: Damien George <damien@micropython.org>
2023-02-28 11:07:34 +11:00
Jim Mussared a08087249f top: Update Python formatting to black "2023 stable style".
See https://black.readthedocs.io/en/stable/the_black_code_style/index.html

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-03 17:12:38 +11:00
Jim Mussared a5ef231e7d aioble/README.md: Demostrate optional args to aioble.scan().
Adds missing "duration_ms" argument to the example, and a second example
that shows the "interval_us" / "window_us" and also active scan.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-01-17 14:36:41 +11:00
Jim Mussared 50b7aca171 aioble/client.py: Fix default for the `response` arg to char.write().
- `_FLAG_WRITE` was incorrectly `_FLAGS_WRITE`
- `response` should be defaulted to `None` rather than `False` in order
  to detect that when it is unspecified.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-11-08 18:57:29 +11:00
Jim Mussared 8503017e3b aioble: Split into optional components.
This replaces the options that could be specified previously to include
and require.

The `aioble` package now provides everything. For a minimal install, the
individual components can now be installed or require()'ed explicitly.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-06 16:45:15 +11:00
Andrew Leech eba897420d aioble/server.py: Maintain write order for captured characteristics.
This replaced the per-characteristic queues with a single shared queue,
which means that the characteristics will return from `written()` in the
exact order that the original writes arrived, even if the writes are
occuring across multiple different characteristics.

This work was funded by Planet Innovation.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-27 22:47:30 +10:00
Andrew Leech 0c5880d2e4 aioble/l2cap: Fix psm variable name.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-27 14:28:56 +10:00
Jim Mussared d080924d12 aioble/multitests: Add descriptor multitest.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09 11:26:54 +10:00
Jim Mussared e58b609572 aioble/client.py: Make read/write events work for descriptors.
Descriptors were missing common initialisation for events shared with
characteristics.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09 11:26:54 +10:00
Jim Mussared 765f14b501 aioble/server.py: Fix registration for descriptors.
This allows a server to register descriptors, which was previously not
fully implemented.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09 11:26:54 +10:00
Jim Mussared 64e752cce6 aioble/client.py: Use characteristic end handle (when available).
The `bluetooth` module replaced the def_handle field with end_handle
in the characteristic result IRQ. Use this when querying for
descriptors.

In the case where this is not available (older versions of micropython)
continue the existing behavior of searching just past the value handle,
although decrease this to +2 to avoid finding other characteristic's
descriptors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09 11:26:54 +10:00
Jim Mussared ce66e701a5 all: Replace metadata.txt with manifest.py.
Uses the new require()/package()/module() functions from manifestfile.py.

Add manifest.py for iperf3 and pyjwt.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-05 17:50:28 +10:00
Philip Peitsch a18d49cda7 aioble: Make l2cap chunk size configurable to allow optimization by app. 2022-09-05 15:14:13 +10:00
Philip Peitsch c4fada7f6f aioble: Fix missing GattError import in server.py.
2015-01-01 07:45:46.790 INFO Received OLCP_OP_FIRST
2015-01-01 07:45:46.979 ERROR Error in ble_write_listener
Traceback (most recent call last):
  File "aioble/server.py", line 223, in indicate
NameError: name 'GattError' isn't defined
2022-09-05 15:12:48 +10:00
Andrew Leech 09f0e47386 aioble: Add timeout to device.exchange_mtu.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-01 22:30:43 +10:00
Matt Trentini 0c31e0b3d7 micropython/aioble: Prioritise services in advertisement payload.
A number of fields (services, appearance, manufacturer, name) can appear
when a scan is requested.  However there is only so much space in the
header so, if a user has configured multiple fields, some may be 'pushed'
into the active scan response which requires additional communication.

When iOS scans for BLE devices it can filter by services, and so services
must be in the advertising (as opposed to scan response) payload.
2022-03-24 11:25:31 +11:00
Jim Mussared cdd260f079 aioble/multitests: Add multitest for shutdown handlers.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-12 13:36:18 +11:00
Jim Mussared 10ec742baa aioble: Add a shutdown handler for cleanup.
This allows `aioble.stop()` to reset all internal state.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-12 13:35:52 +11:00
Jim Mussared a61bfc1460 aioble/README.md: Add l2cap example.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-12 13:35:50 +11:00
Jim Mussared 3ea74867f3 aioble: Add l2cap channel disconnected().
Allows `await channel.disconnected()`.

This also fixes a bug where connection._l2cap_channel wasn't being set to
None on disconnect.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-12 13:35:45 +11:00
Jim Mussared dd9b783568 aioble/multitests: Add test for subscription and notification.
This replicates the failure described in #453 (which is fixed by #459.

Also adds a test for subscription.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-10 17:41:11 +11:00
Jim Mussared 9169ca6543 aioble: Add support for write-with-update.
This allows a server to write a characteristic and automatically
notify/indicate all subscribed clients.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-10 13:47:04 +11:00
Jim Mussared dc03b4af4d aioble: Fix notified/indicated event waiting.
After a client does a successful `await char.notified()`, then before the
next call to `notified()` a notification arrives, then they call
`notified()` twice before the _next_ notification, the second call will
return None rather than waiting.

This applies the same fix as in 5a86aa5866
which solved a similar problem for server-side `char.written()`. Using
a deque is slightly overkill here, but it's consistent with the server
side, and also makes it very easy to support having a notification queue
in the future.

Also makes the client characteristic properly flags/properties-aware (i.e.
explicitly fail operations that aren't supported).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-08 17:34:08 +11:00
Jim Mussared 43cad17946 aioble/multitests/ble_write_capture.py: Add multitest for write capture.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-05 14:30:40 +11:00
Jim Mussared 23b3c7fe2d aioble/multitests: Fix existing multitests.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-05 14:30:31 +11:00
Jim Mussared 5a86aa5866 aioble: Add a write queue for gatt server.
This fixes a bug where an incoming write before `written` is awaited causes
`written` to return None.  It also introduces a mechanism for a server to
"capture" all incoming written values (instead of only having access to the
most recent value).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-05 14:30:08 +11:00
Jim Mussared 3c383f6d28 aioble: Fix docs for subscribe (needs await).
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-07-12 13:38:33 +10:00
Jim Mussared 32684886ee micropython/bluetooth/aioble: subscribe must register the connection.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-07-08 15:15:47 +10:00
Jim Mussared 8631225b7f micropython/aioble: Add asyncio-based wrapper for ubluetooth.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-05-28 18:26:49 +10:00