Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

BlueGPS for J2ME – The Saga Continues

Aug 29

In my last post I mentioned that I was unable to retrieve the Bluetooth address of my GPS receiver, this wasn’t entirely accurate. I stumbled across Benhui’s Bluelet library that simplies Bluetooth device/service discovery. This worked like a charm but the problem turned out to be making a call for the first service record:

ServiceRecord r = bluelet.getFirstDiscoveredService();

kept returning null. Therefore I was unable to retrieve the connection URL for connecting to the device using the serial port profile. So what I had to do was build the URL manually from the device’s Bluetooth address. So in the Bluelet code I created a variable that stores the device address and was able to access it my MIDlet using:

url = “btspp://” + bluelet.btaddr + “:1″;

Notice the connection string built around the device address. I’ve successfully connected to the device and now it’s time to write the parser to decode the NMEA 0183 sentences.

Read More

Bluetooth GPS with J2ME

Aug 27

I’ve been working hard to move my BlueGPS application to J2ME. This will enable the application to run on millions of more devices than it’s current Symbian implementation. The key will be getting past the technical hurdle that I’m currently faced with. I’m having problems with programmatically retrieving the device address of my Bluetooth receiver. Whenever I make the appropriate API call it continues to return null. I’ve read that some people have hardcoded the device address to get it to connect properly. In my opinion this doesn’t scale so I’m looking to get device discovery working.

If worse comes to worse I’ll have some sort of object that stores common Bluetooth device addresses. This will be something that needs to be updated continuously, but it will be much easier to maintain if the codebase in written in Java. This is just my personal preference here. I’m optimistic that I’ll get the device discovery working in my spare time over the next week. Once I do this will be worked into photo uploading where you can upload a photo and GPS location to be displayed on a Google map. It should be pretty tight and I’m excited about the potential it has. Stay tuned!

Read More

Simple Ruby with Ajax Example

Aug 25

With my ongoing investigation and fascination with Ruby on Rails I’ve been extremely impressed with the ajax integration. In most development scenarios you’re left with conjuring up the XMLHTTPRequest code on the client. While I’m a huge advocate of actually understanding the lower-level code I’m an even bigger advocate of abstraction. That’s why ColdFusion has always appealed to me. I’m becoming even more interested in ROR since it shields me from writing any JavaScript when using ajax. I’m not saying this is true in all cases but definitely for a majority of them.

So I wanted to walk through a simple example similar to my ColdFusion/Ajax IP address example. I don’t have ROR currently running on my server so this will walk you through running the example locally. I’m assuming that you have ROR up and running. If not, you can click here to learn more about installing it.

The first thing we’ll do is create our rails application in the appropriate directory. Within this directory you’ll want to issue the

rails ajax_demo

command to create the application framework. Now that the framework is created let’s go ahead and start the built-in Ruby WEBrick server. You’ll want to cd into the ajax_demo directory and issue the

ruby script/server

command to start the server. We can leave this running while we edit and save files for testing purposes. The application should now be running at http://localhost:3000. Now we’ll go ahead and create a controller so we can ultimately add the “get_ip” action to it. The command to generate the controller is

ruby script/generate controller Test

I use the controller name “Test” because I’m lacking creativity at this moment! Feel free to call this what you like as it won’t matter much in this example. You should now be able to browser to http://localhost:3000/test and receive the default “No action responded to index” message. Let’s fix this. Instead of getting into the details of creating different methods within our controller I’m going to create simple views (.rhtml files) that will be rendered when actions are invoked. Let me elaborate a little more. If you browse to the app/controllers/test_controller.rb file you’ll see the controller skeleton. If you add the following code within the class definition

and access http://localhost:3000/test again you’ll see the text printed to the page. The index method is the default for the controller and is what gets rendered and displayed to the user. If the method doesn’t exist then the views/test/index.rhtml view gets rendered. So let’s remove the method from the controller and create our index.rhtml view. The code looks something like

Notice the inclusion of the JavaScript prototype library which contains all of the necessary ajax functions. The next thing you’ll notice is the link_to_remote method which takes three paramers: 1. the text to display for the link 2. the id of the div to update and 3. the action to call. In our case we’re updating the “ipdiv” and calling the “get_ip” action.

Now we’re going to look into creating the get_ip method in our Test controller. Here’s the controller’s code