Data Connections - Siemens XT65 User Manual

Siemens cell phone accessories user manual
Hide thumbs Also See for XT65:
Table of Contents

Advertisement

Java User's Guide
13.1 Using the AT Command API
122
13.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("Dialing: 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\rThis 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);
}
}
/* The example continues after the next block of text */
wm_java_usersguide_v12
Confidential / Released
Page 115 of 123
s
2008-02-25

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ac65Ac75Xt75Tc65

Table of Contents