You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library provides simple byte and string based inter-device communication
via BLE.
It works like a walkie-talkie: configure your device to use a certain channel
(numbered 0-255, default being 42) and it will broadcast on that channel and
receive any messages from other devices using that channel.
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
the Adafruit library and driver bundle.
Usage Example
All the functionality is exposed via the very simple Radio class:
from adafruit_ble_radio import Radio
# A radio instance listens/broadcasts on a numbered channel.
r = Radio(channel=7)
# Update radio instance settings.
r.configure(channel=9)
# Broadcast a simple string message.
r.send("Hello")
# Broadcast raw bytes.
r.send_bytes(b"Hello")
# A loop to listen for incoming string based messages...
while True:
msg = r.receive()
if msg:
print(msg)
# Alternatively, to get the raw bytes and other details...
while True:
msg = r.receive_full()
if msg:
msg_bytes = msg[0]
msg_strength = msg[1]
msg_time = msg[2]
print("Recieved {} (strength {}, at time {})".format(
msg_bytes,
msg_strength,
msg_time))
Unit Tests
To run the test suite you should have pytest and pytest-coverage
installed (pip install pytest pytest-coverage).