public StreamConnection acceptAndOpen() throws IOException { return ((StreamConnectionNotifier) impl).acceptAndOpen(); }
UUID uuid = new UUID("1101", false); String SurveyAnswer=""; //Create the service url String connectionString = "btspp://localhost:" + uuid + ";name=xyz"; //open server url StreamConnectionNotifier streamConnNotifier = (StreamConnectionNotifier) Connector.open(connectionString); //Wait for client connection System.out.println("\nServer Started. Waiting for clients to connect..."); while(true){ StreamConnection connection = streamConnNotifier.acceptAndOpen(); System.out.println("Client connected starting communication"); new CommunicationThread(connection).start(); }
public synchronized Connection acceptAndOpen(ServerRequestHandler handler, Authenticator auth) throws IOException { if (notifier == null) { throw new IOException("Session closed"); } if (handler == null) { throw new NullPointerException("handler is null"); } OBEXServerSessionImpl sessionImpl = new OBEXServerSessionImpl(notifier.acceptAndOpen(), handler, auth, obexConnectionParams); sessionImpl.startSessionHandlerThread(); return sessionImpl; }
UUID serialUUID = new UUID("1101", true); String serviceURL = "btspp://localhost:" + serialUUID + ";name=Android BT Server;authorize=false;authenticate=false"; StreamConnectionNotifier connectionNotifier = (StreamConnectionNotifier) Connector .open(serviceURL); // Blocking method will wait for client to connect StreamConnection connection = connectionNotifier.acceptAndOpen(); RemoteDevice remoteDevice = RemoteDevice.getRemoteDevice(connection); InputStream btInput = connection.openInputStream(); OutputStream btOutput = connection.openOutputStream();
// code at sender side StreamConnectionNotifier service = (StreamConnectionNotifier) Connector.open( url ); //System.out.println("opened"); StreamConnection con = (StreamConnection) service.acceptAndOpen(); OutputStream outputStream = con.openOutputStream(); // file to send Scanner in = new Scanner(inFile); //just count lines String s=null; int countLines=0; while(in.hasNext()) { s=in.nextLine(); countLines++; } //send num of lines outputStream.write(Integer.toHexString(countLines).getBytes()); try{Thread.sleep(100);} catch(InterruptedException e){} //send lines in = new Scanner(inFile); for(int i=0; i<countLines; i++) { s=in.nextLine()+"\n"; outputStream.write(s.getBytes()); Thread.sleep(100); }
LocalDevice localDevice = LocalDevice.getLocalDevice(); localDevice.setDiscoverable(DiscoveryAgent.GIAC); // Advertising the service String url = "btspp://localhost:" + device_UUID + ";name=BlueToothServer"; StreamConnectionNotifier server = (StreamConnectionNotifier) Connector.open(url); StreamConnection connection = server.acceptAndOpen(); // Wait until client connects //=== At this point, two devices should be connected ===// DataInputStream dis = connection.openDataInputStream(); char c; while (true) { c = dis.readChar(); if (c == 'x') break; } connection.close();
LocalDevice localDevice = LocalDevice.getLocalDevice(); localDevice.setDiscoverable(DiscoveryAgent.GIAC); // Advertising the service String url = "btspp://localhost:" + device_UUID + ";name=BlueToothServer"; StreamConnectionNotifier server = (StreamConnectionNotifier) Connector.open(url); StreamConnection connection = server.acceptAndOpen(); // Wait until client connects //=== At this point, two devices should be connected ===// DataInputStream dis = connection.openDataInputStream(); char c; while (true) { c = dis.readChar(); if (c == 'x') break; } connection.close();
UUID serialUUID = new UUID("1101", true); String SERVICE_URL = "btspp://localhost:" + serialUUID + ";name=My Bluetooth Server;authorize=false;authenticate=false"; StreamConnectionNotifier connectionNotifier = (StreamConnectionNotifier) Connector.open(SERVICE_URL); System.out.println("Server is waiting for client ... \n URL=" + SERVICE_URL); // Wait until client connects i.e. a blocking method StreamConnection connection = connectionNotifier.acceptAndOpen(); RemoteDevice remoteDevice = RemoteDevice.getRemoteDevice(connection); System.out.println("Client connected: "+remoteDevice.getBluetoothAddress()); // Communicate with the device using the below I/O streams InputStream iStream = connection.openInputStream(); OutputStream oStream = connection.openOutputStream();
StreamConnection connection = (StreamConnection) service.acceptAndOpen(); new Listener(connection).start();
StreamConnection conn = notifier.acceptAndOpen(); InputStream in = conn.openInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
return null; connection = notifier.acceptAndOpen(); InputStream inputStream = connection.openInputStream(); BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream));
StreamConnection connection=streamConnNotifier.acceptAndOpen();
connection = notifier.acceptAndOpen(); final RemoteDevice remoteDevice = RemoteDevice .getRemoteDevice(connection);