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

Commit 3aa115c

Browse files
authored
v1.2.5
### Releases v1.2.5 1. Clean-up all compiler warnings possible. 2. Update Table of Contents 3. Add examples 4. Add Version String
1 parent 6343285 commit 3aa115c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1890
-244
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
## Contributing to ESP_WiFiManager
1+
## Contributing to AsyncWebServer_STM32
22

33
### Reporting Bugs
44

5-
Please report bugs in ESP_WiFiManager if you find them.
5+
Please report bugs in AsyncWebServer_STM32 if you find them.
66

77
However, before reporting a bug please check through the following:
88

9-
* [Existing Open Issues](https://github.com/khoih-prog/ESP_WiFiManager/issues) - someone might have already encountered this.
9+
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_STM32/issues) - someone might have already encountered this.
1010

11-
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/ESP_WiFiManager/issues/new).
11+
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_STM32/issues/new).
1212

1313
### How to submit a bug report
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.11) or Platform.io version
18-
* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v2.6.3 or ESP32 v1.0.4)
17+
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
18+
* Board Core Version (e.g. STM32F7 Nucleo-144 NUCLEO_F767ZI core v1.9.0, etc.)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.11
30-
ESP8266 Core Version 2.6.3
31-
OS: Ubuntu 16.04 LTS
32-
Linux Inspiron 4.4.0-170-generic #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
29+
Arduino IDE version: 1.8.13
30+
STM32F7 Nucleo-144 NUCLEO_F767ZI core v1.9.0
31+
OS: Ubuntu 20.04 LTS
32+
Linux xy-Inspiron-3593 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
I encountered an endless loop while trying to connect to Local WiFi.
@@ -44,7 +44,7 @@ Steps to reproduce:
4444

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

47-
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP_WiFiManager/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
47+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncWebServer_STM32/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
4848

4949
### Sending Pull Requests
5050

README.md

Lines changed: 363 additions & 98 deletions
Large diffs are not rendered by default.

