如何在 Mbed OS 6 中通过 BLE 读取/写入数据?
我有一部 Android 智能手机和一块 Discovery L475VG IoT 开发板。我正在尝试通过 BLE 发送/接收数据(双向)。我查阅了大量文档(尽管其中大部分对于 Mbed OS 6 来说已经过时),并且我一直在尝试分析 GattServercharacteristicUpdate 和characteristicWrite 示例代码中发生的情况。 参见此处
这两个示例代码适用于它们应该演示的内容,但他们似乎以不同的方式实现读取和写入,或者也许我只是没有关注正在发生的事情?
如果不是很明显,那么我对整个 BLE 堆栈并不是非常熟悉,尤其是它的 mbed 实现。我之前制作了一个基于 Arduino 的系统,它实现了我在这里尝试的相同目标,但我无法找出 mbed 提供的更复杂、较低级别的库。
read() 和 write() 函数看起来是我需要的显而易见的东西,但它们似乎是私有函数,因此我认为还有更多功能,而且,mbed Studio 自然不会只让我调用它们来自 main()。
有人能指出我从哪里开始的正确方向吗?
I have an Android smartphone and a Discovery L475VG IoT development board. I am trying send/receive data (both directions) via BLE. I have consulted a good bit of documentation (although much of it is out of date for Mbed OS 6) and I have been trying to analyze what's going on in the GattServer characteristicUpdate and characteristicWrite example codes. See here
The two example codes work for what they're supposed to demonstrate, but they seem to go about implementing reads and writes differently, or maybe I am just not following what's going on?
If it isn't obvious, I am not super familiar with the BLE stack as a whole, and particularly not the mbed implementation of it. I previously made an Arduino-based system that accomplished the same goal I'm trying to here, but I am having trouble figuring out more complicated, lower-level library that mbed provides.
The read() and write() functions, which seem like the obvious things I would need, appear to be private functions, so I assume there is more to it than that and, naturally, mbed Studio doesn't just let me call them from main().
Can someone point me in the right direction of where to start?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试修改 BLE_GattServer_CharacteristicWrite 允许您在写入后设置特征值。这种方法完全未经测试,因为我无法访问 mbed 开发板。
随后读取时,应将特性设置为写入值 * 2。
I tried to modify the BLE_GattServer_CharacteristicWrite to allow you to set the characteristic value after writing. This approach is completely untested since I don't have access to a mbed developer board.
This should set the characteristic to the written value * 2 when reading afterwards.
好的,我已经弄清楚了,感谢 Michael Kotzjan 的帮助:
当手机向 mbed 板发送一个字节时,mbed 板将写入特性设置为接收到的值的两倍。指针的东西有点令人困惑,但现在可以了。
Ok, I have figured it out, thanks to Michael Kotzjan for the help:
When the phone sends a byte to the mbed board, the mbed board sets the write characteristic to double the value that was received. The pointer stuff was a bit confusing, but this works now.