diff options
author | dakkar <dakkar@thenautilus.net> | 2018-03-31 00:02:48 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2018-03-31 00:02:48 +0100 |
commit | 3ded39fe0062799b1781575641a3f5446e446d1c (patch) | |
tree | 8353a678b68717d61199efeb6a75206dd0319a17 /src | |
parent | boh (diff) | |
download | gobbledegook-3ded39fe0062799b1781575641a3f5446e446d1c.tar.gz gobbledegook-3ded39fe0062799b1781575641a3f5446e446d1c.tar.bz2 gobbledegook-3ded39fe0062799b1781575641a3f5446e446d1c.zip |
strings everywhere
Diffstat (limited to 'src')
-rw-r--r-- | src/Server.cpp | 10 | ||||
-rw-r--r-- | src/standalone.cpp | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/Server.cpp b/src/Server.cpp index 4651ccf..f3464c6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -299,15 +299,15 @@ Server::Server(const std::string &serviceName, const std::string &advertisingNam // Standard characteristic "ReadValue" method call .onReadValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { - int16_t temperature = self.getDataValue<int16_t>("room-1", 0); + const char *temperature = self.getDataPointer<const char*>("room-1", ""); self.methodReturnValue(pInvocation, temperature, true); }) // Standard characteristic "WriteValue" method call .onWriteValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { - GVariant *pValue = g_variant_get_child_value(pParameters, 0); - self.setDataValue("room-1", g_variant_get_int16(pValue)); + GVariant *pValue = g_variant_get_child_value(pParameters, 0); + self.setDataPointer("room-1", Utils::stringFromGVariantByteArray(pValue).c_str()); }) // GATT Descriptor: Characteristic User Description (0x2901) @@ -332,7 +332,7 @@ Server::Server(const std::string &serviceName, const std::string &advertisingNam // Standard characteristic "ReadValue" method call .onReadValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { - int16_t temperature = self.getDataValue<int16_t>("room-2", 0); + const char *temperature = self.getDataPointer<const char*>("room-2", ""); self.methodReturnValue(pInvocation, temperature, true); }) @@ -340,7 +340,7 @@ Server::Server(const std::string &serviceName, const std::string &advertisingNam .onWriteValue(CHARACTERISTIC_METHOD_CALLBACK_LAMBDA { GVariant *pValue = g_variant_get_child_value(pParameters, 0); - self.setDataValue("room-2", g_variant_get_int16(pValue)); + self.setDataPointer("room-2", Utils::stringFromGVariantByteArray(pValue).c_str()); }) // GATT Descriptor: Characteristic User Description (0x2901) diff --git a/src/standalone.cpp b/src/standalone.cpp index 46047f1..9b32043 100644 --- a/src/standalone.cpp +++ b/src/standalone.cpp @@ -106,7 +106,7 @@ #include <iostream> #include <thread> #include <sstream> -#include <map> +#include <vector> #include "../include/Gobbledegook.h" @@ -121,7 +121,7 @@ static const int kMaxAsyncInitTimeoutMS = 30 * 1000; // Server data values // -static int16_t temperatures[] = {0,0,0,0,0}; +static std::vector<std::string> temperatures(5); // // Logging @@ -192,7 +192,7 @@ const void *dataGetter(const char *pName) LogInfo((std::string("reading: ")+strName).c_str()); char idx = strName.back(); - return &(temperatures[idx-'0']); + return temperatures[idx-'0'].c_str(); } // Called by the server when it wants to update a named value @@ -216,11 +216,11 @@ int dataSetter(const char *pName, const void *pData) std::string strName = pName; - int16_t temp = *static_cast<const int16_t *>(pData); + const char* temp = static_cast<const char *>(pData); char idx = strName.back(); temperatures[idx-'0']=temp; - LogDebug((std::string("Server data: temperature of ")+strName+" set to " + std::to_string(temp)).c_str()); + LogDebug((std::string("Server data: temperature of ")+strName+" set to " + temp).c_str()); return 1; } |