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 
205 
210 
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 
236 
242 
248 
255  void asyncRequestModemOperation(const std::string& modemid, const dpyModem::ModemOperation& operation, dpyModem::result_handler_function handler);
256 
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 
304 
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 
407 
415  void asyncForceNetworkMode(const std::string& modemid, dpyModem::NetworkMode mode,dpyModem::result_handler_function handler);
416 
422 
423 #else
424  virtual bool isAlive();
426  virtual void monitorServiceAvailability_U();
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);
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);
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);
453 #endif
454 };
void monitorServiceAvailability_S(dpyModem::service_availability_handler_function handler)
Monitor Modem service availability.
@ ENABLE_DATA_CONNECTION
Operation that enables the data connections performed with the modem (modem data connection enabled b...
Definition: modemApi.h:50
void getSimStatusEvents_U()
Method which requests sims associated with a specific modem.
void asyncForceNetworkMode(const std::string &modemid, dpyModem::NetworkMode mode, dpyModem::result_handler_function handler)
Force a modem to work under a specific Network Mode (2G,3G,4G,...)
@ SIM_IMSI
SIM card IMSI (International Mobile Subscriber Identity)
Definition: modemApi.h:34
void getModemWarningEvents_S(dpyModem::modem_warning_event_handler_function handler)
Subscribes to modem warning events.
boost::shared_ptr< ModemClient > mClient
Reference to an Client Object.
Definition: modemApi.h:180
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
bool isAlive()
Method to check if Modem Service is alive.
@ FW_VERSION
Modem firmware version.
Definition: modemApi.h:32
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
@ SIM_OPERATOR
Current operator used by the SIM card.
Definition: modemApi.h:36
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
void asyncGetActiveSims(const std::string &modemid, dpyModem::sim_list_handler_function handler)
Method which requests sims being in use for a specific modem.
boost::function< void(const bool &available)> service_availability_handler_function
Prototype of the handler function used to monitor service availability.
Definition: modemApi.h:136
void asyncGetSimStatus(const std::string &simid, dpyModem::simStatus_handler_function handler)
Method which requests sim status.
ListEvent
Definition: iModem.h:15
@ MANUFACTURER
Modem Manufacturer.
Definition: modemApi.h:30
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
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
void getSimStatusEvents_S(dpyModem::simStatus_handler_function handler)
Subscribes to sim status events.
void asyncAddNewApn(const std::string &imsi, const dpyModem::AccessPointNetwork &apn, dpyModem::result_handler_function handler)
Add a new APN to the APN list being used by the Modem when performing Modem data communications.
@ SIM_APN
APN that is being used by the SIM card to perform data connections.
Definition: modemApi.h:37
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, 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
void asyncModifyApnByImsi(const std::string &current_imsi, const dpyModem::AccessPointNetwork &new_apn, dpyModem::result_handler_function handler)
Modify an existing APN (associated with a specific imsi) in the APN list.
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
@ DISABLE
Operation that shuts down the modem completely.
Definition: modemApi.h:44
Defines the status information structure that is obtained after a MODEM STATUS report.
Definition: iModem.h:130
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
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
void asyncSwitchCurrentSimCard(const std::string &modemid, dpyModem::result_handler_function handler)
Change current Sim card being used by the specified modem, and start using alternative sim.
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
void asyncForceCustomApn(const std::string &imsi, dpyModem::result_handler_function handler, const bool &force=false, const dpyModem::AccessPointNetwork &custom_apn={})
Allows to select a specific APN manually ignoring the APN list (disabled by default)....
void asyncIsDataConnectionEnabled(const std::string &modemid, dpyModem::modem_data_connection_status_handler_function handler)
Query if a specific modem data connection functionalities are enabled or not.
virtual ~ModemManager()
Destructor of the class.
Modem Client class that interacts with the modem Service.
Definition: modemClient.h:13
MODEM_INFO
Defines the possible information that can be queried.
Definition: modemApi.h:28
void asyncGetModems(dpyModem::modem_list_handler_function handler)
Method which requests available modems.
@ MODEL
Modem Model.
Definition: modemApi.h:31
void monitorServiceAvailability_U()
Stop monitoring Modem service availability.
void asyncGetModemInfo(const std::string &modemid, dpyModem::modem_info_handler_function handler)
Method which requests modem information.
Definition: iSim.h:40
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
@ SLEEP
Operation that sets the modem sleep mode.
Definition: modemApi.h:46
@ IMEI
Modem IMEI (International Mobile Equipment Identity)
Definition: modemApi.h:33
ModemOperation
Defines the possible operations that can be queried to a modem.
Definition: modemApi.h:42
void asyncGetSimInfo(const std::string &simid, dpyModem::sim_info_handler_function handler)
Method which requests modem information.
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
@ SW_RESTART
Operation that generates a software modem restart.
Definition: modemApi.h:47
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 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
Defines the structure containing Modem information.
Definition: iModem.h:142
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
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
@ DISABLE_DATA_CONNECTION
Operation that disables the data connections performed with the modem.
Definition: modemApi.h:49
Allows to interact with Modem Service.
Definition: modemApi.h:174
Deepsy Modem namespace that includes the different enums, structs or method signatures that should be...
ModemWarning
Defines the possible warnings that the modem can report during its operation.
Definition: iModem.h:152
NetworkMode
Defines the possible network modes.
Definition: iModem.h:100
void getModemStatusEvents_S(dpyModem::modem_status_handler_function handler)
Establish the handler that the subscriber will call when a new modem status (coming from any modem) i...
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
Defines the structure containing Sim information.
Definition: iSim.h:60
void asyncGetModemSims(const std::string &modemid, dpyModem::sim_list_handler_function handler)
Method which requests sims associated with a specific modem.
void getModemListEvents_S(dpyModem::modem_list_event_handler_function handler)
Subscribes to modem list events.
void asyncRequestModemOperation(const std::string &modemid, const dpyModem::ModemOperation &operation, dpyModem::result_handler_function handler)
Query a specific modem to perform a specific operation.
@ HW_RESTART
Operation that generates a hardware modem restart.
Definition: modemApi.h:48
void asyncGetApnByImsi(const std::string &imsi, dpyModem::get_apn_by_imsi_handler_function handler)
Obtain the APN that corresponds to the specified imsi as it would be obtained with the APN list.
SimStatus
Defines the possible states in which SIM card may be.
Definition: iSim.h:48
void asyncDeleteApnByImsi(const std::string &imsi, dpyModem::result_handler_function handler)
Delete a particular APN from the APN list by specifying the IMSI.
ModemManager(std::string ip="127.0.0.1")
Constructor of the class.
@ SIM_ICCID
SIM card ICCID (Integrated Circuit Card Identifier)
Definition: modemApi.h:35
void asyncGetModemStatus(const std::string &modemid, dpyModem::modem_status_handler_function handler)
Method which requests modem status.
@ ENABLE
Operation that enables the modem (modem enabled by default)
Definition: modemApi.h:45
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
void asyncGetForcedAPN(dpyModem::forced_apn_handler_function handler)
Obtain the Forced APN configured on the device. If there is no forced APN, it returns an empty one.
void getCurrentSimSlot(const std::string &modemid, dpyModem::sim_slot_handler_function handler)
Get current Sim card slot being used by the specified modem.
void getSimListEvents_S(dpyModem::sim_list_event_handler_function handler)
Subscribes to sim list events.
void asyncGetInterfaceStatistics(const std::string &modemid, dpyModem::interface_statistics_function_handler)
Allows to obtain different statistics of the interface related to transmission and reception of packa...