Skip to main content

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

Project description

Introduction

Documentation Status Discord Build Status

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/

Contributing

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

Documentation

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

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

File details

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

File metadata

  • Download URL: adafruit-circuitpython-ble-radio-0.3.5.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for adafruit-circuitpython-ble-radio-0.3.5.tar.gz
Algorithm Hash digest
SHA256 98c7447580f240516d58a8af16019e797d70da747039675d5efb2972895e1955
MD5 76061bd4b0f70c4ec1ca33c50a57f562
BLAKE2b-256 4a9bacdc4486c40e19e3cf70bae42e0da0543e54c52f31c0241cfe84dbbf54ac

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