Hi all!
I'm trying to do a basic Java client-bluetooth application with JSR-82.
It is a starndard "of the school-book" exampel app. that starts a inquire and print the information found.
So far so good, everything starts like it should, but the app. doesn't find any devices!
The app. works just fine in the emulators (and emulators with bluecove, finding real devices) and on a Sonyericsson k750i.
The Nokia I'm using is a 6680 of the shelf.
Any ideas whats wrong?
Here is the code:
Ps. the code have some searchSearch(), connectService() functions that works well on the other devices (i.e. emulator, k750i). But on the Nokia it never even reaches the deviceDiscovered() function.Code:public class BT implements DiscoveryListener { private LocalDevice device; private DiscoveryAgent agent; private Vector remoteDevices = new Vector(); private TT cm; public static final UUID uuid = new UUID( "27012f0c68af4fbf8dbe6bbaf7ab651b", false); BT(TT cm) { this.cm = cm; try { device = LocalDevice.getLocalDevice(); agent = device.getDiscoveryAgent(); cm.msg("** Start Inquire"); agent.startInquiry(DiscoveryAgent.GIAC, this); } catch (Exception e) { } } private void searchServices(RemoteDevice remoteDevice) { try { agent.searchServices(new int[] { 0x0100, 0x0101 }, new UUID[] { uuid }, remoteDevice, this); } catch (BluetoothStateException e) { e.printStackTrace(); } } private void connectServices(ServiceRecord service) { System.out.println("** " + service.getAttributeValue(0x0100)); try { StreamConnection connection = (StreamConnection) Connector .open(service.getConnectionURL( ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false)); DataOutputStream dos = new DataOutputStream(connection.openOutputStream()); dos.writeUTF("abc 123\nåäö 123"); dos.close(); connection.close(); } catch (Exception e) { } } public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass deviceClass) { try { String msg = "** Device found!\n" + "Friendly name: " + remoteDevice.getFriendlyName(true) + "\n" + "Device klass: " + deviceClass + "\n" + "BT Adress: " + remoteDevice.getBluetoothAddress(); cm.msg(msg); } catch (IOException e) { e.printStackTrace(); } searchServices(remoteDevice); } public void servicesDiscovered(int arg0, ServiceRecord[] arg1) { cm.msg("** Service discovered"); for (int i = 0; i < arg1.length; i++) { connectServices(arg1[i]); } } public void serviceSearchCompleted(int arg0, int arg1) { cm.msg("** Service search complete"); } public void inquiryCompleted(int arg0) { cm.msg("** Inquiry complete"); } }

Reply With Quote

