| Reply | « Previous Thread | Next Thread » |
|
Hi again, Fisrt of all happy new year. I had already made this question but I was bussy trying to solve another problems with my application and I forgot for a moment this one. I still need help because I haven´t be able to solve it.
I developed a MIDlet using Net Beans IDE 6.0.1, Java 1.6.0_05 and OS XP. This application send a string from a cellular using bluetooth to another cellular phone, in the simulator it works properly, but once in the nokia telephones it doesn´t send anything, the MIDlet run and works good but when I try to send, it send nothing. Testing the midlet in sony ericsson phones, it works perfectly and send the string as it should do, but I need to use it in nokia phones. By the way, the MIDlet detects perfectly the bluetooth devices (the problem is when I try to send the string). I´m using javax.bluetooth.*, DataOutputStream, and writechars. My code is this: //”msg” is the message I need to send public void sendM(String msg){ ServiceRecord sr = (ServiceRecord)servicios_encontrados.elementAt(0); String URL = sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false); try{ StreamConnection con = (StreamConnection)Connector.open(URL); DataOutputStream out = con.openDataOutputStream(); out.writeChars(msg); out.flush(); out.close(); con.close(); mostrarAlarma(null, SPPCliente, 2); } catch(Exception e){ mostrarAlarma(e, SPPCliente, 0); } } The method "mostrarAlarma" is used just for display some message like "The string was sent" or "There was a problem". In nokia phones my MIDlet show neither "The string was sent" nor "There was a problem", it just return to the previous screen. I was wondering if nokia phones (in this case simbian) need to configure some privilegies or I´m missing some code. Please help me, I will be really grateful. |
|
I'm using NetBeans 6.5 with the WTK 2.5.2. The WTK only emulates the BT connection, but it reacts quite similar to the real devices.
It might be a good idea to connect only once and keep the streams as (private) class objects or send the stream as an method argument, so that you don't reconnect to the device for each message you want to send. In my program I'm using OutputStream (not DataOutputStream) and then its Code:
os.write(msg.getBytes()); |
|
Quote:
|
|
Are you sure that the ServiceRecord which you're connecting to is a Serial Port service (UUID = 0x1101)?
and then the URL string should begin with "btspp:". Can you maybe post your receive message function? It might be that your problem lies rather in your receive and not in your send function... |
|
Hi Pada, thanks for your answer, yeah... the UUID is 0x1101, and I verified the value of my URL String when I try to connect and it is , for example: btspp://001C35947988:15;authenticate=false;encrypt=false;master=false. Now I´m using my nokia telephone to send, and my sony ericsson to receive. I don´t think the problem is in the receiver because when I use the transfer MIDlet in a sony ericsson and the receiver in another sony ericsson, it receives the string whitout problem. I discovered that when the receiver is in a nokia telephone and the transfer in a sony ericsson, there is an exception in the transfer: java.lang.illegalArgumentException... My code for receiving data is:
while(!fin){ try{ append("waiting message:",null); sc = servidor.acceptAndOpen(); rd = rd.getRemoteDevice(sc); DataInputStream in = sc.openDataInputStream(); Alert alerta; char p = in.readChar(); alerta = new Alert("Data received", null, AlertType.ERROR); SPPServidorMIDlet.display.setCurrent(alerta,this); sc.close(); } catch(Exception e){ mostrarAlarma(e,this, 0); return; } Thanks again |
|
Hmm, I'm sorry, I don't know that much about these Bluetooth connections to help you anymore...
Can you post the IllegalArgumentException's description? If you got "java.lang.IllegalArgumentException: can't use the local address.", then its because your trying to connect to a fixed (your own device's) URL. You can have a look at the document http://developers.sun.com/mobility/a...bluetoothcore/ They are writing & reading a whole UTF-8 string using the DataOutputStream.writeUTF(String str) & String DataInputStream.readUTF() methods. The writeUTF writes the length of the string to the OutputStream first, and then the contents of the string. I'm also developing on Windows (Vista) and I'm using MicroEmu ( http://www.microemu.org/ ) together with the BlueCove bluetooth stack ( http://code.google.com/p/bluecove/ ) to debug/test my applications. MicroEmu allows me to use my PC's bluetooth (where as the WTK is only emulating bluetooth) to connect & communicate with other bluetooth devices (like cellphones). One problem with MicroEmu is that it can't display CustomItem components.
Last edited by Pada : 2009-01-20 at 13:46.
|
|
Please, do not create several threads about one topic: Where should someone answer? Let us continue with your original question …
Last edited by traud : 2009-01-23 at 15:32.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Bluetooth Connection Problem | atonical | General Symbian C++ | 4 | 2008-11-28 12:20 |
| which phones for laptop | dvdljns | PC Suite API and PC Connectivity SDK | 2 | 2006-02-14 13:58 |
| 7650 Bluetooth Modem with Toshiba Tecra 9000 Windows XP - RESOLVED Now! | d0lph1n | Bluetooth Technology | 5 | 2003-02-07 12:25 |