summaryrefslogtreecommitdiff
path: root/docs/library
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2019-11-20 10:45:14 +1100
committerDamien George <damien.p.george@gmail.com>2019-11-25 17:32:10 +1100
commite873d352ada8c392985e9f248271c5cf0fcd32ed (patch)
tree4963b1c140a7b76725e299281b36545c362c7994 /docs/library
parentfbb7646e3bd6fd17b2c39ac40d537cc0b07af188 (diff)
extmod/modbluetooth: Simplify management of pre-allocated event data.
The address, adv payload and uuid fields of the event are pre-allocated by modbluetooth, and reused in the IRQ handler. Simplify this and move all storage into the `mp_obj_bluetooth_ble_t` instance. This now allows users to hold on to a reference to these instances without crashes, although they may be overwritten by future events. If they want to hold onto the values longer term they need to copy them.
Diffstat (limited to 'docs/library')
-rw-r--r--docs/library/ubluetooth.rst6
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/library/ubluetooth.rst b/docs/library/ubluetooth.rst
index 6e95a9e92..2d3af1bb6 100644
--- a/docs/library/ubluetooth.rst
+++ b/docs/library/ubluetooth.rst
@@ -52,6 +52,12 @@ Event Handling
The optional *trigger* parameter allows you to set a mask of events that
your program is interested in. The default is all events.
+ Note: the ``addr``, ``adv_data`` and ``uuid`` entries in the tuples are
+ references to data managed by the :mod:`ubluetooth` module (i.e. the same
+ instance will be re-used across multiple calls to the event handler). If
+ your program wants to use this data outside of the handler, then it must
+ copy them first, e.g. by using ``bytes(addr)`` or ``bluetooth.UUID(uuid)``.
+
An event handler showing all possible events::
def bt_irq(event, data):