![](/img/trans.png)
[英]Convert from Nsnumber to data to send rssi to bluetooth module IOS swift 4
[英]sending data to bluetooth module to be read by arduino rom iOS swift 3
如果我想将数据发送到已连接至Arduino的蓝牙模块,则需要特别注意哪些代码行。
我想向蓝牙模块发送数字“ 75”,Arduino会读取它
谢谢
蓝牙LE很长而且很麻烦,介于两者之间。 写入数据的最小路径是:
CBPeripheralDelegate.peripheral:didDiscoverCharacteristicsFor:service如果特性数组中的一个特性是您想要的,则:
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { guard let characteristics = service.characteristics else { return } for characteristic in characteristics { if characteristic.uuid == CBUUID(string: characteristicIdentifier) { let value: UInt8 = 75 let data = Data(bytes: [value]) peripheral.writeValue(data, for: characteristic, type: .withResponse) } } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.