Skip to content

Commit 7283b7b

Browse files
committed
Replace Broadcaster with Peripheral
1 parent bc8b7f3 commit 7283b7b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

adafruit_ble/beacon.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ def __init__(self, advertising_packet, interval=1.0):
4040
"""Set up a beacon with the given AdvertisingPacket.
4141
4242
:param AdvertisingPacket advertising_packet
43-
:param float interval: Advertising interval in seconds
4443
"""
45-
self._broadcaster = bleio.Broadcaster(interval)
44+
self._broadcaster = bleio.Peripheral(name=None)
4645
self._advertising_packet = advertising_packet
4746

48-
def start(self):
49-
"""Turn on beacon."""
50-
self._broadcaster.start_advertising(self._advertising_packet.packet_bytes)
47+
def start(self, interval=1.0):
48+
"""Turn on beacon.
49+
50+
:param float interval: Advertising interval in seconds
51+
"""
52+
self._broadcaster.start_advertising(self._advertising_packet.packet_bytes, interval=interval)
5153

5254
def stop(self):
5355
"""Turn off beacon."""
@@ -60,7 +62,7 @@ class LocationBeacon(Beacon):
6062
Used for Apple iBeacon, Nordic nRF Beacon, etc.
6163
"""
6264
# pylint: disable=too-many-arguments
63-
def __init__(self, company_id, uuid, major, minor, rssi, interval=1.0):
65+
def __init__(self, company_id, uuid, major, minor, rssi):
6466
"""Create a beacon with the given values.
6567
6668
:param int company_id: 16-bit company id designating beacon specification owner
@@ -69,7 +71,6 @@ def __init__(self, company_id, uuid, major, minor, rssi, interval=1.0):
6971
:param int major: 16-bit major number, such as a store number
7072
:param int minor: 16-bit minor number, such as a location within a store
7173
:param int rssi: Signal strength in dBm at 1m (signed 8-bit value)
72-
:param float interval: Advertising interval in seconds
7374
7475
Example::
7576
@@ -93,7 +94,7 @@ def __init__(self, company_id, uuid, major, minor, rssi, interval=1.0):
9394
bytes(reversed(uuid.uuid128)),
9495
# major and minor are big-endian.
9596
struct.pack(">HHb", major, minor, rssi))))
96-
super().__init__(adv, interval=interval)
97+
super().__init__(adv)
9798

9899

99100
class EddystoneURLBeacon(Beacon):
@@ -127,12 +128,11 @@ class EddystoneURLBeacon(Beacon):
127128
'.gov',
128129
)
129130

130-
def __init__(self, url, tx_power=0, interval=1.0):
131+
def __init__(self, url, tx_power=0):
131132
"""Create a URL beacon with an encoded version of the url and a transmit power.
132133
133134
:param url URL to encode. Must be short enough to fit after encoding.
134135
:param int tx_power: transmit power in dBm at 0 meters (8 bit signed value)
135-
:param float interval: advertising interval in seconds
136136
"""
137137

138138
adv = AdvertisingPacket()
@@ -155,4 +155,4 @@ def __init__(self, url, tx_power=0, interval=1.0):
155155
b'\x10',
156156
struct.pack("<bB", tx_power, url_scheme_num),
157157
bytes(short_url, 'ascii'))))
158-
super().__init__(adv, interval)
158+
super().__init__(adv)

0 commit comments

Comments
 (0)