private void waitForConnection() {
		// retrieve the local Bluetooth device object
		LocalDevice local = null;
		
		StreamConnectionNotifier notifier;
		StreamConnection connection = null;
		
		// setup the server to listen for connection
		try {
			local = LocalDevice.getLocalDevice();
			local.setDiscoverable(DiscoveryAgent.GIAC);
                System.out.println( LocalDevice.getLocalDevice().getFriendlyName());
			
			UUID uuid = new UUID("04c6093b00001000800000805f9b34fb", false);
			System.out.println(uuid.toString());
			
                        String url = "btspp://localhost:" + uuid.toString() + ";name=RemoteBluetooth";
                         notifier = (StreamConnectionNotifier)Connector.open(url);
        }        catch (BluetoothStateException e) {
                            System.out.println("Bluetooth is not turned on.");
                            	e.printStackTrace();
                                    return;
		} catch (IOException e) {
			e.printStackTrace();
                            return;
		}
		
		// waiting for connection
                        while(true) {
                                try {
                                     Thread.sleep(100);
                                     
                                	System.out.println("waiting for connection...");
                                        conex=1;
                                        Status(conex);
                                       
                                        main.setBluetooth("Bluetooth Device: \n"+LocalDevice.getLocalDevice().getFriendlyName());
                                         
       
                                              connection = notifier.acceptAndOpen();
	            
                                                Thread processThread = new Thread(new ProcessConnectionThread(connection));
                                                     processThread.start();
                                                     
	            
			} catch (Exception e) {
                                    e.printStackTrace();
				return;
			}
		}
	}