IOS Core Bluetooth : Writing NSData for Characteristic

后端 未结 5 1093
花落未央
花落未央 2021-02-11 01:48

I am using the following code to write the 0xDE value for a Bluetooth Caracteristic (Reset Device) using the IOS Core Bluetooth :

...
NSData *bytes = [@\"0xDE\"          


        
5条回答
  •  没有蜡笔的小新
    2021-02-11 02:09

    Swift 3.0: In case anyone is wondering the format for Swift is slightly different as writeValue can get the count from the array.

    let value: UInt8 = 0xDE
    let data = Data(bytes: [value])
    peripheral.writeValue(data, for: characteristic, type: .withResponse)
    

提交回复
热议问题