我一直在使用 nrf51x。我有一个用 Obj-C 编写的示例代码。我无法将其转换为 Swift。
uint8_t value = ACTIVATE_AND_RESET_REQUEST;
[self.bluetoothPeripheral writeValue:[NSData dataWithBytes:&value length:sizeof(value)] forCharacteristic:self.dfuControlPointCharacteristic type:CBCharacteristicWriteWithResponse];
我试过了
var value: UInt8 = DfuOperations.VALIDATE_FIRMWARE_REQUEST.rawValue
let ptr = UnsafePointer<Void>(value)
let data = NSData(ptr, length: sizeofValue(value))
dfuPeripheral!.writeValue(data, forCharacteristic: self.dfuControlPointCharacteristic, type: CBCharacteristicWriteType.WithResponse)
和这个
var value: UInt8 = DfuOperations.VALIDATE_FIRMWARE_REQUEST.rawValue
let data = NSData(&value, length: sizeofValue(value))
谁能帮我?非常感谢