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

Commit ed32b94

Browse files
authored
Update README.md and use allman astyle
1 parent 5950f93 commit ed32b94

22 files changed

+1327
-1097
lines changed

CONTRIBUTING.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Arduino IDE version: v1.8.19
3030
ESP8266 Core Version v3.0.2
3131
ESP8266_NODEMCU_ESP12E
3232
OS: Ubuntu 20.04 LTS
33-
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
33+
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
3434
3535
Context:
36-
I encountered a crash while using TimerInterrupt.
36+
I encountered a crash while using this library
3737
3838
Steps to reproduce:
3939
1. ...
@@ -42,12 +42,32 @@ Steps to reproduce:
4242
4. ...
4343
```
4444

45+
---
46+
4547
### Sending Feature Requests
4648

4749
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
4850

49-
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP8266_PWM/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
51+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESPAsyncTCP/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
52+
53+
---
5054

5155
### Sending Pull Requests
5256

5357
Pull Requests with changes and fixes are also welcome!
58+
59+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
60+
61+
1. Change directory to the library GitHub
62+
63+
```
64+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/ESPAsyncTCP_GitHub/
65+
xy@xy-Inspiron-3593:~/Arduino/xy/ESPAsyncTCP_GitHub$
66+
```
67+
68+
2. Issue astyle command
69+
70+
```
71+
xy@xy-Inspiron-3593:~/Arduino/xy/ESPAsyncTCP_GitHub$ bash utils/restyle.sh
72+
```
73+

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# ESPAsyncTCP (forked copy)
1+
# ESPAsyncTCP Library (forked copy)
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESPAsyncTCP.svg?)](https://www.ardu-badge.com/ESPAsyncTCP)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESPAsyncTCP.svg)](https://github.com/khoih-prog/ESPAsyncTCP/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/ESPAsyncTCP.svg)](http://github.com/khoih-prog/ESPAsyncTCP/issues)
77

88

9+
<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>
10+
<a href="https://profile-counter.glitch.me/khoih-prog-ESPAsyncTCP/count.svg" title="Forked ESPAsyncTCP Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESPAsyncTCP/count.svg" style="height: 30px;width: 200px;"></a>
11+
912
---
1013
---
1114

@@ -102,16 +105,17 @@ The base classes on which everything else is built. They expose all possible sce
102105

103106
### AsyncPrinter
104107

105-
This class can be used to send data like any other ```Print``` interface (```Serial``` for example).
106-
The object then can be used outside of the Async callbacks (the loop) and receive asynchronously data using ```onData```. The object can be checked if the underlying ```AsyncClient```is connected, or hook to the ```onDisconnect``` callback.
108+
This class can be used to send data like any other `Print` interface (`Serial` for example).
109+
110+
The object then can be used outside of the Async callbacks (the loop) and receive asynchronously data using ```onData```. The object can be checked if the underlying `AsyncClient` is connected, or hook to the `onDisconnect` callback.
107111

108112
### AsyncTCPbuffer
109113

110-
This class is really similar to the ```AsyncPrinter```, but it differs in the fact that it can buffer some of the incoming data.
114+
This class is really similar to the `AsyncPrinter`, but it differs in the fact that it can buffer some of the incoming data.
111115

112116
### SyncClient
113117

114-
It is exactly what it sounds like. This is a standard, blocking TCP Client, similar to the one included in ```ESP8266WiFi```
118+
It is exactly what it sounds like. This is a standard, blocking TCP Client, similar to the one included in `ESP8266WiFi`
115119

116120
---
117121
---
@@ -167,7 +171,8 @@ Submit issues to: [ESPAsyncTCP issues](https://github.com/khoih-prog/ESPAsyncTCP
167171

168172
1. Try to convert to use with new ESP8266 cores v3.0.2+ without `axtls` support
169173
2. Add Table of Contents
170-
3. Modify examples
174+
3. Modify examples\
175+
4. Add astyle using `allman` style. Restyle the library
171176

172177
---
173178
---
@@ -209,8 +214,8 @@ If you want to contribute to this project:
209214

210215
## Copyright
211216

212-
- Copyright 2016- Hristo Gochkov
213-
- Copyright 2022- Khoi Hoang
217+
- Copyright (c) 2016- Hristo Gochkov
218+
- Copyright (c) 2022- Khoi Hoang
214219

215220

216221

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
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/ESPAsyncTCP.svg)](http://github.com/khoih-prog/ESPAsyncTCP/issues)
88

9+
10+
<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>
11+
<a href="https://profile-counter.glitch.me/khoih-prog-ESPAsyncTCP/count.svg" title="Forked ESPAsyncTCP Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESPAsyncTCP/count.svg" style="height: 30px;width: 200px;"></a>
12+
913
---
1014
---
1115

@@ -21,6 +25,6 @@
2125

2226
### Release v1.3.0
2327

24-
1. Initial modifications for ESP8266 boards, using WiFi or LwIP Ethernet, with [ESP8266 core v3.0.2+](https://github.com/esp8266/Arduino/releases/tag/3.0.2) or WiFi with [ESP8266 core v2.7.4](https://github.com/esp8266/Arduino/releases/tag/2.7.4) to avoid compile errors
28+
1. Initial modifications for ESP8266 boards, using WiFi or LwIP Ethernet, with [ESP8266 core v3.0.2+](https://github.com/esp8266/Arduino/releases/tag/3.0.2) or WiFi with [ESP8266 core v2.7.4-](https://github.com/esp8266/Arduino/releases/tag/2.7.4) to avoid compile errors
2529

2630

examples/ClientServer/Client/Client.ino

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,50 @@ extern "C"
1313

1414
static os_timer_t intervalTimer;
1515

16-
static void replyToServer(void* arg)
16+
static void replyToServer(void* arg)
1717
{
1818
AsyncClient* client = reinterpret_cast<AsyncClient*>(arg);
1919

2020
// send reply
21-
if (client->space() > 32 && client->canSend())
21+
if (client->space() > 32 && client->canSend())
2222
{
2323
char message[32];
24-
24+
2525
sprintf(message, "this is from %s", WiFi.localIP().toString().c_str());
2626
client->add(message, strlen(message));
2727
client->send();
2828
}
2929
}
3030

3131
/* event callbacks */
32-
static void handleData(void* arg, AsyncClient* client, void *data, size_t len)
32+
static void handleData(void* arg, AsyncClient* client, void *data, size_t len)
3333
{
34-
(void) arg;
35-
3634
Serial.printf("\n data received from %s \n", client->remoteIP().toString().c_str());
3735
Serial.write((uint8_t*)data, len);
3836

3937
os_timer_arm(&intervalTimer, 2000, true); // schedule for reply to server at next 2s
4038
}
4139

42-
void onConnect(void* arg, AsyncClient* client)
40+
void onConnect(void* arg, AsyncClient* client)
4341
{
44-
(void) arg;
45-
4642
Serial.printf("\n client has been connected to %s on port %d \n", SERVER_HOST_NAME, TCP_PORT);
4743
replyToServer(client);
4844
}
4945

5046

51-
void setup()
47+
void setup()
5248
{
5349
Serial.begin(115200);
50+
5451
while (!Serial && millis() < 5000);
55-
52+
5653
delay(200);
5754

5855
// connects to access point
5956
WiFi.mode(WIFI_STA);
6057
WiFi.begin(SSID, PASSWORD);
61-
62-
while (WiFi.status() != WL_CONNECTED)
58+
59+
while (WiFi.status() != WL_CONNECTED)
6360
{
6461
Serial.print('.');
6562
delay(500);
@@ -74,6 +71,6 @@ void setup()
7471
os_timer_setfn(&intervalTimer, &replyToServer, client);
7572
}
7673

77-
void loop()
74+
void loop()
7875
{
7976
}

examples/ClientServer/Client/config.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#define CONFIG_H
33

44
/*
5-
* This example demonstrate how to use asynchronous client & server APIs
6-
* in order to establish tcp socket connections in client server manner.
7-
* server is running (on port 7050) on one ESP, acts as AP, and other clients running on
8-
* remaining ESPs acts as STAs. after connection establishment between server and clients
9-
* there is a simple message transfer in every 2s. clients connect to server via it's host name
10-
* (in this case 'esp_server') with help of DNS service running on server side.
11-
*
12-
* Note: default MSS for ESPAsyncTCP is 536 byte and defualt ACK timeout is 5s.
5+
This example demonstrate how to use asynchronous client & server APIs
6+
in order to establish tcp socket connections in client server manner.
7+
server is running (on port 7050) on one ESP, acts as AP, and other clients running on
8+
remaining ESPs acts as STAs. after connection establishment between server and clients
9+
there is a simple message transfer in every 2s. clients connect to server via it's host name
10+
(in this case 'esp_server') with help of DNS service running on server side.
11+
12+
Note: default MSS for ESPAsyncTCP is 536 byte and defualt ACK timeout is 5s.
1313
*/
1414

1515
#define SSID "ESP-TEST"

examples/ClientServer/Server/Server.ino

Lines changed: 52 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,87 +12,78 @@ static DNSServer DNS;
1212

1313
static std::vector<AsyncClient*> clients; // a list to hold all clients
1414

15-
/* clients events */
16-
static void handleError(void* arg, AsyncClient* client, int8_t error)
15+
/* clients events */
16+
static void handleError(void* arg, AsyncClient* client, int8_t error)
1717
{
18-
(void) arg;
19-
20-
Serial.printf("\n connection error %s from client %s \n", client->errorToString(error), client->remoteIP().toString().c_str());
18+
Serial.printf("\n connection error %s from client %s \n", client->errorToString(error),
19+
client->remoteIP().toString().c_str());
2120
}
2221

23-
static void handleData(void* arg, AsyncClient* client, void *data, size_t len)
22+
static void handleData(void* arg, AsyncClient* client, void *data, size_t len)
2423
{
25-
(void) arg;
26-
27-
Serial.printf("\n data received from client %s \n", client->remoteIP().toString().c_str());
28-
Serial.write((uint8_t*)data, len);
29-
30-
// reply to client
31-
if (client->space() > 32 && client->canSend())
32-
{
33-
char reply[32];
34-
sprintf(reply, "this is from %s", SERVER_HOST_NAME);
35-
client->add(reply, strlen(reply));
36-
client->send();
37-
}
24+
Serial.printf("\n data received from client %s \n", client->remoteIP().toString().c_str());
25+
Serial.write((uint8_t*)data, len);
26+
27+
// reply to client
28+
if (client->space() > 32 && client->canSend())
29+
{
30+
char reply[32];
31+
sprintf(reply, "this is from %s", SERVER_HOST_NAME);
32+
client->add(reply, strlen(reply));
33+
client->send();
34+
}
3835
}
3936

40-
static void handleDisconnect(void* arg, AsyncClient* client)
37+
static void handleDisconnect(void* arg, AsyncClient* client)
4138
{
42-
(void) arg;
43-
44-
Serial.printf("\n client %s disconnected \n", client->remoteIP().toString().c_str());
39+
Serial.printf("\n client %s disconnected \n", client->remoteIP().toString().c_str());
4540
}
4641

47-
static void handleTimeOut(void* arg, AsyncClient* client, uint32_t time)
42+
static void handleTimeOut(void* arg, AsyncClient* client, uint32_t time)
4843
{
49-
(void) arg;
50-
(void) time;
51-
52-
Serial.printf("\n client ACK timeout ip: %s \n", client->remoteIP().toString().c_str());
44+
Serial.printf("\n client ACK timeout ip: %s \n", client->remoteIP().toString().c_str());
5345
}
5446

5547

5648
/* server events */
57-
static void handleNewClient(void* arg, AsyncClient* client)
49+
static void handleNewClient(void* arg, AsyncClient* client)
5850
{
59-
(void) arg;
60-
61-
Serial.printf("\n new client has been connected to server, ip: %s", client->remoteIP().toString().c_str());
62-
63-
// add to list
64-
clients.push_back(client);
65-
66-
// register events
67-
client->onData(&handleData, NULL);
68-
client->onError(&handleError, NULL);
69-
client->onDisconnect(&handleDisconnect, NULL);
70-
client->onTimeout(&handleTimeOut, NULL);
51+
Serial.printf("\n new client has been connected to server, ip: %s", client->remoteIP().toString().c_str());
52+
53+
// add to list
54+
clients.push_back(client);
55+
56+
// register events
57+
client->onData(&handleData, NULL);
58+
client->onError(&handleError, NULL);
59+
client->onDisconnect(&handleDisconnect, NULL);
60+
client->onTimeout(&handleTimeOut, NULL);
7161
}
7262

73-
void setup()
63+
void setup()
7464
{
75-
Serial.begin(115200);
65+
Serial.begin(115200);
66+
7667
while (!Serial && millis() < 5000);
77-
78-
delay(200);
79-
80-
// create access point
81-
while (!WiFi.softAP(SSID, PASSWORD, 6, false, 15))
82-
{
83-
delay(500);
84-
}
85-
86-
// start dns server
87-
if (!DNS.start(DNS_PORT, SERVER_HOST_NAME, WiFi.softAPIP()))
88-
Serial.printf("\n failed to start dns service \n");
89-
90-
AsyncServer* server = new AsyncServer(TCP_PORT); // start listening on tcp port 7050
91-
server->onClient(&handleNewClient, server);
92-
server->begin();
68+
69+
delay(200);
70+
71+
// create access point
72+
while (!WiFi.softAP(SSID, PASSWORD, 6, false, 15))
73+
{
74+
delay(500);
75+
}
76+
77+
// start dns server
78+
if (!DNS.start(DNS_PORT, SERVER_HOST_NAME, WiFi.softAPIP()))
79+
Serial.printf("\n failed to start dns service \n");
80+
81+
AsyncServer* server = new AsyncServer(TCP_PORT); // start listening on tcp port 7050
82+
server->onClient(&handleNewClient, server);
83+
server->begin();
9384
}
9485

95-
void loop()
86+
void loop()
9687
{
97-
DNS.processNextRequest();
88+
DNS.processNextRequest();
9889
}

examples/ClientServer/Server/config.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#define CONFIG_H
33

44
/*
5-
* This example demonstrate how to use asynchronous client & server APIs
6-
* in order to establish tcp socket connections in client server manner.
7-
* server is running (on port 7050) on one ESP, acts as AP, and other clients running on
8-
* remaining ESPs acts as STAs. after connection establishment between server and clients
9-
* there is a simple message transfer in every 2s. clients connect to server via it's host name
10-
* (in this case 'esp_server') with help of DNS service running on server side.
11-
*
12-
* Note: default MSS for ESPAsyncTCP is 536 byte and defualt ACK timeout is 5s.
5+
This example demonstrate how to use asynchronous client & server APIs
6+
in order to establish tcp socket connections in client server manner.
7+
server is running (on port 7050) on one ESP, acts as AP, and other clients running on
8+
remaining ESPs acts as STAs. after connection establishment between server and clients
9+
there is a simple message transfer in every 2s. clients connect to server via it's host name
10+
(in this case 'esp_server') with help of DNS service running on server side.
11+
12+
Note: default MSS for ESPAsyncTCP is 536 byte and defualt ACK timeout is 5s.
1313
*/
1414

1515
#define SSID "ESP-TEST"

0 commit comments

Comments
 (0)