diff options
author | dakkar <dakkar@thenautilus.net> | 2018-03-30 23:06:47 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-03-20 12:44:52 +0000 |
commit | 15b4121137d9c78869d69196b84cea0a0e213bf3 (patch) | |
tree | a7cba4958cefb956ece36bb6ae937b42b894dcf8 /src | |
parent | maybe it compiles? (diff) | |
download | gobbledegook-15b4121137d9c78869d69196b84cea0a0e213bf3.tar.gz gobbledegook-15b4121137d9c78869d69196b84cea0a0e213bf3.tar.bz2 gobbledegook-15b4121137d9c78869d69196b84cea0a0e213bf3.zip |
boh
Diffstat (limited to 'src')
-rw-r--r-- | src/Server.cpp | 10 | ||||
-rw-r--r-- | src/standalone.cpp | 13 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/Server.cpp b/src/Server.cpp index bc3433e..0917523 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -292,15 +292,15 @@ Server::Server(const std::string &serviceName, const std::string &advertisingNam .gattServiceEnd() // Thermo store service - .gattServiceBegin("thermo", "00000001") + .gattServiceBegin("thermo", "11111111-2222-3333-4444-000000000000") // Characteristic: String value - .gattCharacteristicBegin("room1", "00000001-1", {"read", "write"}) + .gattCharacteristicBegin("room1", "11111111-2222-3333-4444-000000000001", {"read", "write"}) // Standard characteristic "ReadValue" method call .onReadValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { - int8_t temperature = self.getDataValue<int8_t>("room-1", 0); + int16_t temperature = self.getDataValue<int16_t>("room-1", 0); self.methodReturnValue(pInvocation, temperature, true); }) @@ -328,12 +328,12 @@ Server::Server(const std::string &serviceName, const std::string &advertisingNam .gattCharacteristicEnd() // Characteristic: String value - .gattCharacteristicBegin("room2", "00000001-2", {"read", "write"}) + .gattCharacteristicBegin("room2", "11111111-2222-3333-4444-000000000002", {"read", "write"}) // Standard characteristic "ReadValue" method call .onReadValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { - int8_t temperature = self.getDataValue<int8_t>("room-2", 0); + int16_t temperature = self.getDataValue<int16_t>("room-2", 0); self.methodReturnValue(pInvocation, temperature, true); }) diff --git a/src/standalone.cpp b/src/standalone.cpp index 16225f0..57177cd 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<std::string,int> 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<const int16_t *>(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; } |