Skip to content

Commit

Permalink
Fix bug with connecting to bonded printer
Browse files Browse the repository at this point in the history
  • Loading branch information
skyestudiosDev committed May 13, 2024
1 parent 38b6542 commit 804a0c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
30 changes: 15 additions & 15 deletions composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ fun App() {
showDialog = message.isNotEmpty()
}
LaunchedEffect(connectionState){
if (connectionState.isBluetoothReady && !connectionState.discoveredPrinter && !connectionState.isScanning && scanCount == 0){
scanCount++
scope.launch {
bluetoothConnection.scanForPrinters()
}
//println("Scanning")
}
if (connectionState.discoveredPrinter && !connectionState.isConnected){
bluetoothConnection.connect()
println("Connecting")
}
if (connectionState.isPrinting){
//printingStarted = true
println("Printing")
}
// if (connectionState.isBluetoothReady && !connectionState.discoveredPrinter && !connectionState.isScanning && scanCount == 0){
// scanCount++
// scope.launch {
// bluetoothConnection.scanForPrinters()
// }
// //println("Scanning")
// }
// if (connectionState.discoveredPrinter && !connectionState.isConnected){
// bluetoothConnection.connect()
// println("Connecting")
// }
// if (connectionState.isPrinting){
// //printingStarted = true
// println("Printing")
// }
}

Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ android {
@Suppress("UnstableApiUsage")
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01, true)
val versionTxt = "0.0.3"
val versionTxt = "0.0.4"
val isDev = findProperty("env")?.equals("dev") ?: false
val version = if (isDev) "0.0.1-SNAPSHOT" else versionTxt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ internal object AndroidBluetoothConnection: BlueLine {
}



}


Expand Down Expand Up @@ -187,8 +188,8 @@ internal object AndroidBluetoothConnection: BlueLine {
return
}
if (bluetoothGatt != null){
bluetoothGatt?.connect()
return
val isReconnect = bluetoothGatt?.connect()
if (isReconnect == true) return
}
bluetoothGatt = bluetoothDevice?.connectGatt(applicationContext, false, gattCallback, BluetoothDevice.TRANSPORT_LE)
}
Expand Down

0 comments on commit 804a0c2

Please sign in to comment.