Skip to content

Commit 5b00d8f

Browse files
committed
Fix element count when numbers are in the format.
1 parent 2505ce2 commit 5b00d8f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_ble/advertising/standard.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ class ManufacturerDataField:
215215
def __init__(self, key, value_format, field_names=None):
216216
self._key = key
217217
self._format = value_format
218-
self.element_count = len(value_format.strip("><!=@").replace("x", ""))
218+
# TODO: Support format strings that use numbers to repeat a given type. For now, we strip
219+
# numbers because Radio specifies string length with it.
220+
self.element_count = len(value_format.strip("><!=@0123456789").replace("x", ""))
219221
if self.element_count > 1 and (not field_names or len(field_names) != self.element_count):
220222
raise ValueError("Provide field_names when multiple values are in the format")
221223
self._entry_length = struct.calcsize(value_format)

0 commit comments

Comments
 (0)