I am creating an unsafe rfcomm connection from my HTC One X to SENA bluetooth ESD110 Serial module with this code:
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(addr); BluetoothSocket socket = null; try{ socket = device.createInsecureRfcommSocketToServiceRecord(UUID.fromString(SERVICE_UUID)); mBluetoothAdapter.cancelDiscovery(); socket.connect(); sendMessage(socket,"working!"); socket.close();
Here you need to connect to the module with automatic parry, and all this works, but it takes about 15 seconds to establish a connection.
Debugging is saved:
socket.connect();
within 15 seconds and only after this connection and transfer of the string to the module (it takes 1 second).
Is it possible that the phone will process some other data (service discovery and more) before connecting to the MAC address and how can I connect it to FASTER? Or could it be a problem with HTC hardware?
source share