iModem.h
1 #ifndef IMODEM_H_
2 #define IMODEM_H_
3 
4 #include <boost/system/error_code.hpp>
5 #include <boost/asio.hpp>
6 #include <boost/chrono.hpp>
7 
8 #include <list>
9 #include <string>
10 
11 #include "iSim.h"
12 
13 namespace dpyModem {
14 
15 typedef enum
16 {
17  ADDED = 0,
18  REMOVED = 1,
19 } ListEvent;
20 
22 typedef enum
23 {
24  MODEMMANAGERGENERIC_USB = 0,
25  MODEMMANAGER_EM7455 = 1,
26  BGS2W_PREINSTALLED = 2,
27  MODEMMANAGER_RC7620 = 3,
28  MODEMMANAGER_EC25 = 4,
29  MODEMMANAGER_WP7607 = 5,
30  MODEMMANAGER_RC7611 = 6,
31  MODEMMANAGER_EG25 = 7,
32  MODEMMANAGER_RG255C = 8
33 } ModemType;
34 
41 enum ModemState
44 {
58 };
59 
62 {
67 };
68 
71 {
77 };
78 
81 {
87 };
88 
91 {
97 };
98 
101 {
102  MODE_NONE = 0,
103  MODE_CS = 1,
104  MODE_2G = 2,
105  MODE_3G = 4,
106  MODE_4G = 8,
107  MODE_5G = 16,
108  MODE_ANY = 32,
109 };
110 
111 
114 {
117  GSM,
125  LTE,
127 };
128 
131 {
138 };
140 
142 struct ModemInfo
143 {
144  std::string manufacturer;
145  std::string model;
146  std::string imei;
147  std::string fw_version;
148 };
149 
150 
153 {
164 };
165 
171 {
172  int audio_mode;
173  int ringtone;
174  int volume_ringtone;
175  int volume_percent;
176  int micro_gain;
177  int micro_mult_factor;
178 };
179 
180 } //dpyModem
181 
182 class IModem;
183 
189 {
190 public:
196  virtual void updateModemState(const std::string& modemid,const dpyModem::ModemState& state) = 0;
197 
203  virtual void processModemWarningEvent(const std::string& modemid,const dpyModem::ModemWarning& warning) = 0;
204 
211  virtual void updateSimList(const std::string& modemid, const std::string& simid,const dpyModem::ListEvent& event) = 0;
212 
216  virtual ~ModemObserver()
217  {
218  }
219 };
220 
225 class IModem
226 {
227 private:
228  std::string mId;
229  std::vector<ModemObserver*> mObserversList;
230 
231 protected:
232  std::map<std::string, boost::shared_ptr<ISim>> mIdToSimMap;
233  void setId(const std::string& id);
234  void notifyModemStateUpdate(const std::string& modemid, const dpyModem::ModemState& status);
235  void notifyModemWarningEvent(const std::string& modemid, const dpyModem::ModemWarning& warning);
236  void notifySimListEvent(const std::string& modemid, const std::string& simid, const dpyModem::ListEvent& event);
237  void notifySimStatusUpdate(const std::string& simid, const dpyModem::SimStatus& status);
238 
239 public:
240 
244  virtual ~IModem();
245 
250  std::string getId() const;
251 
257  virtual boost::system::error_code getModemInfo(dpyModem::ModemInfo& info) const = 0;
258 
264  virtual boost::system::error_code getCurrentSim(boost::shared_ptr<ISim>& sim) const = 0;
265 
271  virtual boost::system::error_code getSims(std::list<boost::shared_ptr<ISim>>& list ) const = 0;
272 
278  virtual bool isSimActive(const std::string& simId) const = 0;
279 
285  virtual boost::system::error_code getActiveSims(std::list<boost::shared_ptr<ISim>>& list ) const = 0;
286 
293  virtual boost::system::error_code getSimById(const std::string& simid, boost::shared_ptr<ISim>& sim) const = 0;
294 
300  virtual boost::system::error_code getStatus(dpyModem::ModemStatus& status) = 0;
301 
307  virtual bool enableModem(boost::system::error_code& ec) = 0;
308 
314  virtual bool disableModem(boost::system::error_code& ec) = 0;
315 
322  virtual bool sleepModem(boost::system::error_code& ec) = 0;
323 
329  virtual bool softwareRestartModem(boost::system::error_code& ec) = 0;
330 
337  virtual bool hardwareRestartModem(boost::system::error_code& ec) = 0;
338 
344  virtual boost::system::error_code enableDataConnection() = 0;
345 
350  virtual boost::system::error_code disableDataConnection() = 0;
351 
356  virtual bool isDataConnectionEnabled() = 0;
357 
363  virtual boost::system::error_code forceNetworkMode(const dpyModem::NetworkMode& mode) = 0;
364 
370  boost::system::error_code subscribe(ModemObserver* observer);
371 
377  boost::system::error_code unsubscribe(ModemObserver* observer);
378 
379 };
380 
381 #endif /* IMODEM_H_ */
Defines the status information structure that is obtained after a MODEM STATUS report.
Definition: iModem.h:130
Modem searching for a operator for the GPRS mobile network.
Definition: iModem.h:93
Modem full functionality mode.
Definition: iModem.h:66
Modem functions are not available.
Definition: iModem.h:63
Modem module is back to normal temperature.
Definition: iModem.h:160
Modem Data connection system is being initiated.
Definition: iModem.h:53
4G mode
Definition: iModem.h:106
Modem Cellular network capabilities are being enabled but cellular network may not be available yet...
Definition: iModem.h:48
Modem is being restarted.
Definition: iModem.h:64
Signal quality is good enough to perform communications.
Definition: iModem.h:75
Supply voltage is close to the overvoltage threshold. If the voltage continues to increase until it c...
Definition: iModem.h:155
5G mode
Definition: iModem.h:107
Modem interface class.
Definition: iModem.h:225
Modem is registered in the Cellular network : home network.
Definition: iModem.h:51
Deepsy Modem namespace that includes the different enums, structs or method signatures that should be...
std::map< std::string, boost::shared_ptr< ISim > > mIdToSimMap
Associates modem ids with the sim objects.
Definition: iModem.h:232
AccessTechnology
Defines the possible network access technologies a modem can make use of in order to communicate with...
Definition: iModem.h:113
Modem not registered in the Cellular network.
Definition: iModem.h:82
Modem waiting for next connection try.
Definition: iModem.h:57
HSUPA (3G network)
Definition: iModem.h:123
Modem has not been able to register either in Home or Roaming networks.
Definition: iModem.h:96
std::string manufacturer
Modem Manufacturer.
Definition: iModem.h:144
std::string imei
Modem IMEI (International Mobile Equipment Identity)
Definition: iModem.h:146
REMOVED.
Definition: iModem.h:18
Modem has been able to register in the GPRS Home network.
Definition: iModem.h:94
Indicates that the modem restart is finished and the modem is again available.
Definition: iModem.h:163
NetworkMode
Defines the possible network modes.
Definition: iModem.h:100
Modem is off, modem functionalities are not available.
Definition: iModem.h:45
Signal quality is not adequate and this can affect performance.
Definition: iModem.h:73
ADDED.
Definition: iModem.h:17
ModemPowerStatus
Defines the possible MODEM POWER states that the modem can be in.
Definition: iModem.h:61
Modem not registered in the GPRS mobile network.
Definition: iModem.h:92
ModemState currentState
Current modem FSM state.
Definition: iModem.h:132
EDGE (2G network)
Definition: iModem.h:119
HSDPA (3G network)
Definition: iModem.h:122
ListEvent
Definition: iModem.h:15
Not using any technology (modem disabled, sleep or being enabled) or technology is unknown...
Definition: iModem.h:115
Modem has been able to register in the Cellular Roaming network (i.e. an external network) ...
Definition: iModem.h:85
Signal quality should be enough to perform communications.
Definition: iModem.h:74
SimStatus simStatus
Current Sim Status.
Definition: iModem.h:134
std::string model
Modem Model.
Definition: iModem.h:145
Modem Data connection has been configured and enabled.
Definition: iModem.h:54
Modem is enabled and SIM card is ready.
Definition: iModem.h:49
GPRS_NETWORK_STATUS
Defines the possible GPRS network registration status that can be reported. Note that this field info...
Definition: iModem.h:90
Modem searching for a operator for the Cellular network.
Definition: iModem.h:83
UMTS (3G network)
Definition: iModem.h:120
CSD, GSM and circuit-switched.
Definition: iModem.h:103
GPRS (2G network)
Definition: iModem.h:118
Supply voltage is close to the undervoltage threshold. If the voltage continues to decrease until it ...
Definition: iModem.h:154
Signal quality is high.
Definition: iModem.h:76
Plain old telephone service.
Definition: iModem.h:116
Struct to keep call Configuration as configured by the Voice call.
Definition: iModem.h:170
3G mode
Definition: iModem.h:105
Indicates that the power-off procedure is finished and the modem will be switched off in less than 1 ...
Definition: iModem.h:162
SimStatus
Defines the possible states in which SIM card may be.
Definition: iSim.h:48
Modem module is above overtemperature limit, imminent switch off.
Definition: iModem.h:159
Modem has been able to register in the Cellular Home network.
Definition: iModem.h:84
AccessTechnology accessTech
Current network Access Technology being used.
Definition: iModem.h:137
std::string fw_version
Modem firmware version.
Definition: iModem.h:147
Modem Jamming has been detected in the module.
Definition: iModem.h:161
ModemState
Definition: iModem.h:43
Modem signal quality is good enough to perform communications.
Definition: iModem.h:50
Modem has been able to register in the GPRS Roaming network (i.e., an external network) ...
Definition: iModem.h:95
SignalQuality signalQuality
Current Signal Quality.
Definition: iModem.h:135
ModemType
Modem types.
Definition: iModem.h:22
GSM (2G network)
Definition: iModem.h:117
LTE (4G network)
Definition: iModem.h:125
Defines the structure containing Modem information.
Definition: iModem.h:142
Modem is being restarted, modem functionalities are not available.
Definition: iModem.h:46
Modem Antenna is not connected to the device.
Definition: iModem.h:72
2G mode
Definition: iModem.h:104
Modem module is below undertemperature limit, imminent switch off.
Definition: iModem.h:158
HSPA (3G network)
Definition: iModem.h:121
ModemPowerStatus powerStatus
Current Power Status.
Definition: iModem.h:133
Modem is registered in the Cellular network : roaming network.
Definition: iModem.h:52
Any mode,select to go back to default network mode.
Definition: iModem.h:108
virtual ~ModemObserver()
Destructor.
Definition: iModem.h:216
Modem module is close to undertemperature limit.
Definition: iModem.h:156
CDMA2000 (2G - 3G network)
Definition: iModem.h:124
Modem module is close to overtemperature limit.
Definition: iModem.h:157
NetworkStatus
Defines the possible Cellular network registration status that can be reported. Note that this field ...
Definition: iModem.h:80
Modem low consumption mode, modem functionalities are not available.
Definition: iModem.h:47
Modem low consumption mode.
Definition: iModem.h:65
ModemWarning
Defines the possible warnings that the modem can report during its operation.
Definition: iModem.h:152
SignalQuality
Defines the possible SIGNAL QUALITY results that that can be obtained.
Definition: iModem.h:70
NetworkStatus cellularNetworkStatus
Current Network Status.
Definition: iModem.h:136
Modem has configured the device for data connections and it&#39;s trying to connect.
Definition: iModem.h:55
5GNR
Definition: iModem.h:126
Modem has not been able to register either in Home or Roaming networks.
Definition: iModem.h:86
Modem Observer class.
Definition: iModem.h:188
Modem is ready to perform data connections, a network interface should be available for use...
Definition: iModem.h:56
No mode.
Definition: iModem.h:102