summaryrefslogtreecommitdiff
path: root/minion/src/wifi_module.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-05-13 21:00:25 +0200
committerHampusM <hampus@hampusmat.com>2022-05-13 21:00:25 +0200
commitfc1a41c627f25c1fa52c87d002d08870fa8876ac (patch)
tree78ad84e86d69dd986127735d3967fc670703f4b9 /minion/src/wifi_module.cpp
parent481ef51ac14ad5b3bf0935dd6110b6a7d8afe731 (diff)
fix(minion): conform to the http/1.1 response syntax
Diffstat (limited to 'minion/src/wifi_module.cpp')
-rw-r--r--minion/src/wifi_module.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/minion/src/wifi_module.cpp b/minion/src/wifi_module.cpp
index 7c3e5bc..2f4e57c 100644
--- a/minion/src/wifi_module.cpp
+++ b/minion/src/wifi_module.cpp
@@ -329,11 +329,16 @@ auto WiFiModule::close_connection(size_t connection_id) noexcept -> bool
return true;
}
-auto WiFiModule::send_response(size_t connection_id, const char *data) noexcept -> bool
+auto WiFiModule::send_response(
+ size_t connection_id,
+ size_t status_code,
+ const char *data
+) noexcept -> bool
{
const auto *cmd = "AT+CIPSEND";
- const auto data_length = strlen(data);
+ const auto data_length = strlen(RESPONSE_HTTP_VERSION) + 1 +
+ RESPONSE_STATUS_CODE_LENGTH + 4 + strlen(data);
auto command_length = strlen(cmd) + 50U + data_length + 1U;
@@ -355,6 +360,10 @@ auto WiFiModule::send_response(size_t connection_id, const char *data) noexcept
_read(TIMEOUT_MEDIUM, response);
+ _serial.print(RESPONSE_HTTP_VERSION);
+ _serial.print(" ");
+ _serial.print(status_code);
+ _serial.print("\r\n\r\n");
_serial.print(data);
strcpy(response, "");