Bluetooth Classic Android App(MVVM), Arduino SPP
- If you want to see your bluetooth device like this code preview, modify
mBluetoothStateReceiver
code in registerBluetoothReceiver(), Repository.kt
BluetoothDevice.ACTION_FOUND -> {
if (!foundDevice) {
val device_name = device!!.name
val device_Address = device.address
// It only searches for devices with the prefix "RNM" in the Bluetooth device name.
if (device_name != null && device_name.length > 4) {
if (device_name.substring(0, 3) == "RNM") {
// filter your targetDevice and use connectToTargetedDevice()
targetDevice = device
foundDevice = true
connectToTargetedDevice(targetDevice)
}
}
}
}