Skip to main content

Simple byte and string based inter-device communication via BLE.

Project description

Introduction

Documentation Status Discord Build Status Code Style: Ruff

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.

Dependencies

This library depends on:

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).

Run the unit tests with the following command:

$ pytest --cov-report term-missing --cov=adafruit_ble_radio tests/

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adafruit_circuitpython_ble_radio-0.5.15.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file adafruit_circuitpython_ble_radio-0.5.15.tar.gz.

File metadata

File hashes

Hashes for adafruit_circuitpython_ble_radio-0.5.15.tar.gz
Algorithm Hash digest
SHA256 aab695aff76acd1bedcd7c02525e877ee8499d32c7757393a9d9ef04e54af33f
MD5 349ef945120d41d2c99404c675fafa37
BLAKE2b-256 4f17c66c014c1bd158b04f727aaa228b3fd215fd306e34338848775b6e08992e

See more details on using hashes here.

File details

Details for the file adafruit_circuitpython_ble_radio-0.5.15-py3-none-any.whl.

File metadata

File hashes

Hashes for adafruit_circuitpython_ble_radio-0.5.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3c12f2ae4742347994d6cd5abe34ee97ff73f3c88e7184b73bf28310ce75e9a4
MD5 05c8b54360415d597d4671ca7cc628f0
BLAKE2b-256 8c1f3292452554c1a072138b8ef1a943b17cc7cc9492e9e9486d40bb832b1caa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page