Open
Description
On a Feather M0 Bluetooth LE
running 3.1.1 and all libraries from adafruit-circuitpython-bundle-3.x-mpy-20181208.zip
, this code works:
Adafruit CircuitPython 3.1.1 on 2018-11-02; Adafruit Feather M0 Adalogger with samd21g18
>>>
>>> import board
>>> import busio
>>> from digitalio import DigitalInOut, Direction
>>> from adafruit_bluefruitspi import BluefruitSPI
>>> spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
>>> cs = DigitalInOut(board.D8)
>>> irq = DigitalInOut(board.D7)
>>> rst = DigitalInOut(board.D4)
>>> bluefruit = BluefruitSPI(spi_bus, cs, irq, rst, debug=False)
>>> bluefruit.init()
>>> bluefruit.command_check_OK(b'AT+FACTORYRESET', delay=1)
>>> bluefruit.command_check_OK(b'ATI')
b'BLESPIFRIEND\r\nnRF51822 QFACA10\r\n0102030405060708\r\n0.8.0\r\n0.8.0\r\nSep 25 2017\r\nS110 8.0.0, 0.2\r\n'
But if debug is on then a strange error pops out:
>>> import board
>>> import busio
>>> from digitalio import DigitalInOut, Direction
>>> from adafruit_bluefruitspi import BluefruitSPI
>>> spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
>>> cs = DigitalInOut(board.D8)
>>> irq = DigitalInOut(board.D7)
>>> rst = DigitalInOut(board.D4)
>>> bluefruit = BluefruitSPI(spi_bus, cs, irq, rst, debug=True)
>>> bluefruit.init()
Writing: ['0x10', '0xef', '0xbe', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0']
>>> bluefruit.command_check_OK(b'AT+FACTORYRESET', delay=1)
Writing: ['0x10', '0x0', '0xa', '0x10', '0x41', '0x54', '0x2b', '0x46', '0x41', '0x43', '0x54', '0x4f', '0x52', '0x59', '0x52', '0x45', '0x53', '0x45', '0x54', '0xa']
Reading: ['0x20', '0x0', '0xa', '0x4', '0x4f', '0x4b', '0xd', '0xa', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff']
b'OK\r\n'
>>> bluefruit.command_check_OK(b'ATI')
Writing: ['0x10', '0x0', '0xa', '0x4', '0x41', '0x54', '0x49', '0xa', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0']
Reading: ['0x20', '0x0', '0xa', '0x90', '0x42', '0x4c', '0x45', '0x53', '0x50', '0x49', '0x46', '0x52', '0x49', '0x45', '0x4e', '0x44', '0xd', '0xa', '0x6e', '0x52']
Reading: ['0x20', '0x0', '0xa', '0x90', '0x46', '0x35', '0x31', '0x38', '0x32', '0x32', '0x20', '0x51', '0x46', '0x41', '0x43', '0x41', '0x31', '0x30', '0xd', '0xa']
Reading: ['0x20', '0x0', '0xa', '0x90', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz', '0xzz']
Reading: ['0x20', '0x0', '0xa', '0x90', '0xd', '0xa', '0x30', '0x2e', '0x38', '0x2e', '0x30', '0xd', '0xa', '0x30', '0x2e', '0x38', '0x2e', '0x30', '0xd', '0xa']
Reading: ['0x20', '0x0', '0xa', '0x90', '0x53', '0x65', '0x70', '0x20', '0x32', '0x35', '0x20', '0x32', '0x30', '0x31', '0x37', '0xd', '0xa', '0x53', '0x31', '0x31']
Reading: ['0x20', '0x0', '0xa', '0x90', '0x30', '0x20', '0x38', '0x2e', '0x30', '0x2e', '0x30', '0x2c', '0x20', '0x30', '0x2e', '0x32', '0xd', '0xa', '0x4f', '0x4b']
Reading: ['0x80', '0xa1', '0x80', '0x0', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff', '0xff']
b'BLESPIFRIEND\r\nnRF51822 QFACA10\r\n0102030405060708\r\n0.8.0\r\n0.8.0\r\nSep 25 2017\r\nS110 8.0.0, 0.2\r\nOK'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_bluefruitspi.py", line 253, in command_check_OK
File "adafruit_bluefruitspi.py", line 248, in command
File "adafruit_bluefruitspi.py", line 248, in command
RuntimeError: AT command failure: RuntimeError('Error (id:0xa180)',)
Appears to do this every time and is completely reproducible for me - the serial connection is running at standard 115200.
A glance at the code shows that there's a sleep xor print in _cmd()
based on debug mode. Perhaps there's a timing issue here? For someone more familiar with protocol and peripheral the Reading output will probably give away what's going on here.
I've also observed a buffering issue with read_packet()
but I'll probably put a forum post in for that RSN. I was turning on debug to try and get more info for that.