0
  <CBCharacteristic: 0x281bc6100, UUID = FFF1, properties = 0x10, value = <500c0b62 00008f2c 10223344 55660000 00000000>, notifying = NO>

i want this value " <500c0b62 00008f2c 10223344 55660000 00000000>"

can any one help me ?

  • 1
    `let value = myCharacteristic.value`. Now, what's supposed to be " <500c0b62 00008f2c 10223344 55660000 00000000>"? What is it supposed to mean? Is that a "text"? A custom struct you send? We can't guess how to parse it without infos of the specs of your peripheral. – Larme Dec 05 '18 at 09:32
  • i want to print this value <500c0b62 00008f2c 10223344 55660000 00000000> from peripheral.how can i get this value ?. – Vadlapalli Masthan Dec 05 '18 at 09:38
  • 1
    `let value = myCharacteristic.value`. But `<500c0b62 00008f2c 10223344 55660000 00000000>` is more a debug value, you can get it with `print("\(value as NSData)")`, but printing hex data seems weird. You can check https://stackoverflow.com/questions/39075043/how-to-convert-data-to-hex-string-in-swift for the hex representation. – Larme Dec 05 '18 at 09:40
  • thanks...you so much i got value. – Vadlapalli Masthan Dec 05 '18 at 09:47

1 Answers1

-1

Try this

if(characteristic.value != nil){
            if let ASCIIstring = NSString(data: characteristic.value!, encoding: String.Encoding.utf8.rawValue) {
                characteristicASCIIValue = ASCIIstring
                print("Value Recieved: \((characteristicASCIIValue as String))")

            }
        }
Shahzaib Qureshi
  • 989
  • 8
  • 13
  • Please don't do `if(characteristic.value != nil)` and then `characteristic.value!`: instead, directly safely unwrap with "if let", it's much better and swifty. – Eric Aya Dec 06 '18 at 13:06