Skip to main content

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

Project description

Introduction

Documentation Status Discord Build Status Code Style: Black

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

Built Distribution

File details

Details for the file adafruit-circuitpython-ble-radio-0.5.10.tar.gz.

File metadata

File hashes

Hashes for adafruit-circuitpython-ble-radio-0.5.10.tar.gz
Algorithm Hash digest
SHA256 699a23d1b54b9a92f84b3852fdf187e065484c76645e4fd48acd563596e7ce24
MD5 708cc668c51aabc2e3ed1b2407df201a
BLAKE2b-256 5f42bbc02b39eda8a7f44d02614189a86f42c2245935c8995176fbbe7a3cb93c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adafruit_circuitpython_ble_radio-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 92867fb62b9e1850dca7e483e9a390a8bf68344ca95b14bca41440e286c6de85
MD5 66673c51056b70fdccc81a2637fc5ae9
BLAKE2b-256 c71dd6e4a9e9baeb44d88db2f242800ec12016ecb010a5313d52e26a578386ee

See more details on using hashes here.

Supported by

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