Conceptual questions. Why do we have to discover services again?
Ricardo1980 opened this issue · 1 comments
Hello,
There is something I don't understand here:
manager.scanForPeripherals(withServices: [serviceId])
.take(1)
.flatMap { $0.peripheral.establishConnection() }
.flatMap { $0.discoverServices([serviceId]) }
.flatMap { Observable.from($0) }
.flatMap { $0.discoverCharacteristics([characteristicId]) }
.flatMap { Observable.from($0) }
.flatMap { $0.readValue() }
.subscribe(onNext: { print("Value: \($0.value)") })
What is the reason of using discoverServices if we already know that the device has the service we want? (using scanForPeripherals)
And another question, in iOS, can I use a service that is not being advertised?
It seems in android is possible but according to this, that is not possible in iOS (second response):
https://stackoverflow.com/questions/45896372/ios-how-to-discover-unadvertised-services-on-a-ble-peripheral
What do you think about that? Thanks a lot.
using scanForPeripherals only get peripheral and advertisementData,sure,you can get serverid from advertisementData,but the serverid from advertisementData is not always equal to the serviceid
from discoverServices