1- # The MIT License (MIT)
1+ # SPDX-FileCopyrightText: 2018 Dan Halbert for Adafruit Industries
22#
3- # Copyright (c) 2018 Dan Halbert for Adafruit Industries
4- #
5- # Permission is hereby granted, free of charge, to any person obtaining a copy
6- # of this software and associated documentation files (the "Software"), to deal
7- # in the Software without restriction, including without limitation the rights
8- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9- # copies of the Software, and to permit persons to whom the Software is
10- # furnished to do so, subject to the following conditions:
11- #
12- # The above copyright notice and this permission notice shall be included in
13- # all copies or substantial portions of the Software.
14- #
15- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21- # THE SOFTWARE.
3+ # SPDX-License-Identifier: MIT
4+
225"""
236Advertising is the first phase of BLE where devices can broadcast
247"""
@@ -38,7 +21,7 @@ def to_bytes_literal(seq):
3821
3922def decode_data (data , * , key_encoding = "B" ):
4023 """Helper which decodes length encoded structures into a dictionary with the given key
41- encoding."""
24+ encoding."""
4225 i = 0
4326 data_dict = {}
4427 key_size = struct .calcsize (key_encoding )
@@ -73,7 +56,7 @@ def compute_length(data_dict, *, key_encoding="B"):
7356
7457def encode_data (data_dict , * , key_encoding = "B" ):
7558 """Helper which encodes dictionaries into length encoded structures with the given key
76- encoding."""
59+ encoding."""
7760 length = compute_length (data_dict , key_encoding = key_encoding )
7861 data = bytearray (length )
7962 key_size = struct .calcsize (key_encoding )
@@ -151,7 +134,7 @@ def __str__(self):
151134class String (AdvertisingDataField ):
152135 """UTF-8 encoded string in an Advertisement.
153136
154- Not null terminated once encoded because length is always transmitted."""
137+ Not null terminated once encoded because length is always transmitted."""
155138
156139 def __init__ (self , * , advertising_data_type ):
157140 self ._adt = advertising_data_type
@@ -265,7 +248,7 @@ def __init__(self):
265248 @classmethod
266249 def from_entry (cls , entry ):
267250 """Create an Advertisement based on the given ScanEntry. This is done automatically by
268- `BLERadio` for all scan results."""
251+ `BLERadio` for all scan results."""
269252 self = cls ()
270253 # If data_dict is available, use it directly. Otherwise decode the bytestring.
271254 if hasattr (entry , "data_dict" ):
@@ -282,7 +265,7 @@ def from_entry(cls, entry):
282265 @property
283266 def rssi (self ):
284267 """Signal strength of the scanned advertisement. Only available on Advertisements returned
285- from `BLERadio.start_scan()`. (read-only)"""
268+ from `BLERadio.start_scan()`. (read-only)"""
286269 return self ._rssi
287270
288271 @classmethod
0 commit comments