From 03fdc72d68f04e1dd403b150c4e718ac170ba41c Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 30 Mar 2018 23:06:47 +0100 Subject: boh --- src/standalone.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/standalone.cpp') diff --git a/src/standalone.cpp b/src/standalone.cpp index 6f185d2..46047f1 100644 --- a/src/standalone.cpp +++ b/src/standalone.cpp @@ -121,8 +121,7 @@ static const int kMaxAsyncInitTimeoutMS = 30 * 1000; // Server data values // -// The text string ("text/string") used by our custom text string service (see Server.cpp) -static std::map temperatures; +static int16_t temperatures[] = {0,0,0,0,0}; // // Logging @@ -190,10 +189,10 @@ const void *dataGetter(const char *pName) } std::string strName = pName; - auto it = temperatures.find(strName); - if (it != temperatures.end()) return &(*it); + LogInfo((std::string("reading: ")+strName).c_str()); - return nullptr; + char idx = strName.back(); + return &(temperatures[idx-'0']); } // Called by the server when it wants to update a named value @@ -218,7 +217,9 @@ int dataSetter(const char *pName, const void *pData) std::string strName = pName; int16_t temp = *static_cast(pData); - temperatures[strName]=temp; + char idx = strName.back(); + temperatures[idx-'0']=temp; + LogDebug((std::string("Server data: temperature of ")+strName+" set to " + std::to_string(temp)).c_str()); return 1; } -- cgit v1.2.3