Broadcaster – Broadcast advertising packets.

Implement a BLE broadcaster which sends data in advertising packets and does not connect. Used for beacons and other one-way data transmission.

Usage:

import bleio
import time

# Broadcast once a second.
broadcaster = bleio.Broadcaster(interval=1)
data = 0
# Broadcast a byte of data that's incremented once a minute
while True:
    # data is an entire advertising data packet, starting with flags.
    broadcaster.start_advertising(data)
    time.sleep(60)
    data += 1
class bleio.Broadcaster(interval=1)

Create a new Broadcaster object. :param float interval: how often to broadcast

start_advertising(data)

Start advertising using the given data packet.

Parameters:data (buf) – advertising data packet, starting with advertising data flags (0x01)
stop_advertising()

Stop sending advertising packets.