PolarRestServiceApi

public protocol PolarRestServiceApi

Methods related to working with services conforming to SAGRFC95 Service discovery over PFTP

  • Discover available services from device

    Declaration

    Swift

    func listRestApiServices(identifier: String) -> Single<PolarDeviceRestApiServices>

    Parameters

    identifier

    Polar Device ID or BT address

    Return Value

    emits single PolarDeviceRestApiServices object listing service names and corresponding paths or error

  • Get details related to particular REST API.

    Declaration

    Swift

    func getRestApiDescription(identifier: String, path: String) -> Single<PolarDeviceRestApiServiceDescription>

    Parameters

    identifier

    Polar Device ID or BT address

    path

    the REST API path corresponding to a named service returned by listRestApiServices

    Return Value

    emits single PolarDeviceRestApiServiceDescription object with detailed description of the service or error

  • Notify device via a REST API in the device.

    Declaration

    Swift

    func putNotification(identifier: String, notification: String, path: String) -> Completable

    Parameters

    identifier

    Polar device ID or BT address

    notification

    content of the notification in JSON format.

    path

    the API endpoint that will be notified; the path of the REST API file in device + REST API parameters.

    Return Value

    Completable emitting success or error

  • Streams for received device REST API events parameters decoded as given Decodable type T endlessly. Only dispose , take(1) etc … stops stream.

    Normally requires event action that enables subscribing to the event using putNotification()

    Declaration

    Swift

    func receiveRestApiEvents<T>(identifier: String) -> Observable<[T]> where T : Decodable

    Parameters

    identifier

    Polar device ID or BT address

    Return Value

    Observable stream of REST API event parameters decoded as decodable T from JSON format. Produces onNext after successfully received notification and decoded as [T]. onCompleted not produced unless stream is further configured. onError, see BlePsFtpException, BleGattException