examples/AsyncFSBrowser_STM32/AsyncFSBrowser_STM32.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_STM32
1010
Licensed under MIT license
1111
12-
Version: 1.2.4
12+
Version: 1.2.5
1313
1414
Version Modified By Date Comments
1515
------- ----------- ---------- -----------
1616
1.2.3 K Hoang 02/09/2020 Initial coding for STM32 for built-in Ethernet (Nucleo-144, DISCOVERY, etc).
1717
Bump up version to v1.2.3 to sync with ESPAsyncWebServer v1.2.3
1818
1.2.4 K Hoang 05/09/2020 Add back MD5/SHA1 authentication feature.
19+
1.2.5 K Hoang 28/12/2020 Suppress all possible compiler warnings. Add examples.
1920
*****************************************************************************************************************************/
2021
/*
2122
Currently support
@@ -83,6 +84,8 @@
8384
#define BOARD_NAME BOARD_TYPE
8485
#endif
8586

87+
#define SHIELD_TYPE "LAN8742A built-in Ethernet"
88+
8689
#include <LwIP.h>
8790
#include <STM32Ethernet.h>
8891
#include <AsyncWebServer_STM32.h>
@@ -126,7 +129,7 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
126129
if (type == WS_EVT_CONNECT)
127130
{
128131
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
129-
client->printf("Hello Client %u :)", client->id());
132+
client->printf("Hello Client %lu :)", client->id());
130133
client->ping();
131134
}
132135
else if (type == WS_EVT_DISCONNECT)
@@ -160,7 +163,7 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
160163
}
161164
else
162165
{
163-
char buff[3];
166+
char buff[6];
164167

165168
for (size_t i = 0; i < info->len; i++)
166169
{
@@ -199,7 +202,7 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
199202
}
200203
else
201204
{
202-
char buff[3];
205+
char buff[6];
203206

204207
for (size_t i = 0; i < len; i++)
205208
{
@@ -237,7 +240,8 @@ void setup()
237240
Serial.begin(115200);
238241
while (!Serial);
239242

240-
Serial.println("\nStarting AsyncFSBrowser_STM32 on " + String(BOARD_NAME));
243+
Serial.printf("\nStarting AsyncFSBrowser_STM32 on %s with %s\n", BOARD_NAME, SHIELD_TYPE);
244+
Serial.println(ASYNC_WEBSERVER_STM32_VERSION);
241245

242246
// start the ethernet connection and the server
243247
// Use random mac
@@ -320,6 +324,8 @@ void setup()
320324

321325
server.onRequestBody([](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total)
322326
{
327+
AWS_STM32_UNUSED(request);
328+
323329
if (!index)
324330
Serial.printf("BodyStart: %u\n", total);
325331

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
/****************************************************************************************************************************
2+
AsyncMultiWebServer_STM32.h - Dead simple AsyncWebServer for STM32 built-in LAN8742A Ethernet
3+
4+
For STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
5+
6+
AsyncWebServer_STM32 is a library for the STM32 run built-in Ethernet WebServer
7+
8+
Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer)
9+
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_STM32
10+
Licensed under MIT license
11+
12+
Version: 1.2.5
13+
14+
Version Modified By Date Comments
15+
------- ----------- ---------- -----------
16+
1.2.3 K Hoang 02/09/2020 Initial coding for STM32 for built-in Ethernet (Nucleo-144, DISCOVERY, etc).
17+
Bump up version to v1.2.3 to sync with ESPAsyncWebServer v1.2.3
18+
1.2.4 K Hoang 05/09/2020 Add back MD5/SHA1 authentication feature.
19+
1.2.5 K Hoang 28/12/2020 Suppress all possible compiler warnings. Add examples.
20+
*****************************************************************************************************************************/
21+
/*
22+
Currently support
23+
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
24+
- Nucleo-144 (F429ZI, F767ZI)
25+
- Discovery (STM32F746G-DISCOVERY)
26+
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
27+
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
28+
*/
29+
30+
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
31+
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
32+
defined(STM32WB) || defined(STM32MP1) )
33+
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
34+
#endif
35+
36+
#if defined(STM32F0)
37+
#warning STM32F0 board selected
38+
#define BOARD_TYPE "STM32F0"
39+
#elif defined(STM32F1)
40+
#warning STM32F1 board selected
41+
#define BOARD_TYPE "STM32F1"
42+
#elif defined(STM32F2)
43+
#warning STM32F2 board selected
44+
#define BOARD_TYPE "STM32F2"
45+
#elif defined(STM32F3)
46+
#warning STM32F3 board selected
47+
#define BOARD_TYPE "STM32F3"
48+
#elif defined(STM32F4)
49+
#warning STM32F4 board selected
50+
#define BOARD_TYPE "STM32F4"
51+
#elif defined(STM32F7)
52+
#warning STM32F7 board selected
53+
#define BOARD_TYPE "STM32F7"
54+
#elif defined(STM32L0)
55+
#warning STM32L0 board selected
56+
#define BOARD_TYPE "STM32L0"
57+
#elif defined(STM32L1)
58+
#warning STM32L1 board selected
59+
#define BOARD_TYPE "STM32L1"
60+
#elif defined(STM32L4)
61+
#warning STM32L4 board selected
62+
#define BOARD_TYPE "STM32L4"
63+
#elif defined(STM32H7)
64+
#warning STM32H7 board selected
65+
#define BOARD_TYPE "STM32H7"
66+
#elif defined(STM32G0)
67+
#warning STM32G0 board selected
68+
#define BOARD_TYPE "STM32G0"
69+
#elif defined(STM32G4)
70+
#warning STM32G4 board selected
71+
#define BOARD_TYPE "STM32G4"
72+
#elif defined(STM32WB)
73+
#warning STM32WB board selected
74+
#define BOARD_TYPE "STM32WB"
75+
#elif defined(STM32MP1)
76+
#warning STM32MP1 board selected
77+
#define BOARD_TYPE "STM32MP1"
78+
#else
79+
#warning STM32 unknown board selected
80+
#define BOARD_TYPE "STM32 Unknown"
81+
#endif
82+
83+
#ifndef BOARD_NAME
84+
#define BOARD_NAME BOARD_TYPE
85+
#endif
86+
87+
#define SHIELD_TYPE "LAN8742A built-in Ethernet"
88+
89+
#include <LwIP.h>
90+
#include <STM32Ethernet.h>
91+
#include <AsyncWebServer_STM32.h>
92+
93+
// Enter a MAC address and IP address for your controller below.
94+
#define NUMBER_OF_MAC 20
95+
96+
byte mac[][NUMBER_OF_MAC] =
97+
{
98+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
99+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
100+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
101+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
102+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
103+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
104+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
105+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
106+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
107+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
108+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
109+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
110+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
111+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
112+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
113+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
114+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
115+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
116+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
117+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
118+
};
119+
// Select the IP address according to your local network
120+
IPAddress ip(192, 168, 2, 232);
121+
122+
unsigned int analogReadPin [] = { 12, 13, 14 };
123+
124+
#define BUFFER_SIZE 500
125+
126+
#define HTTP_PORT1 8080
127+
#define HTTP_PORT2 8081
128+
#define HTTP_PORT3 8082
129+
130+
AsyncWebServer* server1;
131+
AsyncWebServer* server2;
132+
AsyncWebServer* server3;
133+
134+
AsyncWebServer* multiServer [] = { server1, server2, server3 };
135+
uint16_t http_port [] = { HTTP_PORT1, HTTP_PORT2, HTTP_PORT3 };
136+
137+
#define NUM_SERVERS ( sizeof(multiServer) / sizeof(AsyncWebServer*) )
138+
139+
unsigned int serverIndex;
140+
141+
String createBuffer()
142+
{
143+
char temp[BUFFER_SIZE];
144+
145+
memset(temp, 0, sizeof(temp));
146+
147+
int sec = millis() / 1000;
148+
int min = sec / 60;
149+
int hr = min / 60;
150+
int day = hr / 24;
151+
152+
snprintf(temp, BUFFER_SIZE - 1,
153+
"<html>\
154+
<head>\
155+
<meta http-equiv='refresh' content='5'/>\
156+
<title>%s</title>\
157+
<style>\
158+
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
159+
</style>\
160+
</head>\
161+
<body>\
162+
<h1>Hello from %s</h1>\
163+
<h2>running AsyncWebServer_STM32</h2>\
164+
<h3>on %s</h3>\
165+
<h3>Uptime: %d d %02d:%02d:%02d</h3>\
166+
</body>\
167+
</html>", BOARD_NAME, BOARD_NAME, "Built-in LAN8742A", day, hr, min % 60, sec % 60);
168+
169+
return temp;
170+
}
171+
172+
173+
void handleRoot(AsyncWebServerRequest * request)
174+
{
175+
String message = createBuffer();
176+
request->send(200, F("text/html"), message);
177+
}
178+
179+
String createNotFoundBuffer(AsyncWebServerRequest * request)
180+
{
181+
String message;
182+
183+
message.reserve(500);
184+
185+
message = F("File Not Found\n\n");
186+
187+
message += F("URI: ");
188+
message += request->url();
189+
message += F("\nMethod: ");
190+
message += (request->method() == HTTP_GET) ? F("GET") : F("POST");
191+
message += F("\nArguments: ");
192+
message += request->args();
193+
message += F("\n");
194+
195+
for (uint8_t i = 0; i < request->args(); i++)
196+
{
197+
message += " " + request->argName(i) + ": " + request->arg(i) + "\n";
198+
}
199+
200+
return message;
201+
}
202+
203+
void handleNotFound(AsyncWebServerRequest * request)
204+
{
205+
String message = createNotFoundBuffer(request);
206+
request->send(404, F("text/plain"), message);
207+
}
208+
209+
void setup()
210+
{
211+
Serial.begin(115200);
212+
while (!Serial);
213+
214+
delay(200);
215+
216+
Serial.printf("\nStarting AsyncMultiWebServer_STM32 on %s with %s\n", BOARD_NAME, SHIELD_TYPE);
217+
Serial.println(ASYNC_WEBSERVER_STM32_VERSION);
218+
219+
// start the ethernet connection and the server
220+
// Use random mac
221+
uint16_t index = millis() % NUMBER_OF_MAC;
222+
223+
// Use Static IP
224+
//Ethernet.begin(mac[index], ip);
225+
// Use DHCP dynamic IP and random mac
226+
Ethernet.begin(mac[index]);
227+
228+
Serial.print("\nConnected to network. IP = ");
229+
Serial.println(Ethernet.localIP());
230+
231+
for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++)
232+
{
233+
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]);
234+
235+
if (multiServer[serverIndex])
236+
{
237+
Serial.printf("Initialize multiServer OK, serverIndex = %d, port = %d\n", serverIndex, http_port[serverIndex]);
238+
}
239+
else
240+
{
241+
Serial.printf("Error initialize multiServer, serverIndex = %d\n", serverIndex);
242+
243+
while(1);
244+
}
245+
246+
multiServer[serverIndex]->on("/", HTTP_GET, [](AsyncWebServerRequest * request)
247+
{
248+
handleRoot(request);
249+
});
250+
251+
multiServer[serverIndex]->on("/hello", HTTP_GET, [](AsyncWebServerRequest * request)
252+
{
253+
String message = F("Hello from AsyncWebServer using built-in LAN8742A Ethernet, running on ");
254+
message += BOARD_NAME;
255+
256+
request->send(200, "text/plain", message);
257+
});
258+
259+
multiServer[serverIndex]->onNotFound([](AsyncWebServerRequest * request)
260+
{
261+
handleNotFound(request);
262+
});
263+
264+
multiServer[serverIndex]->begin();
265+
266+
Serial.printf("HTTP server started at ports %d\n", http_port[serverIndex]);
267+
}
268+
}
269+
270+
void loop()
271+
{
272+
}

0 commit comments

Comments
 (0)