Skip to content

Instantly share code, notes, and snippets.

@yostane
Created March 15, 2017 16:03
Show Gist options
  • Select an option

  • Save yostane/56bb6378ad214823be96ac5fcf11d0d4 to your computer and use it in GitHub Desktop.

Select an option

Save yostane/56bb6378ad214823be96ac5fcf11d0d4 to your computer and use it in GitHub Desktop.
//we will next discover the "ec00" service in order be able to access its characteristics
let discoveryFuture = connectionFuture.flatMap { peripheral -> Future<Peripheral> in
return peripheral.discoverServices([serviceUUID])
}.flatMap { discoveredPeripheral -> Future<Service> in
guard let service = discoveredPeripheral.service(serviceUUID) else {
throw AppError.serviceNotFound
}
peripheral = discoveredPeripheral
DispatchQueue.main.async {
self.connectionStatusLabel.text = "Discovered service \(service.uuid.uuidString). Trying to discover characteristics"
print(self.connectionStatusLabel.text!)
}
//we have discovered the service, the next step is to discover the "ec0e" characteristic
return service.discoverCharacteristics([dateCharacteristicUUID])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment