mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Migrate from astyle to clang-format (#8464)
This commit is contained in:
committed by
Max Prokhorov
parent
46190b61f1
commit
19b7a29720
@ -39,7 +39,7 @@
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
const char *ssid = STASSID;
|
||||
@ -138,11 +138,11 @@ GBEnkz4KpKv7TkHoW+j7F5EMcLcSrUIpyw==
|
||||
|
||||
#endif
|
||||
|
||||
#define CACHE_SIZE 5 // Number of sessions to cache.
|
||||
#define USE_CACHE // Enable SSL session caching.
|
||||
// Caching SSL sessions shortens the length of the SSL handshake.
|
||||
// You can see the performance improvement by looking at the
|
||||
// Network tab of the developer tools of your browser.
|
||||
#define CACHE_SIZE 5 // Number of sessions to cache.
|
||||
#define USE_CACHE // Enable SSL session caching.
|
||||
// Caching SSL sessions shortens the length of the SSL handshake.
|
||||
// You can see the performance improvement by looking at the
|
||||
// Network tab of the developer tools of your browser.
|
||||
//#define DYNAMIC_CACHE // Whether to dynamically allocate the cache.
|
||||
|
||||
#if defined(USE_CACHE) && defined(DYNAMIC_CACHE)
|
||||
@ -181,7 +181,7 @@ void setup() {
|
||||
#ifndef USE_EC
|
||||
server.setRSACert(serverCertList, serverPrivKey);
|
||||
#else
|
||||
server.setECCert(serverCertList, BR_KEYTYPE_KEYX|BR_KEYTYPE_SIGN, serverPrivKey);
|
||||
server.setECCert(serverCertList, BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN, serverPrivKey);
|
||||
#endif
|
||||
|
||||
// Set the server's cache
|
||||
@ -193,31 +193,28 @@ void setup() {
|
||||
server.begin();
|
||||
}
|
||||
|
||||
static const char *HTTP_RES =
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Content-Length: 62\r\n"
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n"
|
||||
"\r\n"
|
||||
"<html>\r\n"
|
||||
"<body>\r\n"
|
||||
"<p>Hello from ESP8266!</p>\r\n"
|
||||
"</body>\r\n"
|
||||
"</html>\r\n";
|
||||
static const char *HTTP_RES = "HTTP/1.0 200 OK\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Content-Length: 62\r\n"
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n"
|
||||
"\r\n"
|
||||
"<html>\r\n"
|
||||
"<body>\r\n"
|
||||
"<p>Hello from ESP8266!</p>\r\n"
|
||||
"</body>\r\n"
|
||||
"</html>\r\n";
|
||||
|
||||
void loop() {
|
||||
static int cnt;
|
||||
BearSSL::WiFiClientSecure incoming = server.accept();
|
||||
if (!incoming) {
|
||||
return;
|
||||
}
|
||||
Serial.printf("Incoming connection...%d\n",cnt++);
|
||||
|
||||
if (!incoming) { return; }
|
||||
Serial.printf("Incoming connection...%d\n", cnt++);
|
||||
|
||||
// Ugly way to wait for \r\n (i.e. end of HTTP request which we don't actually parse here)
|
||||
uint32_t timeout=millis() + 1000;
|
||||
uint32_t timeout = millis() + 1000;
|
||||
int lcwn = 0;
|
||||
for (;;) {
|
||||
unsigned char x=0;
|
||||
unsigned char x = 0;
|
||||
if ((millis() > timeout) || (incoming.available() && incoming.read(&x, 1) < 0)) {
|
||||
incoming.stop();
|
||||
Serial.printf("Connection error, closed\n");
|
||||
@ -228,14 +225,12 @@ void loop() {
|
||||
} else if (x == 0x0D) {
|
||||
continue;
|
||||
} else if (x == 0x0A) {
|
||||
if (lcwn) {
|
||||
break;
|
||||
}
|
||||
if (lcwn) { break; }
|
||||
lcwn = 1;
|
||||
} else
|
||||
lcwn = 0;
|
||||
}
|
||||
incoming.write((uint8_t*)HTTP_RES, strlen(HTTP_RES));
|
||||
incoming.write((uint8_t *)HTTP_RES, strlen(HTTP_RES));
|
||||
incoming.flush();
|
||||
incoming.stop();
|
||||
Serial.printf("Connection closed.\n");
|
||||
|
Reference in New Issue
Block a user