From cfa79e99e7c9c8e7843c8c3c6be109fb3a488a33 Mon Sep 17 00:00:00 2001
From: Paul Beuchat <beuchatp@control.ee.ethz.ch>
Date: Mon, 4 May 2020 13:29:21 +0200
Subject: [PATCH] Changed Get Agent Status service to return strings

---
 .../nodes/AgentStatusForWebInterface.h        |  2 +-
 .../src/nodes/AgentStatusForWebInterface.cpp  | 31 +++++++++++++++++--
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h b/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h
index 2f9724ba..48ea1086 100644
--- a/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h
+++ b/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h
@@ -1,4 +1,4 @@
-//    Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
+//    Copyright (C) 2020, The University of Melbourne, Department of Electrical and Electronic Engineering (EEE), Paul Beuchat
 //
 //    This file is part of D-FaLL-System.
 //    
diff --git a/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp b/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp
index aae072ed..d7718333 100644
--- a/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp
+++ b/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp
@@ -1,4 +1,4 @@
-//    Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
+//    Copyright (C) 2020, The University of Melbourne, Department of Electrical and Electronic Engineering (EEE), Paul Beuchat
 //
 //    This file is part of D-FaLL-System.
 //    
@@ -114,9 +114,36 @@ void studentControllerSetpointChangedCallback(const SetpointWithHeader& newSetpo
 // SERVICE CALLBACK FOR PROVIDING STATUS TO THE WEB INTERFACE
 bool statusForWebInterfaceCallback(IntStringService::Request &request, IntStringService::Response &response)
 {
+	// Get the statuses as string
+	str::string crazyradio_status_string;
+	switch (m_crazyradio_status)
+	{
+		case CRAZY_RADIO_STATE_CONNECTED:
+		{
+			crazyradio_status_string = "connected";
+			break;
+		}
+		case CRAZY_RADIO_STATE_CONNECTING:
+		{
+			crazyradio_status_string = "connecting";
+			break;
+		}
+		case CRAZY_RADIO_STATE_DISCONNECTED:
+		{
+			crazyradio_status_string = "disconnected";
+			break;
+		}
+		default:
+		{
+			crazyradio_status_string = "unknown";
+			break;
+		}
+	}
+
 	// Concatenate the json together using a string stream
 	std::stringstream ss;
-	ss << "{\"crazyradiostatus\": \"" << m_crazyradio_status << "\"}";
+	ss << "{\u0022crazyradiostatus\u0022: \u0022" << crazyradio_status_string << "\u0022}";
+	//ss << R"({"crazyradiostatus": ")" << m_crazyradio_status << R"("})";
 	std::string s = ss.str();
 	// Put the string into the response
 	//response.data = "test of service for web interface";
-- 
GitLab