From 7da6fc9f7be6c732aeae09cdcc338e1af2b5ad4c Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 30 May 2022 13:06:33 +0200 Subject: refactor(minion): store string constants in flash memory --- minion/src/gymnasiearbete.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'minion/src/gymnasiearbete.cpp') diff --git a/minion/src/gymnasiearbete.cpp b/minion/src/gymnasiearbete.cpp index 5c4f725..41be0ea 100644 --- a/minion/src/gymnasiearbete.cpp +++ b/minion/src/gymnasiearbete.cpp @@ -7,6 +7,7 @@ #include #include +#include #include constexpr auto HTTP_PORT = 80U; @@ -43,8 +44,8 @@ void setup() auto wifi_module_connected = wifi_module.test(); - Serial.print("Wifi module connected: "); - Serial.println(wifi_module_connected ? "Yes" : "No"); + Serial.print(F("Wifi module connected: ")); + Serial.println(wifi_module_connected ? F("Yes") : F("No")); if (!wifi_module_connected) { @@ -59,8 +60,8 @@ void setup() wifi_module.connect_to_wifi(WIFI_SSID, WIFI_PASSWORD); Serial.print( - wifi_connect_success ? "Connected to wifi network '" - : "Failed to connect to wifi network '" + wifi_connect_success ? F("Connected to wifi network '") + : F("Failed to connect to wifi network '") ); Serial.print(WIFI_SSID); Serial.println("'"); @@ -76,7 +77,7 @@ void setup() char local_ip[MAX_NETWORK_MODULE_RESPONSE_LENGTH] = ""; - Serial.print("IP address: "); + Serial.print(F("IP address: ")); Serial.println(wifi_module.get_local_ip(local_ip)); wifi_module.set_multiple_connections_enabled(true); @@ -102,16 +103,16 @@ void loop() return; } - Serial.print("Connection ID: "); + Serial.print(F("Connection ID: ")); Serial.println(connection.id()); - Serial.print("Request method: "); + Serial.print(F("Request method: ")); Serial.println(http_request_method_strs[static_cast(request.method())]); - Serial.print("Request HTTP version: "); + Serial.print(F("Request HTTP version: ")); Serial.println(request.http_version()); - Serial.print("Request path: "); + Serial.print(F("Request path: ")); Serial.println(request.path()); const auto temperature_sensor_status = temperature_sensor.read_temperature(); @@ -124,7 +125,7 @@ void loop() if (temperature_sensor_status != TemperatureSensorStatus::OK) { - Serial.print("Error: "); + Serial.print(F("Error: ")); Serial.println(static_cast(temperature_sensor_status)); wifi_module.send_response( @@ -161,7 +162,7 @@ void loop() if (!send_response_ok) { - Serial.println("Failed to send response"); + Serial.println(F("Failed to send response")); wifi_module.close_connection(connection); return; } -- cgit v1.2.3-18-g5258