Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter for and services #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/RxCBCentral/RxPeripheral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public protocol RxPeripheral: AnyObject {
/// The data returned will be processed by the `Preprocessor` given when registering
/// for notifications for this `characteristic`, if one was provided.
func notificationData(for characteristic: CBUUID) -> Observable<Data>

/// Validate if service exist
func hasService(service: CBUUID) -> Observable<Bool>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, can you use modify this interface to use more Swift style naming, like:

func hasService(_ service: CBUUID) -> Observable<Bool>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func hasService(service: CBUUID) -> Observable<Bool>
func hasService(_ service: CBUUID) -> Observable<Bool>


func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor?) -> Observable<Bool>

}

/// Aggregates Data for the purpose of demarcation.
Expand Down
1 change: 1 addition & 0 deletions Sources/RxCBCentral/core/CBPeripheralType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public protocol CBPeripheralType: AnyObject {
func maximumWriteValueLength(for type: CBCharacteristicWriteType) -> Int

func discoverServices(_ serviceUUIDs: [CBUUID]?)
func discoverDescriptors(for characteristic: CBCharacteristic)
func discoverCharacteristics(_ characteristicUUIDs: [CBUUID]?, for service: CBService)

func readValue(for characteristic: CBCharacteristic)
Expand Down
209 changes: 202 additions & 7 deletions Sources/RxCBCentral/core/RxPeripheralImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
}

