summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-10-16 14:57:26 +0200
committerAki <please@ignore.pl>2021-10-16 14:57:26 +0200
commit8f1844febcd87487e979435469645132da4e09c5 (patch)
tree657bf48a77f5af7c91a724e38fbb2e8acc1557e8
parent48cfa84671048346f64236dedb53b61e27156ad9 (diff)
downloadhwd-8f1844febcd87487e979435469645132da4e09c5.zip
hwd-8f1844febcd87487e979435469645132da4e09c5.tar.gz
hwd-8f1844febcd87487e979435469645132da4e09c5.tar.bz2
Library updated to use newly added gpio
-rw-r--r--daemon/src/daemon.cpp12
-rw-r--r--library/include/hwd.h11
-rw-r--r--library/src/library.cpp17
3 files changed, 19 insertions, 21 deletions
diff --git a/daemon/src/daemon.cpp b/daemon/src/daemon.cpp
index 99da92c..449292d 100644
--- a/daemon/src/daemon.cpp
+++ b/daemon/src/daemon.cpp
@@ -10,18 +10,8 @@
int main(int, char **)
{
rpc::server server(hwd::internal::default_port);
- Assembly assembly {server};
Gpio gpio;
+ Assembly assembly {server};
assembly.add("gpio", gpio);
- server.bind("stop_server", []{
- rpc::this_server().stop();
- });
- int value = 0;
- server.bind("set_value", [&value](int a){
- value = a;
- });
- server.bind("get_value", [&value](){
- return value;
- });
server.run();
}
diff --git a/library/include/hwd.h b/library/include/hwd.h
index 197b44b..3bec6be 100644
--- a/library/include/hwd.h
+++ b/library/include/hwd.h
@@ -2,7 +2,10 @@
namespace hwd
{
-void stop_server();
-void set_value(int value);
-int get_value();
-}
+namespace gpio
+{
+void set_mode(const unsigned port, const short mode);
+void write(const unsigned port, const short value);
+short read(const unsigned port);
+} // namespace gpio
+} // namespace hwd
diff --git a/library/src/library.cpp b/library/src/library.cpp
index 73f40f9..d5c51c7 100644
--- a/library/src/library.cpp
+++ b/library/src/library.cpp
@@ -11,19 +11,24 @@ static rpc::client & get_client()
return c;
}
-void stop_server()
+namespace gpio
{
- get_client().call("stop_server");
+
+void set_mode(const unsigned port, const short mode)
+{
+ get_client().call("gpio/set_mode", port, mode);
}
-void set_value(const int value)
+void write(const unsigned port, const short value)
{
- get_client().call("set_value", value);
+ get_client().call("gpio/write", port, value);
}
-int get_value()
+short read(const unsigned port)
{
- return get_client().call("get_value").as<int>();
+ return get_client().call("gpio/read", port).as<short>();
}
+} // namespace gpio
+
} // namespace hwd