From eddaed4e597ce2bc7fa179ce6a15b90951579c6e Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 8 May 2022 23:04:16 +0200 Subject: feat(minion): implement respond to HTTP requests --- minion/src/gymnasiearbete.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'minion/src/gymnasiearbete.cpp') diff --git a/minion/src/gymnasiearbete.cpp b/minion/src/gymnasiearbete.cpp index 0e1adb5..b3c543a 100644 --- a/minion/src/gymnasiearbete.cpp +++ b/minion/src/gymnasiearbete.cpp @@ -64,6 +64,32 @@ void setup() Serial.print("IP address: "); Serial.println(wifi_module.get_local_ip(local_ip)); + + wifi_module.set_multiple_connections_enabled(true); + + delay(1000); + + wifi_module.create_tcp_server(80U); } -void loop() {} +void loop() +{ + if (wifi_module.has_incoming_request()) + { + char raw_request[200] = ""; + + const auto connection_id = wifi_module.read_incoming_request(raw_request); + + Serial.print("Connection ID: "); + Serial.println(connection_id); + + Serial.print("\nRaw request: "); + Serial.println(raw_request); + + wifi_module.send(connection_id, "lmao!"); + + wifi_module.close_connection(connection_id); + + delay(1000); + } +} -- cgit v1.2.3-18-g5258