【问题标题】:How to retrieve DEX from dex wireless adaptor with iOS CoreBluetooth?如何使用 iOS CoreBluetooth 从 dex 无线适配器中检索 DEX?
【发布时间】:2017-07-01 04:21:55
【问题描述】:

我目前有一个 Honeywell 的 DEX BLE-1 适配器,用于从自动售货机检索 dex 数据。我有一个 swift 3 iOS 应用程序,它使用 CoreBluetooth 进行扫描并与外围设备配对。该适配器具有三种服务:串口、电池和dex服务。 dex 服务具有三个特征:固件版本、会话和设置。我想会话特征用于检索 dex;但是,我不知道该怎么做。

我使用didUpdateValueFor外围方法获取与会话特征的uuid相关的值,但该值为nil。

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {

        if characterstic.uuid.uuidString == uuidSession {
            if(characteristic.value != nil) {
                print(characterstic.value)
            }
        }
}

是否应该从会话特征值中检索 DEX?它似乎是几个字节,也许我必须连接字节?但无论如何,价值为零。我是新手,但这应该通过串口完成吗?我在某处读到你可以通过它建立连接,还是完全关闭?

【问题讨论】:

  • 以上你回答了吗?我们需要使用任何 SDK 吗?

标签: ios swift bluetooth-lowenergy core-bluetooth gatt


【解决方案1】:

与自动售货机的 DEX 通信是串行端口连接。

新的 Blu-DEX 是 BLE 4.0,适用于 Android 和 Apple。

【讨论】:

  • 那么,DEX BLE-1适配器不支持串口连接?我确实看到了服务和特征数据和状态。我必须得到另一个?
  • 问题是我使用核心蓝牙在我的 iOS 应用程序中获取串行端口服务。我得到了服务的“数据”特征,它是空的。您如何通过此服务检索 dex? DEX可以存储在特征中吗?
【解决方案2】:

您只是在寻找字符或价值?

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {

    let readValue = characteristic.value
    if let str = String(data: readValue!, encoding: String.Encoding.utf8) {
        print("Line \(index): \(str)")
        index += 1
    } else {
        print("Received an invalid string!")
    }

}

【讨论】:

    猜你喜欢
    • 2021-04-15
    • 2018-01-20
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 2013-10-09
    • 2018-02-26
    相关资源
    最近更新 更多