August 29, 2005

BlueGPS for J2ME - The Saga Continues

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.

Posted by dennis baldwin at 11:38 PM | Comments (2)

August 27, 2005

Bluetooth GPS with J2ME

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!

Posted by dennis baldwin at 06:11 PM | Comments (0)

August 25, 2005

Simple Ruby with Ajax Example

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

We declare the ip variable here and then create a view called get_ip.rhtml. Remember that this will be stored in the views/test directory. The view is basic and simply returns some HTML text with an IP address embedded. It looks like

<strong>Your IP address is: <%= @ip %></strong>

Notice the use of <%= %> which is identical to JSP syntax. In our case it's known as Embedded Ruby (ERb). Now when the "Get IP Address" link is clicked the "get_ip" method is called, returns the IP address, and updates the "ipdiv". All of this without writing a single line of JavaScript! Well we had to do the include but I'm omitting that one-liner.

Although this was a simple example, ROR made it even simpler to implement. I'll be working on some more extensive examples in the future but continue to be blown away by the functionality you get out of the box.....and for FREE. The client and server are becoming more tightly knit and building true rich internet applications is becoming easier than ever.

Posted by dennis baldwin at 10:52 PM | Comments (0)

August 24, 2005

MoPhotos and MoBloggin'

I've been wanting to upload photos to my blog from my Nokia 6620. I first decided to tackle this using Symbian but realized that it would take me ten times longer than writing it using J2ME. Don't get me wrong, I love Symbian and the power it brings to development, but it's extremely complicated. I'm past the days of taking the most complicated approach to solve a problem. Luckily I found that the mobile media API is supported on my device. This was exciting news since I figured I could get a proof of concept working in a matter of nights. This past weekend I was able to get the device code to capture the photo and send it to my server via HTTP post. The next step was to then write a Java servlet to handle the input stream and write the image to disk.

I was able to bang out the servlet in a matter of a couple hours and was pretty pumped about this. It turned out that the servlet or device (not exactly sure) was unable to handle the stream property. So after some digging around I learned that I might need to Base64 encode the image before posting to the server and then let the servlet decode it. This was a mind numbing process that I finally got to work, definitely LONG overdue.

So I'm now able to take photos from anywhere and upload them to the server over my GPRS connection (I'm probably Cingular's #1 customer right now). The next piece was getting them integrated with my blog. On the blog index page you'll see the most recent photo taken with my device. I'm only sending them up at 320x240 res, but plan on publishing the app and making this user configurable. The photo is displayed via a simple ajax call since it integrates nicely with my blog. I'll be working on the Ruby on Rails piece to create a nice photo album to support the uploaded photos.

If you've read any of my previous posts you'll know that I'm literally all over the place. This is definitely the case but as I further my development and investigation of technologies I can see something start to formalize. Please stay tuned and I promise not to let you down!

One last note, I'll be working on getting my Bluetooth GPS integrated with the MoPhoto app so users will be able to upload photos as well as GPS coords. I think you know where I'm heading with this but I'll leave it up to your imagination. If you have any suggestions I would love to hear them.

Posted by dennis baldwin at 08:23 PM | Comments (0)

August 21, 2005

Simple Ajax and ColdFusion Example

If you've read anything about Ajax lately you've probably heard it's the next big thing. Everyone seems to interpret Ajax as this incredible framework for web development that should simplify our lives. The reality is there's no framework at all and it's simply a transport mechanism to send data to the server and back, all without a page refresh. It's all about the user experience here. Ajax enables developers to build applications that are extremely user-friendly and appear to behave similar to desktop applications. A good example of this is Google Maps.

Ajax has been around since 1998 and if you've done any Flash development you'll know that sending/loading data behind the scenes is old school. Flash gives us unlimited capabilities with LoadVariables, XML objects, Web Services, and Flash Remoting. All of these approaches enable developers to load data from a remote location without the need for a page refresh. This is HUGE because it minimizes the amount of data that is sent to and from the server and decreases the amount of time the user has to wait. As Ajax adoption grows I believe we'll start seeing some incredible UI components similar to what Flash offers. There's already some powerful technology becoming available in the server market and a great example is WebORB.

With all this being said I was blown away by the support for Ajax integrated into Ruby on Rails. It actually isolates the developer from having to write any low-level code such as dealing with XMLHTTPRequest directly. I'm fascinated by Ruby on Rails, but let me take a step back and give an example using ColdFusion. I've always loved ColdFusion because of the simplicity and it's where I started on this mad web journey back in '98!

This basic example demonstrates how to make a remote call to a .cfm that returns an IP address. The IP address is wrapped in a simple xml tag and returned to the client. The response looks like:

<result>127.0.0.1</result>

When the result handler receives the response it populates the text field with the client's ip address. This is all done asynchronously (can be made synchronous) which, in my opinion, improves the user experience. To sum it up this means the user does not have to wait for the response and can perform other operations while waiting. I encourage you to run the example and view the source to see how easy it is. Stay tuned for more Ajax adventures, but from an ROR perspective.

Posted by dennis baldwin at 08:42 PM | Comments (0)

August 18, 2005

Google Maps Info Window

I spent a little time this evening updating my Google Maps app to support clicking on a location icon. I struggled with this a few weeks ago where clicking on an icon didn't do anything even though I had added the necessary code to display the info window. It turns out that I was missing one basic parameter:

infoWindowAnchor

This property requires a GPoint that tells it where to anchor the window in relation to the top left of the icon. So the code will ultimately look something like:

icon.infoWindowAnchor = new GPoint(5, 1);

