modemApi.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <boost/function.hpp>
8 #include <boost/system/error_code.hpp>
9 #include <map>
10 #include <vector>
11 
12 #include "iModemList.h"
13 #include "networking.h"
14 
15 class ModemClient;
16 
17 #ifndef MODEM_TYPES_H_
18 #define MODEM_TYPES_H_
19 
25 namespace dpyModem {
26 
29 {
33  IMEI,
38 };
39 
40 
43 {
51 };
52 
58 typedef boost::function<void(boost::system::error_code, std::list<std::string> modems)> modem_list_handler_function;
59 
65 typedef boost::function<void(boost::system::error_code, std::list<std::string> sims)> sim_list_handler_function;
66 
73 typedef boost::function<void(boost::system::error_code error_code,std::string modemid, struct ModemStatus& status)> modem_status_handler_function;
74 
75 
82 typedef boost::function<void(boost::system::error_code, std::string modemid, ListEvent event)> modem_list_event_handler_function;
83 
90 typedef boost::function<void(boost::system::error_code, std::string modemid, dpyModem::ModemWarning warning)> modem_warning_event_handler_function;
91 
98 typedef boost::function<void(boost::system::error_code error_code,std::string modemid, const bool &enabled)> modem_data_connection_status_handler_function;
99 
105 typedef boost::function<void(boost::system::error_code, ModemInfo modeminfo)> modem_info_handler_function;
106 
112 typedef boost::function<void(boost::system::error_code, SimInfo siminfo)> sim_info_handler_function;
113 
121 typedef boost::function<void(boost::system::error_code, std::string modemid, std::string simid, ListEvent event)> sim_list_event_handler_function;
122 
129 typedef boost::function<void(boost::system::error_code, std::string simid, dpyModem::SimStatus status)> simStatus_handler_function;
130 
131 
136 typedef boost::function<void(const bool &available)> service_availability_handler_function;
137 typedef boost::function<void(boost::system::error_code& ec, ModemWarning warning_notif)> warning_handler_function;
138 typedef boost::function<
139  void(boost::system::error_code error_code, MODEM_INFO type, const std::string& value)> get_info_handler_function;
140 typedef boost::function<
141  void(boost::system::error_code error_code, const AccessPointNetwork& apn_info, const bool& forced_apn)> get_apn_handler_function;
142 typedef boost::function<
143  void(boost::system::error_code error_code, const AccessPointNetwork& apn_info)> get_apn_by_imsi_handler_function;
144 typedef boost::function<void(boost::system::error_code error_code)> result_handler_function;
145 typedef boost::function<void(boost::system::error_code error_code, const bool &enabled)> data_connection_status_handler_function;
146 typedef boost::function<void(boost::system::error_code error_code, const std::string& modemId, const std::string& interfaceName, std::map<dpyNetworking::Statistics, uint32_t>statisticsValues, const std::string& interfaceIpAddress )> interface_statistics_function_handler;
147 
154 typedef boost::function<void(boost::system::error_code error_code, std::string modemid, int simSlot)> sim_slot_handler_function;
155 
161 typedef boost::function<void(boost::system::error_code error_code, dpyModem::AccessPointNetwork found_apn)> forced_apn_handler_function;
162 
163 } //dpyModem
164 
165 
166 #endif /* MODEM_TYPES_H_ */
167 
168 
175 {
176 protected:
180  boost::shared_ptr <ModemClient> mClient;
181 public:
186  explicit ModemManager(std::string ip = "127.0.0.1");
190  virtual ~ModemManager();
191 
193 #ifndef TESTING
194 
198  bool isAlive();
199 
204  void monitorServiceAvailability_S(dpyModem::service_availability_handler_function handler);
205 
209  void monitorServiceAvailability_U();
210 
215  void asyncGetModems(dpyModem::modem_list_handler_function handler);
216 
222  void asyncGetModemInfo(const std::string& modemid, dpyModem::modem_info_handler_function handler);
223 
229  void asyncGetModemStatus(const std::string& modemid, dpyModem::modem_status_handler_function handler);
230 
235  void getModemStatusEvents_S(dpyModem::modem_status_handler_function handler);
236 
241  void getModemListEvents_S(dpyModem::modem_list_event_handler_function handler);
242 
247  void getModemWarningEvents_S(dpyModem::modem_warning_event_handler_function handler);
248 
255  void asyncRequestModemOperation(const std::string& modemid, const dpyModem::ModemOperation& operation, dpyModem::result_handler_function handler);
256 
262  void asyncIsDataConnectionEnabled(const std::string& modemid,dpyModem::modem_data_connection_status_handler_function handler);
263 
266 
272  void asyncGetModemSims(const std::string& modemid, dpyModem::sim_list_handler_function handler);
273 
280  void asyncGetActiveSims(const std::string& modemid, dpyModem::sim_list_handler_function handler);
281 
289  void asyncSwitchCurrentSimCard(const std::string& modemid, dpyModem::result_handler_function handler);
290 
297  void getCurrentSimSlot(const std::string& modemid, dpyModem::sim_slot_handler_function handler);
298 
303  void getSimListEvents_S (dpyModem::sim_list_event_handler_function handler);
304 
309  void getSimStatusEvents_S(dpyModem::simStatus_handler_function handler);
310  void getSimStatusEvents_U();
311 
317  void asyncGetSimInfo(const std::string& simid, dpyModem::sim_info_handler_function handler);
318 
324  void asyncGetSimStatus(const std::string& simid, dpyModem::simStatus_handler_function handler);
325 
329 
337  void asyncGetApnByImsi(const std::string& imsi, dpyModem::get_apn_by_imsi_handler_function handler);
338 
350  void asyncAddNewApn(const std::string& imsi, const dpyModem::AccessPointNetwork& apn, dpyModem::result_handler_function handler);
351 
363  void asyncDeleteApnByImsi(const std::string& imsi, dpyModem::result_handler_function handler);
364 
377  void asyncModifyApnByImsi(const std::string& current_imsi, const dpyModem::AccessPointNetwork& new_apn, dpyModem::result_handler_function handler);
378 
387  [[deprecated("Do not use the IMSI parameter to configure a forced APN. Forced APN is used for all inserted SIMs")]]
388  void asyncForceCustomApn(const std::string& imsi, dpyModem::result_handler_function handler, const bool& force = false, const dpyModem::AccessPointNetwork& custom_apn = {});
391 
399  void asyncForceCustomApn(dpyModem::result_handler_function handler, const bool& force = false, const dpyModem::AccessPointNetwork& custom_apn = {});
400 
406  void asyncGetInterfaceStatistics(const std::string& modemid, dpyModem::interface_statistics_function_handler);
407 
415  void asyncForceNetworkMode(const std::string& modemid, dpyModem::NetworkMode mode,dpyModem::result_handler_function handler);
416 
421  void asyncGetForcedAPN(dpyModem::forced_apn_handler_function handler);
422 
423 #else
424  virtual bool isAlive();
425  virtual void monitorServiceAvailability_S(dpyModem::service_availability_handler_function handler);
426  virtual void monitorServiceAvailability_U();
427  virtual void asyncGetModems(dpyModem::modem_list_handler_function handler);
428  virtual void asyncGetModemInfo(const std::string& modemid, dpyModem::modem_info_handler_function handler);
429  virtual void asyncGetModemStatus(const std::string& modemid, dpyModem::modem_status_handler_function handler);
430  virtual void getModemStatusEvents_S(dpyModem::modem_status_handler_function handler);
431  virtual void getModemListEvents_S(dpyModem::modem_list_event_handler_function handler);
432  virtual void getModemWarningEvents_S(dpyModem::modem_warning_event_handler_function handler);
433  virtual void asyncRequestModemOperation(const std::string& modemid, const dpyModem::ModemOperation& operation, dpyModem::result_handler_function handler);
434  virtual void asyncIsDataConnectionEnabled(const std::string& modemid,dpyModem::modem_data_connection_status_handler_function handler);
435  virtual void asyncGetModemSims(const std::string& modemid, dpyModem::sim_list_handler_function handler);
436  virtual void asyncGetActiveSims(const std::string& modemid, dpyModem::sim_list_handler_function handler);
437  virtual void asyncSwitchCurrentSimCard(const std::string& modemid, dpyModem::result_handler_function handler);
438  virtual void getCurrentSimSlot(const std::string& modemid, dpyModem::sim_slot_handler_function handler);
439  virtual void getSimListEvents_S (dpyModem::sim_list_event_handler_function handler);
440  virtual void getSimStatusEvents_S(dpyModem::simStatus_handler_function handler);
441  virtual void getSimStatusEvents_U();
442  virtual void asyncGetSimInfo(const std::string& simid, dpyModem::sim_info_handler_function handler);
443  virtual void asyncGetSimStatus(const std::string& simid, dpyModem::simStatus_handler_function handler);
444  virtual void asyncGetApnByImsi(const std::string& imsi, dpyModem::get_apn_by_imsi_handler_function handler);
445  virtual void asyncAddNewApn(const std::string& imsi, const dpyModem::AccessPointNetwork& apn, dpyModem::result_handler_function handler);
446  virtual void asyncDeleteApnByImsi(const std::string& imsi, dpyModem::result_handler_function handler);
447  virtual void asyncModifyApnByImsi(const std::string& current_imsi, const dpyModem::AccessPointNetwork& new_apn, dpyModem::result_handler_function handler);
448  virtual void asyncForceCustomApn(const std::string& imsi, dpyModem::result_handler_function handler, const bool& force = false, const dpyModem::AccessPointNetwork& custom_apn = {});
449  virtual void asyncForceCustomApn(dpyModem::result_handler_function handler, const bool& force = false, const dpyModem::AccessPointNetwork& custom_apn = {});
450  virtual void asyncGetInterfaceStatistics(const std::string& modemid, dpyModem::interface_statistics_function_handler);
451  virtual void asyncForceNetworkMode(const std::string& modemid, dpyModem::NetworkMode mode,dpyModem::result_handler_function handler);
452  virtual void asyncGetForcedAPN(dpyModem::forced_apn_handler_function handler);
453 #endif
454 };
boost::function< void(boost::system::error_code, std::string simid, dpyModem::SimStatus status)> simStatus_handler_function
Prototype of the handler function for sim status getter and events.
Definition: modemApi.h:129
APN that is being used by the SIM card to perform data connections.
Definition: modemApi.h:37
SIM card IMSI (International Mobile Subscriber Identity)
Definition: modemApi.h:34
Operation that sets the modem sleep mode.
Definition: modemApi.h:46
Operation that generates a software modem restart.
Definition: modemApi.h:47
Operation that disables the data connections performed with the modem.
Definition: modemApi.h:49
Deepsy Modem namespace that includes the different enums, structs or method signatures that should be...
ModemOperation
Defines the possible operations that can be queried to a modem.
Definition: modemApi.h:42
Operation that enables the modem (modem enabled by default)
Definition: modemApi.h:45
boost::function< void(boost::system::error_code, std::list< std::string > modems)> modem_list_handler_function
Prototype of the handler function for getting available modems.
Definition: modemApi.h:58
boost::function< void(boost::system::error_code error_code, const std::string &modemId, const std::string &interfaceName, std::map< dpyNetworking::Statistics, uint32_t >statisticsValues, const std::string &interfaceIpAddress)> interface_statistics_function_handler
Prototype of the handler function for asyncGetInterfaceStatistics method.
Definition: modemApi.h:146
NetworkMode
Defines the possible network modes.
Definition: iModem.h:100
boost::function< void(boost::system::error_code error_code, const AccessPointNetwork &apn_info, const bool &forced_apn)> get_apn_handler_function
Prototype of the handler function for obtaining apn information (getCurrentApn or getApnByImsi method...
Definition: modemApi.h:141
Current operator used by the SIM card.
Definition: modemApi.h:36
boost::function< void(boost::system::error_code error_code, std::string modemid, struct ModemStatus &status)> modem_status_handler_function
Prototype of the handler function for modem status getter and events.
Definition: modemApi.h:73
boost::function< void(boost::system::error_code error_code, MODEM_INFO type, const std::string &value)> get_info_handler_function
Prototype of the handler function for getModemInfo method.
Definition: modemApi.h:139
SIM card ICCID (Integrated Circuit Card Identifier)
Definition: modemApi.h:35
Modem Model.
Definition: modemApi.h:31
boost::function< void(boost::system::error_code &ec, ModemWarning warning_notif)> warning_handler_function
Prototype of the handler function for getModemNotifications_S method.
Definition: modemApi.h:137
MODEM_INFO
Defines the possible information that can be queried.
Definition: modemApi.h:28
boost::function< void(boost::system::error_code, std::string modemid, dpyModem::ModemWarning warning)> modem_warning_event_handler_function
Prototype of the handler function for subscribing to modem warnings.
Definition: modemApi.h:90
Operation that enables the data connections performed with the modem (modem data connection enabled b...
Definition: modemApi.h:50
Modem Client class that interacts with the modem Service.
Definition: modemClient.h:13
boost::function< void(boost::system::error_code error_code, dpyModem::AccessPointNetwork found_apn)> forced_apn_handler_function
Prototype of the handler function for get the global forced APN.
Definition: modemApi.h:161
boost::shared_ptr< ModemClient > mClient
Reference to an Client Object.
Definition: modemApi.h:180
Operation that generates a hardware modem restart.
Definition: modemApi.h:48
Modem IMEI (International Mobile Equipment Identity)
Definition: modemApi.h:33
boost::function< void(boost::system::error_code, SimInfo siminfo)> sim_info_handler_function
Prototype of the handler function used to get a specific sim information.
Definition: modemApi.h:112
boost::function< void(boost::system::error_code error_code, std::string modemid, const bool &enabled)> modem_data_connection_status_handler_function
Prototype of the handler function to receive modem data connection status.
Definition: modemApi.h:98
boost::function< void(boost::system::error_code, std::list< std::string > sims)> sim_list_handler_function
Prototype of the handler function for getting available sims.
Definition: modemApi.h:65
Allows to interact with Modem Service.
Definition: modemApi.h:174
boost::function< void(boost::system::error_code error_code, const AccessPointNetwork &apn_info)> get_apn_by_imsi_handler_function
Prototype of the handler function for obtaining apn information (getCurrentApn or getApnByImsi method...
Definition: modemApi.h:143
boost::function< void(boost::system::error_code, std::string modemid, std::string simid, ListEvent event)> sim_list_event_handler_function
Prototype of the handler function for subscribing to list events.
Definition: modemApi.h:121
Modem firmware version.
Definition: modemApi.h:32
Operation that shuts down the modem completely.
Definition: modemApi.h:44
boost::function< void(const bool &available)> service_availability_handler_function
Prototype of the handler function used to monitor service availability.
Definition: modemApi.h:136
boost::function< void(boost::system::error_code error_code, const bool &enabled)> data_connection_status_handler_function
Prototype of the handler function for isDataConnectionEnabled method.
Definition: modemApi.h:145
boost::function< void(boost::system::error_code error_code, std::string modemid, int simSlot)> sim_slot_handler_function
Prototype of the handler function for get the current sim slot.
Definition: modemApi.h:154
Definition: iSim.h:40
Modem Manufacturer.
Definition: modemApi.h:30
boost::function< void(boost::system::error_code, ModemInfo modeminfo)> modem_info_handler_function
Prototype of the handler function used to get a specific modem information.
Definition: modemApi.h:105
boost::function< void(boost::system::error_code, std::string modemid, ListEvent event)> modem_list_event_handler_function
Prototype of the handler function for subscribing to list events.
Definition: modemApi.h:82
boost::function< void(boost::system::error_code error_code)> result_handler_function
Prototype of the handler function for obtaining result of the different operations.
Definition: modemApi.h:144