nRF8001 runs out of 'credits'

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DanalEstes
 
Posts: 19
Joined: Sat Mar 14, 2015 2:27 am

nRF8001 runs out of 'credits'

Post by DanalEstes »

I am using the nRF8001 with Sparkfun Arduino Pro Mini. All basic functionality works quite well. I am posting for help with three issues and one request:

1) When attempting to send more than a few calls to BTLEserial.print() or BTLEserial.write() in a short period of time, I get error messages indicating the system has "run out of credits". Interspersing calls to BTLEserial.pollACI() does not help. Delays, up to 1 second long, do not help. From looking at the library, I see where credits are deducted. I am unclear on how credits are regained. Obviously, the code after the case statement "ACI_EVT_DATA_CREDIT" adds credits... but when is this called?

The problem can be reproduced with the Adafruit supplied echoDemo program. Copy this line

Code: Select all

BTLEserial.write(sendbuffer, sendbuffersize);     
so it repeats about 20 times. Then send "This is a test" via serial. You will see some number of successful sends, followed by:

Code: Select all

	Writing out to BTLE: 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38
ACI Evt Pipe Error: Pipe #:3  Pipe Error Code: 0x91
Where the 91 indicates "out of credits" in the Nordic docs.



2) When resetting the Arduino (while keeping power on), approximately 1/3 of the time, when calling BTELserial.init(), the library indicates an error and puts the Arduino in a "while (1)" loop. Another reset generally clears the problem... but it really shouldn't do this at all. Again, this is AFTER a reset.

Code: Select all

Cmd Queue Full
Cmd Queue Full
Cmd Queue Full
Error in ACI Setup
Cmd Queue Full
Cmd Queue Full
Cmd Queue Full
Error in ACI Setup
Cmd Queue Full
Cmd Queue Full
Cmd Queue Full
Error in ACI Setup
ACI Command 6
Evt Cmd respone: Error. Arduino is in an while(1); loop
3) Line 30 of Adafruit_nRF8001.h (as of Apr 14 2015, in github) contains "#define BLE_RW_DEBUG" which, via '#if defined' statements, causes Serial.print statements to be executed. Shouldn't this be in the user sketch, with documentation via commented lines in the Adfruit files? It would be a non-issue to modify the library... except I am using codebender. This one is somewhat lower priority, because I can add a private library to codebender and comment out this statement.




And the request: The library does not currently implement println; in fact, it really doesn't properly implement print (many types are missing). Can you please update this portion of the library?

Thanks,

Danal

User avatar
DanalEstes
 
Posts: 19
Joined: Sat Mar 14, 2015 2:27 am

Re: nRF8001 runs out of 'credits'

Post by DanalEstes »

With regard to the Reset hang (item 2 above): I just noticed that the Library does NOT use the "reset" pin, ever. I will try issuing a reset, prior to BTLEserial.begin(), in my setup().

Still looking for help on the "Credits" problem. I beginning to believe the library does NOT do flow control with "Credits"? So I need my own routine to do this? Maybe?

User avatar
DanalEstes
 
Posts: 19
Joined: Sat Mar 14, 2015 2:27 am

Re: nRF8001 runs out of 'credits'

Post by DanalEstes »

Two updates:

First, my question about the application possibly needing to do flow control... this is not possible, because the library class (as it stands today) does NOT expose the credits available or any functions to obtain them.

Second, here is a very clear way to reproduce the problem. In the Adafruit provided "echoDemo" sketch, wrap a loop around the BTLEserial.write:

Code: Select all

			{
				BTLEserial.pollACI();
				BTLEserial.write(sendbuffer, sendbuffersize);

				BTLEserial.print(i);
				BTLEserial.println(" ");
				Serial.println(i);
			}
With the 'pollACI' is a little better than without... but either way, it will fail more often than not. Always with code 91 (no credits available).

User avatar
DanalEstes
 
Posts: 19
Joined: Sat Mar 14, 2015 2:27 am

Re: nRF8001 runs out of 'credits'

Post by DanalEstes »

And... since I seem to be talking to myself here... a fix for the "out of credits" issue. Modify the library Adafruit_BLE_UART.cpp by adding the following line of code to the top of the "write" function (in both instances of the write function, because there are two argument prototypes):

Code: Select all

  while (0 == aci_state.data_credit_available) {pollACI(); delay(10);}    //Blocking!   
This does seem to reliably fix the "out of credits" failure.

Still working the reset issue.

User avatar
erwincoumans
 
Posts: 1
Joined: Thu Apr 02, 2015 9:47 pm

Re: nRF8001 runs out of 'credits'

Post by erwincoumans »

DanalEstes wrote:And... since I seem to be talking to myself here... a fix for the "out of credits" issue. Modify the library Adafruit_BLE_UART.cpp by adding the following line of code to the top of the "write" function (in both instances of the write function, because there are two argument prototypes):

Code: Select all

  while (0 == aci_state.data_credit_available) {pollACI(); delay(10);}    //Blocking!   
This does seem to reliably fix the "out of credits" failure.

Still working the reset issue.
Thank you for reporting fix! I got a similar error using the IMUDuino, connecting to a nRF UART app on iPhone. Adding the line fixed it :-)

Afrotastic
 
Posts: 3
Joined: Mon Apr 20, 2015 1:08 pm

Re: nRF8001 runs out of 'credits'

Post by Afrotastic »

DanalEstes wrote:And... since I seem to be talking to myself here... a fix for the "out of credits" issue. Modify the library Adafruit_BLE_UART.cpp by adding the following line of code to the top of the "write" function (in both instances of the write function, because there are two argument prototypes):

Code: Select all

  while (0 == aci_state.data_credit_available) {pollACI(); delay(10);}    //Blocking!   
This does seem to reliably fix the "out of credits" failure.

Still working the reset issue.
I had this error as well. This really works, I even changed the delay to 1 ms for minimum impact on the code and that seems to work as well. Thank you very much!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”