gpt4 book ai didi

ios - 卡里斯塔 OBD ||与 iOS 设备的设备通信

转载 作者:行者123 更新时间:2023-11-30 11:16:02 25 4
gpt4 key购买 nike

我刚刚开始与 Carista 设备通信。我得到了所有的服务和特征。但是当我写命令“ATZ”时,它会给出答案“ATZ”。

我期望从设备获得的实际结果是“ATZELM327 v1.5”

这里我附上了我的代码审查。

func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
guard let characteristics = service.characteristics else { return }
for characteristic in characteristics {
print(characteristic)
caristaPeripheral.setNotifyValue(true, for: characteristic)
let ATZCommand = "ATZ"
let ATZBytes = ATZCommand.data(using: .utf8)
caristaPeripheral.writeValue(ATZBytes!, for: characteristic, type: .withResponse)
}
}


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

let string = String(data: characteristic.value!, encoding: .utf8)

print("CBCharacteristic : \(characteristic.uuid) ====> \(string ?? "none")")

}

请指导我。

最佳答案

我已经找到了解决方案,如下。此时我们在Cari​​sta设备中写入任何命令时都需要附加“\r\n”。因此,根据上面的问题,我们需要将 let ATZCommand = "ATZ" 替换为 let ATZCommand = "ATZ\r\n"

现在,我根据异常情况从 Carista 设备获得了准确的响应。

谢谢......:)

关于ios - 卡里斯塔 OBD ||与 iOS 设备的设备通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51743745/

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