
Question:
I am developing a J2ME application to run in public areas, like supermarkets, shopping centers, etc. So, I want to make possible to install my application in every mobile phones nearby via bluetooth. My intention is to create a separate J2SE application to perform a device discovery and look for OBEX services. After that, ask the user to install the application.
I have tried using javax.microedition.io.Connector, but it always requires a both side (client and server) pass-key.
OBEXClientSessionImpl conn = (OBEXClientSessionImpl) Connector.open(serviceUrl);
I have also found obex-install, which does what I want but the pairing problem persists.
Is there a way to send/install .jar files programatically via bluetooth without pairing or using a fixed PIN number so I can't repeat it in server side?
Thanks in advance, Fernando
Solution:1
I developed a java application to do exactly what you pretend (scan and try to transfer the file to all the devices found) using bluecove and it worked fine on the initial tests. I am considering in the midterm future to opensource the tool or sell it.
Answering your question what I use is something like this (simplified version):
// @todo: scan for devices // @todo: for each device search obex push service String deviceObexUrl = serviceRecords[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); // send file ClientSession clientSession = (ClientSession) Connector.open(deviceObexUrl); HeaderSet hsConnectReply = clientSession.connect(null); if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) { return false; } byte data[] = readAllFile(file); HeaderSet headerSet = clientSession.createHeaderSet(); headerSet.setHeader(HeaderSet.NAME, file.getName()); headerSet.setHeader(HeaderSet.TYPE, mimeType); headerSet.setHeader(HeaderSet.LENGTH, new Long(data.length)); Operation op = clientSession.put(headerSet); OutputStream outputStream = op.openOutputStream(); // @todo: write all data and close outputStream, op and clientSession
Solution:2
It would be easier by using http OTA download. put your j2me jar file on a website, then you can let your client redirect to this website to download the jar file. you don't need the pass-key for OTA download.
Solution:3
What you're trying to do (sending files to a mobile device via OBEX) should be entirely possible without pairing. It sounds like you are trying to connect using authentication.
Try including the parameter "authenticate=false
" in your connection URL (e.g. btgoep://0123456789abcde:1;authenticate=false
).
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon