我从互联网上得到了以下代码
try {
BluetoothDevice device = btAdapter.getRemoteDevice(bdDevice.toString());
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
socket = device.createInsecureRfcommSocketToServiceRecord(uuid);
socket.connect();
Toast.makeText(MainActivity.this,"socket bonded", Toast.LENGTH_LONG).show();
} catch(Exception e) {
tv.setText(e.toString());
}
当然,uuid 只是一个随机代码,那么我如何获得所需的 uuid 呢?它应该是我的 ELM327 设备的 uuid 还是另一个 uuid?对不起,我是 uuid 和 android 开发的新手。