views:

655

answers:

8

Hi,

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

+1  A: 

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.

Steve Zhang
Thanks Steve, but I'm looking for a bluetooth solution.
nandokakimoto
A: 

For more details check here

Bozho
+1  A: 

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
rjlopes
Thanks rjlopes. But my mobile always requires a PIN code to connect with its service. Is there some way to avoid this kind of behavior?
nandokakimoto
The NOAUTHENTICATE_NOENCRYPT should do that, but I didn't tested on all mobile phones: http://bluecove.org/bluecove/apidocs/javax/bluetooth/ServiceRecord.html#NOAUTHENTICATE_NOENCRYPT
rjlopes
A: 

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).

funkybro
funkybro, my service already contains this parameter. btgoep://001BAFE7B45F:11;authenticate=false;encrypt=false;master=false
nandokakimoto
A: 

r u solve this issue? i am suffering from same problem. connector.open() always need client & server. is it not possible to send a file without client program?

gourob
A: 

Hi guys, I guess I have a problem like this. can any one help me?????PLEASE! I need to develop an application which will be called by a server. The task of application is the following: Every time that the server calls the application, it takes all the java sources for a Midlet(using LWUIT) application and then after Obfuscation, creates the jar file. Is there any simple way to do this? from where should I start?

Lina
A: 

How read a file?

chtistian
A: 

@rjlopes

i am using below code to send file. (instead of reading from file i am putting the content in the string just to test...)

On remote device, connection established, passcode exchange etc working fine. Even i got Beep "1 new message" when file transfer completed. But i am not able to get file anywhere on remote device,

i tried with multiple mime-type, like plaintext,html etc. but not much moving ahead. Wondering where the file is going ? i checked inbox, image, games, application etc in the phone but it is going no where... ( i am trying to exchange file from Nokia E51 to Nokia N73 for testing)

Any clue ?


byte[] fileContent = "Raxit Sheth -98922 38248".getBytes(); HeaderSet headerSet = connection.createHeaderSet(); headerSet.setHeader(HeaderSet.NAME, "a.jar"); headerSet.setHeader(HeaderSet.TYPE, "application/java-archive"); headerSet.setHeader(HeaderSet.LENGTH, new Long(fileContent.length)); myForm.append("Debug1.3"); operation = connection.put(headerSet); myForm.append("Debug1.4"); OutputStream out = operation.openOutputStream(); myForm.append("Debug2"); myForm.append("Debug3"); out.write(fileContent); //out.write(-1); myForm.append("Debug4"); out.close(); int responseCode = operation.getResponseCode(); operation.close();

connection.close();

raxit