]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/centralstation.cpp
Add telemetry framework for drivers
[r2c2.git] / source / libr2c2 / centralstation.cpp
index 124c1beed8aa14efba0fc96bc59a8ab17ca7a709..5e82f2e5f117c23d9137bb80ff41b0b4359d2ecb 100644 (file)
@@ -1,4 +1,5 @@
 #include <algorithm>
+#include <msp/core/maputils.h>
 #include <msp/core/refptr.h>
 #include <msp/io/print.h>
 #include <msp/net/resolve.h>
@@ -14,7 +15,7 @@ using namespace Msp;
 
 namespace R2C2 {
 
-CentralStation::CentralStation(const string &host):
+CentralStation::CentralStation(const Options &opts):
        socket(Net::INET),
        pending_commands(0),
        power(false),
@@ -23,7 +24,7 @@ CentralStation::CentralStation(const string &host):
        accessories_synced(false),
        sensors_synced(false)
 {
-       RefPtr<Net::SockAddr> addr = Net::resolve(host+":15471");
+       RefPtr<Net::SockAddr> addr = Net::resolve(opts.get<string>(string())+":15471");
        socket.connect(*addr);
 
        IO::print("Connected to central station at %s\n", addr->str());
@@ -328,6 +329,11 @@ bool CentralStation::get_sensor(unsigned addr) const
        return false;
 }
 
+float CentralStation::get_telemetry_value(const string &name) const
+{
+       throw key_error(name);
+}
+
 void CentralStation::tick()
 {
        while(Message msg = receive())