这真的是通过BLE发送数据的正确方法吗? (使用Adafruit示例作为参考)

问题描述 投票:0回答:1

我必须尽快通过Adafruit BLE SPI好友通过BLE发送数据。我知道我想使用什么GATT服务。在来自adafruit的heartratemonitor.ino BLE示例中,我对他们发送数据的方式感到困惑。看起来他们只是用AT + GATTCHAR =命令更新心率测量特性。然后,只需从他们的Bluefruit应用程序中读取更新。这种发送数据的方法似乎非常缓慢而且效率不高。我已经通过Adafruit BLE library查看了BLE SPI的朋友,我似乎无法找到另一种更新/发送数据的合法方式。我在理解中遗漏了什么,或者这不是发送数据的最佳库?

注意:我必须使用SPI从缓冲区读取数据并通过蓝牙发送。考虑只使用SPI库(ok难度)和任何其他北欧或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);
}
bluetooth bluetooth-lowenergy gatt adafruit nrf51
1个回答
0
投票

这种移动速度较慢的原因是因为循环结束时的延迟。

  /* Delay before next measurement update */
  delay(1000);

这是一种要求Bluefruit再次执行之前等待一秒钟(1000毫秒)的方法。

减少这个数字应该加快循环。

© www.soinside.com 2019 - 2024. All rights reserved.