Porównaj commity

...

3 Commity

Autor SHA1 Wiadomość Data
Trent Piepho 94d5260519
Merge 1a6902b2f2 into 45ead11f96 2024-04-18 11:38:25 -04:00
Damien George 45ead11f96 ssl: Use "from tls import *" to be compatible with axtls.
axtls doesn't define all the CERT_xxx constants, nor the MBEDTLS_VERSION
constant.

This change means that `tls.SSLContext` is imported into the module, but
that's subsequently overridden by the class definition in this module.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-28 17:44:37 +11:00
Trent Piepho 1a6902b2f2 aioble/peripheral.py: Place multiple UUIDs in single advertisement LTV.
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>
2024-01-10 15:04:10 -08:00
3 zmienionych plików z 9 dodań i 17 usunięć

Wyświetl plik

@ -129,14 +129,13 @@ async def advertise(
# Services are prioritised to go in the advertising data because iOS supports
# filtering scan results by service only, so services must come first.
if services:
for uuid in services:
b = bytes(uuid)
if len(b) == 2:
resp_data = _append(adv_data, resp_data, _ADV_TYPE_UUID16_COMPLETE, b)
elif len(b) == 4:
resp_data = _append(adv_data, resp_data, _ADV_TYPE_UUID32_COMPLETE, b)
elif len(b) == 16:
resp_data = _append(adv_data, resp_data, _ADV_TYPE_UUID128_COMPLETE, b)
for uuid_len, code in (
(2, _ADV_TYPE_UUID16_COMPLETE),
(4, _ADV_TYPE_UUID32_COMPLETE),
(16, _ADV_TYPE_UUID128_COMPLETE),
):
if uuids := [bytes(uuid) for uuid in services if len(bytes(uuid)) == uuid_len]:
resp_data = _append(adv_data, resp_data, code, b"".join(uuids))
if name:
resp_data = _append(adv_data, resp_data, _ADV_TYPE_NAME, name)

Wyświetl plik

@ -1,3 +1,3 @@
metadata(version="0.2.0")
metadata(version="0.2.1")
module("ssl.py", opt=3)

Wyświetl plik

@ -1,12 +1,5 @@
import tls
from tls import (
CERT_NONE,
CERT_OPTIONAL,
CERT_REQUIRED,
MBEDTLS_VERSION,
PROTOCOL_TLS_CLIENT,
PROTOCOL_TLS_SERVER,
)
from tls import *
class SSLContext: