diff --git a/client/client/include/ForteSensor.hpp b/client/client/include/ForteSensor.hpp index d322213ea9c89554540b75ea158ddb99e4886e2f..1db845dc1f2f7f063328367f1dc5391502a6cc67 100644 --- a/client/client/include/ForteSensor.hpp +++ b/client/client/include/ForteSensor.hpp @@ -2,12 +2,14 @@ #define _FORTE_SENSOR #include "Message.hpp" +#include "Protocol.hpp" template <class T> class Forte_Sensor { public: - virtual T read_data() = 0; + virtual T readData() = 0; virtual void setup() = 0; - virtual Message build_message() = 0; + virtual Message buildMessage() = 0; + virtual Protocol getProtocol() = 0; private: }; diff --git a/client/client/include/Protocol.hpp b/client/client/include/Protocol.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2bcdab907107c5be3bf9c48911d495e5e897671b --- /dev/null +++ b/client/client/include/Protocol.hpp @@ -0,0 +1,14 @@ +// +// Created by zoe on 10/5/22. +// + +#ifndef CLIENT_PROTOCOL_HPP +#define CLIENT_PROTOCOL_HPP + +#include <map> +enum Protocol { I2C, RS485, Analog }; + +// protocol to string +static std::map<Protocol, const char *> protocolToString = {{I2C, "I2C"}, {RS485, "RS485"}, {Analog, "Analog"}}; + +#endif // CLIENT_PROTOCOL_HPP diff --git a/client/client/lib/caching/src/ram_caching.cpp b/client/client/lib/caching/src/ram_caching.cpp index f5ebd717149218834742eb644e479c4554b30b3d..b7df125c9f9885d5040b4a2c6cf38d14bdb69594 100644 --- a/client/client/lib/caching/src/ram_caching.cpp +++ b/client/client/lib/caching/src/ram_caching.cpp @@ -1,27 +1,28 @@ #include "ram_caching.hpp" static const char* TAG = "CACHING"; +const int NUM_SENSORS = 10; -RTC_DATA_ATTR int cachedAmount = -1; -RTC_DATA_ATTR ClientDataPackage backup[NUM_SENSORS]; - -ClientDataPackage ram_cache_pop() -{ - return backup[cachedAmount--]; -} - -void ram_cache_push(ClientDataPackage data) -{ - backup[++cachedAmount] = data; - ESP_LOGI(TAG, "ClientDataPackage saved"); -} - -bool ram_cache_is_empty() -{ - return cachedAmount == -1; -} - -bool ram_cache_is_full() -{ - return cachedAmount == 9; -} \ No newline at end of file +//RTC_DATA_ATTR int cachedAmount = -1; +//RTC_DATA_ATTR ClientDataPackage backup[NUM_SENSORS]; +// +//ClientDataPackage ram_cache_pop() +//{ +// return backup[cachedAmount--]; +//} +// +//void ram_cache_push(ClientDataPackage data) +//{ +// backup[++cachedAmount] = data; +// ESP_LOGI(TAG, "ClientDataPackage saved"); +//} +// +//bool ram_cache_is_empty() +//{ +// return cachedAmount == -1; +//} +// +//bool ram_cache_is_full() +//{ +// return cachedAmount == 9; +//} \ No newline at end of file diff --git a/client/client/lib/caching/src/ram_caching.hpp b/client/client/lib/caching/src/ram_caching.hpp index 3ade9626a58bf94c7eb4b044eff615ce82677474..f4152ce799a7f746158ba80cc769ff879557f9ea 100644 --- a/client/client/lib/caching/src/ram_caching.hpp +++ b/client/client/lib/caching/src/ram_caching.hpp @@ -1,12 +1,12 @@ #ifndef _RAM_CACHE #define _RAM_CACHE -#include "ClientDataPackage.hpp" +//#include "ClientDataPackage.hpp" #include "esp_log.h" #include <ESP32Time.h> bool ram_cache_is_empty(); bool ram_cache_is_full(); -void ram_cache_push(ClientDataPackage data); -ClientDataPackage ram_cache_pop(); +//void ram_cache_push(ClientDataPackage data); +//ClientDataPackage ram_cache_pop(); #endif \ No newline at end of file diff --git a/client/client/lib/dr26_analogue/src/dr26.cpp b/client/client/lib/dr26_analogue/src/dr26.cpp index c2cec295747bbce97a4be6e09785d18e36bd1525..626203de393505940c9da07197afe660eb5e0664 100644 --- a/client/client/lib/dr26_analogue/src/dr26.cpp +++ b/client/client/lib/dr26_analogue/src/dr26.cpp @@ -17,7 +17,7 @@ void Forte_DR26 ::setup() delay(100); } -float Forte_DR26 ::read_data() +float Forte_DR26 ::readData() { float volts = 0; for (int i = 0; i < 10; i++) { @@ -44,12 +44,16 @@ float Forte_DR26 ::read_data() // GAIN_FOUR // 4x gain +/- 1.024V 1 bit = 0.03125mV // GAIN_EIGHT // 8x gain +/- 0.512V 1 bit = 0.015625mV // GAIN_SIXTEEN // 16x gain +/- 0.256V 1 bit = 0.0078125mV -void Forte_DR26 ::change_Gain(adsGain_t gain) +void Forte_DR26 ::changeGain(adsGain_t gain) { ads.setGain(gain); } -Message Forte_DR26::build_message() +Message Forte_DR26::buildMessage() { throw "Not implemented"; -} \ No newline at end of file +} +Protocol Forte_DR26::getProtocol() +{ + return Analog; +} diff --git a/client/client/lib/dr26_analogue/src/dr26.hpp b/client/client/lib/dr26_analogue/src/dr26.hpp index b06c420e530ab082e47074094629e8c87cf84cd6..9c9efa5132d20a2691eb48ada26d12fa5646249d 100644 --- a/client/client/lib/dr26_analogue/src/dr26.hpp +++ b/client/client/lib/dr26_analogue/src/dr26.hpp @@ -11,9 +11,10 @@ class Forte_DR26 : public Forte_Sensor<float> { public: void setup() override; - float read_data() override; - void change_Gain(adsGain_t gain); - Message build_message() override; + float readData() override; + void changeGain(adsGain_t gain); + Message buildMessage() override; + Protocol getProtocol() override; private: }; diff --git a/client/client/lib/drs26_digital/drs26.cpp b/client/client/lib/drs26_digital/drs26.cpp index f6f97caa2c147ec1c3493b610107e76a019395ee..9e7723012adecd699c583eb6f232c6459c6b20b8 100644 --- a/client/client/lib/drs26_digital/drs26.cpp +++ b/client/client/lib/drs26_digital/drs26.cpp @@ -1,6 +1,6 @@ #include <drs26.hpp> -static const char* TAG = "DRS26"; +static const std::string TAG = "DRS26"; /* It happens for some reason that the sensor cant get reached every 2 time Because the sensor use sdi12 protocoll we have to wait aproxemettly 1 secound between the commands @@ -12,7 +12,7 @@ void Forte_DRS26 ::setup() drs26.begin(4); } -out_data_drs26 Forte_DRS26 ::read_data() +out_data_drs26 Forte_DRS26 ::readData() { String sdiResponse = ""; String measurement_command = @@ -36,16 +36,20 @@ out_data_drs26 Forte_DRS26 ::read_data() if (sdiResponse.length() > 1) { data.id = sdiResponse.substring(0, 8).toInt(); - data.circumference = sdiResponse.substring(9, 15).toFloat(); - data.temperatur = sdiResponse.substring(16, 22).toFloat(); + data.circumferenceIncrement = sdiResponse.substring(9, 15).toFloat(); + data.temperature = sdiResponse.substring(16, 22).toFloat(); } return data; } -Message Forte_DRS26 ::build_message() +Message Forte_DRS26 ::buildMessage() { - auto message = Message(); - message.add_data(12.12, 1); - ESP_LOGE(TAG, "test"); - return message; -} \ No newline at end of file + auto message = Message(); + message.addData(12.12, measurementTypeToString[MeasurementType::TEMPERATURE], TAG, 4); + ESP_LOGE(TAG.c_str(), "test"); + return message; +} +Protocol Forte_DRS26::getProtocol() +{ + return I2C; +} diff --git a/client/client/lib/drs26_digital/drs26.hpp b/client/client/lib/drs26_digital/drs26.hpp index 6a64da5870bd1b060ce13933826a5af6eb19a247..153371d1da8e3f0964968e052d95a0edfeaf2af9 100644 --- a/client/client/lib/drs26_digital/drs26.hpp +++ b/client/client/lib/drs26_digital/drs26.hpp @@ -7,22 +7,30 @@ #include "esp_log.h" #include "pinout.hpp" #include <SDI12.h> +#include <map> struct out_data_drs26 { int id; - float circumference; - float temperatur; + float circumferenceIncrement; + float temperature; }; class Forte_DRS26 : public Forte_Sensor<out_data_drs26> { public: void setup() override; - out_data_drs26 read_data() override; - Message build_message() override; + out_data_drs26 readData() override; + Message buildMessage() override; + Protocol getProtocol() override; private: SDI12 drs26; out_data_drs26 data; + enum class MeasurementType { TEMPERATURE, CIRCUMFERENCE_INCREMENT }; + + // enum to string + std::map<MeasurementType, const char *> measurementTypeToString = { + {MeasurementType::TEMPERATURE, "TEMPERATURE"}, + {MeasurementType::CIRCUMFERENCE_INCREMENT, "CIRCUMFERENCE_INCREMENT"}}; }; #endif \ No newline at end of file diff --git a/client/client/lib/espnow/README b/client/client/lib/espnow/README index 55f89c0b2141283b3dd2d94c882cdaccbe2064fe..bbf1db0c44bf4b375af8aefcd9f6649864d64677 100644 --- a/client/client/lib/espnow/README +++ b/client/client/lib/espnow/README @@ -1,7 +1,7 @@ # basic usage To send data using espnow, create a new Message object, -then use the add_data(value, identifier) method for every value +then use the addData(value, identifier) method for every value to fill the message. when every value is added, use the send() method to send the data to the host (fipy). If the esp client has never recieved a config diff --git a/client/client/lib/espnow/src/ClientDataPackage.hpp b/client/client/lib/espnow/src/ClientDataPackage.hpp index 52f2be6032a190e6346bef71457cb78c983b0038..727127ddca5151a2b9fc7c40cd61f31d328570e0 100644 --- a/client/client/lib/espnow/src/ClientDataPackage.hpp +++ b/client/client/lib/espnow/src/ClientDataPackage.hpp @@ -1,14 +1,46 @@ #pragma once -#define NUM_SENSORS 10 -// packing the struct without padding, makes reading it on the fipy easier -#pragma pack(1) +#include "ArduinoJson.h" +#include "Protocol.hpp" +#include <list> +#include <string> +#include <utility> + +struct MeasurementData { + double value; + int channel; + std::string measurementType; // TODO: consider using an enum +}; // having the data be a struct of basic types makes sending easier, // otherwise we would have to serialize the data before sending -struct ClientDataPackage { - int identifiers[NUM_SENSORS]; - float values[NUM_SENSORS]; - int amountData; +class ClientDataPackage { + private: + MeasurementData value; + std::string sensorName; + std::string protocol; long timestamp; // maybe make this array + + public: + ClientDataPackage(MeasurementData value, std::string sensorName, long timestamp, Protocol protocol) + : value(std::move(std::move(value))), sensorName(std::move(sensorName)), timestamp(timestamp), + protocol(protocolToString[protocol]) + { + } + + std::string getDataPackageAsMinifiedJsonString() + { + StaticJsonDocument<250> document; // 250 byte is the max send size of espnow + + document["sensorName"] = sensorName; + document["timestamp"] = timestamp; + document["protocol"] = protocol; + document["value"] = value.value; + document["channel"] = value.channel; + document["measurementType"] = value.measurementType; + + std::string jsonString; + serializeJson(document, jsonString); + return jsonString; + } }; diff --git a/client/client/lib/espnow/src/Message.cpp b/client/client/lib/espnow/src/Message.cpp index 447242cffb717bb8eabb5a10021e4a9f56d4d47c..4a23314919254b6280aa94bd9c1d0f7ca90569ea 100644 --- a/client/client/lib/espnow/src/Message.cpp +++ b/client/client/lib/espnow/src/Message.cpp @@ -2,51 +2,89 @@ static const char *TAG = "MESSAGE"; -void Message::add_data(float value, int identifier) +void Message::addData(float value, int identifier) { - if (data.amountData < NUM_SENSORS) { - data.values[data.amountData] = value; - data.identifiers[data.amountData] = identifier; - data.amountData++; - } + StaticJsonDocument<100> document; + document["value"] = value; + document["identifier"] = identifier; + data["values"].add(document); + ESP_LOGD(TAG, "Added data: %s", getMessageAsMinifiedJsonString().c_str()); +} + +void Message::addData(float value, const std::string &measurementType, const std::string &sensorName) +{ + StaticJsonDocument<100> document; + + document["sensorName"] = sensorName; + document["measurementType"] = measurementType; + data["values"].add(document); + + ESP_LOGD(TAG, "Added data: %s", getMessageAsMinifiedJsonString().c_str()); +} + +/** + * Add data to a message that originates from an analog sensor with multiple channels + * @param value Value of the measurement + * @param measurementType Type of the measurement + * @param sensorName Name of the sensor + * @param channel Connected analog channel + */ +void Message::addData(float value, const std::string &measurementType, const std::string &sensorName, int channel) +{ + StaticJsonDocument<100> document; + + document["sensorName"] = sensorName; + document["channel"] = channel; + document["measurementType"] = measurementType; + document["value"] = value; + data["values"].add(document); + + ESP_LOGD(TAG, "Added data: %s", getMessageAsMinifiedJsonString().c_str()); } esp_err_t Message::send() { ESP_LOGI(TAG, "Sending message"); esp_err_t success; - success = esp_now_send(recipient, (uint8_t *)&data, sizeof(data)); - // if(success != ESP_OK){ - // if(!ram_cache_is_full()){ - // ram_cache_push(*data); - // } - // } - for (int i = 0; i < data.amountData; i++) { - ESP_LOGD(TAG, "Sent data: %i", data.values[i]); + auto messageData = getMessageAsMinifiedJsonString(); + success = esp_now_send(recipient, (uint8_t *)&messageData, sizeof(data)); + if (success != ESP_OK) { + // TODO REWRITE FOR JSON +// if (!ram_cache_is_full()) { +// // ram_cache_push(messageData); +// } } + ESP_LOGD(TAG, "Sent data: %s", messageData.c_str()); - ESP_LOGD(TAG, "time sent: %l", data.timestamp); + std::string timestampString = data["timestamp"]; + ESP_LOGD(TAG, "time sent: %s", timestampString.c_str()); ESP_LOGD(TAG, "send status: %d", success); return success; } +StaticJsonDocument<256> Message::getData() +{ + return data; +} + Message ::Message() { // check for existing host mac address, use broadcast otherwise get_host_mac(recipient); - - data.amountData = 0; - data.timestamp = esptime::rtc.getMillis(); // I am assuming we are not sending data from Unix Epoch + data["values"] = JsonArray(); + addTimestamp(); } -Message ::Message(ClientDataPackage old_data) +std::string Message::getMessageAsMinifiedJsonString() { - data = old_data; - // memcpy(&data, &old_data, sizeof(data)); - get_host_mac(recipient); + std::string minimizedJson; + serializeJson(data, minimizedJson); + return minimizedJson; } -ClientDataPackage Message::getData() +void Message::addTimestamp() { - return data; + // TODO: if we are not time synced (i.e. didn't reach the host for current time, use another value like number of + // reboots of the ESP) + data["timestamp"] = esptime::rtc.getMillis(); } diff --git a/client/client/lib/espnow/src/Message.hpp b/client/client/lib/espnow/src/Message.hpp index 101f7549bc4e87019ddf000045665804c1057644..8a26ea7e341faf7ca1d3b7159663ac182db0eecf 100644 --- a/client/client/lib/espnow/src/Message.hpp +++ b/client/client/lib/espnow/src/Message.hpp @@ -5,6 +5,7 @@ #include "Time.hpp" #include "esp_log.h" #include <Arduino.h> +#include <ArduinoJson.h> #include <ESP32Time.h> #include <esp_now.h> @@ -12,13 +13,19 @@ // if more things are sent from the host the name might not be accurate anymore class Message { public: + void addData(float value, int identifier); + void addData(float value, const std::string &measurementType, const std::string &sensorName); + void addData(float value, const std::string &measurementType, const std::string &sensorName, int channel); + Message(); - explicit Message(ClientDataPackage old_data); - void add_data(float value, int identifier); + esp_err_t send(); - ClientDataPackage getData(); + StaticJsonDocument<256> getData(); + std::string getMessageAsMinifiedJsonString(); private: - ClientDataPackage data; - uint8_t recipient[6]; + StaticJsonDocument<256> data; + void addTimestamp(); + // ClientDataPackage data; + uint8_t recipient[6]{}; }; \ No newline at end of file diff --git a/client/client/lib/ina219/ina219.cpp b/client/client/lib/ina219/ina219.cpp index 7c9360c5400bce65e67c0cefe18acb2a65d7c80c..5d1ff385c716b9a0feed02a64d2244742b85eab1 100644 --- a/client/client/lib/ina219/ina219.cpp +++ b/client/client/lib/ina219/ina219.cpp @@ -12,7 +12,7 @@ void Forte_INA219 ::setup() } } -out_data_ina219 Forte_INA219 ::read_data() +out_data_ina219 Forte_INA219 ::readData() { if (!ina219.getOverflow()) { data.shuntVoltage_mV = ina219.getShuntVoltage_mV(); @@ -27,7 +27,11 @@ out_data_ina219 Forte_INA219 ::read_data() return data; } -Message Forte_INA219::build_message() +Message Forte_INA219::buildMessage() { throw "Not yet implemented"; -} \ No newline at end of file +} +Protocol Forte_INA219::getProtocol() +{ + return I2C; +} diff --git a/client/client/lib/ina219/ina219.hpp b/client/client/lib/ina219/ina219.hpp index 64e8728e31e43e25dd6a4d8da5a9376b5fb379a8..cfcb01df0737516f53a8cb4bce16be80f1fb2986 100644 --- a/client/client/lib/ina219/ina219.hpp +++ b/client/client/lib/ina219/ina219.hpp @@ -20,8 +20,9 @@ struct out_data_ina219 { class Forte_INA219 : public Forte_Sensor<out_data_ina219> { public: void setup() override; - out_data_ina219 read_data() override; - Message build_message() override; + out_data_ina219 readData() override; + Message buildMessage() override; + Protocol getProtocol() override; private: INA219_WE ina219; diff --git a/client/client/lib/scd30/scd30.cpp b/client/client/lib/scd30/scd30.cpp index 0ad4f2c440daf10c8368bb62db037dc41aba6085..eb7e743d7c3d6323ab395f32b12a4abbba247023 100644 --- a/client/client/lib/scd30/scd30.cpp +++ b/client/client/lib/scd30/scd30.cpp @@ -12,7 +12,7 @@ void Forte_SCD30 ::setup() } } -out_data_scd30 Forte_SCD30 ::read_data() +out_data_scd30 Forte_SCD30 ::readData() { if (airSensor.dataAvailable()) { data.C02 = airSensor.getCO2(); @@ -25,7 +25,11 @@ out_data_scd30 Forte_SCD30 ::read_data() // return out_data_scd30{-1, -1, -1}; } -Message Forte_SCD30::build_message() +Message Forte_SCD30::buildMessage() { throw "Not yet implemented"; -} \ No newline at end of file +} +Protocol Forte_SCD30::getProtocol() +{ + return I2C; +} diff --git a/client/client/lib/scd30/scd30.hpp b/client/client/lib/scd30/scd30.hpp index dcd05a4a4cba4198245e69b58d5c6e5f3b17eb2c..a1fa2901b2921fa1d93433d468b8584ac4184625 100644 --- a/client/client/lib/scd30/scd30.hpp +++ b/client/client/lib/scd30/scd30.hpp @@ -18,8 +18,9 @@ struct out_data_scd30 { class Forte_SCD30 : public Forte_Sensor<out_data_scd30> { public: void setup() override; - out_data_scd30 read_data() override; - Message build_message() override; + out_data_scd30 readData() override; + Message buildMessage() override; + Protocol getProtocol() override; private: SCD30 airSensor; diff --git a/client/client/platformio.ini b/client/client/platformio.ini index 8b0ba5710afc13eeb3489c185f40cf3c33a09629..a28a589ef548bc1828a8d7cd263eb20b00657d1a 100644 --- a/client/client/platformio.ini +++ b/client/client/platformio.ini @@ -13,16 +13,17 @@ platform = espressif32 board = esp32-c3-devkitm-1 framework = arduino monitor_speed = 115200 -build_flags = - -I include - -DCORE_DEBUG_LEVEL=5 -lib_deps = - sparkfun/SparkFun SCD30 Arduino Library@^1.0.18 - Wire - adafruit/Adafruit ADS1X15@^2.4.0 - wollewald/INA219_WE@^1.3.1 - adafruit/Adafruit BusIO@^1.13.2 - Adafruit_I2CDevice - SPI - envirodiy/SDI-12@^2.1.4 - fbiego/ESP32Time@^2.0.0 +build_flags = + -I include + -DCORE_DEBUG_LEVEL=5 +lib_deps = + sparkfun/SparkFun SCD30 Arduino Library@^1.0.18 + Wire + adafruit/Adafruit ADS1X15@^2.4.0 + wollewald/INA219_WE@^1.3.1 + adafruit/Adafruit BusIO@^1.13.2 + Adafruit_I2CDevice + SPI + envirodiy/SDI-12@^2.1.4 + fbiego/ESP32Time@^2.0.0 + bblanchon/ArduinoJson@^6.19.4 diff --git a/client/client/src/main.cpp b/client/client/src/main.cpp index 266c4c78072af0f01a23454e5524118150f8692d..fe98c199301791f6956f2d35104f24c5ff4f2b42 100644 --- a/client/client/src/main.cpp +++ b/client/client/src/main.cpp @@ -24,8 +24,8 @@ void loop() try { espnow_setup(); - // data = drs26.read_data(); - auto message = drs26.build_message(); + // data = drs26.readData(); + auto message = drs26.buildMessage(); message.send(); } catch (const NoDataAvailableException &e) { std::cerr << e.what() << '\n'; diff --git a/client/client/test/TestClientDataPackage.cpp b/client/client/test/TestClientDataPackage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bae42a2bec83c989bed2b80d02e84b2ad9cb5597 --- /dev/null +++ b/client/client/test/TestClientDataPackage.cpp @@ -0,0 +1,19 @@ +// +// Created by zoe on 10/6/22. +// + +#include "TestClientDataPackage.hpp" +#include "Protocol.hpp" +#include <vector> + +void test_export_to_json() +{ + ClientDataPackage dataPackage = ClientDataPackage(MeasurementData{1.1, 0, "TEMPERATURE"}, "DRS26", 0, Analog); + + std::string json = dataPackage.getDataPackageAsMinifiedJsonString(); + // expected + std::string expected = + R"({"sensorName":"DRS26","timestamp":0,"protocol":"Analog","value":1.1,"channel":0,"measurementType":"TEMPERATURE"})"; + + TEST_ASSERT_EQUAL_STRING(expected.c_str(), json.c_str()); +} \ No newline at end of file diff --git a/client/client/test/TestClientDataPackage.hpp b/client/client/test/TestClientDataPackage.hpp new file mode 100644 index 0000000000000000000000000000000000000000..74a7b90dfbb55dfcc8005551c444436dfcae6c67 --- /dev/null +++ b/client/client/test/TestClientDataPackage.hpp @@ -0,0 +1,14 @@ +// +// Created by zoe on 10/6/22. +// + +#ifndef CLIENT_TESTCLIENTDATAPACKAGE_HPP +#define CLIENT_TESTCLIENTDATAPACKAGE_HPP + +#include <unity.h> +#include <Arduino.h> +#include <ClientDataPackage.hpp> + +void test_export_to_json(); + +#endif // CLIENT_TESTCLIENTDATAPACKAGE_HPP diff --git a/client/client/test/TestMessage.cpp b/client/client/test/TestMessage.cpp deleted file mode 100644 index 56b7ccc83ab80707afba68c9c33fbe1f6ad6f0b1..0000000000000000000000000000000000000000 --- a/client/client/test/TestMessage.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "TestMessage.hpp" - -void test_on_data_recv() -{ - Message message = Message{}; - - TEST_ASSERT_EQUAL(0, message.getData().amountData); -} - -void test_new_message_filled() -{ - Message message = Message{}; - - message.add_data(1.1, 0); - message.add_data(1.2, 1); - message.add_data(1.3, 2); - - float expectedValuesArray[] = {1.1, 1.2, 1.3}; - int expectedIdentifiersArray[] = {0, 1, 2}; - - TEST_ASSERT_EQUAL(3, message.getData().amountData); - TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedValuesArray, message.getData().values, 3); - TEST_ASSERT_EQUAL_INT_ARRAY(expectedIdentifiersArray, message.getData().identifiers, 3); -} \ No newline at end of file diff --git a/client/client/test/TestMessage.hpp b/client/client/test/TestMessage.hpp deleted file mode 100644 index 80d5be09d9d13954d96d1b6ef0b366783b414398..0000000000000000000000000000000000000000 --- a/client/client/test/TestMessage.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include <Arduino.h> -#include <ESPNow.hpp> -#include <unity.h> - -void test_on_data_recv(); - -void test_new_message_filled(); \ No newline at end of file diff --git a/client/client/test/main.cpp b/client/client/test/main.cpp index 82d68817015b01f036c346b18fa79601a5e842aa..b4aedce632de89c915499d0d953c91e6f5a292cb 100644 --- a/client/client/test/main.cpp +++ b/client/client/test/main.cpp @@ -1,7 +1,7 @@ #include "TestESPNow.hpp" -#include "TestMessage.hpp" #include <Arduino.h> #include <unity.h> +#include "TestClientDataPackage.hpp" void setup() { @@ -9,8 +9,7 @@ void setup() UNITY_BEGIN(); RUN_TEST(test_on_data_recv_valid_config); - RUN_TEST(test_on_data_recv); - RUN_TEST(test_new_message_filled); + RUN_TEST(test_export_to_json); UNITY_END(); }