examples/bluetooth: Raise ValueError when advertising data is too large.
Signed-off-by: Alexander Wilde <alexander.wilde87@gmail.com>
This commit is contained in:
parent
845d0c79ff
commit
b94ab6a2ef
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user