Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us
 

Forward Logo (image)      

J2ME Application
to Connect to pfodDevices™

by Matthew Ford 21st July 2012 (original 2nd December 2010)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

J2ME Application for connecting Mobile Phones to pfodDevices™ V1.2

This page provides a J2ME application the implements most, but not all, of the pfodSpecification

NOTE: This J2ME application has been superseded by the pfodAppTM for AndroidTM

The J2ME application provided here does not honour a pfodDevice's re-request time. You need to manually refresh (see the option under the Menu. It also displays only very limited prompt text on the navigation screen and does not filter the text input screen to remove special characters. Because of these deficiencies the J2ME application does not meet the standard necessary to be called a J2MEapp. However it provides enough utility to be useful in controlling pfodDevices, so I am making it freely available. See here for pfodAppTM for AndroidTM and for more details on pfodTM.

Table of Contents

Choosing your Mobile Phone

To use the J2MEapp, you need a suitable mobile phone. Your Mobile Phone needs that supports the Java JSR-82 Java Bluetooth API. My old phone did not so I purchased an inexpensive Samsung C3110. I used the website http://www.club-java.com/TastePhone/J2ME/MIDP_Benchmark.jsp to check if the phone would support Java JSR-82. Or you can just down load the J2MEapp and see if it runs.

The J2MEapp.jar (updated 30th July 2012 to V1.2) and J2MEapp.jad files are available for download. Right click on the links and choose Save Link As.. and save both these files to your hard drive and then transfer them to your phone. There is also a J2M2.zip file containing both files. (See Loading Java Programs to your Phone)

When you run the program you should see a display something like this.

Setting up the Connections

Once you have confirmed the J2ME App runs on your phone, you need to set your own connection list. This is done by editing the J2MEapp.jad text file. First take a copy of the file in case your changes don't work.


The last line is the only line you need to change
pfodDevices: 0066601E8B2~PC,0|00066601E6A0~Led Controller,1000

The pfodDevices: line is where you define the bluetooth addresses and display names and timeouts for each pfodDevice you want to connect to. The format is
<bluetoothAddress> [[ ~ <displayName> ] [ , <charTimeOut>]] [ | <bluetoothAddress> [[ ~ <displayName> ] [ , <cmdTimeOut>]] ]*
The [ ] indicate optional sections, [ ]* means zero or more of these sections.

That is, one pfodDevice™ connection must be defined and you can add as many others as you like each separated by the | character. Within each connection the display name and timeout are optional. If the displayName is omitted then the bluetooth address is displayed in the Connect To menu. If the command timeout is omitted, then the default of 0mS is used, i.e. never times out waiting for a response. Setting a character timeout of 0 means the connection never times out. This is useful for testing.

Looking at the current settings,
pfodDevices: 0066601E8B2~PC,0|00066601E6A0~Led Controller,1000
This line defines two pfodDevice™ connections separated by |

For the first connection the bluetooth address is 0066601E8B2 , you should change this to the bluetooth address of your laptop. Look in the Control Panel under Bluetooth Connection for your Device Address address. The screen shots below are from my Sony Vaio running Windows 2000. Your Bluetooth configuration screen may look different.

Don't enter the :'s just put in the 12 characters, shown below blanked out.



Following the bluetooth address is the menu display name separated by
~ in this case just PC Then comes the character timeout, separated by , in this case 0 which means the connection never times out waiting for the start of message or for the next character in a message.

The second connection is separated from the first by | and defines the bluetooth address of the Led Controller. You can read the bluetooth address off the label on the SparkFun's bluetooth module. This connection defines a connection timeout of 1000mS. This means the Led Controller connection must respond to a message within 1sec, otherwise the J2MEapp will assume the connection is broken and will disconnect.

Connecting to Your Computer (Windows, Mac or Linux)

To test the J2ME application, you can connect to a terminal emulator on your compute via serial bluetooth as detailed here.

Connecting J2MEapp to TeraTerm

You need to start TeraTerm before connecting from your mobile phone J2MEapp, because the J2MEapp sends the getMainMenu message, {.}, immediately after the connection is established. If TeraTerm is not already running and listening to the bluetooth COM port, then you will miss this message.

Start the J2MEapp on your mobile phone and connect to your PC.

Choose the PC connection you have setup.



The TeraTerm window shows the {.} message from the J2MEapp.



The J2MEapp expects the pfodDevice™ to reply with its main menu of functionality. Type in the Main Menu response. Actually it is easier to type up the command in a text editor and then cut and paste it to the TeraTerm window because TeraTerm sends every character you type, immediately, including your typos.



The J2MEapp will display

This confirms that you J2MEapp is working. You can now try controlling a pfodDeviceTM like the ones described on this page.


pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2017 Forward Computing and Control Pty. Ltd. ACN 003 669 994