~ubuntu-branches/ubuntu/trusty/gsmlib/trusty

« back to all changes in this revision

Viewing changes to gsmlib/gsm_me_ta.h

  • Committer: Bazaar Package Importer
  • Author(s): Mikael Hedin
  • Date: 2002-01-24 12:59:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020124125907-b7qkpokx5283jdpu
Tags: upstream-1.8
ImportĀ upstreamĀ versionĀ 1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// *************************************************************************
 
2
// * GSM TA/ME library
 
3
// *
 
4
// * File:    gsm_me_ta.h
 
5
// *
 
6
// * Purpose: Mobile Equipment/Terminal Adapter and SMS functions
 
7
// *          (ETSI GSM 07.07 and 07.05)
 
8
// *
 
9
// * Author:  Peter Hofmann (software@pxh.de)
 
10
// *
 
11
// * Created: 3.5.1999
 
12
// *************************************************************************
 
13
 
 
14
#ifndef GSM_ME_TA_H
 
15
#define GSM_ME_TA_H
 
16
 
 
17
#include <gsmlib/gsm_error.h>
 
18
#include <gsmlib/gsm_event.h>
 
19
#include <gsmlib/gsm_phonebook.h>
 
20
#include <gsmlib/gsm_sms_store.h>
 
21
#include <gsmlib/gsm_util.h>
 
22
#include <gsmlib/gsm_at.h>
 
23
#include <gsmlib/gsm_sms.h>
 
24
#include <string>
 
25
#include <vector>
 
26
 
 
27
using namespace std;
 
28
 
 
29
namespace gsmlib
 
