Commit Graph

24 Commits

Author SHA1 Message Date
Jim Mussared c70930fb24 tests/multi_bluetooth/ble_subscribe.py: Add test for subscription.
This tests both sending indications/notifications from a server to
subscribed clients via gatts_write(...,send_update=True) and subscribing
from a client.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 22:44:47 +10:00
Damien George 7842085434 tests/multi_bluetooth/ble_gap_advertise.py: Allow to work without set.
Signed-off-by: Damien George <damien@micropython.org>
2021-06-06 21:58:07 +10:00
Damien George 1d9528210b tests/multi_bluetooth: Add performance test for gatt char writes.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 16:14:48 +10:00
Damien George e98ff3f08e tests/multi_bluetooth: Skip tests when BLE features are unsupported.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 20:08:20 +11:00
Jim Mussared 1342debb9b tests/multi_bluetooth: Add basic performance tests.
1. Exchange GATT notifications.
2. Transmit a stream of data over L2CAP.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-02-19 17:53:43 +11:00
Damien George c8b0557178 tests/multi_bluetooth: Add multitests for BLE pairing and bonding.
Signed-off-by: Damien George <damien@micropython.org>
2020-12-02 14:44:55 +11:00
Jim Mussared 23fad2526d tests/multi_bluetooth: Add L2CAP channels multi-test.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-24 01:07:17 +11:00
Jim Mussared efc0800132 tests/multi_bluetooth: Add a test for WB55 concurrent flash access.
This test currently passes on Unix/PYBD, but fails on WB55 because it lacks
synchronisation of the internal flash.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-16 17:04:02 +11:00
Jim Mussared 7e75245d54 tests/multi_bluetooth: Change dict index-and-del to pop, to clear event.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-16 17:03:27 +11:00
Jim Mussared ccfd535af4 tests/multi_bluetooth: Improve reliability of event waiting.
Use the same `wait_for_event` in all tests that doesn't hold a reference to
the event data tuple and handles repeat events.

Also fix a few misc reliability issues around timeouts and sequencing.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13 17:19:05 +11:00
Damien George 81f2162ca0 extmod/modbluetooth: Change module-owned bytes objects to memoryview.
A read-only memoryview object is a better representation of the data, which
is owned by the ubluetooth module and may change between calls to the
user's irq callback function.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-25 12:23:11 +10:00
Jim Mussared 3086d35e16 tests/multi_bluetooth/ble_mtu.py: Add multitest for BLE MTU. 2020-09-18 12:51:21 +10:00
Jim Mussared fe642ced43 tests/multi_bluetooth: Update UUID format in .exp files. 2020-09-18 12:51:21 +10:00
Jim Mussared 5eda362e0a tests/multi_bluetooth: Make ble_gap_connect robust against event timing. 2020-09-08 23:53:12 +10:00
Jim Mussared 26b66804e9 tests/multi_bluetooth: Update to new config('mac') behaviour. 2020-09-08 12:53:24 +10:00
Jim Mussared 9d823a5d9a extmod/modbluetooth: Add event for "indicate acknowledgement".
This commit adds the IRQ_GATTS_INDICATE_DONE BLE event which will be raised
with the status of gatts_indicate (unlike notify, indications require
acknowledgement).

An example of its use is added to ble_temperature.py, and to the multitests
in ble_characteristic.py.

Implemented for btstack and nimble bindings, tested in both directions
between unix/btstack and pybd/nimble.
2020-07-20 23:26:41 +10:00
Jim Mussared e152d0c197 extmod/btstack: Schedule notify/indicate/write ops for bg completion.
The goal of this commit is to allow using ble.gatts_notify() at any time,
even if the stack is not ready to send the notification right now.  It also
addresses the same issue for ble.gatts_indicate() and ble.gattc_write()
(without response).  In addition this commit fixes the case where the
buffer passed to write-with-response wasn't copied, meaning it could be
modified by the caller, affecting the in-progress write.

The changes are:

- gatts_notify/indicate will now run in the background if the ACL buffer is
  currently full, meaning that notify/indicate can be called at any time.

- gattc_write(mode=0) (no response) will now allow for one outstanding
  write.

- gattc_write(mode=1) (with response) will now copy the buffer so that it
  can't be modified by the caller while the write is in progress.

All four paths also now track the buffer while the operation is in
progress, which prevents the GC free'ing the buffer while it's still
needed.
2020-07-18 14:23:47 +10:00
Jim Mussared 9902ce12eb tests/multi_bluetooth: Update to work with new BLE events.
Updates the tests to use non-bitmask events, event renames, as well as some
of the new completion events to improve reliability of the tests.
2020-06-05 14:08:47 +10:00
Damien George 3b6c9119eb extmod/modbluetooth: Add support for changing the GAP device name.
This commit allows the user to set/get the GAP device name used by service
0x1800, characteristic 0x2a00.  The usage is:

    BLE.config(gap_name="myname")
    print(BLE.config("gap_name"))

As part of this change the compile-time setting
MICROPY_PY_BLUETOOTH_DEFAULT_NAME is renamed to
MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME to emphasise its link to GAP and this
new "gap_name" config value.  And the default value of this for the NimBLE
bindings is changed from "PYBD" to "MPY NIMBLE" to be more generic.
2020-05-11 21:30:41 +10:00
Damien George 037c83b0ed tests/multi_bluetooth: Fix typo printing wrong IRQ type. 2020-05-08 13:23:45 +10:00
Jim Mussared 9b06efb943 tests/multi_bluetooth/ble_gap_advertise: Fix bytes/str compare warning. 2020-04-29 16:45:46 +10:00
Damien George c5a21a94f8 extmod/modbluetooth: Provide FLAG_WRITE_NO_RESPONSE for characteristics.
This flag is supported and needs to be set if characteristics are write-
without-response.
2020-04-07 13:46:56 +10:00
Damien George dd0bc26e65 extmod/modbluetooth: Change scan result's "connectable" to "adv_type".
This commit changes the BLE _IRQ_SCAN_RESULT data from:

    addr_type, addr, connectable, rssi, adv_data

to:

    addr_type, addr, adv_type, rssi, adv_data

This allows _IRQ_SCAN_RESULT to handle all scan result types (not just
connectable and non-connectable passive scans), and to distinguish between
them using adv_type which is an integer taking values 0x00-0x04 per the BT
specification.

This is a breaking change to the API, albeit a very minor one: the existing
connectable value was a boolean and True now becomes 0x00, False becomes
0x02.

Documentation is updated and a test added.

Fixes #5738.
2020-03-11 14:00:44 +11:00
Damien George 4fda7a5b44 tests/multi_bluetooth: Add initial tests for bluetooth BLE. 2020-03-10 02:22:34 +11:00