如何解决加快蓝牙经典发现
我正在 Kotlin 的 Android 上进行蓝牙经典发现,想知道是否有可能让已知设备更频繁地响应发现。目前我的一个设备每 5-10 秒快速连续响应两次。
发现码:
private val bluetoothdiscoveryResult = object : broadcastReceiver()
{
override fun onReceive(context: Context?,intent: Intent?)
{
if (intent?.action == BluetoothDevice.ACTION_FOUND)
{
val device: BluetoothDevice =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)!!
val RSSi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE)
.toInt()
val name = device.name
Log.i(
"discovery","Action: ${intent?.action} Device: ${device.name} ${device.address}" + " "
"Signal Strength:$RSSi)")
}
}
}
private fun begindiscovery() {
registerReceiver(bluetoothdiscoveryResult,IntentFilter(BluetoothDevice.ACTION_FOUND))
bluetoothAdapter.startdiscovery()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。