Coder Social home page Coder Social logo

mlupo / adafruit_circuitpython_ble_radio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adafruit/adafruit_circuitpython_ble_radio

0.0 0.0 0.0 167 KB

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

License: MIT License

Python 100.00%

adafruit_circuitpython_ble_radio's Introduction

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.

adafruit_circuitpython_ble_radio's People

Contributors

caternuson avatar dhalbert avatar evaherrada avatar kattni avatar mlupo avatar ntoll avatar sommersoft avatar tannewt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.