Skip to content

Commit

Permalink
fixed initialization when we want to use a custom message parser
Browse files Browse the repository at this point in the history
  • Loading branch information
neoBortx committed Feb 3, 2024
1 parent 4ab325f commit dee915a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
VERSION_LIB=0.0.9
VERSION_LIB=0.0.10
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class SimpleBleClientBuilder {
}

private fun buildInstance(context: Context): SimpleBleClient {
bleLibraryContainer.init(context)

with(bleLibraryContainer.getBleConfiguration()) {
operationTimeOutMillisConf?.let { operationTimeoutMillis = it }
Expand All @@ -116,6 +115,8 @@ public class SimpleBleClientBuilder {
messageBufferRetriesConf?.let { messageBufferRetries = it }
}

bleLibraryContainer.init(context)

with(bleLibraryContainer) {
return SimpleBleClientFactory(
context.applicationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ import com.bortxapps.simplebleclient.scanner.BleDeviceScannerSettingsBuilder
import kotlinx.coroutines.sync.Mutex

internal class BleLibraryContainer {
private lateinit var blueToothScanner: BluetoothLeScanner
private lateinit var bleConfiguration: BleConfiguration
private var bleConfiguration = BleConfiguration()

private lateinit var blueToothScanner: BluetoothLeScanner
private lateinit var bleDeviceScannerManager: BleDeviceScannerManager
private lateinit var bleManagerGattCallBacks: BleManagerGattCallBacks
private lateinit var bleManagerDeviceSearchOperations: BleManagerDeviceSearchOperations
private lateinit var bleManagerGattConnectionOperations: BleManagerGattConnectionOperations
private lateinit var bleManagerGattSubscriptions: BleManagerGattSubscriptions
private lateinit var bleManagerGattWriteOperations: BleManagerGattWriteOperations
private lateinit var bleManagerGattReadOperations: BleManagerGattReadOperations

private lateinit var gattMutex: Mutex
private lateinit var buildVersionProvider: BuildVersionProvider
private lateinit var bleMessageProcessorProvider: BleMessageProcessorProvider

fun init(context: Context) {
gattMutex = Mutex()

bleConfiguration = BleConfiguration()

bleMessageProcessorProvider = BleMessageProcessorProvider(bleConfiguration)

buildVersionProvider = BuildVersionProvider()
Expand Down Expand Up @@ -87,9 +84,6 @@ internal class BleLibraryContainer {
}

fun getBleConfiguration(): BleConfiguration {
if (::bleConfiguration.isInitialized.not()) {
throw SimpleBleClientException(BleError.LIBRARY_NOT_INITIALIZED)
}
return bleConfiguration
}

Expand Down

0 comments on commit dee915a

Please sign in to comment.