Remove All Ads from XDA

Bluetooth Chat Example - Service Discovery failed

20 posts
Thanks Meter: 0
By Pommes9485, Junior Member on 18th April 2014, 04:43 PM
Post Reply Email Thread

for my app, which needs to communicate with a HC-06 Bluetooth module, I modified the bluetooth chat example.
Then and now the process of creating sockets failes and I do not know why. I did not change anythin in that part, except for the UUID:
private static final UUID MY_UUID_SECURE =
    private static final UUID MY_UUID_INSECURE =
For the ones, who do not know, what the connectThread looks like:

private class ConnectThread extends Thread {
        private final BluetoothSocket mmSocket;
        private final BluetoothDevice mmDevice;
        private String mSocketType;

        public ConnectThread(BluetoothDevice device, boolean secure) {
            mmDevice = device;
            BluetoothSocket tmp = null;
            mSocketType = secure ? "Secure" : "Insecure";

            // Get a BluetoothSocket for a connection with the
            // given BluetoothDevice
            try {
            	secure = false;
            	/*Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
                tmp = (BluetoothSocket) m.invoke(device, 1);*/
            	//UUID uuid = mmDevice.getUuids()[0].getUuid();

                if (secure) {
                    tmp = device.createRfcommSocketToServiceRecord(
                         MY_UUID_SECURE  );
                } else {
                    tmp = device.createInsecureRfcommSocketToServiceRecord(
            } catch (Exception e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
            mmSocket = tmp;
Does anyone know, what to do?

I already tried to change the UUID and to reflect the Method "createRFCommSocket".

Please help me!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes