我有一个 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/