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;
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 
296 
301  virtual dpyModem::CallInfo getLastCallInfo() const = 0;
302 
304 };
305 
306 #endif /* ISIM_H_ */
Sim Observer class.
Definition: iSim.h:177
CallMpty
Multiparty.
Definition: iSim.h:129
@ MODE_DATA_VOICE
Voice followed by data, data mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:122
virtual std::string getIccid() const =0
Retrieve sim iccid.
@ DIR_UNKNOWN
2 -> Mobile terminated call (MTC)
Definition: iSim.h:74
@ STAT_INCOMING
Incoming (MTC)
Definition: iSim.h:85
@ CONVERSATION
The call is active.
Definition: iSim.h:106
CallStat
State.
Definition: iSim.h:79
@ TYPE_OTHERWISE
Otherwise.
Definition: iSim.h:149
boost::system::error_code unsubscribe(SimObserver *observer)
Unsubscribe from the different sim events.
@ MPTY_ACTIVE
Call is one of multiparty (conference) call parties.
Definition: iSim.h:132
@ SIM_LOCKED_PUK
Sim card is blocked and PUK code must be entered.
Definition: iSim.h:55
CallDir dir
Call direction.
Definition: iSim.h:156
@ TYPE_INTERNATIONAL_CODE
Dialing string number includes international access code character '+'.
Definition: iSim.h:146
@ SIM_INVALID_OR_UNSUPPORTED
Sim card cannot be read or it is not correctly inserted.
Definition: iSim.h:51
boost::system::error_code subscribe(SimObserver *observer)
Subscribe to the different sim events.
@ STAT_ACTIVE
The call is active.
Definition: iSim.h:81
CallMpty mpty
Multiparty.
Definition: iSim.h:159
@ NOT_AVAILABLE
Not available.
Definition: iSim.h:94
double sec
Seconds after the minute - [0.0,59.999].
Definition: iSim.h:28
@ STAT_DIALING
Dialing (MOC)
Definition: iSim.h:83
@ TRAFFIC_CHANNEL_NOT_ASSIGNED
No traffic channel assigned. Transmission of DTMF tones not possible.
Definition: iSim.h:138
@ DIALING
Dialing (Mobile Originated call)
Definition: iSim.h:105
int min
Minutes after the hour - [0,59].
Definition: iSim.h:27
virtual dpyModem::CallSourceStatus getCallSourceStatus() const =0
Used to retrieve last call information.
int year
Years - [2000-2999].
Definition: iSim.h:20
AccessPointNetwork apn_information
Sim APN information.
Definition: iSim.h:65
std::string password
Password used to access the network.
Definition: iSim.h:44
std::string IMSI
Sim IMSI.
Definition: iSim.h:62
@ FINISHED
The call is not active anymore, but inband information is still available.
Definition: iSim.h:108
@ STAT_DROPPED
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:88
CallMode mode
Bearer/teleservice mode.
Definition: iSim.h:158
@ SIM_LOCKED
Sim card is blocked, it may be needed to introduce some PIN or PUK code.
Definition: iSim.h:52
std::string number
Phone number.
Definition: iSim.h:161
@ SIM_NOT_INSERTED
Sim card is not present in the device, or Sim status Unknown.
Definition: iSim.h:50
A interface for Sims.
Definition: iSim.h:214
CallType
Type of address octet as defined by 3GPP.
Definition: iSim.h:143
CallTrafficChannel trafficChannel
Traffic channel.
Definition: iSim.h:160
@ TYPE_NATIONAL_NUM
National number.
Definition: iSim.h:147
CallType type
type of address octet. 161 -> National number
Definition: iSim.h:162
int month
Months after the year - [1,12].
Definition: iSim.h:19
virtual void updateSimStatus(const std::string &simId, const dpyModem::SimStatus &status)=0
Method that will be called on sim status changes.
Defines the struct type used to store the DATE_INFO.
Definition: iSim.h:16
virtual std::string getImsi() const =0
Retrieve the sim imsi.
@ TRAFFIC_CHANNEL_ASSIGNED
Traffic channel is assigned and the progress indicator IE has been received(call setup) or a voice co...
Definition: iSim.h:139
Definition: iSim.h:40
Struct to keep info from a call.
Definition: iSim.h:153
@ SIM_LOCKED_PIN
Sim card is blocked and PIN code must be entered.
Definition: iSim.h:53
std::string operator_name
Sim operator.
Definition: iSim.h:64
bool apn_forced
Flag that indicates if the apn is forced by the user or retrieved from the list.
Definition: iSim.h:66
virtual dpyModem::SimStatus getStatus() const =0
Retrieve the sim status.
virtual void processVoiceCallEvent(const std::string &simId, const dpyModem::CallStatus &callStatus)=0
Method that will be called on Sim events.
@ DIR_INCOMING
1 -> Mobile terminated call (MTC)
Definition: iSim.h:73
@ TYPE_RESTRICTED_NUM
Number is restricted.
Definition: iSim.h:145
CallSourceStatus
Defines the possible status that a voice call source can report regarding calls.
Definition: iSim.h:92
CallMode
Mode.
Definition: iSim.h:114
@ WAITING
Waiting.
Definition: iSim.h:103
@ DIR_OUTGOING
0 -> Mobile originated call (MOC)
Definition: iSim.h:72
@ ALERTING
Alerting (Mobile Originated call)
Definition: iSim.h:109
@ CALLS_DISABLED
The calls are not available.
Definition: iSim.h:102
@ MPTY_INACTIVE
Call is not one of multiparty (conference) call parties.
Definition: iSim.h:131
@ MODE_FAX
Fax.
Definition: iSim.h:118
virtual ~SimObserver()
Destructor.
Definition: iSim.h:204
int day
Days after the month - [1,31].
Definition: iSim.h:18
@ DROPPED
The call has been suspended by the network, but may resumed later.
Definition: iSim.h:110
std::string ICCID
Sim ICCID.
Definition: iSim.h:63
@ MODE_VOICE
Voice.
Definition: iSim.h:116
@ MODE_VOICE_DATA
Voice followed by data, voice mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:119
Defines the struct type used to store the UTC_INFO.
Definition: iSim.h:24
int duration_seconds
Duration of the call, expressed in seconds.
Definition: iSim.h:163
Deepsy Modem namespace that includes the different enums, structs or method signatures that should be...
@ RINGING
Incoming call being received (Mobile Terminated Call)
Definition: iSim.h:104
int hour
Hours since midnight - [0,23].
Definition: iSim.h:26
CallTrafficChannel
Traffic channel assigned.
Definition: iSim.h:136
@ STAT_WAITING
Waiting (MTC)
Definition: iSim.h:86
std::string APN
Access point network (url form)
Definition: iSim.h:42
Defines the structure containing Sim information.
Definition: iSim.h:60
std::string getId() const
Retrieve the sim ID.
CallDir
Direction.
Definition: iSim.h:70
@ TYPE_SUPPLEM_SERVICE_CODE
Dialing string number contains "*", "#" characters for Supplementary Services codes....
Definition: iSim.h:148
@ MODE_VOICE_ALT_DATA
Alternating voice/data, voice mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:120
@ MODE_UNKNOWN
Unknown.
Definition: iSim.h:125
virtual boost::system::error_code getApn(dpyModem::AccessPointNetwork &apn, bool &forced)=0
Retrieve the sim APN.
@ MODE_VOICE_ALT_FAX
Alternating voice/fax, voice mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:121
SimStatus
Defines the possible states in which SIM card may be.
Definition: iSim.h:48
virtual ~ISim()
Destructor.
@ BUSY
Resource is busy, a call may be in progress.
Definition: iSim.h:96
virtual dpyModem::CallInfo getLastCallInfo() const =0
Used to retrieve last call information.
virtual boost::system::error_code getSimInfo(dpyModem::SimInfo &sim_info)=0
Retrieve sim related information.
virtual void updateCallSourceStatus(const std::string &simId, const dpyModem::CallSourceStatus &sourceStatus)=0
Method that will be called on Sim events.
@ MODE_DATA_ALT_VOICE
Alternating voice/data, data mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:123
virtual std::string getOperatorName() const =0
Retrieve the sim operator name.
@ SIM_READY
Sim is ready to be used.
Definition: iSim.h:56
@ IDLE
Ready to perform calls.
Definition: iSim.h:95
CallStatus
Defines the possible call status.
Definition: iSim.h:100
@ HELD
The call is held.
Definition: iSim.h:107
@ MODE_DATA
Data.
Definition: iSim.h:117
@ MODE_FAX_ALT_VOICE
Alternating voice/fax, fax mode (only in connection with single numbering scheme AT+CSNS)
Definition: iSim.h:124
@ STAT_ALERTING
Alerting (MOC)
Definition: iSim.h:84
@ STAT_HELD
The call is held.
Definition: iSim.h:82
CallStatus stat
State of the call.
Definition: iSim.h:157
@ SIM_LOCKED_PIN2
Sim card is blocked and PIN2 code must be entered.
Definition: iSim.h:54
std::string user
User used to access the network.
Definition: iSim.h:43
@ STAT_TERMINATING
The call is not active anymore, but inband information is still available.
Definition: iSim.h:87