46
46
47
47
def broadcast (measurement , * , broadcast_time = 0.1 , extended = False ):
48
48
"""Broadcasts the given measurement for the given broadcast time. If extended is False and the
49
- measurement would be too long, it will be split into multiple measurements for transmission.
50
- """
49
+ measurement would be too long, it will be split into multiple measurements for transmission.
50
+ """
51
51
global _sequence_number # pylint: disable=global-statement,invalid-name
52
52
for submeasurement in measurement .split (252 if extended else 31 ):
53
53
submeasurement .sequence_number = _sequence_number
@@ -83,7 +83,9 @@ class AdafruitSensorMeasurement(Advertisement):
83
83
# This prefix matches all
84
84
match_prefixes = (
85
85
# Matches the sequence number field header (length+ID)
86
- struct .pack ("<BHBH" , _MANUFACTURING_DATA_ADT , _ADAFRUIT_COMPANY_ID , 0x03 , 0x0003 ),
86
+ struct .pack (
87
+ "<BHBH" , _MANUFACTURING_DATA_ADT , _ADAFRUIT_COMPANY_ID , 0x03 , 0x0003
88
+ ),
87
89
)
88
90
89
91
manufacturer_data = LazyObjectField (
@@ -178,7 +180,7 @@ def __str__(self):
178
180
if value is not None :
179
181
parts .append ("{}={}" .format (attr , str (value )))
180
182
return "<{} {} >" .format (self .__class__ .__name__ , " " .join (parts ))
181
-
183
+
182
184
def __bytes__ (self ):
183
185
"""The raw packet bytes."""
184
186
# Must reorder the ManufacturerData contents so the sequence number field is always first.
@@ -188,7 +190,7 @@ def __bytes__(self):
188
190
189
191
def split (self , max_packet_size = 31 ):
190
192
"""Split the measurement into multiple measurements with the given max_packet_size. Yields
191
- each submeasurement."""
193
+ each submeasurement."""
192
194
current_size = 8 # baseline for mfg data and sequence number
193
195
if current_size + len (self .manufacturer_data ) < max_packet_size :
194
196
yield self
0 commit comments