adafruit / Adafruit_BluefruitLE_nRF51

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

ble.update() leaks "OK"s #17

Closed crackmonkey closed 8 years ago

crackmonkey commented 8 years ago

I'm using the new callbacks to handle UART RX's and GATT writes, but I am also forwarding traffic between the BlueFruit and Serial so I can talk to the module directly for debugging. (while (ble.available()){Serial.write(ble.read()} and vice-versa). When I first got it running I was getting a constant stream of "OK"s from my reads. I tracked them down to being the responses to println( F("AT+EVENTSTATUS") ); in Adafruit_BLE::update line 284. I think line 285 should be waitForOK(); instead of readline(); so that update() consumes the full result of "AT+EVENTSTATUS". I made the change locally and it seems to work, I can interact with the BLE module without a any excess OK's appearing. It shouldn't require any other changes to the code since waitForOK() puts the data in this->buffer same as readline(). I guess it does cost another BLE_BUFSIZE+1 (49) bytes of ram though.

hathach commented 8 years ago

Hi,

Thank you for filing the issue. Could you please post your example sketch here. Just to be sure that we are working on the same code.

crackmonkey commented 8 years ago

PasteStick - Copy.txt

hathach commented 8 years ago

thanks, we will check it soon enough :)

hathach commented 8 years ago

thank you very much for the detail description and the solution. That is an huge bug, nice catch !!! Sorry for getting back late, since we are buried in another yet exciting project :) . I have added waitForOK() at line 285 as you suggested. Thanks again.