diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-30 13:06:33 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-05-30 13:06:33 +0200 |
commit | 7da6fc9f7be6c732aeae09cdcc338e1af2b5ad4c (patch) | |
tree | 6363660972ccfcc48dc4d2068ad174214e9f38b5 /minion/src/gymnasiearbete.cpp | |
parent | 1452435a8d662bbd39f0c812cdc24ddd4ec226d3 (diff) |
refactor(minion): store string constants in flash memory
Diffstat (limited to 'minion/src/gymnasiearbete.cpp')
-rw-r--r-- | minion/src/gymnasiearbete.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
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 <Arduino.h> #include <SoftwareSerial.h> +#include <avr/pgmspace.h> #include <string.h> 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<size_t>(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<int>(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; } |