Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Bluetooth Chat Example - Service Discovery failed

OP Pommes9485

18th April 2014, 04:43 PM   |  #1  
OP Junior Member
Thanks Meter: 0
 
7 posts
Join Date:Joined: May 2011
Hello,

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:
Code:
private static final UUID MY_UUID_SECURE =
        UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    private static final UUID MY_UUID_INSECURE =
        UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
For the ones, who do not know, what the connectThread looks like:


Code:
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(
                    		 MY_UUID_INSECURE);
                }
            } catch (Exception e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
                ServerAccess.errorLog(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
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes