gpt4 book ai didi

ios - 如何在 iOS 中获取 HM-10 Bluetooth LE 的特性

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:13:13 26 4
gpt4 key购买 nike

我正在尝试将一些数据从 iOS 设备发送到连接到 arduino 的 HM-10 蓝牙 LE 模块。问题是连接到模块 discoverServices 后没有返回服务的特征。

    func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) {
if(error != nil) {
print(error?.description)
}
for service in peripheral.services! {
let thisService = service as CBService
print("Service: \(thisService.description)")
print("Characteristic: \(thisService.characteristics)")
}
}

这个输出:

Service: <CBService: 0x137e84ea0, isPrimary = YES, UUID = FFE0>
Characteristic: nil

我是 arduino 和 iOS 方面的初学者。因此,欢迎提出任何建议。也许有一种方法可以在不知道特性的情况下写入蓝牙模块……我不知道。

最佳答案

我终于找到了答案。由于我对 CoreBluetooth 框架的初步了解,我忘记在 didDiscoverServices 中调用 discoverCharacteristics。好吧,我真的是边做边学。 (我以某种方式认为 discoverServices 会调用 discoverCharacteristics 本身。)

关于ios - 如何在 iOS 中获取 HM-10 Bluetooth LE 的特性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34270236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com