Skip to content

Rename to Adafruit CircuitPython BLE Radio #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ install:
- pip install --force-reinstall pylint==1.9.2

script:
- pylint adafruit_radio.py
- pylint adafruit_ble_radio.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-radio --library_location .
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ble-radio --library_location .
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Introduction
:target: https://discord.gg/nBQh6qu
:alt: Discord

.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_radio.svg?branch=master
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_radio
.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_BLE_Radio.svg?branch=master
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_BLE_Radio
:alt: Build Status

This library provides simple byte and string based inter-device communication
Expand All @@ -36,7 +36,7 @@ Usage Example

All the functionality is exposed via the very simple ``Radio`` class::

from adafruit_radio import Radio
from adafruit_ble_radio import Radio


# A radio instance listens/broadcasts on a numbered channel.
Expand All @@ -47,7 +47,7 @@ All the functionality is exposed via the very simple ``Radio`` class::

# Broadcast a simple string message.
r.send("Hello")

# Broadcast raw bytes.
r.send_bytes(b"Hello")

Expand Down Expand Up @@ -77,13 +77,13 @@ installed (``pip install pytest pytest-coverage``).

Run the unit tests with the following command::

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

Contributing
============

Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_radio/blob/master/CODE_OF_CONDUCT.md>`_
<https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.

Documentation
Expand Down
4 changes: 2 additions & 2 deletions adafruit_radio.py → adafruit_ble_radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`adafruit_radio`
`adafruit_ble_radio`
================================================================================

Simple byte and string based inter-device communication via BLE.
Expand Down Expand Up @@ -48,7 +48,7 @@


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_radio.git"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio.git"


#: Maximum length of a message (in bytes).
Expand Down
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
.. use this format as the module name: "adafruit_foo.foo"

.. automodule:: adafruit_radio
.. automodule:: adafruit_ble_radio
:members:
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["digitalio", "busio", "adafruit_ble"]
autodoc_mock_imports = ["digitalio", "busio", "adafruit_ble", "micropython"]


intersphinx_mapping = {
Expand All @@ -38,7 +38,7 @@
master_doc = "index"

# General information about the project.
project = "Adafruit radio Library"
project = "Adafruit BLE Radio Library"
copyright = "2019 Nicholas H.Tollervey"
author = "Nicholas H.Tollervey"

Expand Down
4 changes: 2 additions & 2 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Simple test

Ensure your device works with this simple test.

.. literalinclude:: ../examples/radio_simpletest.py
:caption: examples/radio_simpletest.py
.. literalinclude:: ../examples/ble_radio_simpletest.py
:caption: examples/ble_radio_simpletest.py
:linenos:
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Table of Contents
.. toctree::
:caption: Other Links

Download <https://github.com/adafruit/adafruit_CircuitPython_radio/releases/latest>
Download <https://github.com/adafruit/adafruit_CircuitPython_BLE_Radio/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import digitalio
import board
from adafruit_radio import Radio
from adafruit_ble_radio import Radio


slide_switch = digitalio.DigitalInOut(board.SLIDE_SWITCH)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
long_description=long_description,
long_description_content_type="text/x-rst",
# The project's main homepage.
url="https://github.com/adafruit/Adafruit_CircuitPython_radio",
url="https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio",
# Author details
author="Adafruit Industries",
author_email="[email protected]",
Expand All @@ -49,5 +49,5 @@
# simple. Or you can use find_packages().
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
# CHANGE `py_modules=['...']` TO `packages=['...']`
py_modules=["adafruit_radio"],
py_modules=["adafruit_ble_radio"],
)
24 changes: 12 additions & 12 deletions tests/test_adafruit_radio.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Simple unit tests for the adafruit_radio module. Uses experimental mocking
Simple unit tests for the adafruit_ble_radio module. Uses experimental mocking
found in the testconf.py file. See comments therein for explanation of how it
works.
"""
import adafruit_radio
import adafruit_ble_radio
import pytest
import struct
import time
Expand All @@ -15,7 +15,7 @@ def radio():
"""
A fixture to recreate a new Radio instance for each test that needs it.
"""
return adafruit_radio.Radio()
return adafruit_ble_radio.Radio()


def test_radio_init_default():
Expand All @@ -27,8 +27,8 @@ def test_radio_init_default():
* The self.msg_pool is initialised as an empty set.
* The channel is set to the default 42.
"""
r = adafruit_radio.Radio()
assert r.ble == adafruit_radio.BLERadio()
r = adafruit_ble_radio.Radio()
assert r.ble == adafruit_ble_radio.BLERadio()
assert r.uid == 0
assert r.msg_pool == set()
assert r._channel == 42
Expand All @@ -38,7 +38,7 @@ def test_radio_init_channel():
"""
If a channel argument is passed to initialisation, this is correctly set.
"""
r = adafruit_radio.Radio(channel=7)
r = adafruit_ble_radio.Radio(channel=7)
assert r._channel == 7


Expand Down Expand Up @@ -83,7 +83,7 @@ def test_radio_send_bytes_too_long(radio):
A ValueError is raised if the message to be sent is too long (defined by
MAX_LENGTH).
"""
msg = bytes(adafruit_radio.MAX_LENGTH + 1)
msg = bytes(adafruit_ble_radio.MAX_LENGTH + 1)
with pytest.raises(ValueError):
radio.send_bytes(msg)

Expand All @@ -95,10 +95,10 @@ def test_radio_send_bytes(radio):
"""
radio.uid = 255 # set up for cycle back to 0.
msg = b"Hello"
with mock.patch("adafruit_radio.time.sleep") as mock_sleep:
with mock.patch("adafruit_ble_radio.time.sleep") as mock_sleep:
radio.send_bytes(msg)
mock_sleep.assert_called_once_with(adafruit_radio.AD_DURATION)
spy_advertisement = adafruit_radio.AdafruitRadio()
mock_sleep.assert_called_once_with(adafruit_ble_radio.AD_DURATION)
spy_advertisement = adafruit_ble_radio.AdafruitRadio()
chan = struct.pack("<B", radio._channel)
uid = struct.pack("<B", 255)
assert spy_advertisement.msg == chan + uid + msg
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_radio_receive_full_no_messages(radio):
radio.ble.start_scan.return_value = []
assert radio.receive_full() is None
radio.ble.start_scan.assert_called_once_with(
adafruit_radio.AdafruitRadio, minimum_rssi=-255, timeout=1, extended=True
adafruit_ble_radio.AdafruitRadio, minimum_rssi=-255, timeout=1, extended=True
)
radio.ble.stop_scan.assert_called_once_with()

Expand Down Expand Up @@ -169,7 +169,7 @@ def test_radio_receive_full_and_remove_expired_message_metadata(radio):
mock_entry.address.address_bytes = b"adr2"
mock_entry.rssi = -40
radio.ble.start_scan.return_value = [mock_entry]
radio.msg_pool.add((time.monotonic() - adafruit_radio.AD_DURATION - 1, 42, 0, b"addr"))
radio.msg_pool.add((time.monotonic() - adafruit_ble_radio.AD_DURATION - 1, 42, 0, b"addr"))
result = radio.receive_full()
assert result[0] == b"Hello"
assert result[1] == -40
Expand Down