📄 cservice.html
字号:
</DL>
<HR>
<A NAME="setSmscNumber(java.lang.String)"><!-- --></A><H3>
setSmscNumber</H3>
<PRE>
public void <B>setSmscNumber</B>(java.lang.String smscNumber)</PRE>
<DL>
<DD>Sets the Short Message Service Center (SMSC) number. Please use international format. If you don't want to set the SMSC and use the one defined in your GSM device, use an empty string parameter. Another way to do the same, is to pass a null parameter. Some phones may prefer one way or the other - please test your phone.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>smscNumber</CODE> - the SMSC number.</DL>
</DD>
</DL>
<HR>
<A NAME="getSmscNumber()"><!-- --></A><H3>
getSmscNumber</H3>
<PRE>
public java.lang.String <B>getSmscNumber</B>()</PRE>
<DL>
<DD>Returns the Short Message Service Center (SMSC) number you have previously defined with setSmscNumber().
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the SMSC number.</DL>
</DD>
</DL>
<HR>
<A NAME="setSimPin(java.lang.String)"><!-- --></A><H3>
setSimPin</H3>
<PRE>
public void <B>setSimPin</B>(java.lang.String simPin)</PRE>
<DL>
<DD>Sets the SIM pin number. This is used if and when the GSM device asks for it. If you set it to null, then the API does not give any PIN to the device (in order to avoid locking it up), and returns ERR_SIM_PIN_ERROR.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>simPin</CODE> - the SIM pin number.</DL>
</DD>
</DL>
<HR>
<A NAME="setMessageHandler(org.jsmsengine.CSmsMessageListener)"><!-- --></A><H3>
setMessageHandler</H3>
<PRE>
public void <B>setMessageHandler</B>(<A HREF="../../org/jsmsengine/CSmsMessageListener.html" title="interface in org.jsmsengine">CSmsMessageListener</A> messageHandler)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getSimPin()"><!-- --></A><H3>
getSimPin</H3>
<PRE>
public java.lang.String <B>getSimPin</B>()</PRE>
<DL>
<DD>Returns the SIM pin number.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the SIM pin number.</DL>
</DD>
</DL>
<HR>
<A NAME="setReceiveMode(int)"><!-- --></A><H3>
setReceiveMode</H3>
<PRE>
public void <B>setReceiveMode</B>(int receiveMode)</PRE>
<DL>
<DD>Sets the reception mode. There are two reception modes, the synchronous and the asynchronous. In synchronous mode, you should call readMessages() function on demand, where you want to check for new messages. In asynchronous mode, the engine automatically calls the received() method (which you <strong>should</strong> override) for every received message. <br>By default, the reception mode is the synchronous one.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>receiveMode</CODE> - the reception mode (one of values RECEIVE_MODE_ASYNC, RECEIVE_MODE_SYNC).<DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CService.html#getReceiveMode()"><CODE>getReceiveMode()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getReceiveMode()"><!-- --></A><H3>
getReceiveMode</H3>
<PRE>
public int <B>getReceiveMode</B>()</PRE>
<DL>
<DD>Returns the reception mode.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the reception mode (one of values RECEIVE_MODE_ASYNC, RECEIVE_MODE_SYNC).<DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CService.html#setReceiveMode(int)"><CODE>setReceiveMode(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setPhoneBook(java.lang.String)"><!-- --></A><H3>
setPhoneBook</H3>
<PRE>
public void <B>setPhoneBook</B>(java.lang.String phoneBookFile)
throws java.lang.Exception</PRE>
<DL>
<DD>Loads the phonebook. The phonebook is an XML file containing associations of name and phone numbers. <br><br> <strong>The phonebook is optional.</strong>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>phoneBookFile</CODE> - The XML full-path name which keeps the phonebook.
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CPhoneBook.html" title="class in org.jsmsengine"><CODE>CPhoneBook</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#sendMessage(org.jsmsengine.COutgoingMessage)"><CODE>sendMessage(COutgoingMessage)</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#sendMessage(java.util.LinkedList)"><CODE>sendMessage(LinkedList)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getMessageHandler()"><!-- --></A><H3>
getMessageHandler</H3>
<PRE>
protected <A HREF="../../org/jsmsengine/CSmsMessageListener.html" title="interface in org.jsmsengine">CSmsMessageListener</A> <B>getMessageHandler</B>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="connect()"><!-- --></A><H3>
connect</H3>
<PRE>
public void <B>connect</B>()
throws java.lang.Exception</PRE>
<DL>
<DD>Connects to the GSM device. Opens the serial port, and sends the appropriate AT commands to initialize the operation mode of the GSM device. Retrieves information about the GSM device. Notes: <br> <ul> <li>The GSM device specific information (read by the call to refreshDeviceInfo() function is called once from this method. Since some information changes with time (such as battery or signal level), its your responsibility to call refreshDeviceInfo() periodically in order to have the latest information. Otherwise, you will get the information snapshot taken at the time of the initial connection. </li> </ul>
<P>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../org/jsmsengine/AlreadyConnectedException.html" title="class in org.jsmsengine">AlreadyConnectedException</A></CODE>
<DD><CODE><A HREF="../../org/jsmsengine/NoPinException.html" title="class in org.jsmsengine">NoPinException</A></CODE>
<DD><CODE><A HREF="../../org/jsmsengine/InvalidPinException.html" title="class in org.jsmsengine">InvalidPinException</A></CODE>
<DD><CODE><A HREF="../../org/jsmsengine/NoPduSupportException.html" title="class in org.jsmsengine">NoPduSupportException</A></CODE>
<DD><CODE><A HREF="../../org/jsmsengine/CannotDisableIndicationsException.html" title="class in org.jsmsengine">CannotDisableIndicationsException</A></CODE>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CDeviceInfo.html" title="class in org.jsmsengine"><CODE>CDeviceInfo</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#refreshDeviceInfo()"><CODE>refreshDeviceInfo()</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#disconnect()"><CODE>disconnect()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="disconnect()"><!-- --></A><H3>
disconnect</H3>
<PRE>
public void <B>disconnect</B>()</PRE>
<DL>
<DD>Disconnects to the GSM device. Closes the serial port.
<P>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CService.html#connect()"><CODE>connect()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="readMessages(java.util.LinkedList, int)"><!-- --></A><H3>
readMessages</H3>
<PRE>
public void <B>readMessages</B>(java.util.LinkedList messageList,
int messageClass)
throws java.lang.Exception</PRE>
<DL>
<DD>Reads SMS from the GSM device's memory. You should call this method when you want to read messages from the device. In the MessageList object you pass, the method will add objects of type CIncomingMessage, as many of them as the messages pending to be read. The class defines which types of messages should be read. <br><br> <strong>Notes:</strong> <ul> <li>The method <strong>does not delete</strong> the messages it reads from the GSM device. It's your responsibility to delete them, if you don't want them. Otherwise, on the next call of this function you will read the same messages.</li> </ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>messageList</CODE> - a LinkedList object which will be loaded with the messages.<DD><CODE>messageClass</CODE> - one of the CLASS_* values defined in CIncomingMessage class which define what type of messages are to be read.
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../org/jsmsengine/NotConnectedException.html" title="class in org.jsmsengine">NotConnectedException</A></CODE>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CIncomingMessage.html" title="class in org.jsmsengine"><CODE>CIncomingMessage</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#deleteMessage(org.jsmsengine.CIncomingMessage)"><CODE>deleteMessage(CIncomingMessage)</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#deleteMessage(int)"><CODE>deleteMessage(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="sendMessage(org.jsmsengine.COutgoingMessage)"><!-- --></A><H3>
sendMessage</H3>
<PRE>
public boolean <B>sendMessage</B>(<A HREF="../../org/jsmsengine/COutgoingMessage.html" title="class in org.jsmsengine">COutgoingMessage</A> message)
throws java.lang.Exception</PRE>
<DL>
<DD>Send an SMS message from the GSM device. Once connected, you can create a COutgoingMessage object with the message you want to send, and pass it to this function. <br><br> <strong>Notes:</strong> <ul> <li>If you have set a phonebook, you can create the COutgoingMessage object with a nickname, instead of the actual phone number.</li> </ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>message</CODE> - a COutgoingMessage containing the message you wish to send.
<DT><B>Returns:</B><DD>true if sending succeded.
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/COutgoingMessage.html" title="class in org.jsmsengine"><CODE>COutgoingMessage</CODE></A>,
<A HREF="../../org/jsmsengine/CPhoneBook.html" title="class in org.jsmsengine"><CODE>CPhoneBook</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#sendMessage(java.util.LinkedList)"><CODE>sendMessage(LinkedList)</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#setPhoneBook(java.lang.String)"><CODE>setPhoneBook(String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="sendMessage(java.util.LinkedList)"><!-- --></A><H3>
sendMessage</H3>
<PRE>
public void <B>sendMessage</B>(java.util.LinkedList messageList)
throws java.lang.Exception</PRE>
<DL>
<DD>Send an series of SMS messages from the GSM device. This method is used when you want to send more than one message as a batch. If your GSM device support the feature of keeping the GSM link open during message dispatch, this method should work faster than calling the sendMessage(COutgoingMessage) method many times. <br> Just create a LinkedList object, add as many COutgoingMessage objects you wish and call the method. <br><br> <strong>Notes:</strong> <ul> <li>If you have set a phonebook, you can create the COutgoingMessage object with a nickname, instead of the actual phone number.</li> </ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>messageList</CODE> - a LinkedList filled with COutgoingMessage objects.
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../org/jsmsengine/NotConnectedException.html" title="class in org.jsmsengine">NotConnectedException</A></CODE>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/COutgoingMessage.html" title="class in org.jsmsengine"><CODE>COutgoingMessage</CODE></A>,
<A HREF="../../org/jsmsengine/CPhoneBook.html" title="class in org.jsmsengine"><CODE>CPhoneBook</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#sendMessage(org.jsmsengine.COutgoingMessage)"><CODE>sendMessage(COutgoingMessage)</CODE></A>,
<A HREF="../../org/jsmsengine/CService.html#setPhoneBook(java.lang.String)"><CODE>setPhoneBook(String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="deleteMessage(int)"><!-- --></A><H3>
deleteMessage</H3>
<PRE>
public void <B>deleteMessage</B>(int memIndex)
throws java.lang.Exception</PRE>
<DL>
<DD>Deletes an SMS message from the GSM device memory. <br><br> <strong>Notes:</strong> <ul> <li>A deleted message cannot be recovered.</li> <li>It is highly recommended to use the other form of the deleteMessage() method.</li> </ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>memIndex</CODE> - the memory index of the GSM device's memory from where the message (if there is any message there) should be deleted.
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../org/jsmsengine/NotConnectedException.html" title="class in org.jsmsengine">NotConnectedException</A></CODE>
<DD><CODE>java.lang.Exception</CODE><DT><B>See Also:</B><DD><A HREF="../../org/jsmsengine/CService.html#deleteMessage(org.jsmsengine.CIncomingMessage)"><CODE>deleteMessage(CIncomingMessage)</CODE></A></DL>
</DD>
</DL>
<HR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -