Skip to main content

Bluetooth API in JavaME

4 replies [Last post]
alpha_manic
Offline
Joined: 2005-09-15
Points: 0

Hi Guys,

I'm not been able to find any bluetooth devices using the JavaME's bluetooth API. See code sample below:

public class ListDevices extends MIDLet implments DiscoveryListener{
. . .

public void searchAvailableDevices(){
device = LocalDevice().getLocalDevice();
agent = device.getDiscoveryAgent();
agent.startInquiry(DiscoveryAgent.GIAC,this);
}
public void deviceDiscovered(RemoteDevice rDevice, DeviceClass cod){
System.out.println(rDevice.getFriendlyName(true));
//search services code
}
}

I'm running this code on Netbeans IDE 6.1 running Sun java wireless tookit 2.5.2 for CLDC emulator platform. I have a mobile phone which is bluetooth enabled.

Any clues?

Cheers,

A

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Tijl Houtbeckers

The WTK only gives you a "fake" enviroment to test it as far as I
know. You can use MicroEmulator in combination with BlueCove (if your
bluetooth hardware is compatible) to do real word testing, from your
desktop computer. You should be aware though that (escp under windows)
bluetooth drivers only implement a subset of the features found in
JSR-82. Also there are a lot of bugs in these drivers (same for the
phones). Not a 100% garantue for success..

regards,
Tijl Houtbeckers
The Netherlands

> I'm not been able to find any bluetooth devices using the JavaME's
> bluetooth API. See code sample below:
>
> public class ListDevices extends MIDLet implments DiscoveryListener{
> . . .
>
> public void searchAvailableDevices(){
> device = LocalDevice().getLocalDevice();
> agent = device.getDiscoveryAgent();
> agent.startInquiry(DiscoveryAgent.GIAC,this);
> }
> public void deviceDiscovered(RemoteDevice rDevice, DeviceClass cod){
> System.out.println(rDevice.getFriendlyName(true));
> //search services code
> }
> }
>
> I'm running this code on Netbeans IDE 6.1 running Sun java wireless
> tookit 2.5.2 for CLDC emulator platform. I have a mobile phone which
> is bluetooth enabled.
>
> Any clues?
>
> Cheers,
>
> A
> [Message sent by forum member 'alpha_manic' (alpha_manic)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288056
>
> =
> =
> =
> =
> =
> ======================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in
> the body
> of the message "signoff KVM-INTEREST". For general help, send email
> to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

brunogh
Offline
Joined: 2006-04-23
Points: 0

If you are using the emulator, you need to start a new instance of it in order to be able to find something. If you want to make a desktop application that looks for you mobile, you need a JSR 82 implementation in your desktop (http://weblogs.java.net/blog/brunogh/archive/2007/09/jsr_82_is_not_o_1.html). More at http://wiki.java.net/bin/view/Mobileandembedded/BluetoothResources.

Thanks,
Bruno

alpha_manic
Offline
Joined: 2005-09-15
Points: 0

Hi Bruno,

Thanks for your reply.

I thought that JavaME complies with JSR 82 why need 3rd party libs?

Cheers,

A

davjoh
Offline
Joined: 2007-07-18
Points: 0

JME does comply with JSR 82, so _phones_ implementing it will work.

The problem is that there is no Bluetooth stack for Java on the _desktop_, so running your code in the WTK emulator won't work without 3rd party libraries as the emulator does not provide a desktop Bluetooth stack implementation.

Chances are your code will work fine if you deploy it to a phone with JSR 82 capability.

So as Bruno says, check out those resource links and you can get an open-source BT implementation of JSR 82 for your desktop to use. Oh, and of obviously, make sure you have a Bluetooth chip/dongle installed on your desktop or laptop that your're using the WTK on.