public func read(service: CBUUID, characteristic: CBUUID) -> Single<Data?> {

print("READ RxPeripheralImpl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("READ RxPeripheralImpl")

return connectionState

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

.flatMapLatest { (state: ConnectionState) -> Observable<([CBService], Error?)> in
guard case let .connected(peripheral) = state,
let cbPeripheral = peripheral as? CBPeripheral,
Expand All @@ -70,6 +71,12 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
self.peripheral.discoverServices([service])

return self.didDiscoverServicesSubject.asObservable()
}.filter { (services: [CBService], error: Error?) -> Bool in
if (services.count == 0){
return false
} else {
return true
}
Comment on lines +75 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (services.count == 0){
return false
} else {
return true
}
return services.count == 0 ? false : true

}
.map { (services: [CBService], error: Error?) -> (CBService?, Error?) in
// check that given service exists on the peripheral
Expand All @@ -94,8 +101,10 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
}
.take(1)
.map { (characteristics: [CBCharacteristic], error: Error?) -> (CBCharacteristic?, Error?) in
print("READ \(#line) ",characteristics.first?.uuid.uuidString,characteristic.uuidString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("READ after \(#line) ",characteristic)

return (characteristic, error)
}
.flatMapLatest { (matchingCharacteristic: CBCharacteristic?, error: Error?) -> Observable<(CBCharacteristic, Error?)> in
Expand Down Expand Up @@ -189,11 +198,14 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
return
didDiscoverServicesSubject
.map { (services: [CBService], error: Error?) -> (CBService?, Error?) in
print("RFN ",services.count, services)
print("RFN ",services.first?.uuid.uuidString, service.uuidString)
Comment on lines +201 to +202
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +201 to +202
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN ",services.count, services)
print("RFN ",services.first?.uuid.uuidString, service.uuidString)

let matchingService = services.first { $0.uuid.uuidString == service.uuidString }
return (matchingService, error)
}
.take(1)
.flatMapLatest { (matchingService: CBService?, error: Error?) -> Observable<([CBCharacteristic], Error?)> in
print("MATCHINGSERVICE :",matchingService)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("MATCHINGSERVICE :",matchingService)

guard let matchingService = matchingService else {
RxCBLogger.sharedInstance.log("Error: service not found")
return Observable.error(GattError.serviceNotFound)
Expand All @@ -204,14 +216,34 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
return Observable.error(error)
}

print("CHARACTERISTIC TO SEARCH: ",characteristic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("CHARACTERISTIC TO SEARCH: ",characteristic)

self.peripheral.discoverCharacteristics([characteristic], for: matchingService)

return self.didDiscoverCharacteristicsSubject.asObservable()
}
.filter { (characteristics: [CBCharacteristic], error: Error?) -> Bool in
for c in characteristics{
print(c.uuid.uuidString, characteristic.uuidString)
if(c.uuid.uuidString == characteristic.uuidString){
return true
}
}
return false
}
Comment on lines +224 to +232
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.filter { (characteristics: [CBCharacteristic], error: Error?) -> Bool in
for c in characteristics{
print(c.uuid.uuidString, characteristic.uuidString)
if(c.uuid.uuidString == characteristic.uuidString){
return true
}
}
return false
}
.filter { (characteristics: [CBCharacteristic], error: Error?) -> Bool in
for c in characteristics where c.uuid.uuidString == characteristic.uuidString {
return true
}
return false
}

.take(1)
.map { (characteristics: [CBCharacteristic], error: Error?) -> (CBCharacteristic?, Error?) in
let characteristic = characteristics.first { $0.uuid.uuidString == characteristic.uuidString }
return (characteristic, error)
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)
Comment on lines +235 to +246
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup required

Comment on lines +235 to +246
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
for c in characteristics where c.uuid.uuidString == characteristic.uuidString {
return (c, error)
}
return (characteristics.first, GattError.characteristicNotFound)

}
.do(onNext: { [weak self] (_, error: Error?) in
if let self = self, error == nil {
Expand All @@ -224,6 +256,7 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
}
})
.flatMapLatest { (matchingCharacteristic: CBCharacteristic?, error: Error?) -> Observable<(CBCharacteristic, Error?)> in
print("RFN \(#line)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN \(#line)")

guard let matchingCharacteristic = matchingCharacteristic else {
RxCBLogger.sharedInstance.log("Error: characteristic not found")
return Observable.error(GattError.characteristicNotFound)
Expand All @@ -235,14 +268,15 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
}
// let CB give an error if property isn't notify-able
self.peripheral.setNotifyValue(true, for: matchingCharacteristic)

print("RFN \(#line)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN \(#line)")

return self.didUpdateValueForCharacteristicSubject.asObservable()
}
.take(1)
.flatMapLatest { (_, error: Error?) -> Completable in
if let error = error {
return Observable.error(error).asCompletable()
}
print("RFN completed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN completed")

return Observable.empty().asCompletable()
}
.take(1)
Expand All @@ -253,27 +287,170 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
}

public func notificationData(for characteristic: CBUUID) -> Observable<Data> {
print("notificationData Enabled for: ",characteristic.uuidString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("notificationData Enabled for: ",characteristic.uuidString)

return didUpdateValueForCharacteristicSubject
.filter { (arg: (CBCharacteristic, Error?)) -> Bool in
let (notifyCharacteristic, error) = arg
print("notificationData \(#line): ",notifyCharacteristic.uuid.uuidString, " match char: ",characteristic.uuidString, " error: ",error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("notificationData \(#line): ",notifyCharacteristic.uuid.uuidString, " match char: ",characteristic.uuidString, " error: ",error)

return characteristic.uuidString == notifyCharacteristic.uuid.uuidString && error == nil
}
.flatMap { [weak self] (notifyCharacteristic: CBCharacteristic, _) -> Observable<Data?> in
var processedData: Data? = nil

print("notificationData \(#line): ",notifyCharacteristic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("notificationData \(#line): ",notifyCharacteristic)

guard let `self` = self, let data = notifyCharacteristic.value else { return Observable.just(nil) }

print("notificationData Data\(#line): ",data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("notificationData Data\(#line): ",data)

self.synchronized(self.processSync) {
if let preprocessor = self.preprocessorDict[characteristic] {
processedData = preprocessor.process(data: data)
}
}

print("notificationData processedData\(#line): ",processedData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("notificationData processedData\(#line): ",processedData)

return Observable.just(processedData)
}
.filterNil()
}

public func hasService(service: CBUUID) -> Observable<Bool> {
return
didDiscoverServicesSubject
.filter { (services: [CBService], error: Error?) -> Bool in
if (services.count == 0){
return false
} else {
return true
}
Comment on lines +317 to +321
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (services.count == 0){
return false
} else {
return true
}
return services.count == 0 ? false : true

}
.map { (services: [CBService], error: Error?) -> (CBService?, Error?) in
print("RFN ",services.count, services)
print("RFN ",services.first?.uuid.uuidString, service.uuidString)
Comment on lines +324 to +325
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN ",services.count, services)
print("RFN ",services.first?.uuid.uuidString, service.uuidString)

let matchingService = services.first { $0.uuid.uuidString == service.uuidString }
return (matchingService, error)
}
.take(1)
.flatMapLatest { (matchingService: CBService?, error: Error?) -> Observable<Bool> in
print("MATCHINGSERVICE :",matchingService)
guard let matchingService = matchingService else {
RxCBLogger.sharedInstance.log("Error: service not found")
return Observable.just(false)
}

if let error = error {
RxCBLogger.sharedInstance.log("Error: \(error.localizedDescription)")
return Observable.just(false)
}

return Observable.just(true)
}.do(onSubscribe: {
self.peripheral.discoverServices([service])
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}

public func setIndicateDescriptor(service: CBUUID, characteristic: CBUUID, preprocessor: Preprocessor? = nil) -> Observable<Bool>{
print("setIndicateDescriptor")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("setIndicateDescriptor")

return
didDiscoverServicesSubject
.map { (services: [CBService], error: Error?) -> (CBService?, Error?) in
let matchingService = services.first { $0.uuid.uuidString == service.uuidString }
return (matchingService, error)
}
.take(1)
.flatMapLatest { (matchingService: CBService?, error: Error?) -> Observable<([CBCharacteristic], Error?)> in
print("MATCHINGSERVICE SID :",matchingService)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("MATCHINGSERVICE SID :",matchingService)

guard let matchingService = matchingService else {
RxCBLogger.sharedInstance.log("Error: service not found")
return Observable.error(GattError.serviceNotFound)
}

if let error = error {
RxCBLogger.sharedInstance.log("Error: \(error.localizedDescription)")
return Observable.error(error)
}

print("CHARACTERISTIC TO SEARCH: ",characteristic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("CHARACTERISTIC TO SEARCH: ",characteristic)

self.peripheral.discoverCharacteristics([characteristic], for: matchingService)

return self.didDiscoverCharacteristicsSubject.asObservable()
}
.filter
{
print($0,$1)
for c in $0{
print(c.uuid.uuidString, characteristic.uuidString)
if(c.uuid.uuidString == characteristic.uuidString){
return true
}
}
return false
}
Comment on lines +375 to +385
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.filter
{
print($0,$1)
for c in $0{
print(c.uuid.uuidString, characteristic.uuidString)
if(c.uuid.uuidString == characteristic.uuidString){
return true
}
}
return false
}
.filter {
for c in $0 where c.uuid.uuidString == characteristic.uuidString {
return true
}
return false
}

.take(1)
.map {(characteristics: [CBCharacteristic], error: Error?) -> (CBCharacteristic?, Error?) in
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)
Comment on lines +388 to +396
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
for c in characteristics where c.uuid.uuidString == characteristic.uuidString {
return (c, error)
}
return (characteristics.first,GattError.characteristicNotFound)

}
.do(onNext: { [weak self] (_, error: Error?) in
if let self = self, error == nil {
// if given a preprocessor, track it with the char UUID
if let preprocessor = preprocessor {
self.synchronized(self.processSync) {
self.preprocessorDict[characteristic] = preprocessor
}
}
}
})
.flatMapLatest { (matchingCharacteristic: CBCharacteristic?, error: Error?) -> Observable<(CBCharacteristic, [CBDescriptor], Error?)> in
print("RFN \(#line)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("RFN \(#line)")

guard let matchingCharacteristic = matchingCharacteristic else {
RxCBLogger.sharedInstance.log("Error: characteristic not found")
return Observable.error(GattError.characteristicNotFound)
}

if let error = error {
RxCBLogger.sharedInstance.log("Error: \(error.localizedDescription)")
return Observable.error(error)
}
// let CB give an error if property isn't notify-able
self.peripheral.discoverDescriptors(for: matchingCharacteristic)
print("DiscoverDiscriptors \(#line)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("DiscoverDiscriptors \(#line)")

return self.didDiscoverDescriptorsForSubject.asObservable()
}
.take(1)
.flatMapLatest { (characteristic: CBCharacteristic?, descriptors: [CBDescriptor], error: Error?) -> Observable<Bool> in

guard let matchingCharacteristic = characteristic else {
RxCBLogger.sharedInstance.log("Error: characteristic not found")
return Observable.error(GattError.characteristicNotFound)
}

if let error = error {
RxCBLogger.sharedInstance.log("Error: \(error.localizedDescription)")
return Observable.error(error)
}

print("DescriptorsForChar: ",matchingCharacteristic.uuid.uuidString, descriptors)
print("PropertiesForChat: ",matchingCharacteristic.properties)

Comment on lines +437 to +439
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("DescriptorsForChar: ",matchingCharacteristic.uuid.uuidString, descriptors)
print("PropertiesForChat: ",matchingCharacteristic.properties)

for descriptor in descriptors{
print(descriptor)
// self.peripheral.writeValue(Data(_:[UInt8(0x20)]), for: descriptor)
}
Comment on lines +440 to +443
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please arrange here.

self.peripheral.setNotifyValue(true, for: matchingCharacteristic)

return Observable.just(true)
}
.do(onSubscribe: {
self.peripheral.discoverServices([service])
})
}


// MARK: - CBPeripheralDelegate

public func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?) {
Expand All @@ -294,9 +471,26 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
didDiscoverCharacteristicsSubject.onNext(characteristicsData)
}

public func peripheral(_ peripheral: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error: Error?) {
let discoveredDescriptors = characteristic.descriptors ?? []
let descriptorsData = (characteristic, discoveredDescriptors, error)
for des in discoveredDescriptors {
print("SET INDICATE FOR:SPAKA DESCRIPTOR========>\(des)")
// peripheral.writeValue(Data(_:[0x20]), for: des) //RAISE ERROR
// 'NSInternalInconsistencyException', reason: 'Client Characteristic Configuration descriptors must be configured using setNotifyValue:forCharacteristic:'

}
Comment on lines +477 to +482
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please arrange here.

didDiscoverDescriptorsForSubject.onNext(descriptorsData)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}

/// Invoked when you retrieve a characteristic’s value, or when the peripheral notifies you the value has changed
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
let valueData = (characteristic, error)
if characteristic.value != nil {
let cmd = [UInt8](characteristic.value ?? Data(_:[0x00]))
print("didUpdateValueFor UINT8: ",cmd)
}
Comment on lines +490 to +493
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if characteristic.value != nil {
let cmd = [UInt8](characteristic.value ?? Data(_:[0x00]))
print("didUpdateValueFor UINT8: ",cmd)
}

didUpdateValueForCharacteristicSubject.onNext(valueData)
}

Expand Down Expand Up @@ -328,6 +522,7 @@ class RxPeripheralImpl: NSObject, RxPeripheral, CBPeripheralDelegate {
private let didDiscoverCharacteristicsSubject = PublishSubject<([CBCharacteristic], Error?)>()
private let didUpdateValueForCharacteristicSubject = PublishSubject<(CBCharacteristic, Error?)>()
private let didWriteToCharacteristicSubject = PublishSubject<Error?>()
private let didDiscoverDescriptorsForSubject = PublishSubject<(CBCharacteristic, [CBDescriptor], Error?)>()
}

extension GattError: LocalizedError {
Expand Down
10 changes: 10 additions & 0 deletions Sources/RxCBCentral/mocks/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ public class BluetoothDetectorTypeMock: BluetoothDetectorType {
}

public class CBPeripheralTypeMock: CBPeripheralType {
public func discoverDescriptors(for characteristic: CBCharacteristic) {
print("ok")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please arrange here.

}


private var _doneInit = false
public init(identifier: UUID = UUID(), state: CBPeripheralState = .disconnected) {
Expand Down Expand Up @@ -566,6 +570,12 @@ public class RxPeripheralMock: RxPeripheral {
}
return Observable.empty()
}
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)
}
Comment on lines +573 to +578
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
}

}

class CBCentralManagerTypeMock: CBCentralManagerType {
Expand Down