Skip to content

Commit 1448fd8

Browse files
committed
docs: library and reference audit (pyb, vfs, senml, bluetooth, ROMFS, ...)
Comprehensive audit and rewrite of library and reference docs for OpenMV-accuracy and stub-generator friendliness. Library: - pyb.*: deprecation warning on the module; per-board pin/bus tables for UART/I2C/SPI/CAN/DAC reduced to a single shared mapping where the header pins are the same across STM32 OpenMV cams; per-board LED and Servo channel tables; MCU-agnostic prose for clock domains, timer ranges and STM32-specific values; assorted typo/grammar fixes. - bluetooth: NimBLE-only API; address-mode / I/O-cap / GATTS-error / passkey-action / ADV-type tables; event-code reference table with payload tuples replacing the long elif example; flag-value table for gatts_register_services; cleaner register_services example. - aioble: drop installation/sub-package noise. - vfs: remove VfsLfs1/VfsLfs2 (not exposed on OpenMV); add VfsRom and rom_ioctl from upstream PR 19127; VfsPosix marked Unix-port-only; AbstractBlockDev "Simple form / Extended form" rewrite, drops littlefs name from prose. - cryptolib: AES-128/256 only, ECB/CBC only, document the lengths and block-size constraint. - deflate: per-board availability table; per-constant docs for AUTO/RAW/ZLIB/GZIP with RFC links. - framebuf: rewrite; image.Image cross-ref note; fill_rect and FrameBuffer1 documented; ellipse quadrant bits + format table with bytes-per-pixel. - micropython: split heap_lock/heap_unlock/heap_locked into separate function entries; RingIO description tightened. - senml: per-attribute :type: str docs for all 57 SENML_UNIT_* names so the stub gen emits real typed attributes (autocomplete works); drop installation prose; readable example. - omv.requests: HTTP-verb docs (HEAD/GET/POST/PUT/PATCH/DELETE) describe semantics, idempotence, and the kwargs that make sense per verb. - omv.bno055: AXIS_P0..AXIS_P7 expanded -- summary table of register bytes + output axes + mounting, plus per-constant remap descriptions. - omv.gif / omv.mjpeg: time-based recording examples (4 s / 20 s) using time.ticks_ms() / time.ticks_diff(); one-import-per-line. - uctypes: per-constant docs for UINT*/INT*/FLOATn/VOID/PTR/ARRAY, expanded :mod:`struct` see-also block. - machine.Signal: replace invalid 'pin_arguments...' signature with *args/**kwargs form so the stub is valid Python. - openamp: STM32H7 caveat consolidated into one warning before the RemoteProc class. Reference: - New romfs.rst page from upstream PR 19127, retargeted to OpenMV boards with a per-camera availability table. - index.rst: add romfs.rst to the toctree.
1 parent 7b9e177 commit 1448fd8

44 files changed

Lines changed: 2828 additions & 1160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/library/aioble.rst

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,85 @@ indicate, l2cap recv/send, pair) are awaitable and support timeouts.
3535
* **Security** --- JSON-backed key/secret management, initiate pairing,
3636
query encryption / authentication state.
3737

38-
The package is delivered as a meta-package built from several optional
39-
sub-packages, any combination of which may be installed:
40-
41-
* ``aioble-core`` --- core BLE functionality required by every aioble user.
42-
* ``aioble-central`` --- Central (and Observer) role: scanning and
43-
connecting.
44-
* ``aioble-client`` --- GATT client (typically used by central-role
45-
devices, but can also be used on peripherals).
46-
* ``aioble-peripheral`` --- Peripheral (and Broadcaster) role: advertising.
47-
* ``aioble-server`` --- GATT server (typically used by peripheral-role
48-
devices, but can also be used on centrals).
49-
* ``aioble-l2cap`` --- L2CAP connection-oriented-channel support.
50-
* ``aioble-security`` --- pairing and bonding support.
51-
52-
Installing the meta-package ``aioble`` pulls all of them in.
53-
54-
Requires MicroPython v1.17 or higher.
38+
Examples
39+
--------
40+
41+
Scan for nearby BLE devices and print each one as it is seen::
42+
43+
import aioble
44+
import asyncio
45+
46+
async def find_devices():
47+
async with aioble.scan(duration_ms=5000, active=True) as scanner:
48+
async for result in scanner:
49+
print(result.device.addr_hex(), result.rssi, result.name())
50+
51+
asyncio.run(find_devices())
52+
53+
Connect to a peripheral advertising the Heart Rate service as a **central**
54+
and subscribe to its measurement notifications::
55+
56+
import aioble
57+
import asyncio
58+
import bluetooth
59+
60+
_HR_SERVICE = bluetooth.UUID(0x180D)
61+
_HR_MEASUREMENT = bluetooth.UUID(0x2A37)
62+
63+
async def connect_and_read():
64+
device = None
65+
async with aioble.scan(duration_ms=5000, active=True) as scanner:
66+
async for result in scanner:
67+
if _HR_SERVICE in result.services():
68+
device = result.device
69+
break
70+
if device is None:
71+
return
72+
73+
async with await device.connect() as conn:
74+
service = await conn.service(_HR_SERVICE)
75+
char = await service.characteristic(_HR_MEASUREMENT)
76+
await char.subscribe(notify=True)
77+
while True:
78+
data = await char.notified()
79+
print("notify:", data)
80+
81+
asyncio.run(connect_and_read())
82+
83+
Act as a **peripheral**: register a GATT service, advertise it, and push
84+
notifications to whoever connects::
85+
86+
import aioble
87+
import asyncio
88+
import bluetooth
89+
import struct
90+
91+
_ENV_SERVICE = bluetooth.UUID(0x181A)
92+
_TEMP_CHAR = bluetooth.UUID(0x2A6E)
93+
94+
def encode_temperature(deg_c):
95+
# Bluetooth Temperature (0x2A6E) is sint16 little-endian, 0.01 degC units.
96+
return struct.pack("<h", round(deg_c * 100))
97+
98+
service = aioble.Service(_ENV_SERVICE)
99+
temp_char = aioble.Characteristic(service, _TEMP_CHAR, read=True, notify=True)
100+
aioble.register_services(service)
101+
102+
async def peripheral_task():
103+
while True:
104+
connection = await aioble.advertise(
105+
interval_us=250000,
106+
name="openmv-sensor",
107+
services=[_ENV_SERVICE],
108+
appearance=0x0300,
109+
)
110+
print("connected:", connection.device.addr_hex())
111+
async with connection:
112+
while connection.is_connected():
113+
temp_char.write(encode_temperature(23.68), send_update=True)
114+
await asyncio.sleep(1)
115+
116+
asyncio.run(peripheral_task())
55117

56118
Module-level functions
57119
----------------------

0 commit comments

Comments
 (0)