aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-03-31 00:02:48 +0100
committerdakkar <dakkar@thenautilus.net>2019-03-20 12:44:52 +0000
commit939fd8f37fdab0941ae8eb3125bab572a97a0b26 (patch)
tree2572c376a3145b06a1edcbbc5d54d834aff32c13
parentboh (diff)
downloadgobbledegook-939fd8f37fdab0941ae8eb3125bab572a97a0b26.tar.gz
gobbledegook-939fd8f37fdab0941ae8eb3125bab572a97a0b26.tar.bz2
gobbledegook-939fd8f37fdab0941ae8eb3125bab572a97a0b26.zip
strings everywhere
-rw-r--r--src/Server.cpp10
-rw-r--r--src/standalone.cpp10
2 files changed, 10 insertions, 10 deletions
diff --git a/src/Server.cpp b/src/Server.cpp
index 0917523..7e7e0f8 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -300,15 +300,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)
@@ -333,7 +333,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);
})
@@ -341,7 +341,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 57177cd..b86e64e 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;
}