adafruit_ble_radio

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

  • Author(s): Nicholas H.Tollervey for Adafruit Industries

Hardware:

Adafruit Feather nRF52840 Express <https://www.adafruit.com/product/4062> Adafruit Circuit Playground Bluefruit <https://www.adafruit.com/product/4333>

Software and Dependencies:

adafruit_ble_radio.AD_DURATION = 0.5

Amount of time to advertise a message (in seconds).

adafruit_ble_radio.MAX_LENGTH = 248

Maximum length of a message (in bytes).

class adafruit_ble_radio.Radio(**args)

Represents a connection through which one can send or receive strings and bytes. The radio can be tuned to a specific channel upon initialisation or via the configure method.

configure(channel=42)

Set configuration values for the radio.

Parameters:channel (int) – The channel (0-255) the radio is listening / broadcasting on.
receive()

Returns a message received on the channel on which the radio is listening.

Returns:A string representation of the received message, or else None.
receive_full()

Returns a tuple containing three values representing a message received on the channel on which the radio is listening. If no message was received then None is returned.

The three values in the tuple represent:

  • the bytes received.
  • the RSSI (signal strength: 0 = max, -255 = min).
  • a microsecond timestamp: the value returned by time.monotonic() when the message was received.
Returns:A tuple representation of the received message, or else None.
send(message)

Send a message string on the channel to which the radio is broadcasting.

Parameters:message (str) – The message string to broadcast.
send_bytes(message)

Send bytes on the channel to which the radio is broadcasting.

Parameters:message (bytes) – The bytes to broadcast.