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 struct s_SMSInfo
71 {
72  std::string content;
73  std::string sender_phone;
76 };
77 
80 {
81  SENT,
85 };
86 
88 enum CallDir
89 {
93 };
94 
95 
98 {
100  STAT_HELD = 1,
107 };
108 
111 {
113  IDLE = 1,
114  BUSY = 2
115 };
116 
119 {
121  WAITING = 1,
122  RINGING = 2,
123  DIALING = 3,
125  HELD = 5,
126  FINISHED = 6,
127  ALERTING = 7,
128  DROPPED = 8,
129 };
130 
133 {
135  MODE_DATA = 1,
136  MODE_FAX = 2,
144 };
145 
148 {
151 };
152 
155 {
158 };
159 
162 {
168 };
169 
171 struct CallInfo
172 {
173  std::string id = "";
174  CallDir dir = CallDir::DIR_OUTGOING;
175  CallStatus stat = CallStatus::CALLS_DISABLED;
176  CallMode mode = CallMode::MODE_VOICE;
177  CallMpty mpty = CallMpty::MPTY_INACTIVE;
178  CallTrafficChannel trafficChannel = CallTrafficChannel::TRAFFIC_CHANNEL_NOT_ASSIGNED;
179  std::string number = "";
180  CallType type = CallType::TYPE_RESTRICTED_NUM;
181  int duration_seconds = 0;
182 };
183 
185 
186 } //dpyModem
187 
188 #endif //SIM_TYPES
189 
190 
196 {
197 public:
203  virtual void updateSimStatus(const std::string& simId, const dpyModem::SimStatus& status) = 0;
204 
210  virtual void processSmsEvent(const std::string& simId,const std::string& smsId, const dpyModem::SmsEvent& smsEvent) = 0;
211 
217  virtual void updateCallSourceStatus(const std::string& simId, const dpyModem::CallSourceStatus& sourceStatus) = 0;
218 
224  virtual void processVoiceCallEvent(const std::string& simId, const dpyModem::CallStatus& callStatus) = 0;
225 
229  virtual ~SimObserver()
230  {
231  }
232 };
233 
239 class ISim
240 {
241 private:
242  std::string mId;
243  std::vector<SimObserver*> mObserversList;
244 protected:
245  void setId(const std::string& id);
246  void notifySimStatusUpdate(const std::string& simId, const dpyModem::SimStatus& status);
247  void notifySmsEvent(const std::string& simId,const std::string& smsId, const dpyModem::SmsEvent& smsEvent);
248  void notifyCallSourceStatusUpdate(const std::string& simId, const dpyModem::CallSourceStatus& sourceStatus);
249  void notifyVoiceCallEvent(const std::string& simId, const dpyModem::CallStatus& callStatusEvent);
250 
251 public:
252 
256  virtual ~ISim();
257 
262  std::string getId() const;
263 
268  virtual std::string getIccid() const = 0;
269 
274  virtual std::string getImsi() const = 0;
275 
280  virtual std::string getOperatorName() const = 0;
281 
288  virtual boost::system::error_code getApn(dpyModem::AccessPointNetwork& apn, bool& forced ) = 0;
289 
295  virtual boost::system::error_code getSimInfo(dpyModem::SimInfo& sim_info) = 0;
296 
301  virtual dpyModem::SimStatus getStatus() const = 0;
302 
308  boost::system::error_code subscribe(SimObserver* observer);
309 
315  boost::system::error_code unsubscribe(SimObserver* observer);
316 
317 
320 
328  virtual boost::system::error_code getSmsInfo(const std::string& smsId,dpyModem::s_SMSInfo& smsInfo) = 0;
329 
335  virtual boost::system::error_code getAllSmsInfo(std::map<std::string, dpyModem::s_SMSInfo>& smsList) = 0;
336 
342  virtual boost::system::error_code deleteSms(const std::string& smsId) = 0;
343 
345 
346 
349 
351  virtual dpyModem::CallSourceStatus getCallSourceStatus() const = 0;
352 
357  virtual dpyModem::CallInfo getLastCallInfo() const = 0;
358 
359 
361 
362 
363 };
364 
365 #endif /* ISIM_H_ */
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:128
Voice followed by data, voice mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:137
Ready to perform calls.
Definition: iSim.h:113
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:126
Traffic channel is assigned and the progress indicator IE has been received(call setup) or a voice co...
Definition: iSim.h:157
int year
Years - [2000-2999].
Definition: iSim.h:20
CallMode
Mode.
Definition: iSim.h:132
The call is held.
Definition: iSim.h:125
The call is active.
Definition: iSim.h:99
Otherwise.
Definition: iSim.h:167
std::string ICCID
Sim ICCID.
Definition: iSim.h:63
The call is not active anymore, but inband information is still available.
Definition: iSim.h:105
Alerting (MOC)
Definition: iSim.h:102
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:143
Modem module has just sent an SMS.
Definition: iSim.h:81
SmsEvent
Defines the possible sms notifications that a sim can report.
Definition: iSim.h:79
Modem module SMS storage is full, some SMS should be deleted.
Definition: iSim.h:84
CallDir
Direction.
Definition: iSim.h:88
Alerting (Mobile Originated call)
Definition: iSim.h:127
Sim is ready to be used.
Definition: iSim.h:56
CallTrafficChannel
Traffic channel assigned.
Definition: iSim.h:154
Alternating voice/fax, voice mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:139
UTC_INFO time
Time at which the message was received.
Definition: iSim.h:74
CallStat
State.
Definition: iSim.h:97
Struct to keep info from a call.
Definition: iSim.h:171
Defines the structure containing SMS information.
Definition: iSim.h:70
No traffic channel assigned. Transmission of DTMF tones not possible.
Definition: iSim.h:156
DATE_INFO date
Date at which the message was received.
Definition: iSim.h:75
Alternating voice/data, data mode (only in connection with single numbering scheme AT+CSNS) ...
Definition: iSim.h:141
CallStatus
Defines the possible call status.
Definition: iSim.h:118
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:166
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:163
Resource is busy, a call may be in progress.
Definition: iSim.h:114
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:106
double sec
Seconds after the minute - [0.0,59.999].
Definition: iSim.h:28
Modem SMS has been deleted from memory.
Definition: iSim.h:83
The calls are not available.
Definition: iSim.h:120
int month
Months after the year - [1,12].
Definition: iSim.h:19
std::string sender_phone
Sender telephone number that sent the message.
Definition: iSim.h:73
Waiting (MTC)
Definition: iSim.h:104
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:140
std::string IMSI
Sim IMSI.
Definition: iSim.h:62
Data.
Definition: iSim.h:135
std::string APN
Access point network (url form)
Definition: iSim.h:42
1 -> Mobile terminated call (MTC)
Definition: iSim.h:91
0 -> Mobile originated call (MOC)
Definition: iSim.h:90
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:142
Defines the struct type used to store the DATE_INFO.
Definition: iSim.h:16
virtual ~SimObserver()
Destructor.
Definition: iSim.h:229
Incoming call being received (Mobile Terminated Call)
Definition: iSim.h:122
The call is held.
Definition: iSim.h:100
Incoming (MTC)
Definition: iSim.h:103
2 -> Mobile terminated call (MTC)
Definition: iSim.h:92
Sim Observer class.
Definition: iSim.h:195
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:138
CallType
Type of address octet as defined by 3GPP.
Definition: iSim.h:161
The call is active.
Definition: iSim.h:124
National number.
Definition: iSim.h:165
Dialing (MOC)
Definition: iSim.h:101
CallMpty
Multiparty.
Definition: iSim.h:147
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:164
CallSourceStatus
Defines the possible status that a voice call source can report regarding calls.
Definition: iSim.h:110
Dialing (Mobile Originated call)
Definition: iSim.h:123
A interface for Sims.
Definition: iSim.h:239
Waiting.
Definition: iSim.h:121
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
std::string content
Information contained in the SMS.
Definition: iSim.h:72
Call is not one of multiparty (conference) call parties.
Definition: iSim.h:149
Voice.
Definition: iSim.h:134
Definition: iSim.h:40
Fax.
Definition: iSim.h:136
Modem module has just received a SMS.
Definition: iSim.h:82
std::string password
Password used to access the network.
Definition: iSim.h:44
Not available.
Definition: iSim.h:112
Call is one of multiparty (conference) call parties.
Definition: iSim.h:150
Defines the struct type used to store the UTC_INFO.
Definition: iSim.h:24