ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
example_http.cpp
Go to the documentation of this file.
1
11#include <Arduino.h>
12#include <ArduinoLog.h>
13
14#include "dirtviz.hpp"
15
16void setup() {
17 Serial.begin(115200);
18
19 Log.begin(LOG_LEVEL_VERBOSE, &Serial);
20
21 std::string resp =
22 "HTTP/2 200 OK\r\n"
23 "content-type: application/json\r\n"
24 "content-length: 59\r\n"
25 "date: Fri, 01 Nov 2024 23:53:02 GMT\r\n"
26 "access-control-allow-origin: *\r\n"
27 "server: gunicorn\r\n"
28 "x-cache: Miss from cloudfront\r\n"
29 "via: 1.1 4a628119373a320de50f1e6bc0e5f87a.cloudfront.net "
30 "(CloudFront)\r\n"
31 "x-amz-cf-pop: SFO5-P2\r\n"
32 "x-amz-cf-id: "
33 "t9EARJ8Hsu4FipZqiiVhsjwEU29sICEwjA7XMJNIOEXgOnJA-TlhdA==\r\n"
34 "\r\n"
35 "{\r\n"
36 " \"hello\": \"I'm alive and healthy! Super healthy :D\"\r\n"
37 "}\r\n";
38
39 Log.traceln("Input string:\r\n%s", resp.c_str());
40
41 HttpClient client(resp);
42
43 Log.traceln("Version: %s", client.Version().c_str());
44 Log.traceln("Return code: %d", client.ResponseCode());
45 Log.traceln("date: %s", client.Header("date").c_str());
46 Log.traceln("data:\r\n%s", client.Data().c_str());
47}
48
49void loop() {}
HTTP request parser library.
Definition http.hpp:28
std::string Version()
Get the Http version.
Definition http.cpp:29
unsigned int ResponseCode()
Get the http response code.
Definition http.cpp:31
std::string Header(std::string header)
Get value of header.
Definition http.cpp:33
std::string Data()
Get data from Http request.
Definition http.cpp:35
void setup()
void loop()