diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/bluetooth/ble_advertising.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/bluetooth/ble_advertising.py b/examples/bluetooth/ble_advertising.py index eed527f55..6dc78c5e3 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("<h", appearance)) + if len(payload) > _ADV_MAX_PAYLOAD: + raise ValueError("advertising payload too large") + return payload |
