@Override
    public synchronized void start() {
        if (D) Log.d(TAG, "start");

        // Cancel any thread attempting to make a connection
        for (ConnectThread ct : connectionAttempts.values()) ct.cancel();
        connectionAttempts.clear();

        // Cancel any thread currently running a connection
        for (ConnectedThread ct : remoteConnections.values()) ct.cancel();
        remoteConnections.clear();

        setState(STATE_LISTEN);

        // Start the thread to listen on a BluetoothServerSocket
        if (mSecureBluetoothServer == null) {
            mSecureBluetoothServer = new BluetoothServer(Rfcomm.this, true, timeout);
            mSecureBluetoothServer.addListener(this);
            mSecureBluetoothServer.start();
        }

        if (mInsecureBluetoothServer == null) {
            mInsecureBluetoothServer = new BluetoothServer(Rfcomm.this, false, timeout);
            mSecureBluetoothServer.addListener(this);
            mInsecureBluetoothServer.start();
        }
    }