Add filter for and services#24
Conversation
|
Wilson Jaramillo seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
jpsoultanis
left a comment
There was a problem hiding this comment.
Thanks for the contribution to RxCBCentral! In general things look good, just please cleanup debugging comments and remove your print statements.
| func notificationData(for characteristic: CBUUID) -> Observable<Data> | ||
|
|
||
| /// Validate if service exist | ||
| func hasService(service: CBUUID) -> Observable<Bool> |
There was a problem hiding this comment.
Nice addition, can you use modify this interface to use more Swift style naming, like:
func hasService(_ service: CBUUID) -> Observable<Bool>
| print("RFN ",services.count, services) | ||
| print("RFN ",services.first?.uuid.uuidString, service.uuidString) |
There was a problem hiding this comment.
Printing is helpful for debugging purposes but we don't want to ship the library with live print statements. Please remove or add these to the logger.
| print("RFN characteristics ",characteristics.count, characteristics) | ||
| for c in characteristics { | ||
| print(c.uuid.uuidString, characteristic.uuidString) | ||
| if(c.uuid.uuidString == characteristic.uuidString){ | ||
| return (c, error) | ||
| } | ||
| } | ||
| print("not found , what to do, raise an error") | ||
| return (characteristics.first,GattError.characteristicNotFound) | ||
| // print("RFN ",characteristics.first?.uuid.uuidString , characteristic.uuidString) | ||
| // let characteristic = characteristics.first { $0.uuid.uuidString == characteristic.uuidString } | ||
| // return (characteristic, error) |
| // des.setValue(<#T##value: Any?##Any?#>, forKey: <#T##String#>) | ||
| print("BEGIN:SPAKA DESCRIPTOR========>\(des)") | ||
| // self.peripheral.setNotifyValue(true, for: characteristic) |
| if characteristic.value != nil { | ||
| let value = characteristic.value?.subdata(in: Range(1...2)).withUnsafeBytes {$0.load(as: UInt8.self)} | ||
| print("didUpdateValueFor Characteristic", characteristic, " value:", value ?? "No data 324") | ||
| } |
There was a problem hiding this comment.
Please delete, since we don't want to ship the library with live print statements
| func notificationData(for characteristic: CBUUID) -> Observable<Data> | ||
|
|
||
| /// Validate if service exist | ||
| func hasService(service: CBUUID) -> Observable<Bool> |
There was a problem hiding this comment.
| func hasService(service: CBUUID) -> Observable<Bool> | |
| func hasService(_ service: CBUUID) -> Observable<Bool> |
| if (services.count == 0){ | ||
| return false | ||
| } else { | ||
| return true | ||
| } |
There was a problem hiding this comment.
| if (services.count == 0){ | |
| return false | |
| } else { | |
| return true | |
| } | |
| return services.count == 0 ? false : true |
| } | ||
| .take(1) | ||
| .map { (characteristics: [CBCharacteristic], error: Error?) -> (CBCharacteristic?, Error?) in | ||
| print("READ \(#line) ",characteristics.first?.uuid.uuidString,characteristic.uuidString) |
There was a problem hiding this comment.
| print("READ \(#line) ",characteristics.first?.uuid.uuidString,characteristic.uuidString) |
| print("READ \(#line) ",characteristics.first?.uuid.uuidString,characteristic.uuidString) | ||
| // check that given characteristic exists on the peripheral | ||
| let characteristic = characteristics.first { $0.uuid.uuidString == characteristic.uuidString } | ||
| print("READ after \(#line) ",characteristic) |
There was a problem hiding this comment.
| print("READ after \(#line) ",characteristic) |
| } | ||
| .take(1) | ||
| .flatMapLatest { (matchingService: CBService?, error: Error?) -> Observable<([CBCharacteristic], Error?)> in | ||
| print("MATCHINGSERVICE :",matchingService) |
There was a problem hiding this comment.
| print("MATCHINGSERVICE :",matchingService) |
| if characteristic.value != nil { | ||
| let cmd = [UInt8](characteristic.value ?? Data(_:[0x00])) | ||
| print("didUpdateValueFor UINT8: ",cmd) | ||
| } |
There was a problem hiding this comment.
| if characteristic.value != nil { | |
| let cmd = [UInt8](characteristic.value ?? Data(_:[0x00])) | |
| print("didUpdateValueFor UINT8: ",cmd) | |
| } |
|
|
||
| public class CBPeripheralTypeMock: CBPeripheralType { | ||
| public func discoverDescriptors(for characteristic: CBCharacteristic) { | ||
| print("ok") |
| public func hasService(service: CBUUID) -> Observable<Bool>{ | ||
| return Observable.just(true) | ||
| } | ||
| public func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor? = nil) -> Observable<Bool>{ | ||
| return Observable.just(true) | ||
| } |
There was a problem hiding this comment.
| public func hasService(service: CBUUID) -> Observable<Bool>{ | |
| return Observable.just(true) | |
| } | |
| public func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor? = nil) -> Observable<Bool>{ | |
| return Observable.just(true) | |
| } | |
| public func hasService(service: CBUUID) -> Observable<Bool>{ | |
| return Observable.just(true) | |
| } | |
| public func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor? = nil) -> Observable<Bool>{ | |
| return Observable.just(true) | |
| } |
| } | ||
|
|
||
| public func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor? = nil) -> Observable<Bool>{ | ||
| print("setIndicateDescriptor") |
There was a problem hiding this comment.
| print("setIndicateDescriptor") |
| } | ||
| .take(1) | ||
| .flatMapLatest { (matchingService: CBService?, error: Error?) -> Observable<([CBCharacteristic], Error?)> in | ||
| print("MATCHINGSERVICE SID :",matchingService) |
There was a problem hiding this comment.
| print("MATCHINGSERVICE SID :",matchingService) |
No description provided.