Skip to content

Commit

Permalink
Version information included
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Mar 22, 2022
1 parent 995a843 commit fba63e6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
Expand Up @@ -45,6 +45,7 @@ val BleManager.bondingState: BondState
* Multiple calls for this method return the same object.
* If a different connection observer was set using [BleManager.setConnectionObserver], this
* method will throw [IllegalStateException].
* @since 2.3.0
*/
fun BleManager.stateAsFlow(): StateFlow<ConnectionState> = with(connectionObserver) {
when (this) {
Expand All @@ -59,6 +60,7 @@ fun BleManager.stateAsFlow(): StateFlow<ConnectionState> = with(connectionObserv
* Multiple calls for this method return the same object.
* If a different bond state observer was set using [BleManager.setBondingObserver], this
* method will throw [IllegalStateException].
* @since 2.3.0
*/
fun BleManager.bondingStateAsFlow(): StateFlow<BondState> = with(bondingObserver) {
when (this) {
Expand Down
Expand Up @@ -16,6 +16,7 @@ import java.util.UUID
* manually.
*
* @return GATT characteristic object or null if no characteristic was found.
* @since 2.3.0
*/
fun BluetoothGattService.getCharacteristic(
uuid: UUID,
Expand Down
Expand Up @@ -13,6 +13,7 @@ import no.nordicsemi.android.ble.data.DefaultMtuSplitter
/**
* The upload or download progress indication.
*
* @since 2.4.0
* @property index The 0-based index of the packet. Only the packets that passed the filter
* will be reported. As the number of expected packets is not know, it is up to the
* application to calculate the real progress based on the index and data length.
Expand Down Expand Up @@ -48,6 +49,7 @@ data class ProgressIndication(val index: Int, val data: ByteArray?) {
* The returned flow will be notified each time a new packet is received.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun ReadRequest.mergeWithProgressFlow(merger: DataMerger): Flow<ProgressIndication> {
// Make sure the callbacks are called without unnecessary delay.
Expand Down Expand Up @@ -75,6 +77,7 @@ fun ReadRequest.mergeWithProgressFlow(merger: DataMerger): Flow<ProgressIndicati
* The returned flow will be notified each time a new packet is received.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun WaitForValueChangedRequest.mergeWithProgressFlow(merger: DataMerger): Flow<ProgressIndication> {
// Make sure the callbacks are called without unnecessary delay.
Expand Down Expand Up @@ -102,6 +105,7 @@ fun WaitForValueChangedRequest.mergeWithProgressFlow(merger: DataMerger): Flow<P
* The returned flow will be notified each time a new packet is received.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun ValueChangedCallback.mergeWithProgressFlow(merger: DataMerger): Flow<ProgressIndication> {
// Make sure the callbacks are called without unnecessary delay.
Expand Down Expand Up @@ -129,6 +133,7 @@ fun ValueChangedCallback.mergeWithProgressFlow(merger: DataMerger): Flow<Progres
* The returned flow will be notified each time a new packet is sent.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun WriteRequest.splitWithProgressFlow(): Flow<ProgressIndication> = splitWithProgressFlow(DefaultMtuSplitter())

Expand All @@ -140,6 +145,7 @@ fun WriteRequest.splitWithProgressFlow(): Flow<ProgressIndication> = splitWithPr
* The returned flow will be notified each time a new packet is sent.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun WriteRequest.splitWithProgressFlow(splitter: DataSplitter): Flow<ProgressIndication> {
// Make sure the callbacks are called without unnecessary delay.
Expand Down Expand Up @@ -167,6 +173,7 @@ fun WriteRequest.splitWithProgressFlow(splitter: DataSplitter): Flow<ProgressInd
* The returned flow will be notified each time a new packet is sent.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun WaitForReadRequest.splitWithProgressFlow(): Flow<ProgressIndication> = splitWithProgressFlow(DefaultMtuSplitter())

Expand All @@ -178,6 +185,7 @@ fun WaitForReadRequest.splitWithProgressFlow(): Flow<ProgressIndication> = split
* The returned flow will be notified each time a new packet is sent.
*
* @return The flow with progress indications.
* @since 2.4.0
*/
fun WaitForReadRequest.splitWithProgressFlow(splitter: DataSplitter): Flow<ProgressIndication> {
// Make sure the callbacks are called without unnecessary delay.
Expand Down
Expand Up @@ -16,6 +16,7 @@ import kotlin.coroutines.resumeWithException

/**
* Suspends the coroutine until the request is completed.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -28,6 +29,7 @@ suspend fun Request.suspend() = suspendCancellable()
/**
* Suspends the coroutine until the data have been written.
* @return The data written.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down Expand Up @@ -58,6 +60,7 @@ suspend fun WriteRequest.suspend(): Data {
* ).suspendForResponse()
*
* @return The data written parsed to required type.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -78,6 +81,7 @@ suspend inline fun <reified T: WriteResponse> WriteRequest.suspendForResponse():
/**
* Suspends the coroutine until the data have been read.
* @return The data read.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -103,6 +107,7 @@ suspend fun ReadRequest.suspend(): Data {
* .suspendForResponse()
*
* @return The data read parsed to required type.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down Expand Up @@ -131,6 +136,7 @@ suspend inline fun <reified T: ReadResponse> ReadRequest.suspendForResponse(): T
* .suspendForValidResponse()
*
* @return The data read parsed to required type.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -147,6 +153,7 @@ suspend inline fun <reified T: ProfileReadResponse> ReadRequest.suspendForValidR
/**
* Suspends the coroutine until the RSSI value is received.
* @return The current RSSI value.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -165,6 +172,7 @@ suspend fun ReadRssiRequest.suspend(): Int {
/**
* Suspends the coroutine until the MTU value is received.
* @return The current MTU value.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -183,6 +191,7 @@ suspend fun MtuRequest.suspend(): Int {
/**
* Suspends the coroutine until the TX and RX PHY values are received.
* @return A pair of TX and RX PHYs.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -201,6 +210,7 @@ suspend fun PhyRequest.suspend(): Pair<Int, Int> {
/**
* Suspends the coroutine until the value of the attribute has changed.
* @return The new value of the attribute.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down Expand Up @@ -236,6 +246,7 @@ suspend fun WaitForValueChangedRequest.suspend(): Data = suspendCancellableCoro
* .suspendForResponse()
*
* @return The new value of the attribute.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down Expand Up @@ -263,6 +274,7 @@ suspend inline fun <reified T: ReadResponse> WaitForValueChangedRequest.suspendF
* .suspendForValidResponse()
*
* @return The new value of the attribute.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand All @@ -279,6 +291,7 @@ suspend inline fun <reified T: ProfileReadResponse> WaitForValueChangedRequest.s
/**
* Suspends the coroutine until the value of the attribute has changed.
* @return The new value of the attribute.
* @since 2.3.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down Expand Up @@ -318,6 +331,7 @@ suspend fun WaitForReadRequest.suspend(): Data = suspendCancellableCoroutine {
* .suspendForResponse()
*
* @return The new value of the attribute.
* @since 2.4.0
*/
@Throws(
BluetoothDisabledException::class,
Expand Down
Expand Up @@ -18,6 +18,7 @@ import no.nordicsemi.android.ble.response.ReadResponse
*
* val hrmMeasurementsData = setNotificationCallback(hrmCharacteristic).asFlow() // Flow<Data>
* @return The flow.
* @since 2.3.0
*/
@ExperimentalCoroutinesApi
fun ValueChangedCallback.asFlow(): Flow<Data> = callbackFlow {
Expand All @@ -41,6 +42,7 @@ fun ValueChangedCallback.asFlow(): Flow<Data> = callbackFlow {
* setNotificationCallback(hrmCharacteristic)
* .asResponseFlow()
* @return The flow.
* @since 2.4.0
*/
@ExperimentalCoroutinesApi
inline fun <reified T: ReadResponse> ValueChangedCallback.asResponseFlow(): Flow<T> = callbackFlow {
Expand All @@ -65,6 +67,7 @@ inline fun <reified T: ReadResponse> ValueChangedCallback.asResponseFlow(): Flow
* setNotificationCallback(hrmCharacteristic)
* .asValidResponseFlow()
* @return The flow.
* @since 2.4.0
*/
@ExperimentalCoroutinesApi
inline fun <reified T: ProfileReadResponse> ValueChangedCallback.asValidResponseFlow(): Flow<T> = callbackFlow {
Expand Down

0 comments on commit fba63e6

Please sign in to comment.