adafruit / Adafruit_BluefruitLE_nRF51

Arduino library for nRF51822-based Adafruit Bluefruit LE modules
197 stars 122 forks source link

Setting BUFSIZE (in BluefruitConfig.h) to 256 breaks SPI comms with the module. #60

Open foodini opened 2 years ago

foodini commented 2 years ago

Running the atcommand example, I am using an otherwise unmodifiedBluefruitConfig.h, with settings for a MKRZero using hardware SPI. This means that the only change I had to make was:

#define BLUEFRUIT_SPI_CS               5
#define BLUEFRUIT_SPI_IRQ              3
#define BLUEFRUIT_SPI_RST              6    // Optional but recommended, set to -1 if unused

I did make one other change, however. I have a lot of memory to work with on this board and I'm not sure how often I'll be able to check for incoming messages - and I know that they'll be on the order of 32B and coming fast. So.... I set the buffer size (BUFSIZE) to 256.

With the buffer at 160, I can send AT commands just fine. Here's ATI:

-------------------------------------
Initialising the Bluefruit LE module: OK!
Performing a factory reset: 
AT+FACTORYRESET

<- OK
ATE=0

<- OK
Requesting Bluefruit info:
----------------
BLESPIFRIEND
nRF51822 QFACA00
4A01B079A608DD56
0.6.7
0.6.7
Sep 17 2015
S110 8.0.0, 0.2
----------------
AT > ATI

<- BLESPIFRIEND
nRF51822 QFACA00
4A01B079A608DD56
0.6.7
0.6.7
Sep 17 2015
S110 8.0.0, 0.2
OK
AT >

And here it is again with a buffer of 256:

-------------------------------------
Initialising the Bluefruit LE module: OK!
Performing a factory reset: 
AT+FACTORYRESET

<- OK
ATE=0

<- OK
Requesting Bluefruit info:
----------------
BLESPIFRIEND
nRF51822 QFACA00
4A01B079A608DD56
0.6.7
0.6.7
Sep 17 2015
S110 8.0.0, 0.2
----------------
AT > Y*

<- ERROR
AT > Y*

<- ERROR
AT > Y*
...
...
...
...

(With the errors coming in, nonstop, at maybe 100/sec?)

The buffer size is the only thing I have changed between the two examples. The working version is the default 160 and the broken one is 256. Given that the MKRZero has something like 32KB of memory, I'm not running out. Strangely, setting BUFSIZE to 300 works, as does 1000. If it needs to be divisible by a specific number, BluefruitConfig.h should note this.