File tree Expand file tree Collapse file tree 2 files changed +49
-30
lines changed
Expand file tree Collapse file tree 2 files changed +49
-30
lines changed Original file line number Diff line number Diff line change @@ -23,49 +23,21 @@ void setup() {
2323
2424 Log.infof (" Connected to operator: %s\r\n " , Lte.getOperator ().c_str ());
2525
26- testHttp ();
27- }
28-
29- void testHttp () {
26+ // --- HTTP ---
3027
3128 Log.info (" ---- Testing HTTP ----" );
3229
33- HttpResponse response;
34-
35- // --- HTTP ---
36-
3730 if (!HttpClient.configure (DOMAIN, 80 , false )) {
3831 Log.info (" Failed to configure http client\r\n " );
3932 }
4033
4134 Log.info (" Configured to HTTP" );
4235
43- response = HttpClient.post (" /post" , " {\" hello\" : \" world\" }" );
36+ HttpResponse response = HttpClient.post (" /post" , " {\" hello\" : \" world\" }" );
4437 Log.infof (" POST - status code: %u, data size: %u\r\n " ,
4538 response.status_code ,
4639 response.data_size );
4740
48- Log.raw (" \r\n " );
49-
50- // --- HTTPS ---
51- Log.info (" ---- Testing HTTPS ----" );
52-
53- if (!HttpClient.configure (DOMAIN, 443 , true )) {
54- Log.info (" Failed to configure https client\r\n " );
55- }
56-
57- Log.info (" Configured to HTTPS" );
58-
59- response = HttpClient.head (" /get" );
60- Log.infof (" HEAD - status code: %d, data size: %d\r\n " ,
61- response.status_code ,
62- response.data_size );
63-
64- response = HttpClient.get (" /get" );
65- Log.infof (" GET - status code: %d, data size: %d\r\n " ,
66- response.status_code ,
67- response.data_size );
68-
6941 String body = HttpClient.readBody (512 );
7042
7143 if (body != " " ) {
Original file line number Diff line number Diff line change 1+ #include < Arduino.h>
2+ #include < http_client.h>
3+ #include < led_ctrl.h>
4+ #include < log.h>
5+ #include < lte.h>
6+
7+ #define DOMAIN " httpbin.org"
8+
9+ void testHttp ();
10+
11+ void setup () {
12+
13+ Log.begin (115200 );
14+
15+ LedCtrl.begin ();
16+ LedCtrl.startupCycle ();
17+
18+ // Start LTE modem and connect to the operator
19+ if (!Lte.begin ()) {
20+ Log.error (" Failed to connect to the operator" );
21+ return ;
22+ }
23+
24+ Log.infof (" Connected to operator: %s\r\n " , Lte.getOperator ().c_str ());
25+
26+ // --- HTTPS ---
27+ Log.info (" ---- Testing HTTPS ----" );
28+
29+ if (!HttpClient.configure (DOMAIN, 443 , true )) {
30+ Log.info (" Failed to configure https client\r\n " );
31+ }
32+
33+ Log.info (" Configured to HTTPS" );
34+
35+ HttpResponse response = HttpClient.post (" /post" , " {\" hello\" : \" world\" }" );
36+ Log.infof (" POST - status code: %u, data size: %u\r\n " ,
37+ response.status_code ,
38+ response.data_size );
39+
40+ String body = HttpClient.readBody (512 );
41+
42+ if (body != " " ) {
43+ Log.infof (" Body: %s\r\n " , body.c_str ());
44+ }
45+ }
46+
47+ void loop () {}
You can’t perform that action at this time.
0 commit comments