So if you click on any of the icons on my Google Maps app then you should see a window display with the lat, lng, and date/time for that location. I'm working on adding support to display images uploaded from a mobile device or computer, which will hopefully tie into my Ruby on Rails app. Yes I'm highly optimistic I can get all this done within the next month, stay tuned!

Posted by dennis baldwin at 11:28 PM | Comments (0)

August 17, 2005

Puttin' Ruby on Rails

I've been reading a great book called "Agile Web Development with Rails". I stumbled across Ruby on Rails a few weeks ago and was intrigued with all the hype. I come from a strong ColdFusion background with moderate experience working with JSP and PHP. ColdFusion has enabled me to rapidly prototype and develop applications in the past and has always been my weapon of choice.

ROR has enormous potential and provides a very object oriented framework that lends well to web development. Prior to ColdFusion CFCs everything was pretty much spaghetti code. CFCs enabled us to be more methodical in our approaches to web apps, but left us a bit short. ROR takes an MVC approach to web development. I've shunned the thought of MVC in web apps in the past, but believe it definitely has a place. I've often felt that MVC was an unnecessary complexity but ROR has proven me wrong. It provides a very clean approach and makes code maintenance and building new functionality a breeze.

I'll be posting more in the coming weeks and stay tuned for a public (possibly open source) ROR app that I'll be releasing in the near future. This is mainly an exercise to learn more about the technology as well as release a useful app into the community.

Posted by dennis baldwin at 10:21 PM | Comments (0)

August 16, 2005

Patch Your Kernel and Become a Linux Supervillian

If you've ever used linux then this about sums it up:

http://mirror1.spikedhumor.com/1209/SwitchLinux.swf

My favorite line is when he mentions "patching your kernel" and throws up a nice salute. Despite this anecdotal Flash movie, Linux has become much more user friendly and if you decide to give it a go I would recommend Knoppix which runs from a CD. That way, you can try before you format or partition. Luckily we have a couple of solid alternatives to M$, although Vista looks very cool. I don't think it's going to be enough to sway me from the Tiger!

Posted by dennis baldwin at 10:15 PM | Comments (0)

August 11, 2005

Konsider Konfabulator

A good friend of mine emailed me early this week asking if my Golf Tips widget would run in Konfabulator. I was fairly optimistic that it would work with a few tweaks. I think he knew that if he planted the seed I would get around to porting it. So I got started this eve and made huge progress. I have to say that the Konfabulator dev environment is one of the easiest that I've worked with yet. They support all kinds of crazy JavaScript that lets you grab system information such as memory usage, battery level, cpu usage, etc. There's even a speak function that will do text-to-speech. This works like a champ on my Mac but haven't tried it on Win.

I'm posting a screen of the current working version which I plan on publishing here and the Konfabulator widget gallery this weekend. In my opinion, the user experience of Konfabulator blows the Mac OS X dashboard concept out of the water. It's even rumored that Mac stole the concept from Konfabulator which doesn't suprise me. Anyway, you can have certain widgets activated at all times that sit on top of your applications. On OS X you have to go to the Dashboard to view the widgets. There's a hack where you can select and hold a widget from the dock, hit F12, and actuallly drop it on your desktop. Yet this doesn't even come close to the Konfabulator experience. I could go on and on but you should download a copy (it's completely free) and use it. I'm currently running it on both my Mac and PC.

The most incredible thing about this whole "Dashboard" concept is that Konfabulator was recently purchased by Yahoo. Can you say three guys in a garage writing killer software?!? That's right.....THREE GUYS! I'm blown away by the quality of the product in terms of funtionality, easy of development, documentation, and gorgeous graphics. The CEO of Konfab, Arlo Rose, puts out some KILLER widgets. I'm not sure if he does the actual widget design himself, but there's some amazing talent coming from this team. So stay tuned for my Konfab Golf Tips widget and here's the preliminary screen:

Posted by dennis baldwin at 11:51 PM | Comments (0)

August 07, 2005

PolkaDachs.com Launched

Lately I've been doing a good amount of soul searching to find out what it is I really want to do in life. I won't go into detail about that here and promise to get back to it in a future post. It basically boils down to the fact that I need to be involved with technology. I have a huge passion for all things tech and that's why you've seen products such as BlueGPS, Daylite, and GolfTips from me. About the only thing these products have in common are the fact that they're somewhat tech related. While I continue to search for "the product" I like to fill the void with odds and ends.

With that being said I'd like to share my latest spare-time project: www.polkadachs.com. This concept was dreamed up by my wife and she truly has a creative talent for these types of projects. She's had every creative idea under the sun and I think she's found one that will keep her busy for years to come. I decided to build the site for her because it's been over a year since I've done any e-commerce work and I was up for the challenge. The most exciting part for me was doing the site design since I don't have many opportunities to do this kind of work anymore. Actually, this blog needs a serious facelift and maybe I'll make that my next project.

The key to the PolkaDachs site was keeping it simple and making the shopping experience as fun as possible. One product that enabled us to do this was a shopping cart system known as x-cart. A huge shout out to my buddy Brent Evans @ Holland Simpson for turning me on to this product. You would not believe the granularity you get when customizing the shopping cart and there are options for EVERYTHING. It's seriously one of the most affordable/functional shopping cart systems I've ever used. Let me also add that the out-of-the-box templates are butt ugly. So be sure to contact a true professional like Brent or myself to get you up and running ;) Customization of this system is definitely a lengthy process.

So please feel free to check it out and let me know what you think. Now that I've filled one void with this project I can get back to my next idea.....more on that later!

Posted by dennis baldwin at 08:46 PM | Comments (0)