This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need some help getting faster sending rates with the NRF8001 and Arduino Library. Running out of credits.

I'm using the NRF8001 with a Teensy 4.0. I've been able to find a port of the Arduino library for the Teensy here (https://github.com/tato123/nrf8001_arm_support)

I'm trying to send a bunch of data in 20 byte chunks to my android phone very quickly. I've got a function called sendData that does this:

void sendData(uint8_t *buffint buff_len)
{

    if (lib_aci_is_pipe_available(&aci_statePIPE_UART_OVER_BTLE_UART_TX_TX))
    {

    if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TXbuffbuff_len))
    {
        Serial.println(F("Serial input dropped"));
    }
    else
    {
        Serial.println("Sent Data");
    }
    }
}
In my Teensy loop I do this:
uint8_t gB[20];
uint8_t *gPtr = gB;

uint8_t altimeterBuffer[20];
uint8_t *altimeterPtr = altimeterBuffer;

uint8_t YPRBuffer[20];
uint8_t *YPRPtr = YPRBuffer;

uint8_t ABuffer[20];
uint8_t *APtr = ABuffer;

int i = 0;
String joinedg;
String joinedB;
String joinedYPR;
String joinedA;

void loop()
{

  //Process any ACI commands or events
  aci_loop();

  //buzzerIdle();

  if (IMUChrono.hasPassed(20))
  {
    updateIMU();
    updateAltimeter();
  }

  if (btleChrono.hasPassed(50) && btle_connected)
  {
    btleChrono.restart();

    joinedg = "G " + (String)(int)x_gyro + " " + (String)(int)y_gyro + " " + (String)(int)z_gyro;
    joinedg.getBytes(gB20);
    sendData(gPtr20);
    delay(100);

    joinedB = "B " + (String)altimeter_alt_rel;
    joinedB.getBytes(altimeterBuffer20);
    sendData(altimeterPtr20);
    delay(100);

    joinedYPR = "O " + (String)(int)yaw + " " + (String)(int)pitch + " " + (String)(int)roll;
    joinedYPR.getBytes(YPRBuffer20);
    sendData(YPRPtr20);
    delay(100);

    joinedA = "A " + (String)(int)x_accel + " " + (String)(int)y_accel + " " + (String)(int)z_accel;
    joinedA.getBytes(ABuffer20);
    sendData(APtr20);
    delay(100);
  }
}
When I do this, the NRF8001 sometimes doesn't send the commands and complains about not having enough credits. Is there anything in the codebase I can do to make it work faster without dropping sends?
Related