From 8e8f9e77922558b5090b2e3f722ca70f3852c5cc Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 22:22:36 +0100 Subject: [PATCH 1/7] remove certificate for encryption --- user/event_sensors/main.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/user/event_sensors/main.cpp b/user/event_sensors/main.cpp index f490697..201442e 100644 --- a/user/event_sensors/main.cpp +++ b/user/event_sensors/main.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include @@ -145,7 +143,7 @@ std::optional getTrustStore(const std::string &certPath) int main(int argc, char *argv[]) { - static const std::string SERVER_URI = "ssl://193.170.192.224:8883"; + static const std::string SERVER_URI = "193.170.192.224:1883"; static const std::string CLIENT_ID = "event_sensors"; static const int DEFAULT_THRESHOLD = 12000; @@ -193,18 +191,7 @@ int main(int argc, char *argv[]) { // Setup MQTT client // mqtt::client client(SERVER_URI, CLIENT_ID); - mqtt::ssl_options sslOptions; - auto trustStoreOpt = getTrustStore("ca.crt"); - if (!trustStoreOpt.has_value()) { - return -1; - } - sslOptions.set_trust_store(trustStoreOpt.value()); - - mqtt::connect_options options; - options.set_ssl(sslOptions); - - client.connect(options); - + client.connect(); // // Setup sensors From d6b588b315ef8b6f90e0350e0daa30ee2fd8d732 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 22:26:02 +0100 Subject: [PATCH 2/7] format on save --- user/event_sensors/main.cpp | 62 +++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/user/event_sensors/main.cpp b/user/event_sensors/main.cpp index 201442e..1a9ecf2 100644 --- a/user/event_sensors/main.cpp +++ b/user/event_sensors/main.cpp @@ -21,7 +21,6 @@ using namespace std::literals::chrono_literals; - void compressMemory(void *in_data, size_t in_data_size, std::vector &out_data) { std::vector buffer; @@ -81,17 +80,20 @@ void publishData(const std::vector &data, const std::string &topic, mqtt:: // how many burst packets need to be sent? int bursts = std::ceil(1.0 * data.size() / MAX_PACKETS_PER_BURST); - for (int b = 0; b < bursts; b++) { + for (int b = 0; b < bursts; b++) + { // the size of the current burst packet - int size = std::min(MAX_PACKETS_PER_BURST, (int) data.size() - b * MAX_PACKETS_PER_BURST); + int size = std::min(MAX_PACKETS_PER_BURST, (int)data.size() - b * MAX_PACKETS_PER_BURST); msg.str(""); msg << "["; bool first = true; - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { auto &v = data[b * MAX_PACKETS_PER_BURST + i]; - if (!first) { + if (!first) + { msg << ","; } first = false; @@ -108,8 +110,9 @@ void publishData(const std::vector &data, const std::string &topic, mqtt:: } } -template -void publishSensorData(SENSOR &sensor, mqtt::client &client) { +template +void publishSensorData(SENSOR &sensor, mqtt::client &client) +{ auto pollingData = sensor.getQueue(); auto eventData = sensor.getEventQueue(); @@ -127,12 +130,14 @@ std::optional getTrustStore(const std::string &certPath) static const std::string FALLBACK_CERT = "/etc/SmartSystemsLab/ca.crt"; std::ifstream f(certPath); - if (f) { + if (f) + { return certPath; } f.open(FALLBACK_CERT); - if (f) { + if (f) + { std::cout << "Using fallback certificate" << std::endl; return FALLBACK_CERT; } @@ -141,10 +146,10 @@ std::optional getTrustStore(const std::string &certPath) return std::nullopt; } - -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ static const std::string SERVER_URI = "193.170.192.224:1883"; - static const std::string CLIENT_ID = "event_sensors"; + static const std::string CLIENT_ID = "event_sensors"; static const int DEFAULT_THRESHOLD = 12000; // @@ -152,33 +157,42 @@ int main(int argc, char *argv[]) { // int threshold = DEFAULT_THRESHOLD; - if (argc > 2) { + if (argc > 2) + { std::cerr << "Usage: " << argv[0] << " []" << std::endl; return -1; - } else if (argc == 2) { - try { + } + else if (argc == 2) + { + try + { size_t idx = 0; threshold = std::stoi(argv[1], &idx); - if (idx < strlen(argv[1])) { + if (idx < strlen(argv[1])) + { throw std::invalid_argument(argv[1]); } - } catch (const std::invalid_argument &ex) { + } + catch (const std::invalid_argument &ex) + { std::cerr << "Argument '" << argv[1] << "' cannot be parsed as an integer" << std::endl; return -1; } } - // // Check operation mode // #ifndef NO_SENSORS std::cout << "Operation mode: actual sensors" << std::endl; - try { + try + { initFPGA("event_sensors"); - } catch (const std::string &s) { + } + catch (const std::string &s) + { std::cerr << "Failed to initialize FPGA: " << s << std::endl; return -1; } @@ -186,7 +200,6 @@ int main(int argc, char *argv[]) { std::cout << "Operation mode: dummy data" << std::endl; #endif - // // Setup MQTT client // @@ -206,12 +219,12 @@ int main(int argc, char *argv[]) { sensorThreads.emplace_back(std::bind(&MPU9250::startPolling, &mpu9250)); sensorThreads.emplace_back(std::bind(&APDS9301::startPolling, &apds9301)); - // // Every second publish all available sensor data at once // auto iterationEnd = std::chrono::high_resolution_clock::now(); - while (true) { + while (true) + { iterationEnd += std::chrono::milliseconds(1000); // std::cout << "HDC1000: "; @@ -231,7 +244,8 @@ int main(int argc, char *argv[]) { mpu9250.stop(); apds9301.stop(); - for (auto &&t: sensorThreads) { + for (auto &&t : sensorThreads) + { t.join(); } return 0; From 9405c7aa45de993d4979ca97a57f3fd765a4f083 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 22:26:31 +0100 Subject: [PATCH 3/7] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0f214e3..ee741e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ drivers/**/.tmp_versions/ user/**/*.o user/show_ip/show_ip +user/event_sensors/event_sensors user/streaming_sensors/streaming_sensors # ModelSim temporary files From 5c474953a40a73f48e0d9a6e6aafe2e9326a1e2a Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 23:09:27 +0100 Subject: [PATCH 4/7] add get_ip module --- user/event_sensors/get_ip.cpp | 169 ++++++++++++++++++++++++++++++++++ user/event_sensors/get_ip.h | 6 ++ 2 files changed, 175 insertions(+) create mode 100644 user/event_sensors/get_ip.cpp create mode 100644 user/event_sensors/get_ip.h diff --git a/user/event_sensors/get_ip.cpp b/user/event_sensors/get_ip.cpp new file mode 100644 index 0000000..5c485ad --- /dev/null +++ b/user/event_sensors/get_ip.cpp @@ -0,0 +1,169 @@ +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +using namespace std::literals::chrono_literals; + +static const std::string CHARACTER_DEVICE = "/dev/sevensegment"; +static const int SEGMENT_COUNT = 6; + +struct IPv4Address +{ + uint8_t segments[4]; +}; + +int writeToCDev(char chars[], uint8_t brightness) +{ + + // prepare input values + uint8_t values[SEGMENT_COUNT]; + uint8_t combinedEnabled = 0; + + for (int i = 0; i < SEGMENT_COUNT; ++i) + { + bool isValidChar = (chars[i] >= '0' && chars[i] <= '9'); + combinedEnabled |= (((int)isValidChar) & 1) << (SEGMENT_COUNT - i - 1); + + if (isValidChar) + { + values[i] = chars[i]; + } + else + { + values[i] = '0'; + } + + // Convert to binary for driver + values[i] -= '0'; + } + + // open character device + auto fd = fopen(CHARACTER_DEVICE.c_str(), "wb"); + if (!fd) + { + std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; + return -1; + } + + // write display values + for (int i = 0; i < SEGMENT_COUNT; ++i) + { + if (fputc(values[i], fd) == EOF) + { + std::cerr << "Failed to write character (index " << i << ")" << std::endl; + return -1; + } + } + + // write brightness level + if (fputc(brightness, fd) == EOF) + { + std::cerr << "Failed to write brightness level" << std::endl; + return -1; + } + + // write enable bits + if (fputc(combinedEnabled, fd) == EOF) + { + std::cerr << "Failed to write enable bits" << std::endl; + return -1; + } + + (void)fclose(fd); + + return 0; +} + +uint8_t getBrightness() +{ + uint8_t data[SEGMENT_COUNT + 2] = {0}; // +2 for brightness and enable byte + + // open character device + auto fd = fopen(CHARACTER_DEVICE.c_str(), "rb"); + if (!fd) + { + std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; + return -1; + } + + memcpy(data, fd, sizeof(data)); + + (void)fclose(fd); + + // Return the byte that represents the brightness value. + // (see driver file 'sevensegment.c') + return data[SEGMENT_COUNT]; +} + +IPv4Address getIP() +{ + // drop 127.0.0.1 + static const uint32_t LOCAL_IP = 16777343; + IPv4Address result; + + struct ifaddrs *ifAddrStruct = NULL; + getifaddrs(&ifAddrStruct); + + for (auto ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) + { + if (!ifa->ifa_addr) + { + continue; + } + + if (ifa->ifa_addr->sa_family == AF_INET) + { + auto ip = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr; + if (ip == LOCAL_IP) + { + continue; + } + + // use the first non-local IP + for (int i = 0; i < 4; ++i) + { + result.segments[i] = static_cast((ip >> (i * 8)) & 0xff); + } + break; + } + } + + if (ifAddrStruct) + { + freeifaddrs(ifAddrStruct); + } + + return result; +} + +void show_ip() +{ + + auto ip = getIP(); + + while (1) + { + for (int i = 0; i < 4; ++i) + { + char chars[7] = {0}; + auto s = ip.segments[i]; + + snprintf(chars, 6, "%d", s); + + uint8_t brightness = getBrightness(); + + (void)writeToCDev(chars, brightness); + + std::this_thread::sleep_for(1000ms); + } + } +} diff --git a/user/event_sensors/get_ip.h b/user/event_sensors/get_ip.h new file mode 100644 index 0000000..fe6b208 --- /dev/null +++ b/user/event_sensors/get_ip.h @@ -0,0 +1,6 @@ +#ifndef GET_IP_H +#define GET_IP_H + +void show_ip(); + +#endif // GET_IP_H From f213d190408d464e48ab34cabb8a874dd64d2e84 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 23:15:27 +0100 Subject: [PATCH 5/7] call it --- user/event_sensors/get_ip.cpp | 5 +++-- user/event_sensors/main.cpp | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/user/event_sensors/get_ip.cpp b/user/event_sensors/get_ip.cpp index 5c485ad..650518e 100644 --- a/user/event_sensors/get_ip.cpp +++ b/user/event_sensors/get_ip.cpp @@ -4,12 +4,12 @@ #include #include +#include #include #include #include #include -#include using namespace std::literals::chrono_literals; @@ -160,10 +160,11 @@ void show_ip() snprintf(chars, 6, "%d", s); uint8_t brightness = getBrightness(); + std::cout << "Brightness: " << brightness << std::endl; (void)writeToCDev(chars, brightness); - std::this_thread::sleep_for(1000ms); + std::this_thread::sleep_for(500ms); } } } diff --git a/user/event_sensors/main.cpp b/user/event_sensors/main.cpp index 1a9ecf2..da412d2 100644 --- a/user/event_sensors/main.cpp +++ b/user/event_sensors/main.cpp @@ -18,6 +18,7 @@ #include "hdc1000.h" #include "mpu9250.h" #include "sensors.h" +#include "get_ip.h" using namespace std::literals::chrono_literals; @@ -218,6 +219,7 @@ int main(int argc, char *argv[]) sensorThreads.emplace_back(std::bind(&HDC1000::startPolling, &hdc1000)); sensorThreads.emplace_back(std::bind(&MPU9250::startPolling, &mpu9250)); sensorThreads.emplace_back(std::bind(&APDS9301::startPolling, &apds9301)); + sensorThreads.emplace_back(std::thread(show_ip)); // // Every second publish all available sensor data at once From 31924413c2c96b1603deabc43afd557d64bb49b1 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 00:34:29 +0100 Subject: [PATCH 6/7] always display IP address --- user/event_sensors/apds9301.cpp | 66 +++++++++++------ user/event_sensors/apds9301.h | 3 + user/event_sensors/get_ip.cpp | 123 ++++++-------------------------- user/event_sensors/get_ip.h | 11 ++- user/event_sensors/main.cpp | 2 +- 5 files changed, 79 insertions(+), 126 deletions(-) diff --git a/user/event_sensors/apds9301.cpp b/user/event_sensors/apds9301.cpp index e9d6f81..8430933 100644 --- a/user/event_sensors/apds9301.cpp +++ b/user/event_sensors/apds9301.cpp @@ -6,21 +6,23 @@ #include "fpga.h" #include "tsu.h" +#include "get_ip.h" -struct APDS9301POD { +struct APDS9301POD +{ uint32_t timestamp_lo; uint32_t timestamp_hi; uint16_t value; } __attribute__((packed)); - -std::string APDS9301::getTopic() const { +std::string APDS9301::getTopic() const +{ static const std::string TOPIC_NAME = "compressed/sensors/apds9301"; return TOPIC_NAME; } - -void APDS9301::doProcess(APDS9301Data const &data) { +void APDS9301::doProcess(APDS9301Data const &data) +{ #ifdef NO_SENSORS // nothing to process here return; @@ -30,24 +32,39 @@ void APDS9301::doProcess(APDS9301Data const &data) { // dimm 7-segment display according to the latest light intensity // - static const int SEGMENT_COUNT = 6; + static const int SEGMENT_COUNT = 6; static const std::string CHARACTER_DEVICE = "/dev/sevensegment"; - uint8_t brightness = data.value >> 8; - uint8_t values[SEGMENT_COUNT] = {0}; + float scale = (float)data.value / UINT16_MAX; + uint8_t brightness = (uint8_t)(scale * UINT8_MAX); + if (brightness < 3) + brightness = 3; + + getIPdata_t getIPdata = {0}; + if (mIP_octet < 3) + mIP_octet++; + else + mIP_octet = 0; + memcpy(&getIPdata, get_ip(mIP_octet), sizeof(getIPdata_t)); auto _lck = lockFPGA(); // open character device auto fd = fopen(CHARACTER_DEVICE.c_str(), "wb"); - if (!fd) { + if (!fd) + { std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; return; } // write display values - for (int i = 0; i < SEGMENT_COUNT; ++i) { - if (fputc(values[i], fd) == EOF) { + for (int i = 0; i < SEGMENT_COUNT; ++i) + { + // Convert to binary for driver + getIPdata.hex_values[i] -= '0'; + + if (fputc(getIPdata.hex_values[i], fd) == EOF) + { std::cerr << "Failed to write character (index " << i << ")" << std::endl; fclose(fd); return; @@ -55,23 +72,26 @@ void APDS9301::doProcess(APDS9301Data const &data) { } // write brightness level - if (fputc(brightness, fd) == EOF) { + if (fputc(brightness, fd) == EOF) + { std::cerr << "Failed to write brightness level" << std::endl; fclose(fd); return; } // write enable bits - if (fputc(0xff, fd) == EOF) { + if (fputc(getIPdata.hex_enable, fd) == EOF) + { std::cerr << "Failed to write enable bits" << std::endl; fclose(fd); return; } - (void) fclose(fd); + (void)fclose(fd); } -std::optional APDS9301::doPoll() { +std::optional APDS9301::doPoll() +{ #ifdef NO_SENSORS static int c = 0; @@ -86,37 +106,39 @@ std::optional APDS9301::doPoll() { static const std::string CHARACTER_DEVICE = "/dev/apds9301"; static const int READ_SIZE = sizeof(APDS9301POD); - APDS9301Data results {}; + APDS9301Data results{}; APDS9301POD pod = {}; - // lock fpga device using a lock guard // the result is never used, but it keeps the mutex locked until it goes out of scope auto _lck = lockFPGA(); // open character device auto fd = fopen(CHARACTER_DEVICE.c_str(), "rb"); - if (!fd) { + if (!fd) + { std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; return {}; } - if (fread(&pod, READ_SIZE, 1, fd) != 1) { + if (fread(&pod, READ_SIZE, 1, fd) != 1) + { std::cerr << "Failed to read sensor values" << std::endl; return {}; } - auto timestamp = (((uint64_t) pod.timestamp_hi) << 32) | pod.timestamp_lo; + auto timestamp = (((uint64_t)pod.timestamp_hi) << 32) | pod.timestamp_lo; results.timeStamp = TimeStampingUnit::getResolvedTimeStamp(timestamp); results.value = pod.value; // close character device - (void) fclose(fd); + (void)fclose(fd); return std::make_optional(results); } -std::string APDS9301Data::toJsonString() const { +std::string APDS9301Data::toJsonString() const +{ std::stringstream ss; ss << "{"; ss << "\"ambient_light\":" << value << ","; diff --git a/user/event_sensors/apds9301.h b/user/event_sensors/apds9301.h index dbfac44..7498369 100644 --- a/user/event_sensors/apds9301.h +++ b/user/event_sensors/apds9301.h @@ -20,6 +20,9 @@ class APDS9301 : public StreamingSensor { protected: std::optional doPoll() override; void doProcess(APDS9301Data const &data) override; + +private: + int mIP_octet; }; #endif // APDS9301_H diff --git a/user/event_sensors/get_ip.cpp b/user/event_sensors/get_ip.cpp index 650518e..48c1a00 100644 --- a/user/event_sensors/get_ip.cpp +++ b/user/event_sensors/get_ip.cpp @@ -11,100 +11,16 @@ #include #include -using namespace std::literals::chrono_literals; +#include "get_ip.h" -static const std::string CHARACTER_DEVICE = "/dev/sevensegment"; -static const int SEGMENT_COUNT = 6; +using namespace std::literals::chrono_literals; struct IPv4Address { uint8_t segments[4]; }; -int writeToCDev(char chars[], uint8_t brightness) -{ - - // prepare input values - uint8_t values[SEGMENT_COUNT]; - uint8_t combinedEnabled = 0; - - for (int i = 0; i < SEGMENT_COUNT; ++i) - { - bool isValidChar = (chars[i] >= '0' && chars[i] <= '9'); - combinedEnabled |= (((int)isValidChar) & 1) << (SEGMENT_COUNT - i - 1); - - if (isValidChar) - { - values[i] = chars[i]; - } - else - { - values[i] = '0'; - } - - // Convert to binary for driver - values[i] -= '0'; - } - - // open character device - auto fd = fopen(CHARACTER_DEVICE.c_str(), "wb"); - if (!fd) - { - std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; - return -1; - } - - // write display values - for (int i = 0; i < SEGMENT_COUNT; ++i) - { - if (fputc(values[i], fd) == EOF) - { - std::cerr << "Failed to write character (index " << i << ")" << std::endl; - return -1; - } - } - - // write brightness level - if (fputc(brightness, fd) == EOF) - { - std::cerr << "Failed to write brightness level" << std::endl; - return -1; - } - - // write enable bits - if (fputc(combinedEnabled, fd) == EOF) - { - std::cerr << "Failed to write enable bits" << std::endl; - return -1; - } - - (void)fclose(fd); - - return 0; -} - -uint8_t getBrightness() -{ - uint8_t data[SEGMENT_COUNT + 2] = {0}; // +2 for brightness and enable byte - - // open character device - auto fd = fopen(CHARACTER_DEVICE.c_str(), "rb"); - if (!fd) - { - std::cerr << "Failed to open character device '" << CHARACTER_DEVICE << "'" << std::endl; - return -1; - } - - memcpy(data, fd, sizeof(data)); - - (void)fclose(fd); - - // Return the byte that represents the brightness value. - // (see driver file 'sevensegment.c') - return data[SEGMENT_COUNT]; -} - -IPv4Address getIP() +IPv4Address getIPfromSystem() { // drop 127.0.0.1 static const uint32_t LOCAL_IP = 16777343; @@ -145,26 +61,29 @@ IPv4Address getIP() return result; } -void show_ip() +getIPdata_t *get_ip(int hex_index) { + auto ip = getIPfromSystem(); - auto ip = getIP(); + char chars[7] = {0}; + auto s = ip.segments[hex_index]; + snprintf(chars, 6, "%d", s); - while (1) - { - for (int i = 0; i < 4; ++i) - { - char chars[7] = {0}; - auto s = ip.segments[i]; + static getIPdata_t data = {0}; - snprintf(chars, 6, "%d", s); - - uint8_t brightness = getBrightness(); - std::cout << "Brightness: " << brightness << std::endl; - - (void)writeToCDev(chars, brightness); + for (int i = 0; i < SEGMENT_COUNT; ++i) + { + bool isValidChar = (chars[i] >= '0' && chars[i] <= '9'); + data.hex_enable |= (((int)isValidChar) & 1) << (SEGMENT_COUNT - i - 1); - std::this_thread::sleep_for(500ms); + if (isValidChar) + { + data.hex_values[i] = chars[i]; + } + else + { + data.hex_values[i] = '0'; } } + return &data; } diff --git a/user/event_sensors/get_ip.h b/user/event_sensors/get_ip.h index fe6b208..6f8937d 100644 --- a/user/event_sensors/get_ip.h +++ b/user/event_sensors/get_ip.h @@ -1,6 +1,15 @@ #ifndef GET_IP_H #define GET_IP_H -void show_ip(); +static const std::string CHARACTER_DEVICE = "/dev/sevensegment"; +static const int SEGMENT_COUNT = 6; + +struct getIPdata_t +{ + uint8_t hex_values[SEGMENT_COUNT]; + uint8_t hex_enable; +}; + +getIPdata_t *get_ip(int hex_index); #endif // GET_IP_H diff --git a/user/event_sensors/main.cpp b/user/event_sensors/main.cpp index da412d2..69d639e 100644 --- a/user/event_sensors/main.cpp +++ b/user/event_sensors/main.cpp @@ -22,6 +22,7 @@ using namespace std::literals::chrono_literals; + void compressMemory(void *in_data, size_t in_data_size, std::vector &out_data) { std::vector buffer; @@ -219,7 +220,6 @@ int main(int argc, char *argv[]) sensorThreads.emplace_back(std::bind(&HDC1000::startPolling, &hdc1000)); sensorThreads.emplace_back(std::bind(&MPU9250::startPolling, &mpu9250)); sensorThreads.emplace_back(std::bind(&APDS9301::startPolling, &apds9301)); - sensorThreads.emplace_back(std::thread(show_ip)); // // Every second publish all available sensor data at once From f6380089b87b017f6d34f5b9f809deaa7250987c Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 01:02:39 +0100 Subject: [PATCH 7/7] initialize mIP_octet; format --- user/event_sensors/apds9301.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/user/event_sensors/apds9301.h b/user/event_sensors/apds9301.h index 7498369..ea2e2e3 100644 --- a/user/event_sensors/apds9301.h +++ b/user/event_sensors/apds9301.h @@ -3,15 +3,16 @@ #include "sensors.h" - -struct APDS9301Data : public Serializable { +struct APDS9301Data : public Serializable +{ std::string toJsonString() const override; uint64_t timeStamp; uint16_t value; }; -class APDS9301 : public StreamingSensor { +class APDS9301 : public StreamingSensor +{ public: using StreamingSensor::StreamingSensor; @@ -22,7 +23,7 @@ class APDS9301 : public StreamingSensor { void doProcess(APDS9301Data const &data) override; private: - int mIP_octet; + int mIP_octet = 0; }; -#endif // APDS9301_H +#endif // APDS9301_H