30
{
 
31
  // *** phone capability description (you could also call it phone quirks)
 
32
 
 
33
  struct Capabilities
 
34
  {
 
35
    bool _hasSMSSCAprefix;      // SMS have service centre address prefix
 
36
    int _cpmsParamCount;        // number of SMS store parameters to
 
37
                                // CPMS command
 
38
    bool _omitsColon;           // omits trailing ':' in AT responses
 
39
    bool _veryShortCOPSanswer;  // Falcom A2-1
 
40
    bool _wrongSMSStatusCode;   // Motorola Timeport 260
 
41
    bool _CDSmeansCDSI;         // Nokia Cellular Card Phone RPE-1 GSM900
 
42
    Capabilities();             // constructor, set default behaviours
 
43
  };
 
44
  
 
45
  // *** auxiliary structs
 
46
 
 
47
  // Static ME information (AT command sequences given in brackets)
 
48
  struct MEInfo
 
49
  {
 
50
    string _manufacturer;       // (+CGMI)
 
51
    string _model;              // (+CGMM)
 
52
    string _revision;           // (+CGMR)
 
53
    string _serialNumber;       // (+CGSN), IMEI
 
54
  };
 
55
 
 
56
  // modes for network operation selection
 
57
  enum OPModes {AutomaticOPMode = 0, ManualOPMode = 1,
 
58
                DeregisterOPMode = 2, ManualAutomaticOPMode = 4};
 
59
 
 
60
  // status codes or network operaton selection
 
61
  enum OPStatus {UnknownOPStatus = 0, AvailableOPStatus = 1,
 
62
                 CurrentOPStatus = 2, ForbiddenOPStatus = 3};
 
63
 
 
64
  // network operator info
 
65
  struct OPInfo
 
66
  {
 
67
    OPModes _mode;
 
68
    OPStatus _status;
 
69
    string _longName;
 
70
    string _shortName;
 
71
    int _numericName;           // may be NOT_SET
 
72
 
 
73
    OPInfo() : _status(UnknownOPStatus), _numericName(NOT_SET) {}
 
74
  };
 
75
 
 
76
  // facility classes
 
77
  enum FacilityClass {VoiceFacility = 1, DataFacility = 2, FaxFacility = 4};
 
78
  const int ALL_FACILITIES = VoiceFacility | DataFacility | FaxFacility;
 
79
 
 
80
  // struct to hold password info
 
81
  struct PWInfo
 
82
  {
 
83
    string _facility;
 
84
    int _maxPasswdLen;
 
85
  };
 
86
 
 
87
  // call forward reasons
 
88
  // AllReasons encompasses 0..3
 
89
  // AllConditionalReasons encompasses 1..3
 
90
  enum ForwardReason {UnconditionalReason = 0, MobileBusyReason = 1,
 
91
                      NoReplyReason = 2, NotReachableReason = 3,
 
92
                      AllReasons = 4, AllConditionalReasons = 5, NoReason = 6};
 
93
 
 
94
  // call forward modes
 
95
  enum ForwardMode {DisableMode = 0, EnableMode = 1,
 
96
                    RegistrationMode = 3, ErasureMode = 4};
 
97
 
 
98
  // call forward info
 
99
  struct ForwardInfo
 
100
  {
 
101
    bool _active;               // status in the network
 
102
    FacilityClass _cl;          // voice, fax, or data
 
103
    string _number;             // telephone number
 
104
    string _subAddr;            // subaddress
 
105
    int _time;                  // time in the range 1..30 (for NoReplyReason)
 
106
    ForwardReason _reason;      // reason for the forwarding
 
107
  };
 
108
 
 
109
  // SMS types
 
110
  typedef Ref<SMSStore> SMSStoreRef;
 
111
  typedef vector<SMSStoreRef> SMSStoreVector;
 
112
 
 
113
  // this class allows access to all functions of a ME/TA as described
 
114
  // in sections 5-8 of ETSI GSM 07.07
 
115
  // Note: If the ME is changed (ie. disconnected an another one connected
 
116
  // to the TA), a new ME object must be created
 
117
  // (Mobile equipment = ME, terminal adapter = TA)
 
118
  class MeTa : public RefBase
 
119
  {
 
120
  protected:
 
121
    Ref<Port> _port;            // port the ME/TA is connected to
 
122
    Ref<GsmAt> _at;             // chat object for the port
 
123
    PhonebookVector _phonebookCache; // cache of all used phonebooks
 
124
    SMSStoreVector _smsStoreCache; // cache of all used phonebooks
 
125
    string _lastPhonebookName;  // remember last phonebook set on ME/TA
 
126
    string _lastSMSStoreName;   // remember last SMS store set on ME/TA
 
127
    Capabilities _capabilities; // ME/TA quirks
 
128
    GsmEvent _defaultEventHandler; // default event handler
 
129
                                // see comments in MeTa::init()
 
130
    string _lastCharSet;        // remember last character set
 
131
 
 
132
    // init ME/TA to sensible defaults
 
133
    void init() throw(GsmException);
 
134
 
 
135
  public:
 
136
    // initialize a new MeTa object given the port
 
137
    MeTa(Ref<Port> port) throw(GsmException);
 
138
 
 
139
    // initialize a new MeTa object given the AT handler
 
140
    //MeTa(Ref<GsmAt> at) throw(GsmException);
 
141
 
 
142
    // set the current phonebook in the ME
 
143
    // remember the last phonebook set for optimisation
 
144
    void setPhonebook(string phonebookName) throw(GsmException);
 
145
 
 
146
    // set the current SMS store in the ME
 
147
    // set storeTypes to
 
148
    //   1 to set store for reading and deleting
 
149
    //   2 to set store for writing and sending (includes type 1)
 
150
    //   3 to preferred store for receiving SMS (includes types 1 and 2)
 
151
    // remember the last SMS store set for optimisation
 
152
    // if needResultCode is set this optimisation is not done
 
153
    string setSMSStore(string smsStore, int storeTypes,
 
154
                       bool needResultCode = false)
 
155
      throw(GsmException);
 
156
 
 
157
    // get capabilities of this ME/TA
 
158
    Capabilities getCapabilities() const {return _capabilities;}
 
159
 
 
160
    // return my port
 
161
    Ref<Port> getPort() {return _port;}
 
162
 
 
163
    // return my at handler
 
164
    Ref<GsmAt> getAt() {return _at;}
 
165
 
 
166
    // set event handler for unsolicited result codes
 
167
    GsmEvent *setEventHandler(GsmEvent *newHandler)
 
168
      {return _at->setEventHandler(newHandler);}
 
169
 
 
170
    // wait for an event
 
171
    void waitEvent(GsmTime timeout) throw(GsmException);
 
172
 
 
173
    // *** ETSI GSM 07.07 Section 5: "General Commands"
 
174
 
 
175
    // return ME information
 
176
    MEInfo getMEInfo() throw(GsmException);
 
177
 
 
178
    // return available character sets
 
179
    vector<string> getSupportedCharSets() throw(GsmException);// (+CSCS=?)
 
180
    
 
181
    // return current character set (default: GSM)
 
182
    string getCurrentCharSet() throw(GsmException);// (+CSCS?)
 
183
 
 
184
    // set character set to use
 
185
    void setCharSet(string charSetName) throw(GsmException);// (+CSCS=)
 
186
    
 
187
    // *** ETSI GSM 07.07 Section 6: "Call control commands and methods"
 
188
    
 
189
    // get extended error report
 
190
    string getExtendedErrorReport() throw(GsmException);// (+CEER)
 
191
 
 
192
    // dial a number, CLI presentation as defined in network
 
193
    void dial(string number) throw(GsmException);// (ATD)
 
194
 
 
195
 
 
196
    // *** ETSI GSM 07.07 Section 7: "Network service related commands"
 
197
    
 
198
    // return available network operators
 
199
    // this fills in all fields of OPInfo with the exception of _mode
 
200
    vector<OPInfo> getAvailableOPInfo() throw(GsmException); // (+COPS=?)
 
201
 
 
202
    // return current network operators
 
203
    // this fills in all the fields of OPInfo with the exception of _status
 
204
    OPInfo getCurrentOPInfo() throw(GsmException);
 
205
 
 
206
    // set network operator
 
207
    // caller must fill in ALL names it has read from previous calls
 
208
    // of getCurrentOPInfo() or getAvailableOPInfo()
 
209
    // (because ME/TA might not implement all names)
 
210
    void setCurrentOPInfo(OPModes mode,
 
211
                          string longName = "",
 
212
                          string shortName = "",
 
213
                          int numericName = NOT_SET) throw(GsmException);
 
214
 
 
215
    // get facility lock capabilities (+CLCK)
 
216
    vector<string> getFacilityLockCapabilities() throw(GsmException);
 
217
 
 
218
    // query facility lock status for named facility
 
219
    bool getFacilityLockStatus(string facility, FacilityClass cl)
 
220
      throw(GsmException);
 
221
 
 
222
    // lock facility
 
223
    void lockFacility(string facility, FacilityClass cl, string passwd = "")
 
224
      throw(GsmException);
 
225
 
 
226
    // unlock facility
 
227
    void unlockFacility(string facility, FacilityClass cl, string passwd = "")
 
228
      throw(GsmException);
 
229
 
 
230
    // return names of facility for which a password can be set
 
231
    // and the maximum length of the respective password
 
232
    vector<PWInfo> getPasswords() throw(GsmException);// (+CPWD=?)
 
233
 
 
234
    // set password for the given facility
 
235
    void setPassword(string facility, string oldPasswd, string newPasswd)
 
236
      throw(GsmException);
 
237
    // (+CPWD=)
 
238
 
 
239
    // get CLIP (caller line identification presentation) in the network
 
240
    bool getNetworkCLIP() throw(GsmException);// (+CLIP?)
 
241
 
 
242
    // set CLIP presentation on or off
 
243
    // enables GsmEvent::callerLineID
 
244
    void setCLIPPresentation(bool enable) throw(GsmException);// (+CLIP=)
 
245
 
 
246
    // returns if the above is enable
 
247
    bool getCLIPPresentation() throw(GsmException);// (+CLIP?)
 
248
 
 
249
    // set call forwarding
 
250
    void setCallForwarding(ForwardReason reason,
 
251
                           ForwardMode mode,
 
252
                           string number,
 
253
                           string subaddr,
 
254
                           FacilityClass cl = (FacilityClass)ALL_FACILITIES,
 
255
                           int forwardTime = NOT_SET)
 
256
      throw(GsmException); // (+CCFC=)
 
257
 
 
258
    // get Information of currently set CF in the network
 
259
    // the caller must give the reason to query
 
260
    void getCallForwardInfo(ForwardReason reason,
 
261
                            ForwardInfo &voice,
 
262
                            ForwardInfo &fax,
 
263
                            ForwardInfo &data)
 
264
      throw(GsmException); // (+CCFC=)
 
265
 
 
266
 
 
267
    // *** ETSI GSM 07.07 Section 8: "Mobile Equipment control
 
268
    //                                and status commands"
 
269
 
 
270
    // return battery charge status (+CBC):
 
271
    // 0 ME is powered by the battery
 
272
    // 1 ME has a battery connected, but is not powered by it
 
273
    // 2 ME does not have a battery connected
 
274
    // 3 Recognized power fault, calls inhibited
 
275
    int getBatteryChargeStatus() throw(GsmException);
 
276
 
 
277
    // return battery charge (range 0..100) (+CBC)
 
278
    int getBatteryCharge() throw(GsmException);
 
279
 
 
280
    // get signal strength indication (+CSQ):
 
281
    // 0 -113 dBm or less
 
282
    // 1 -111 dBm
 
283
    // 2...30 -109... -53 dBm
 
284
    // 31 -51 dBm or greater
 
285
    // 99 not known or not detectable
 
286
    int getSignalStrength() throw(GsmException);
 
287
 
 
288
    // get channel bit error rate (+CSQ):
 
289
    // 0...7 as RXQUAL values in the table in GSM 05.08 [20] subclause 8.2.4
 
290
    // 99 not known or not detectable
 
291
    int getBitErrorRate() throw(GsmException);
 
292
 
 
293
    // get available phone book memory storage strings (+CPBS=?)
 
294
    vector<string> getPhoneBookStrings() throw(GsmException);
 
295
 
 
296
    // get phone book given the phone book memory storage string
 
297
    PhonebookRef getPhonebook(string phonebookString,
 
298
                              bool preload = false) throw(GsmException);
 
299
 
 
300
 
 
301
    // *** ETSI GSM 07.05 SMS functions
 
302
 
 
303
    // return service centre address (+CSCA?)
 
304
    string getServiceCentreAddress() throw(GsmException);
 
305
 
 
306
    // set service centre address (+CSCA=)
 
307
    void setServiceCentreAddress(string sca) throw(GsmException);
 
308
    
 
309
    // return names of available message stores (<mem1>, +CPMS=?)
 
310
    vector<string> getSMSStoreNames() throw(GsmException);
 
311
 
 
312
    // return SMS store given the name
 
313
    SMSStoreRef getSMSStore(string storeName) throw(GsmException);
 
314
 
 
315
    // send a single SMS message
 
316
    void sendSMS(SMSMessageRef smsMessage) throw(GsmException);
 
317
 
 
318
    // set SMS service level
 
319
    // if set to 1 send commands return ACK PDU, 0 is the default
 
320
    void setMessageService(int serviceLevel) throw(GsmException);
 
321
 
 
322
    // return SMS service level
 
323
    unsigned int getMessageService() throw(GsmException);
 
324
 
 
325
    // return true if any of the thre message types GsmEvent::SMSMessageType
 
326
    // is routed directly to the TA and not stored in the ME
 
327
    void getSMSRoutingToTA(bool &smsRouted, // (+CNMI?)
 
328
                           bool &cbsRouted,
 
329
                           bool &statusReportsRouted) throw(GsmException);
 
330
 
 
331
    // sets routing of SMS to TA to true for all supported SMSMessageTypes
 
332
    // if onlyReceptionIndication is set to true
 
333
    // only GsmEvent::SMSReceptionIndication is called
 
334
    // this has two reasons: GSM 07.05 section 3.4.1 does not recommend
 
335
    // direct routing of new SMS to the TA
 
336
    // I cannot test direct routing of SMS because it does not work with
 
337
    // my hardware
 
338
    void setSMSRoutingToTA(bool enableSMS, bool enableCBS,
 
339
                           bool enableStatReport,
 
340
                           bool onlyReceptionIndication = true)
 
341
      throw(GsmException);
 
342
    // (+CNMI=)
 
343
 
 
344
    friend class Phonebook;
 
345
    friend class SMSStore;
 
346
  };
 
347
};
 
348
 
 
349
#endif // GSM_ME_TA_H