Hello,
Perhaps my question is silly.Look the way on how to establish the output and the input stream on this example from
wm_java_usersguide_v19 manual.
***************************************************
OutputStream dataOut = ATCmd.getDataOutputStream();
InputStream dataIn = ATCmd.getDataInputStream();
***************************************************
If getDataOutputStream returns a DataOutputStream object and getDataInputStream returns DataInputStream object something is wrong.Why not use getOutputStream and getInputStream directly?
OutputStream dataOut = ATCmd.getOutputStream();
InputStream dataIn = ATCmd.getInputStream();
Regards,
GF
wm_java_usersguide_v19
Page 102
12.1.1.3 Data Connections
If a data connection is created with the
ATCommand class, for instance with
ATD an input stream is opened to receive the data from the connection. Similarly, an output stream can be
opened to send data on the connection.
/* Please note that this example would not work unless the module had
* been initialized and logged into a network. */
System.out.println("Dialin g: ATD" + CALLED_NO);
response = atc.send("ATD" + CALLED_NO + "\r");
System.out.println("received: " + response);
if (response.indexOf("CONNECT") >= 0) {
try {
// We have a data connection, now we do some streaming...
// IOException will be thrown
if any of the Stream methods fail
OutputStream dataOut = ATCmd.getDataOutputStream();
InputStream dataIn = ATCmd.getDataInputStream();
// out streaming...
dataOut.write(new String("\n\rHello world\n\r").getBytes());
dataOut.write(new String("\n\r This data was sent by a Java " + "MIDlet!\n\r").getBytes());
dataOut.write(new String("Press 'Q' to close the " + "connection\n\r").getBytes());
// ...and in streaming System.out.println("Waiting
for incoming data, currently " + dataIn.available() + " bytes in buffer.");
rcv = 0;
while(((char)rcv != 'q') &&
((char)rcv != 'Q') && (rcv != -1)){
rcv = dataIn.read();
if (rcv >= 0) {
System.out.print((char)rcv);
}
}
/* continue example */
if (rcv != -1) {
// Now break the data connection
System.out.println ("\n\n\rBreaking connection");
try {
strRcv = ATCmd.breakConnection();
} catch(Exception e) {
System.out.println(e);
}
System.out.println("received: " + strRcv);
} else {
// Received EOF, somebody else broke the connection
System.out.println("\n\n\rSomebody else switched to " +
"command mode!");
}
System.out.println("Hanging up");
strRcv = ATCmd.send("ATH\r");
System.out.println("received: " + strRcv);
} catch(IOException e) {
System.out.println(e);
}
} else {
System.out.println("No data connection established,");
}