bluetooth on J2me platforms

Observations from an outlier

bluetooth on J2me platforms

bluetooth-on-j2me-platforms-vertical-challenge-3

ok, few links to errors I’m seeing thus far:

Future Exception is a new one! This error only started after I re-flashed my Nokia 5800 with version 21 of the firmware.

I used to get further, the URL was discovered from the service search and I’d even get asked for permission to connect… and then get This error

Again, my code is freely available to test your connection issues, but here is a snip. Notice that the URL is false for master, encrypt and for authenticate. This code is actually part of the ZephyrOpen Project for PC and MAC, but being JSR-82, this is supposed to work on the cell phones too.. and it does, just need a Black Berry 8100, that junk phone has never let me down with Devopment tools. Too bad it has no WIFI, could be used as a BT to WIFI bridge.

why does Word Press Mangle this code?

/** * Find and attach to serial port profile for this device * * @return true if connection was established, false if not */

public boolean connect() {

if( ! findService()) { constants.error(“can’t find serial port service on ” + getBluetoothAddress(), this); return false;

}

try {

constants.info( “url = ” + serviceURL, this);

/** open the serial port streams */ connection = (StreamConnection) Connector.open(serviceURL); inputStream = connection.openDataInputStream();

outputStream = connection.openDataOutputStream();

} catch (Exception e) { constants.error(“connect(): ” + e.getMessage(), this); return false;

}

/** all is well, streams open */ return true;

}

/** @return true if target device was found */
private boolean findService() {

constants.info(“Searching for SPP ” + getBluetoothAddress(), this);
serviceSearch = true;

/** Serial Port Profile UUID */ int[] attributes = { 0x100 };

UUID[] uuids = {com.intel.bluetooth.BluetoothConsts.RFCOMM_PROTOCOL_UUID};

/** look for serial port service */ int serviceSearchID = 0;

try {

serviceSearchID =
agent.searchServices(attributes, uuids, this, this);

/** spin lock */
while (serviceSearch) Thread.sleep(DELAY);

} catch (Exception e) { agent.cancelServiceSearch(serviceSearchID); return false;

}

/** found target serial port profile ? */ if( serviceURL == null ) return false; else return true;

}

/** found a service on this device */ public void servicesDiscovered(int arg0, ServiceRecord[] servRecord) {

for (int i = 0; i < servRecord.length; i++) {

DataElement nameElement = (DataElement) servRecord[i].getAttributeValue(0x100); if ((nameElement != null)

&& (nameElement.getDataType() == DataElement.STRING)) {

/** retrieve the name of the service */
String name = (String) nameElement.getValue();

if (name.equals(“Bluetooth Serial Port”)) { serviceURL = servRecord[i].getConnectionURL( ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); serviceSearch = false; } } }

}