Blutooz-Verbindung ... ich schaffs nicht

noobadix

Bekanntes Mitglied
Hallo,

ich friemel seit Tagen an einer Blutuz-Verbindung. Obwohl ich eigentlich Beispiele habe, bei denen ich nur abschreiben bräuchte, klappts nicht. Ich möchte am liebsten ein Object austauschen, mich aber zunächst auch mit einem String zufrieden geben. Hier meine Ansätze für Server (Bluecove, JSE) und Client (J2ME). Ich bekomme den String nicht auf dem Server angezeigt.

Server:

Java:
public class Blue {
		StreamConnectionNotifier notifier;
	    
	    //start server
	    public Blue() throws IOException{
	    	
	    	String serverUUID = "936b8ad0f5e811de8a390800200c9a66";
	    	String connectionString = "btspp://localhost:" + serverUUID;

	        syncMsgLabel.setText(connectionString);
	        syncStatusLabel.setText("Server gestarted:");

	        //open server url and wait for clients
	        LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
	        notifier = (StreamConnectionNotifier)Connector.open( connectionString );
	        SwingUtilities.invokeLater(new Runnable() {
				public void run(){
					try{
						StreamConnection s = (StreamConnection) notifier.acceptAndOpen();
						DataInputStream inStream = s.openDataInputStream();
						String msg = inStream.readUTF();
						System.out.println(msg);
						syncStatusLabel.setText("Hab connection: " + msg);
					}
					catch(Exception e){}
				}
			});
	    }

Client:

Java:
public void startSync(){
		try{
			item.setText("Starte device inquiry...");
			LocalDevice localDevice = LocalDevice.getLocalDevice();
			agent = localDevice.getDiscoveryAgent();
			agent.startInquiry(DiscoveryAgent.GIAC, new discoveryListener());
		}
		catch(Exception e){}
	}

	
	class discoveryListener implements DiscoveryListener{
		public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod){
			try{
				String connectionString = agent.selectService( new UUID("936b8ad0f5e811de8a390800200c9a66",false),ServiceRecord.AUTHENTICATE_ENCRYPT,false);
				item.setText("Service gefunden:");
				connection = (StreamConnection) Connector.open(connectionString);
				outStream = connection.openDataOutputStream();
				outStream.writeUTF("HAAAAllo, client hier");
			}catch(Exception e){}
		}
 
Zuletzt bearbeitet:

Noctarius

Top Contributor
Kurze Anmerkung um die Verwirrung der richtigen Schreibweise komplett zu machen: Es heißt Bluetooth :)

Ansonsten: Sorry noch nie damit gearbeitet
 

Noctarius

Top Contributor
Natürlich darfst du das benutzen, vor allem in Anfragen. Nur darfst du selber kein Programm herausgeben (bzw keine Technik) das so heißt.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
missy72 Kotlin SSH Verbindung mit JSch Android & Cross-Platform Mobile Apps 5
J Android VPN Verbindung herstellen? Android & Cross-Platform Mobile Apps 4
B Android TCP-Verbindung zum Server über welche Prozess auslagerung nutzen? Android & Cross-Platform Mobile Apps 1
M Problem bei Werteübergabe, MSQL verbindung Android & Cross-Platform Mobile Apps 3
H WIFI, Bluetooth und NFC Verbindung überwachen Android & Cross-Platform Mobile Apps 1
H Android 3G TCP Socket Verbindung zum PC durch NAT Android & Cross-Platform Mobile Apps 8
T Android MSSQL Verbindung herstellen - Android Studio Android & Cross-Platform Mobile Apps 2
M Android Server-Client-Verbindung in Android-App mit Sockets aufbauen Android & Cross-Platform Mobile Apps 5
W Android HTTPS-Verbindung mit Client-Authentifizierung Android & Cross-Platform Mobile Apps 0
R Socket Verbindung AsycTask Android & Cross-Platform Mobile Apps 5
F Android USB Verbindung zu Windows Programm Android & Cross-Platform Mobile Apps 3
U Android Https-Verbindung Android & Cross-Platform Mobile Apps 2
K Java ME Bluetooth verbindung parameter Android & Cross-Platform Mobile Apps 3
N Java ME Server-Client Verbindung über Wifi Android & Cross-Platform Mobile Apps 6
A Problem mit HTTP- Verbindung Android & Cross-Platform Mobile Apps 4
N Handy -PC Verbindung Android & Cross-Platform Mobile Apps 2
F Server - Client Verbindung mit Java ME Android & Cross-Platform Mobile Apps 3
G Bluetooth Verbindung zwischen Handy und PC Android & Cross-Platform Mobile Apps 5
G Bluetooth Verbindung Android & Cross-Platform Mobile Apps 2
O Bluetooth Verbindung zwischen 2 Handys Android & Cross-Platform Mobile Apps 5
K HTTP-Verbindung mit J2ME.... Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben