I have connect function and it works perfect
fun connect(btDevice: BluetoothDevice?) {
val id: UUID = btDevice?.uuids?.get(0)!!.uuid
val bts = btDevice.createInsecureRfcommSocketToServiceRecord(id)
bts?.connect()
}
But bts.close()
doesnt`t works, if i call this one
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@518c676, channel: 2, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@d48a477, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@51478e4mSocket: null, mSocketState: CLOSED