我必须用 Adafruit BLE SPI 朋友尽快通过 BLE 发送数据。我知道我想使用什么 GATT 服务。在 adafruit 的heartratemonitor.ino BLE 示例中,我对它们发送数据的方式感到困惑。他们似乎只是用 AT+GATTCHAR= 命令更新了心率测量特性。然后只需从他们的 Bluefruit 应用程序中读取更新。这种发送数据的方法似乎非常缓慢,而且效率也不高。我已经查看了 BLE SPI 朋友的Adafruit BLE 库,但我似乎找不到另一种更新/发送数据的合法方式。我是否遗漏了一些我理解的东西,或者这不是发送数据的最佳库?
注意:我必须使用 SPI 从缓冲区读取数据并通过蓝牙发送。考虑过只使用 SPI 库(确定难度)和任何其他北欧或 nRF51822 库,但学习曲线似乎非常陡峭。
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);
}