adafruit_bluefruitspi

Helper class to work with the Adafruit Bluefruit LE SPI friend breakout.

  • Author(s): Kevin Townsend

Implementation Notes

Hardware:

“* Adafruit Bluefruit LE SPI Friend

Software and Dependencies:

class adafruit_bluefruitspi.BluefruitSPI(spi, cs, irq, reset, debug=False, fifo_len=20)

Helper for the Bluefruit LE SPI Friend

command(string)

Send a command and check response code

command_check_OK(command, delay=0.0)

Send a fully formed bytestring AT command, and check whether we got an ‘OK’ back. Returns payload bytes if there is any

property connected

Whether the Bluefruit module is connected to the central

init()

Sends the SDEP initialize command, which causes the board to reset. This command should complete in under 1s.

pop_keyboard_code_queue()

Send an SDEP packet from the FIFO buffer to the Bluefruit

read_packet()

Will read a Bluefruit Connect packet and return it in a parsed format. Currently supports Button and Color packets only

send_keyboard_code(evt)

Put an AT+BLEKEYBOARDCODE command into the FIFO buffer. Call pop_keyboard_code() to send a single packet to the Bluefruit.

Parameters:

evt – bytearray(8) representing keyboard code to send

uart_rx()

Reads byte data from the BLE UART FIFO.

uart_tx(data)

Sends the specific bytestring out over BLE UART.

Parameters:

data – The bytestring to send.

class adafruit_bluefruitspi.FIFOBuffer(maxlen=20)

FIFO buffer vaguely based on collections.deque.

Uses a tuple internally to allow for O(1) enqueue and dequeue

dequeue()

Pop an item from the front of the FIFO queue

enqueue(data)

Put an item at the end of the FIFO queue