This is not realley about J2ME but interesting anyway.
I tinkered around with the open source J2SE JSR-82 implementation BlueCove (
http://sourceforge.net/projects/bluecove/) and the OBEX on JSR82 implementation avetanaOBEX (
http://sourceforge.net/projects/avetanaobex/).
I managed to send an obex put from my PC to my phone. This was really easy.
import java.io.IOException;import de.avetana.javax.obex.*;
import de.avetana.obexsolo.*;public class OBEXTest {public static void main(String[] args){ try {
String adr = "btgoep://006057d7cdd5:9"; // no lookup code here … put your phone's bt address here!
ClientSession cs = (ClientSession) OBEXConnector.open (adr);
System.out.println("opening");
HeaderSet hs = cs.connect(cs.createHeaderSet());
System.out.println("created header set");
byte text[] = "Test Message from avetanaBlueooth".getBytes("iso-8859-1");
hs.setHeader (HeaderSet.NAME, "test.txt");
hs.setHeader (HeaderSet.TYPE, "text");
//hs.setHeader(0x49, text); // if everything fits inside a packet, the data can be packed in the PUT command
System.out.println("putting....");
Operation po = cs.put(hs);
System.out.println("put....");
po.openOutputStream().write(text);
po.close();
cs.disconnect(null);
cs.close();
System.out.println("closed...");
} catch (Throwable e) {
e.printStackTrace();
}
}
}The only thing you need beside the two jars and the BlueCove DLL in path is the ContentConnection interface. I've put it into
additional.jar for your convenience.
Unfortunately the other way around (receiving obex) doesn't work because BlueCove doesn't support "updateRecord". This might be because the Microsoft Bluetooth Stack don't supports this.