[英]How to filter bluetooth tags through android apps
How to filter bluetooth tags in times of pairing with apps. 与应用配对时如何过滤蓝牙标签。 For instance, "Tile" doesn't connect with tags other than their authorized tags.
例如,“瓷砖”不与除其授权标签以外的其他标签连接。 My question is, how do they recognize their authorized tags through apps?
我的问题是,他们如何通过应用识别他们的授权标签?
A simple solution is to connect to an untrusted device, send a signal with an specific result expected, if it receives fine, then "trust" that device. 一种简单的解决方案是连接到不受信任的设备,发送预期具有特定结果的信号,如果接收良好,则“信任”该设备。
Then, on next loads, check the paired MAC address.. 然后,在下次加载时,检查配对的MAC地址。
Something akin to: 类似于:
private BluetoothDevice mDevice = null;
if (mDevice == null) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null) {
if (mBluetoothAdapter.isEnabled()) {
Set<BluetoothDevice> bluetoothDevices = mBluetoothAdapter
.getBondedDevices();
if (bluetoothDevices != null && bluetoothDevices.size() > 0) {
String bondedID = SharedPreferences.getInstance(
getApplicationContext()
).getPairedAddress();
if (bondedID != null) {
for (final BluetoothDevice device : bluetoothDevices) {
if (device != null
&& device.getAddress().equals(bondedID)) {
mDevice = device;
break;
}
}
}
} else {
Logger.v(TAG, "There are no Bluetooth Paired devices");
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.