Working with Bluetooth and GPS: Follow-up

By Bruce Hopkins

After reading both Part 1 and Part 2 of the “Working with Bluetooth and GPS” series of articles, you were given a clear explanation of the example code that shows you how to do the following:


    1. Use the JSR-82 Bluetooth API to access the data from a Bluetooth-enabled GPS receiver
    2. Parse the data streams in NMEA format and obtain the coordinates of your current location
    3. Formulate an HTTP request to access an external mapping service
    4. Use the JSR-172 XML Parsing and Web Services API to parse an XML result
    5. Make a request in order to display a map image

Therefore, the purpose of this tech tip is to provide answers to the questions that were submitted by the readers of both articles in the series.

Question 1: Hi Bruce, I have a problem when I start the Mpowerplayer tool with any MIDlet that uses Bluetooth and the JSR-82 API. When the application tries to execute my MIDet, it immediately displays a java.lang.NoClassDefFoundError: javax/bluetooth/DiscoveryListener. What could be the problem?

Answer 1: The MPowerplayer made a change on how it handles JSR-82 libraries between releases #1127 and #1185. Unfortunately, it not explicitly stated in the documentation, but you need to make two simple changes in order to run MIDlets that require the JSR-82 API:


    1. Place any JSR-82 implementation in the /mpp-sdk folder. I’ve tested with the following JSR-82 implementations: Avetana (requires a license) and BlueCove (free open-source alternative).
    2. Rename that file to be called bt.jar.

After you make those two changes, you will be able to run any application requires the JSR-82 APIs.

Question 2: Hi Bruce, this is a nice article. I would like to know how to get GPS data from a mobile phone that already has a GPS receiver built-in.

Answer 2: If your mobile phone is MSA-compliant and already has a GPS radio built-in, then you don’t need to use the JSR-82 API to connect to a remote GPS receiver. All you need to do is use the JSR-179 Location APIs in order to retrieve your location data from an embedded GPS receiver. If you’d like to get started with the JSR-179 API, then Qusay Mahmoud has written a great article, Java ME and Location-Based Services, on that topic.

Question 3: I have a Bluetooth-enabled GPS receiver: the Holux Slim 236. I also have a Bluetooth-enabled computer. Can I run this example with what I have?

Answer 3: Yes, you should have no problem running the example code using the tools that you have. If you plan to use the current version of Mpowerplayer, then be sure to follow the instructions in the answer to Q1 first.

Question 4: Hi Bruce, thanks for creating this meaningful guide for developers. Your original article shows developers how to use the Avetana Bluetooth JSR-82 implementation with the Mpowerplayer SDK. The problem, however is that Aventana implementation only provides a free 14-day trial, and afterwards requires a license fee. Is there any way to configure the Mpowerplayer with the BlueCove JSR-82 implementation which is open source?

Answer 4: Yes, please refer to the answer provided to Q1 listed above in order to find out how to use the BlueCove library with the MPowerplayer SDK.

Question 5: Hi, I am having problem with this example with WTK 2.5.2 and NetBeans IDE 6.1 which are both installed in my PC. When I run this application on my PC, I’m not able to get any data from the remote Bluetooth devices.

Answer 5: Actually, the whole point of Part 1 in the two-part series was to show developers how to debug and test their JSR-82 applications on their PCs using the Mpowerplayer. Neither the WTK, the NetBeans IDE, nor the Java ME SDK have the ability to leverage the Bluetooth hardware of your PC in order to discover or search for services on remote Bluetooth devices.

Question 6: I have a Bluetooth-enabled phone with a built-in GPS receiver. I want to send NMEA data from the phone to a Bluetooth-enabled PC. I have a desktop application (Streets & Trips) that can consume GPS data. Since my phone support GPS and Bluetooth, is there a Java ME application that will enable my mobile phone to do this?

Answer 6: I don’t know of any Java ME applications that do this, however this sounds like the basis for another article!

Final Thoughts

Thanks to all the readers who took the time to provide feedback to this article series! Your input, thoughts, questions, and ideas are always welcome and appreciated.

Comments:

will this in tervear with avg

Posted by Richard on June 17, 2009 at 05:48 AM PDT #

Richard,

I think you're asking if this would interfere with SVG rendering. No, accessing GPS data over Bluetooth will not interfere with rendering graphics (such as SVG graphics or animations) as long as your data access code is placed in a separate thread.

Thanks,

Posted by Bruce Hopkins on June 17, 2009 at 07:01 AM PDT #

In my case Bluecove with Mpowerplayer works only if I "connect" to the Bluecove JSR-82 via the classpath attribute in the commmandline:

java -classpath "xyz\\mpp-sdk-1185\\player.jar;xyz\\bluecove-2.1.0.jar" com.mpp.player.PowerPlayerApp ...

Putting bluecove-2.1.0.jar into the mpp-directory and renaming it to bt.jar provides on half of what I expect:

console-output:

java.lang.ClassNotFoundException: de.avetana.bluetooth.connection.Connector
mpowerplayer 2.0.1185
BlueCove version 2.1.0 on winsock

which means that mpp finds the bluecove but expects after that particular avetana classes :-( instead of pure JSR-82 classes.

This is the reason why I am not able to include mpp als "mobile device" into the Eclipse (with J2ME-Plugin) workbench. This is only possible for the avetana stack which furthermore has NOT to be renamed into bt.jar.

Posted by Gerhard Juen on July 20, 2009 at 10:53 PM PDT #

Gerhard,

Thanks for providing this additional information about Avetana vs. BlueCove for the MPowerplayer. Perhaps you might with to make a posting on the MPowerPlayer forums (http://developer.mpowerplayer.com/) to see why it apparently favors Avetana vs. BlueCove.

- Bruce

Posted by Bruce Hopkins on July 21, 2009 at 03:24 AM PDT #

Hi Bruce,

Excellent article.

I am able to run this application over my Nokia 6300 Mobile phone.

I am able to connect My PC (which is another bluetooth data sender) using this sample code, but could not able to receive anything. I tried to send data from PC to Mobile to Phone, but it doesn't show anything on Mobile Phone application.

What could be wrong here ?

Posted by Aniruddha Navare on October 11, 2010 at 06:19 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Tips for developers who use Java technologies (Java SE, Java ME, JavaFX) for mobile and embedded devices.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today