Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit b2cbb71

Browse files
authored
Update README.md and use allman astyle
1 parent 9935931 commit b2cbb71

File tree

14 files changed

+540
-531
lines changed

14 files changed

+540
-531
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Arduino IDE version: 1.8.19
3232
Teensyduino core v1.57
3333
Teensy 4.1 using QNEthernet v0.16.0
3434
OS: Ubuntu 20.04 LTS
35-
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
35+
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3636
3737
Context:
3838
I encountered a crash while using this library

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# AsyncHTTPRequest_Teensy41
1+
# AsyncHTTPRequest_Teensy41 Library
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncHTTPRequest_Teensy41.svg?)](https://www.ardu-badge.com/AsyncHTTPRequest_Teensy41)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncHTTPRequest_Teensy41.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/releases)
55
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
66
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncHTTPRequest_Teensy41.svg)](http://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/issues)
77

8+
89
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
910
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
11+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Teensy41/count.svg" title="AsyncHTTPRequest_Teensy41 Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Teensy41/count.svg" style="height: 30px;width: 200px;"></a>
1013

1114
---
1215
---
@@ -222,7 +225,7 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/blob/558ddadd9345b15f35a
222225
#### 1. [AsyncHTTPRequest](examples/AsyncHTTPRequest) on TEENSY 4.1
223226

224227

225-
```
228+
```cpp
226229
Start AsyncHTTPRequest on TEENSY 4.1
227230
AsyncHTTPRequest_Teensy41 v1.9.2
228231
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
@@ -269,7 +272,7 @@ week_number: 45
269272
#### 2. [AsyncCustomHeader](examples/AsyncCustomHeader) on TEENSY 4.1
270273

271274

272-
```
275+
```cpp
273276
Start AsyncCustomHeader on TEENSY 4.1
274277
AsyncHTTPRequest_Teensy41 v1.9.2
275278
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
@@ -320,7 +323,7 @@ week_number: 45
320323

321324
#### 3. [AsyncDweetGET](examples/AsyncDweetGET) on TEENSY 4.1
322325

323-
```
326+
```cpp
324327
Start AsyncDweetGET on TEENSY 4.1
325328
AsyncHTTPRequest_Teensy41 v1.9.2
326329
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
@@ -337,7 +340,7 @@ Actual value: 66
337340
338341
#### 4. [AsyncDweetPOST](examples/AsyncDweetPOST) on TEENSY 4.1
339342
340-
```
343+
```cpp
341344
Start AsyncDweetPOST on TEENSY 4.1
342345
AsyncHTTPRequest_Teensy41 v1.9.2
343346
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
@@ -357,7 +360,7 @@ Actual value: 1007
357360
#### 5. [AsyncSimpleGET](examples/AsyncSimpleGET) on TEENSY 4.1
358361

359362

360-
```
363+
```cpp
361364
Start AsyncSimpleGET on TEENSY 4.1
362365
AsyncHTTPRequest_Teensy41 v1.9.2
363366
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# AsyncHTTPRequest_Teensy41
1+
# AsyncHTTPRequest_Teensy41 Library
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncHTTPRequest_Teensy41.svg?)](https://www.ardu-badge.com/AsyncHTTPRequest_Teensy41)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncHTTPRequest_Teensy41.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/releases)
55
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/blob/master/LICENSE)
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncHTTPRequest_Teensy41.svg)](http://github.com/khoih-prog/AsyncHTTPRequest_Teensy41/issues)
88

9+
10+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
11+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
13+
<a href="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Teensy41/count.svg" title="AsyncHTTPRequest_Teensy41 Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Teensy41/count.svg" style="height: 30px;width: 200px;"></a>
14+
915
---
1016
---
1117

examples/AsyncCustomHeader/AsyncCustomHeader.ino

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -49,124 +49,124 @@ Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
4949

5050
void sendRequest()
5151
{
52-
static bool requestOpenResult;
53-
54-
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
55-
{
56-
Serial.println("\nSending GET Request to " + String(GET_ServerAddress));
57-
58-
requestOpenResult = request.open("GET", GET_ServerAddress);
59-
60-
//request.setReqHeader("X-CUSTOM-HEADER", "custom_value");
61-
if (requestOpenResult)
62-
{
63-
// Only send() if open() returns true, or crash
64-
request.send();
65-
}
66-
else
67-
{
68-
Serial.println("Can't send bad request");
69-
}
70-
}
71-
else
72-
{
73-
Serial.println("Can't send request");
74-
}
52+
static bool requestOpenResult;
53+
54+
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
55+
{
56+
Serial.println("\nSending GET Request to " + String(GET_ServerAddress));
57+
58+
requestOpenResult = request.open("GET", GET_ServerAddress);
59+
60+
//request.setReqHeader("X-CUSTOM-HEADER", "custom_value");
61+
if (requestOpenResult)
62+
{
63+
// Only send() if open() returns true, or crash
64+
request.send();
65+
}
66+
else
67+
{
68+
Serial.println("Can't send bad request");
69+
}
70+
}
71+
else
72+
{
73+
Serial.println("Can't send request");
74+
}
7575
}
7676

7777
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
7878
{
79-
(void) optParm;
80-
81-
if (readyState == readyStateDone)
82-
{
83-
AHTTP_LOGDEBUG(F("\n**************************************"));
84-
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
85-
86-
if (request->responseHTTPcode() == 200)
87-
{
88-
Serial.println(F("\n**************************************"));
89-
Serial.println(request->responseText());
90-
Serial.println(F("**************************************"));
91-
}
92-
}
79+
(void) optParm;
80+
81+
if (readyState == readyStateDone)
82+
{
83+
AHTTP_LOGDEBUG(F("\n**************************************"));
84+
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
85+
86+
if (request->responseHTTPcode() == 200)
87+
{
88+
Serial.println(F("\n**************************************"));
89+
Serial.println(request->responseText());
90+
Serial.println(F("**************************************"));
91+
}
92+
}
9393
}
9494

9595
void setup()
9696
{
97-
Serial.begin(115200);
97+
Serial.begin(115200);
9898

99-
while (!Serial && millis() < 5000);
99+
while (!Serial && millis() < 5000);
100100

101-
Serial.print("\nStart AsyncCustomHeader on ");
102-
Serial.println(BOARD_NAME);
103-
Serial.println(ASYNC_HTTP_REQUEST_TEENSY41_VERSION);
101+
Serial.print("\nStart AsyncCustomHeader on ");
102+
Serial.println(BOARD_NAME);
103+
Serial.println(ASYNC_HTTP_REQUEST_TEENSY41_VERSION);
104104

105105
#if defined(ASYNC_HTTP_REQUEST_TEENSY41_VERSION_MIN)
106106

107-
if (ASYNC_HTTP_REQUEST_TEENSY41_VERSION_INT < ASYNC_HTTP_REQUEST_TEENSY41_VERSION_MIN)
108-
{
109-
Serial.print("Warning. Must use this example on Version equal or later than : ");
110-
Serial.println(ASYNC_HTTP_REQUEST_TEENSY41_VERSION_MIN_TARGET);
111-
}
107+
if (ASYNC_HTTP_REQUEST_TEENSY41_VERSION_INT < ASYNC_HTTP_REQUEST_TEENSY41_VERSION_MIN)
108+
{
109+
Serial.print("Warning. Must use this example on Version equal or later than : ");
110+
Serial.println(ASYNC_HTTP_REQUEST_TEENSY41_VERSION_MIN_TARGET);
111+
}
112112

113113
#endif
114114

115-
delay(500);
115+
delay(500);
116116

117117
#if USING_DHCP
118-
// Start the Ethernet connection, using DHCP
119-
Serial.print("Initialize Ethernet using DHCP => ");
120-
Ethernet.begin();
118+
// Start the Ethernet connection, using DHCP
119+
Serial.print("Initialize Ethernet using DHCP => ");
120+
Ethernet.begin();
121121
#else
122-
// Start the Ethernet connection, using static IP
123-
Serial.print("Initialize Ethernet using static IP => ");
124-
Ethernet.begin(myIP, myNetmask, myGW);
125-
Ethernet.setDNSServerIP(mydnsServer);
122+
// Start the Ethernet connection, using static IP
123+
Serial.print("Initialize Ethernet using static IP => ");
124+
Ethernet.begin(myIP, myNetmask, myGW);
125+
Ethernet.setDNSServerIP(mydnsServer);
126126
#endif
127127

128-
if (!Ethernet.waitForLocalIP(5000))
129-
{
130-
Serial.println(F("Failed to configure Ethernet"));
131-
132-
if (!Ethernet.linkStatus())
133-
{
134-
Serial.println(F("Ethernet cable is not connected."));
135-
}
136-
137-
// Stay here forever
138-
while (true)
139-
{
140-
delay(1);
141-
}
142-
}
143-
else
144-
{
145-
Serial.print(F("Connected! IP address:"));
146-
Serial.println(Ethernet.localIP());
147-
}
128+
if (!Ethernet.waitForLocalIP(5000))
129+
{
130+
Serial.println(F("Failed to configure Ethernet"));
131+
132+
if (!Ethernet.linkStatus())
133+
{
134+
Serial.println(F("Ethernet cable is not connected."));
135+
}
136+
137+
// Stay here forever
138+
while (true)
139+
{
140+
delay(1);
141+
}
142+
}
143+
else
144+
{
145+
Serial.print(F("Connected! IP address:"));
146+
Serial.println(Ethernet.localIP());
147+
}
148148

149149
#if USING_DHCP
150-
delay(1000);
150+
delay(1000);
151151
#else
152-
delay(2000);
152+
delay(2000);
153153
#endif
154154

155-
request.setDebug(false);
155+
request.setDebug(false);
156156

157-
// 5s timeout
158-
request.setTimeout(5);
157+
// 5s timeout
158+
request.setTimeout(5);
159159

160-
request.onReadyStateChange(requestCB);
160+
request.onReadyStateChange(requestCB);
161161

162-
sendHTTPRequest.start(); //start the ticker.
162+
sendHTTPRequest.start(); //start the ticker.
163163

164-
// Send first request now
165-
delay(10000);
166-
sendRequest();
164+
// Send first request now
165+
delay(10000);
166+
sendRequest();
167167
}
168168

169169
void loop()
170170
{
171-
sendHTTPRequest.update();
171+
sendHTTPRequest.update();
172172
}

examples/AsyncCustomHeader/defines.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define defines_h
2020

2121
#if !( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) )
22-
#error Only Teensy 4.1 supported
22+
#error Only Teensy 4.1 supported
2323
#endif
2424

2525
// Debug Level from 0 to 4
@@ -29,19 +29,19 @@
2929
#define SHIELD_TYPE "Teensy4.1 QNEthernet"
3030

3131
#if (_AWS_TEENSY41_LOGLEVEL_ > 3)
32-
#warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error
32+
#warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error
3333
#endif
3434

3535
#define USING_DHCP true
3636
//#define USING_DHCP false
3737

3838
#if !USING_DHCP
39-
// Set the static IP address to use if the DHCP fails to assign
40-
IPAddress myIP(192, 168, 2, 222);
41-
IPAddress myNetmask(255, 255, 255, 0);
42-
IPAddress myGW(192, 168, 2, 1);
43-
//IPAddress mydnsServer(192, 168, 2, 1);
44-
IPAddress mydnsServer(8, 8, 8, 8);
39+
// Set the static IP address to use if the DHCP fails to assign
40+
IPAddress myIP(192, 168, 2, 222);
41+
IPAddress myNetmask(255, 255, 255, 0);
42+
IPAddress myGW(192, 168, 2, 1);
43+
//IPAddress mydnsServer(192, 168, 2, 1);
44+
IPAddress mydnsServer(8, 8, 8, 8);
4545
#endif
4646

4747
#include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet

0 commit comments

Comments
 (0)