-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.juul.kable | ||
|
||
import com.benasher44.uuid.Uuid | ||
|
||
public class OptionsBuilder internal constructor() { | ||
|
||
private var filterPredicates: List<FilterPredicate> = emptyList() | ||
|
||
/** | ||
* Filters to apply when requesting devices. If predicates are non-empty, then only devices | ||
* that match at least one of the predicates will appear in the `requestDevice` picker. | ||
* | ||
* Filtering on Service Data is not supported because it is not implemented: | ||
* https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md | ||
* | ||
* Filtering on Manufacturer Data is supported and a good explanation can be found here: | ||
* https://github.com/WebBluetoothCG/web-bluetooth/blob/main/data-filters-explainer.md | ||
*/ | ||
public fun filters(builder: FiltersBuilder.() -> Unit) { | ||
filterPredicates = FiltersBuilder().apply(builder).build() | ||
} | ||
|
||
/** | ||
* Access is only granted to services listed as [service filters][Filter.Service] in [filters]. | ||
* If any additional services need to be accessed, they must be specified in [optionalServices]. | ||
* | ||
* https://webbluetoothcg.github.io/web-bluetooth/#device-discovery | ||
*/ | ||
public var optionalServices: List<Uuid>? = null | ||
|
||
internal fun build() = Options(null, optionalServices, filterPredicates) | ||
} |