From 51d36f1c1f9706d60e51166315cf12fc7b32dad9 Mon Sep 17 00:00:00 2001
From: Grigoris Pavlakis <grigpavl@ece.auth.gr>
Date: Sun, 11 Aug 2019 21:43:53 +0300
Subject: [PATCH] Fix compiler/linker errors

---
 inc/Services/Parameter.hpp        | 6 +++---
 inc/Services/ParameterService.hpp | 6 +++---
 src/Services/ParameterService.cpp | 8 ++++----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp
index a00b4021..b75bdff5 100644
--- a/inc/Services/Parameter.hpp
+++ b/inc/Services/Parameter.hpp
@@ -26,6 +26,9 @@ class Parameter {
 	// Various flags (TBD which. Ideas: update with priority, do not poll, etc.)
 
 	public:
+		ValueType currentValue = 0; // Last good value of the parameter. TODO: Find a way to store arbitrary types
+
+		Parameter() = default;
 		Parameter(uint8_t new_ptc, uint8_t new_pfc, uint32_t initialValue = 0, UpdatePtr new_ptr = nullptr) {
 			ptc = new_ptc;
 			pfc = new_pfc;
@@ -38,9 +41,6 @@ class Parameter {
 				currentValue = initialValue;
 			}
 		}
-
-		ValueType currentValue = 0; // Last good value of the parameter. TODO: Find a way to store arbitrary types (w/out
-		// templates preferred)
 };
 
 
diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp
index cc2e5713..83e0b61e 100644
--- a/inc/Services/ParameterService.hpp
+++ b/inc/Services/ParameterService.hpp
@@ -28,7 +28,7 @@
 
 class ParameterService : public Service {
 private:
-	static etl::map<ParamId, Parameter, MAX_PARAMS> paramsList;
+	etl::map<ParamId, Parameter, MAX_PARAMS> paramsList;
 	uint16_t numOfValidIds(Message idMsg); // count the valid ids in a given TC[20, 1]
 
 public:
@@ -39,9 +39,9 @@ public:
 
 	/**
 	 * Adds a new parameter. If the parameter has not been added (either because the map is full or because it already
-	 * exists in it) then returns true.
+	 * exists in it) then returns false.
 	 */
-	static bool addParameter(uint8_t ptc, uint8_t pfc, uint32_t initialValue = 0, UpdatePtr ptr = nullptr);
+	bool addNewParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value = 0, UpdatePtr ptr = nullptr);
 
 	/**
 	 * This function receives a TC[20, 1] packet and returns a TM[20, 2] packet
diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp
index dcbeaa44..e09b1a07 100644
--- a/src/Services/ParameterService.cpp
+++ b/src/Services/ParameterService.cpp
@@ -3,8 +3,8 @@
 
 ParameterService::ParameterService() {
 
-	addParameter(3, 14);
-	addParameter(3, 14);
+	addNewParameter(3, 14);
+	addNewParameter(3, 14);
 
 //	// Test code, setting up some of the parameter fields
 //
@@ -33,9 +33,9 @@ ParameterService::ParameterService() {
 //#endif
 }
 
-bool ParameterService::addParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value, UpdatePtr ptr) {
+bool ParameterService::addNewParameter(uint8_t ptc, uint8_t pfc, uint32_t initial_value, UpdatePtr ptr) {
 	Parameter param = Parameter(ptc, pfc, initial_value, ptr);
-	return paramsList.insert(std::make_pair(0, param)).second;
+	return paramsList.insert(std::make_pair(paramsList.size() + 1, param)).second;
 	// second element of the returned std::pair is whether the given item was inserted or not
 }
 
-- 
GitLab