jordanebelanger / SwiftyBluetooth

Closures based APIs for CoreBluetooth
MIT License
209 stars 66 forks source link

Did not get characteristic value in notification #31

Closed Lufthummel closed 3 years ago

Lufthummel commented 6 years ago

I try to get the actual value of a notification. Example code:

self.peripherals[selected].setNotifyValue(toEnabled: true, forCharacWithUUID: cuuid, ofServiceWithUUID: suuid) { (result) in

        self.log.debug("Notyfying  \(result)")
        self.log.debug("Notyfying  value \(result.value)")
        self.log.debug("Notyfying  description \(result.description)")
        self.log.debug("Notyfying  debug description \(result.debugDescription)")
        self.log.debug("Notyfying  debug description \(result.value)")

    }

The given documentation is not working .. { (isnotifying, error) in ... so that needs to be changed I guess.

So far this works fine but value contains only true

Output:

2018-03-10 15:51:23.873 [Debug] [ViewController.swift:88] notifierTest > Notyfying SUCCESS 2018-03-10 15:51:23.873 [Debug] [ViewController.swift:89] notifierTest > Notyfying value Optional(true) 2018-03-10 15:51:23.873 [Debug] [ViewController.swift:90] notifierTest > Notyfying description SUCCESS 2018-03-10 15:51:23.874 [Debug] [ViewController.swift:91] notifierTest > Notyfying debug description SUCCESS: true

I was expecting the actual values of the changed characteristic (eg.data values).

Maybe I do something wrong, any help appreciated here.

mrommel commented 6 years ago

It's a Result, so the usual {code} switch result { case .success(let data): break // The data was read and is returned as an NSData instance case .failure(let error): break // An error happened while attempting to read the data } {code} will apply here as well.

Not tested