iSim.h
1 #ifndef ISIM_H_
2 #define ISIM_H_
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 
8 #include <boost/system/error_code.hpp>
9 
10 #ifndef SIM_TYPES
11 #define SIM_TYPES
12 
13 namespace dpyModem {
14 
16 struct DATE_INFO
17 {
18  int day;
19  int month;
20  int year;
21 };
22 
24 struct UTC_INFO
25 {
26  int hour;
27  int min;
28  double sec;
29 };
30 
34 
41 {
42  std::string APN;
43  std::string user;
44  std::string password;
45 };
46 
49 {
57 };
58 
60 struct SimInfo
61 {
62  std::string IMSI;
63  std::string ICCID;
64  std::string operator_name;
66  bool apn_forced;
67 };
68 
70 enum CallDir
71 {
75 };
76 
77 
80 {
82  STAT_HELD = 1,
89 };
90 
93 {
95  IDLE = 1,
96  BUSY = 2
97 };
98 
101 {
103  WAITING = 1,
104  RINGING = 2,
105  DIALING = 3,
107  HELD = 5,
108  FINISHED = 6,
109  ALERTING = 7,
110  DROPPED = 8,
111 };
112 
115 {
117  MODE_DATA = 1,
118  MODE_FAX = 2,
126 };
127 
130 {
133 };
134 
137 {
140 };
141 
144 {
150 };
151 
153 struct CallInfo
154 {
155  std::string id = "";
156  CallDir dir = CallDir::DIR_OUTGOING;
157  CallStatus stat = CallStatus::CALLS_DISABLED;
158  CallMode mode = CallMode::MODE_VOICE;
159  CallMpty mpty = CallMpty::MPTY_INACTIVE;
160  CallTrafficChannel trafficChannel = CallTrafficChannel::TRAFFIC_CHANNEL_NOT_ASSIGNED;
161  std::string number = "";
162  CallType type = CallType::TYPE_RESTRICTED_NUM;
163  int duration_seconds = 0;
164 };
165 
167 
168 } //dpyModem
169 
170 #endif //SIM_TYPES
171 
172 
178 {
179 public:
185  virtual void updateSimStatus(const std::string& simId, const dpyModem::SimStatus& status) = 0;
186 
192  virtual void updateCallSourceStatus(const std::string& simId, const dpyModem::CallSourceStatus& sourceStatus) = 0;
193 
199  virtual void processVoiceCallEvent(const std::string& simId, const dpyModem::CallStatus& callStatus) = 0;
200 
204  virtual ~SimObserver()
205  {
206  }
207 };
208 
214 class ISim
215 {
216 private:
217  std::string mId;
218  std::vector<SimObserver*> mObserversList;
219 protected:
220  void setId(const std::string& id);
221  void notifySimStatusUpdate(const std::string& simId, const dpyModem::SimStatus& status);
222  void notifyCallSourceStatusUpdate(const std::string& simId, const dpyModem::CallSourceStatus& sourceStatus);
223  void notifyVoiceCallEvent(const std::string& simId, const dpyModem::CallStatus& callStatusEvent);
224 
225 public:
226 
230  virtual ~ISim();
231 
236  std::string getId() const;
237 
242  virtual std::string getIccid() const = 0;
243 
248  virtual std::string getImsi() const = 0;
249 
254  virtual std::string getOperatorName() const = 0;
255 
262  virtual boost::system::error_code getApn(dpyModem::AccessPointNetwork& apn, bool& forced ) = 0;
263 
269  virtual boost::system::error_code getSimInfo(dpyModem::SimInfo& sim_info) = 0;
270 
275  virtual dpyModem::SimStatus getStatus() const = 0;
276 
282  boost::system::error_code subscribe(SimObserver* observer);
283 
289  boost::system::error_code unsubscribe(SimObserver* observer);
290 
293 
295  virtual dpyModem::CallSourceStatus getCallSourceStatus() const = 0;
296 
301  virtual dpyModem::CallInfo getLastCallInfo() const = 0;
302 
304 };
305 
306 #endif /* ISIM_H_ */
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:110
Voice followed by data, voice mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:119
Ready to perform calls.
Definition: iSim.h:95
int min
Minutes after the hour - [0,59].
Definition: iSim.h:27
The call is not active anymore, but inband information is still available.
Definition: iSim.h:108
Traffic channel is assigned and the progress indicator IE has been received(call setup) or a voice co...
Definition: iSim.h:139
int year
Years - [2000-2999].
Definition: iSim.h:20
CallMode
Mode.
Definition: iSim.h:114
The call is held.
Definition: iSim.h:107
The call is active.
Definition: iSim.h:81
Otherwise.
Definition: iSim.h:149
std::string ICCID
Sim ICCID.
Definition: iSim.h:63
The call is not active anymore, but inband information is still available.
Definition: iSim.h:87
Alerting (MOC)
Definition: iSim.h:84
Sim card is blocked and PIN code must be entered.
Definition: iSim.h:53
Sim card is blocked, it may be needed to introduce some PIN or PUK code.
Definition: iSim.h:52
Deepsy Modem namespace that includes the different enums, structs or method signatures that should be...
Unknown.
Definition: iSim.h:125
CallDir
Direction.
Definition: iSim.h:70
Alerting (Mobile Originated call)
Definition: iSim.h:109
Sim is ready to be used.
Definition: iSim.h:56
CallTrafficChannel
Traffic channel assigned.
Definition: iSim.h:136
Alternating voice/fax, voice mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:121
CallStat
State.
Definition: iSim.h:79
Struct to keep info from a call.
Definition: iSim.h:153
No traffic channel assigned. Transmission of DTMF tones not possible.
Definition: iSim.h:138
Alternating voice/data, data mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:123
CallStatus
Defines the possible call status.
Definition: iSim.h:100
int day
Days after the month - [1,31].
Definition: iSim.h:18
Sim card cannot be read or it is not correctly inserted.
Definition: iSim.h:51
Dialing string number contains "*", "#" characters for Supplementary Services codes. Network support of this type is optional.
Definition: iSim.h:148
Sim card is not present in the device, or Sim status Unknown.
Definition: iSim.h:50
AccessPointNetwork apn_information
Sim APN information.
Definition: iSim.h:65
Number is restricted.
Definition: iSim.h:145
Resource is busy, a call may be in progress.
Definition: iSim.h:96
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:88
double sec
Seconds after the minute - [0.0,59.999].
Definition: iSim.h:28
The calls are not available.
Definition: iSim.h:102
int month
Months after the year - [1,12].
Definition: iSim.h:19
Waiting (MTC)
Definition: iSim.h:86
SimStatus
Defines the possible states in which SIM card may be.
Definition: iSim.h:48
Voice followed by data, data mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:122
std::string IMSI
Sim IMSI.
Definition: iSim.h:62
Data.
Definition: iSim.h:117
std::string APN
Access point network (url form)
Definition: iSim.h:42
1 -> Mobile terminated call (MTC)
Definition: iSim.h:73
0 -> Mobile originated call (MOC)
Definition: iSim.h:72
std::string operator_name
Sim operator.
Definition: iSim.h:64
Defines the structure containing Sim information.
Definition: iSim.h:60
Alternating voice/fax, fax mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:124
Defines the struct type used to store the DATE_INFO.
Definition: iSim.h:16
virtual ~SimObserver()
Destructor.
Definition: iSim.h:204
Incoming call being received (Mobile Terminated Call)
Definition: iSim.h:104
The call is held.
Definition: iSim.h:82
Incoming (MTC)
Definition: iSim.h:85
2 -> Mobile terminated call (MTC)
Definition: iSim.h:74
Sim Observer class.
Definition: iSim.h:177
Sim card is blocked and PIN2 code must be entered.
Definition: iSim.h:54
Alternating voice/data, voice mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:120
CallType
Type of address octet as defined by 3GPP.
Definition: iSim.h:143
The call is active.
Definition: iSim.h:106
National number.
Definition: iSim.h:147
Dialing (MOC)
Definition: iSim.h:83
CallMpty
Multiparty.
Definition: iSim.h:129
Sim card is blocked and PUK code must be entered.
Definition: iSim.h:55
std::string user
User used to access the network.
Definition: iSim.h:43
Dialing string number includes international access code character &#39;+&#39;.
Definition: iSim.h:146
CallSourceStatus
Defines the possible status that a voice call source can report regarding calls.
Definition: iSim.h:92
Dialing (Mobile Originated call)
Definition: iSim.h:105
A interface for Sims.
Definition: iSim.h:214
Waiting.
Definition: iSim.h:103
bool apn_forced
Flag that indicates if the apn is forced by the user or retrieved from the list.
Definition: iSim.h:66
int hour
Hours since midnight - [0,23].
Definition: iSim.h:26
Call is not one of multiparty (conference) call parties.
Definition: iSim.h:131
Voice.
Definition: iSim.h:116
Definition: iSim.h:40
Fax.
Definition: iSim.h:118
std::string password
Password used to access the network.
Definition: iSim.h:44
Not available.
Definition: iSim.h:94
Call is one of multiparty (conference) call parties.
Definition: iSim.h:132
Defines the struct type used to store the UTC_INFO.
Definition: iSim.h:24