-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all BLE logic in FlipperServiceApi (#83)
**Background** Sometime we want execute command longer than application exist **Changes** - Refactor FlipperBleManager - Move all logic to connect in FlipperServiceApi
- Loading branch information
Showing
73 changed files
with
1,979 additions
and
506 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- 'dev' | ||
|
||
env: | ||
VERSION: 0.2 | ||
VERSION: 0.3 | ||
|
||
jobs: | ||
build_internal_release: | ||
|
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
12 changes: 0 additions & 12 deletions
12
components/bridge/api/src/main/java/com/flipperdevices/bridge/api/device/FlipperDeviceApi.kt
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...bridge/api/src/main/java/com/flipperdevices/bridge/api/di/FlipperBleComponentInterface.kt
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.flipperdevices.bridge.api.di | ||
|
||
import com.flipperdevices.bridge.api.pair.FlipperPairApi | ||
import android.bluetooth.BluetoothAdapter | ||
import com.flipperdevices.bridge.api.scanner.FlipperScanner | ||
|
||
interface FlipperBleComponentInterface { | ||
val flipperScanner: FlipperScanner | ||
val flipperPairApi: FlipperPairApi | ||
val bluetoothAdapter: BluetoothAdapter | ||
} |
36 changes: 27 additions & 9 deletions
36
...nents/bridge/api/src/main/java/com/flipperdevices/bridge/api/manager/FlipperBleManager.kt
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 |
---|---|---|
@@ -1,15 +1,33 @@ | ||
package com.flipperdevices.bridge.api.manager | ||
|
||
import android.bluetooth.BluetoothDevice | ||
import com.flipperdevices.bridge.api.model.FlipperGATTInformation | ||
import kotlinx.coroutines.flow.StateFlow | ||
import no.nordicsemi.android.ble.ktx.state.ConnectionState | ||
import com.flipperdevices.bridge.api.manager.delegates.FlipperConnectionInformationApi | ||
import com.flipperdevices.bridge.api.manager.service.FlipperInformationApi | ||
import com.flipperdevices.bridge.api.manager.service.FlipperSerialApi | ||
|
||
interface FlipperBleManager : FlipperSerialApi { | ||
val isDeviceConnected: Boolean | ||
interface FlipperBleManager { | ||
// Manager delegates | ||
val connectionInformationApi: FlipperConnectionInformationApi | ||
|
||
// This section provide access to device apis | ||
val informationApi: FlipperInformationApi | ||
val flipperRequestApi: FlipperRequestApi | ||
fun getInformationStateFlow(): StateFlow<FlipperGATTInformation> | ||
fun getConnectionStateFlow(): StateFlow<ConnectionState> | ||
fun connectToDevice(device: BluetoothDevice) | ||
fun disconnectDevice() | ||
val serialApi: FlipperSerialApi | ||
|
||
/** | ||
* Connect to device {@param device} | ||
* Await while disconnect process is not finish | ||
*/ | ||
suspend fun connectToDevice(device: BluetoothDevice) | ||
|
||
/** | ||
* Disconnect from current device | ||
* Await while disconnect process is not finish | ||
*/ | ||
suspend fun disconnectDevice() | ||
|
||
/** | ||
* Close manager, unregister receivers | ||
*/ | ||
fun close() | ||
} |
9 changes: 9 additions & 0 deletions
9
...n/java/com/flipperdevices/bridge/api/manager/delegates/FlipperConnectionInformationApi.kt
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,9 @@ | ||
package com.flipperdevices.bridge.api.manager.delegates | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
import no.nordicsemi.android.ble.ktx.state.ConnectionState | ||
|
||
interface FlipperConnectionInformationApi { | ||
fun isDeviceConnected(): Boolean | ||
fun getConnectionStateFlow(): StateFlow<ConnectionState> | ||
} |
8 changes: 8 additions & 0 deletions
8
.../api/src/main/java/com/flipperdevices/bridge/api/manager/service/FlipperInformationApi.kt
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,8 @@ | ||
package com.flipperdevices.bridge.api.manager.service | ||
|
||
import com.flipperdevices.bridge.api.model.FlipperGATTInformation | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface FlipperInformationApi { | ||
fun getInformationFlow(): StateFlow<FlipperGATTInformation> | ||
} |
2 changes: 1 addition & 1 deletion
2
...es/bridge/api/manager/FlipperSerialApi.kt → ...e/api/manager/service/FlipperSerialApi.kt
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
35 changes: 0 additions & 35 deletions
35
components/bridge/api/src/main/java/com/flipperdevices/bridge/api/pair/FlipperPairApi.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...s/bridge/impl/src/main/java/com/flipperdevices/bridge/impl/device/FlipperDeviceApiImpl.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.