Skip to content

Commit bb55e32

Browse files
committed
Get rid of move_to_end
Instead, just set a placeholder sequence_number when not created from a ScanEntry. Fixes adafruit#18
1 parent ac76109 commit bb55e32

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

adafruit_ble_broadcastnet.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@ class AdafruitSensorMeasurement(Advertisement):
149149
"""Battery voltage in millivolts. Saves two bytes over voltage and is more readable in bare
150150
packets."""
151151

152-
def __init__(self, *, sequence_number=None):
153-
super().__init__()
154-
if sequence_number:
155-
self.sequence_number = sequence_number
152+
def __init__(self, *, entry=None, sequence_number=None):
153+
super().__init__(entry=entry)
154+
if entry:
155+
return
156+
self.sequence_number = 0
156157

157158
def __str__(self):
158159
parts = []
@@ -164,13 +165,6 @@ def __str__(self):
164165
parts.append("{}={}".format(attr, str(value)))
165166
return "<{} {} >".format(self.__class__.__name__, " ".join(parts))
166167

167-
def __bytes__(self):
168-
"""The raw packet bytes."""
169-
# Must reorder the ManufacturerData contents so the sequence number field is always first.
170-
# Necessary to ensure that match_prefixes works right to reconstruct on the receiver.
171-
self.data_dict[255].data.move_to_end(3, last=False)
172-
return super().__bytes__()
173-
174168
def split(self, max_packet_size=31):
175169
"""Split the measurement into multiple measurements with the given max_packet_size. Yields
176170
each submeasurement."""

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Author details
3434
author="Adafruit Industries",
3535
author_email="[email protected]",
36-
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-ble"],
36+
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-ble >= 8.0.0"],
3737
# Choose your license
3838
license="MIT",
3939
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)