Java User’s Guide
13.1 Using the AT Command API
122
s
wm_java_usersguide_v12 Page 114 of 123 2008-02-25
Confidential / Released
13.1.1.2 Sending an AT Command to the Device, the send() Method
An AT command is sent to the device by using the send() method. The AT command is sent
as a string which must include the finalizing line feed "\r" or the corresponding line end charac-
ter.
This send function is a blocking call, which means that the calling thread will be interrupted until
the module returns a response. The function returns the response, the result code of the AT
command, as a string.
Occasionally it may be infeasible to wait for an AT command that requires some time to be pro-
cessed, such as AT+COPS. There is a second, non-blocking, send function which takes a sec-
ond parameter in addition to the AT command. This second parameter is a callback instance,
ATCommandResponseListener. Any response to the AT command is delivered to the callback
instance when it becomes available. The method itself returns immediately. The ATComman-
dResponseListener and the non-blocking send method are described in Section 13.1.2.
Note: Using the send methods with strings with incorrect AT command syntax will cause errors.
String response = atc.send(“at+cpin?\r”);
/* method returns when the module returns a response */
System.out.println(response);
#Possible response printed to System.out:
+CPIN: READY OK