This commit is contained in:
Piotr Dec 2023-08-13 23:26:10 +02:00
parent 0c6e305aea
commit af676becb3
3 changed files with 0 additions and 362 deletions

View file

@ -28,15 +28,6 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
bluetoothInit()
}
override fun onPause() {
super.onPause()
// bluetoothSerial.onPause()
}
override fun onResume() {
super.onResume()
// bluetoothSerial.onResume()
}
private fun bluetoothInit() {
val bluetoothManager: BluetoothManager = getSystemService(BluetoothManager::class.java)
@ -84,40 +75,6 @@ class MainActivity : AppCompatActivity() {
return true
}
private inner class ConnectThread(val device: BluetoothDevice, val adapter: BluetoothAdapter) : Thread() {
private val mmSocket: BluetoothSocket? by lazy(LazyThreadSafetyMode.NONE) {
checkBt()
// device.createInsecureRfcommSocketToServiceRecord(UUID.fromString("7d00d7f5-921b-450c-8eda-26e1d4a15c61"))
device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"))
}
override fun run() {
// Cancel discovery because it otherwise slows down the connection.
checkBt()
adapter.cancelDiscovery()
mmSocket?.let { socket ->
// Connect to the remote device through the socket. This call blocks
// until it succeeds or throws an exception.
socket.connect()
// The connection attempt succeeded. Perform work associated with
// the connection in a separate thread.
// manageMyConnectedSocket(socket)
}
}
// Closes the client socket and causes the thread to finish.
fun cancel() {
try {
mmSocket?.close()
} catch (e: IOException) {
Log.e(Companion.TAG, "Could not close the client socket", e)
}
}
}
companion object {
private const val TAG = "bt"
}