From b94ab6a2ef56fce3f8db2f84b26e3ac0f4b3b155 Mon Sep 17 00:00:00 2001 From: Alexander Wilde Date: Tue, 20 Jun 2023 11:07:45 +0100 Subject: [PATCH] examples/bluetooth: Raise ValueError when advertising data is too large. Signed-off-by: Alexander Wilde --- examples/bluetooth/ble_advertising.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/bluetooth/ble_advertising.py b/examples/bluetooth/ble_advertising.py index eed527f55d..6dc78c5e3d 100644 --- a/examples/bluetooth/ble_advertising.py +++ b/examples/bluetooth/ble_advertising.py @@ -19,6 +19,8 @@ _ADV_TYPE_UUID32_MORE = const(0x4) _ADV_TYPE_UUID128_MORE = const(0x6) _ADV_TYPE_APPEARANCE = const(0x19) +_ADV_MAX_PAYLOAD = const(31) + # Generate a payload to be passed to gap_advertise(adv_data=...). def advertising_payload(limited_disc=False, br_edr=False, name=None, services=None, appearance=0): @@ -50,6 +52,9 @@ def advertising_payload(limited_disc=False, br_edr=False, name=None, services=No if appearance: _append(_ADV_TYPE_APPEARANCE, struct.pack(" _ADV_MAX_PAYLOAD: + raise ValueError("advertising payload too large") + return payload