View Javadoc
1   package net.sf.atmodem4j.core;
2   
3   /*
4    * #%L
5    * ATModem4J Core
6    * %%
7    * Copyright (C) 2009 - 2014 atmodem4j
8    * %%
9    * atmodem4j - Drivers for the AT modem - http://atmodem4j.sourceforge.net/
10   * Copyright (C) 2009-2014, atmodem4j.sf.net, and individual contributors as indicated
11   * by the @authors tag. See the copyright.txt in the distribution for a
12   * full listing of individual contributors.
13   * 
14   * This is free software; you can redistribute it and/or modify it
15   * under the terms of the GNU General Public License as
16   * published by the Free Software Foundation; either version 3 of
17   * the License, or (at your option) any later version.
18   * 
19   * This software is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22   * Lesser General Public License for more details.
23   * 
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this software; if not, write to the Free
26   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28   * #L%
29   */
30  
31  import java.io.IOException;
32  import java.io.InputStream;
33  import java.io.OutputStream;
34  import net.sf.atmodem4j.core.fax.FaxExtention;
35  import net.sf.atmodem4j.core.gsm.GsmExtention;
36  import net.sf.atmodem4j.core.parser.Parser;
37  import net.sf.atmodem4j.core.parser.ResultCodeToken;
38  import net.sf.atmodem4j.core.voice.VoiceExtention;
39  
40  /**
41   * Main Interface that encapsulates the real modem implementation.
42   *
43   * @author aploese
44   */
45  public interface Modem {
46  
47      /**
48       * Clrl+Z for finishing prompt (gsm sm useage) also known as end of file.
49       */
50      static final char EOF = (char) 0x1A;
51  
52      enum ModemCapabilities {
53          Data, Voice, Fax, Gsm;
54  
55          static ModemCapabilities[] parseCapabilities(String extractLineData) {
56              throw new UnsupportedOperationException("Not yet implemented");
57          }
58      }
59  
60      /**
61       * The state of the modem
62       */
63      enum CallState {
64  
65          Idle, DialPending, AnswerPending, callEstablished;
66      };
67  
68      /**
69       * The default time
70       * @return
71       */
72      int getDefaultWaitTime();
73  
74      int getDefaultTrys();
75  
76      boolean isIdle();
77  
78      void garbageCollected(Parser parser, String s);
79  
80      void parsedResultCode(Parser parser, ResultCodeToken r);
81  
82      void parsedPrompt(Parser parser);
83  
84      void parsedRing(Parser parser);
85  
86      boolean init() throws IOException, InterruptedException;
87  
88      boolean init(String... initStrings) throws IOException, InterruptedException;
89  
90      void removeIncommingCallHandler(CallHandler callHandler);
91  
92      void setIncommingCallHandler(CallHandler callHandler) throws
93              IOException,
94              InterruptedException;
95  
96      boolean sendAndWaitForOK(String cmdLine) throws IOException,
97              InterruptedException;
98  
99      boolean sendAndWaitForOK(String cmdLine, int trys, int waitTime)
100             throws IOException, InterruptedException;
101 
102     boolean sendCommandLineWithPrompt(String command, String data) throws IOException, InterruptedException;
103 
104     String[] sendAndEctractData(String cmdLine) throws IOException,
105             InterruptedException;
106 
107     String[] sendAndEctractData(String cmdLine, int trys, int waitTime)
108             throws IOException, InterruptedException;
109 
110     void setRingListener(RingListener ringListener);
111 
112     void setModemInputStream(InputStream inputStream);
113 
114     void setModemOutputStream(OutputStream outputStream);
115 
116     boolean isGsmExtention();
117 
118     boolean isVoiceExtention();
119 
120     boolean isFaxExtention();
121 
122     GsmExtention getGsmExtention();
123 
124     void setGsmExtention(GsmExtention gsmExtention);
125 
126     VoiceExtention getVoiceExtention();
127 
128     void setVoiceExtention(VoiceExtention voiceExtention);
129 
130     FaxExtention getFaxExtention();
131 
132     void setFaxExtention(FaxExtention faxExtention);
133 
134     Connection dial(String number) throws IOException,
135             InterruptedException;
136 
137     void dial(String number, CallHandler waitingOutgoingCall)
138             throws
139             IOException,
140             InterruptedException;
141 
142     void setSpeaker();
143 
144     boolean reset() throws IOException, InterruptedException;
145 
146     String getAutomaticAnswer() throws IOException, InterruptedException;
147 
148     String getCommandLineTerminationCharacter() throws IOException,
149             InterruptedException;
150 
151     String getResponseFormattingChar() throws IOException,
152             InterruptedException;
153 
154     String getCommandLineEditingChar() throws IOException,
155             InterruptedException;
156 
157     String getModulationSelection() throws IOException,
158             InterruptedException;
159 
160     String getManufacturerId() throws IOException, InterruptedException;
161 
162     String getModelId() throws IOException, InterruptedException;
163 
164     String getRevisionId() throws IOException, InterruptedException;
165 
166     String getSerialNumber() throws IOException, InterruptedException;
167 
168     String getObjectId() throws IOException, InterruptedException;
169 
170     ModemCapabilities[] getCapabilities() throws IOException, InterruptedException;
171 
172     String getCountryOfInstallation() throws IOException,
173             InterruptedException;
174 
175     void setInitStrings(String... initStrings);
176 
177     String[] getInitStrings();
178 
179     boolean hangUp() throws IOException, InterruptedException;
180 
181     boolean close();
182 
183     void reenterDataMode();
184     
185     String extractData(String data);
186 
187 }