gpioApi.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include <boost/function.hpp>
7 #include <boost/system/error_code.hpp>
8 #include <boost/shared_ptr.hpp>
9 #include <vector>
10 #include "iGpio.h"
11 
12 class GpioClient;
13 
19 namespace dpyGpio {
20 
25 typedef boost::function<void(const bool &available)> service_availability_handler;
26 
27 
32 typedef boost::function<void(boost::system::error_code error_code)> result_handler_function;
33 
39 typedef boost::function<void(boost::system::error_code, std::map<std::string, dpyGpio::GpioInfoConf> gpioMap)> gpio_list_handler;
40 
47 typedef boost::function<void(boost::system::error_code error_code, const std::string& id, dpyGpio::GpioStatus status)> gpio_status_handler_function;
48 
49 
50 } //dpyGpio
51 
52 
53 //Note that the GpioApiCPP group must be defined in the general documentation
60 {
61 
62 private:
63  boost::shared_ptr<GpioClient> mClient;
64 
65 public:
66 
67  /*
68  * @brief Constructor of the class
69  * @param ip IP address to be binded to the App
70  */
71  explicit GpioManager(std::string ip = "127.0.0.1");
72 
73  /*
74  * @brief Destructor of the class
75  */
76  ~GpioManager();
77 
82  bool isAlive();
83 
84 
85  void monitorServiceAvailability_S(dpyGpio::service_availability_handler handler);
86  void monitorServiceAvailability_U();
87  void gpioEvents_S(dpyGpio::gpio_status_handler_function handler);
88  void gpioEvents_U();
89 
90  /*
91  * @brief Method which requests gpios
92  * @param handler Handler to be called when a response comes from the service
93  */
94  void asyncGetGpios(dpyGpio::gpio_list_handler handler);
95 
102  void asyncSetGpioValue(dpyGpio::result_handler_function handler, const std::string& gpioid, bool value);
103 
104  /*
105  * @brief Gets gpio status: value and counter
106  * @param handler Hanlder to be called when a response comes from the service
107  * @param gpioid gpio id
108  */
109  void asyncGetGpioStatus(dpyGpio::gpio_status_handler_function handler, const std::string& gpioid);
110 
111  /*
112  * @brief Modifies gpio configuration
113  * @param handler Handler to be called when a response comes from the service
114  * @param gpioid gpio id
115  * @param gpioConfiguration configuration of the gpio to modify
116  */
117  void asyncSetGpioConfiguration(dpyGpio::result_handler_function handler, const std::string& gpioid, dpyGpio::GpioInfoConf gpioConfiguration);
118 };
Allows to interact with a ServiceName service.
Definition: gpioApi.h:59
Deepsy GPIO namespace that includes the different enums, structs or method signatures that should be ...
Definition: gpioApi.h:12
boost::function< void(boost::system::error_code error_code)> result_handler_function
Prototype of the handler function for obtaining a result.
Definition: gpioApi.h:32
Interacts with Gpio service.
Definition: gpioClient.h:13
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: gpioApi.h:25
Definition: iGpio.h:30
boost::function< void(boost::system::error_code error_code, const std::string &id, dpyGpio::GpioStatus status)> gpio_status_handler_function
Prototype of the handler function for getting gpio value.
Definition: gpioApi.h:47
boost::function< void(boost::system::error_code, std::map< std::string, dpyGpio::GpioInfoConf > gpioMap)> gpio_list_handler
Prototype of the handler function for getting gpios.
Definition: gpioApi.h:39