Reputation: 317
I have to send data over BLE as fast as possible with the Adafruit BLE SPI friend. I have an idea of what GATT service I'd like to use. In the heartratemonitor.ino BLE example from adafruit, I am confused about the way they send data. It seems they just update the heart rate measurement characteristic with the AT+GATTCHAR= command. The update is then just read from their Bluefruit app. This method to send data seems to be painfully slow and not very efficient at all. I have looked through the Adafruit BLE library for the BLE SPI friend and I cant seem to find another legit way to update/send data. Am I missing something in my understanding, or is this just not the best library to send data with?
note: I have to read data from a buffer with SPI and send it over bluetooth. Thought about just using a SPI library (ok difficulty) and any other nordic or nRF51822 library, but the learning curve seems VERY steep.
void loop(void)
{
int heart_rate = random(50, 100);
Serial.print(F("Updating HRM value to "));
Serial.print(heart_rate);
Serial.println(F(" BPM"));
/* Command is sent when \n (\r) or println is called */
/* AT+GATTCHAR=CharacteristicID,value */
ble.print( F("AT+GATTCHAR=") );
ble.print( hrmMeasureCharId );
ble.print( F(",00-") );
ble.println(heart_rate, HEX);
/* Check if command executed OK */
if ( !ble.waitForOK() )
{
Serial.println(F("Failed to get response!"));
}
/* Delay before next measurement update */
delay(1000);
}
Upvotes: 0
Views: 1191
Reputation: 670
The reason this is moving slower is because of the delay at the end of the loop.
/* Delay before next measurement update */
delay(1000);
That's a way of asking the Bluefruit to wait one second (1000 milliseconds) before executing again.
Reducing that number should speed up the loop.
Upvotes: 0