hi
i develop a bluetooth aplication that when the server and the client are connected, they send a string to each other. Now, i want send more mesagges without doing the process again, just adding a button, but i doesn't work. Can someone help me!!
each time i push the buton, it calls enviar()Code:public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass deviceClass) { RemoteDevice device = servRecord[i].getHostDevice(); String name = device.getBluetoothAddress(); servicioCliente.append("device:"+device.toString()+"\n"+"name"+name); cancelar(); //cancelamos las busquedas try { coneccion =(StreamConnection) Connector.open(urlNaNe); in = coneccion.openDataInputStream(); out = coneccion.openDataOutputStream(); enviar(); } catch(IOException e) { e.printStackTrace(); } } } public void enviar() { try { out.writeUTF("Saludos desde el cliente!"); out.flush(); String mensajeLlega = in.readUTF(); textoCli.setString(mensajeLlega); servicioCliente.append("\nMensaje de servidor: "+mensajeLlega); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void run() { StringBuffer url = new StringBuffer("btspp://localhost:"); url.append(uuid.toString()); url.append(";name=Brailles"); conexion.append("\n"+url+"\n"); try { StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(url.toString()); //StreamConnectionNotifier connectionNotifier = (StreamConnectionNotifier) Connector.open(url); conexion.append("Servidor en marcha..."); while(true) { try { coneccion = (StreamConnection) notifier.acceptAndOpen(); in = coneccion.openDataInputStream(); out = coneccion.openDataOutputStream(); String texto = "Braille dice Hola!"; out.writeUTF(texto); conexion.append("\n"+texto); textoSer.setString(texto); out.flush(); String mensajeLlega = in.readUTF(); conexion.append("\nMensaje Cliente: "+mensajeLlega); } catch(IOException e) { e.printStackTrace(); } } } catch(IOException e) { pantalla.setCurrent(new Alert("Error++: "+e)); alerta = new Alert("Error conexion",e.toString(),null, AlertType.ERROR); pantalla.setCurrent(alerta); } } }

Reply With Quote


