android - Genuino 101 - 通过 BLE 向 Android 发送 csv 字符串

标签 android arduino bluetooth-lowenergy

我有一个 Genuino 101 开发板,我希望它通过低功耗蓝牙 [BLE] 与 Android 通信。值不断更新,目标是发送逗号分隔的 signed int 字符串,例如-10,2,1023这样拼起来:

void loop() {
  float first, second, third;

  if (central) 
  {
    Serial.print("Connected to central: ");
    [...]
    // as long as the central is still connected:
    while (central.connected()) 
    {
    [...]
    String truple = String((int)first)+","+String((int)second)+","+String((int)third);

    // now from here I want to send this string to the Android UI: how to?
  }

我知道每条消息必须保持在 20 个字节以下。对于这个板,有一个库负责 BLE,CurieBLE.h,但是查看文档我无法弄清楚什么是实现目标的最佳方法。我只需要将这些值发送给Android,不需要接收数据

非常感谢那些愿意提供帮助的人

最佳答案

你需要:

  • 将ble模块附加到genuino,使用软件串行库,因为板上只有一个usart,它已经在你的sketch中用于调试
  • 在 setup() 中初始化
  • 如果 ble 制造商提供固件支持,则使用 serial.println 或其他例程将数据发送到 ble

关于android - Genuino 101 - 通过 BLE 向 Android 发送 csv 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36385492/

相关文章:

android - 在 React Native 中检索 IMEI

java - BOOT_COMPLETED 后无法启动 Intent

android - getBluetoothLeAdvertiser() 返回 null

java - 通知传输已完成超过 20 个字节 onCharactersitcChanged BLE

android - 如何使用android创建圆形图像?

android - 如何将搜索栏添加到 Exoplayer exo_playback_control_view.xml

c - 将数据从 Arduino 内部串行缓冲区移动到内存中

Android + Arduino 蓝牙数据传输

划分两个 float 时的 C 怪异行为

android - 在 Android 中连续读取 BLE 的值