Skip to content

Commit 74fbe6e

Browse files
committed
FIxes
1 parent 5f860e6 commit 74fbe6e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

adafruit_ble_beacon.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ class _BeaconAdvertisement(Advertisement):
8181
path_loss_const: int = 3
8282
"""The path loss constant, typically between 2-4"""
8383

84+
@property
85+
def uuid(self) -> bytes:
86+
raise NotImplementedError("Must be implemented in beacon subclass")
87+
88+
@uuid.setter
89+
def uuid(self, id: bytes) -> None:
90+
raise NotImplementedError("Must be implemented in beacon subclass")
91+
8492
@property
8593
def distance(self) -> float:
8694
"""The approximate distance to the beacon"""
@@ -89,7 +97,11 @@ def distance(self) -> float:
8997

9098
@property
9199
def beacon_tx_power(self) -> int:
92-
raise NotImplementedError("Must be defined in beacon subclass")
100+
raise NotImplementedError("Must be implemented in beacon subclass")
101+
102+
@beacon_tx_power.setter
103+
def beacon_txt_power(self, power: int) -> None:
104+
raise NotImplementedError("Must be implemented in beacon subclass")
93105

94106

95107
class iBeaconAdvertisement(_BeaconAdvertisement):
@@ -123,7 +135,6 @@ def uuid(self, id: bytes) -> None:
123135
self._set_struct_index(3, uuid_msb)
124136
self._set_struct_index(4, uuid_lsb)
125137

126-
127138
@property
128139
def major(self) -> int:
129140
return self._get_struct_index(self._major_index)
@@ -158,4 +169,5 @@ def _get_struct_index(self, index: int) -> int:
158169
return temp_tuple[index]
159170

160171
def _init_struct(self) -> None:
161-
self._beacon_data = (_APPLE_COMPANY_ID_FLIPPED, _IBEACON_TYPE, _IBEACON_LENGTH, 0, 0, 0, 0, 0)
172+
apple_id_flipped = struct.unpack(">H", struct.pack("<H", _APPLE_COMPANY_ID))
173+
self._beacon_data = (apple_id_flipped, _IBEACON_TYPE, _IBEACON_LENGTH, 0, 0, 0, 0, 0)

0 commit comments

Comments
 (0)