1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-23 08:45:22 +03:00

Migrate from astyle to clang-format (#8464)

This commit is contained in:
Maxim Prokhorov
2022-02-20 19:23:33 +03:00
committed by Max Prokhorov
parent 46190b61f1
commit 19b7a29720
241 changed files with 15925 additions and 16197 deletions

View File

@ -12,7 +12,7 @@ using namespace NetCapture;
#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#define STAPSK "your-password"
#endif
const char* ssid = STASSID;
@ -20,43 +20,36 @@ const char* password = STAPSK;
Netdump nd;
//FS* filesystem = &SPIFFS;
// FS* filesystem = &SPIFFS;
FS* filesystem = &LittleFS;
ESP8266WebServer webServer(80); // Used for sending commands
WiFiServer tcpServer(8000); // Used to show netcat option.
File tracefile;
ESP8266WebServer webServer(80); // Used for sending commands
WiFiServer tcpServer(8000); // Used to show netcat option.
File tracefile;
std::map<PacketType, int> packetCount;
enum class SerialOption : uint8_t {
AllFull,
LocalNone,
HTTPChar
};
enum class SerialOption : uint8_t { AllFull,
LocalNone,
HTTPChar };
void startSerial(SerialOption option) {
switch (option) {
case SerialOption::AllFull : //All Packets, show packet summary.
case SerialOption::AllFull: // All Packets, show packet summary.
nd.printDump(Serial, Packet::PacketDetail::FULL);
break;
case SerialOption::LocalNone : // Only local IP traffic, full details
nd.printDump(Serial, Packet::PacketDetail::NONE,
[](Packet n) {
case SerialOption::LocalNone: // Only local IP traffic, full details
nd.printDump(Serial, Packet::PacketDetail::NONE, [](Packet n) {
return (n.hasIP(WiFi.localIP()));
}
);
});
break;
case SerialOption::HTTPChar : // Only HTTP traffic, show packet content as chars
nd.printDump(Serial, Packet::PacketDetail::CHAR,
[](Packet n) {
case SerialOption::HTTPChar: // Only HTTP traffic, show packet content as chars
nd.printDump(Serial, Packet::PacketDetail::CHAR, [](Packet n) {
return (n.isHTTP());
}
);
});
break;
default :
Serial.printf("No valid SerialOption provided\r\n");
default: Serial.printf("No valid SerialOption provided\r\n");
};
}
@ -80,49 +73,39 @@ void setup(void) {
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed, stopping sketch");
while (1) {
delay(1000);
}
while (1) { delay(1000); }
}
if (!MDNS.begin("netdumphost")) {
Serial.println("Error setting up MDNS responder!");
}
if (!MDNS.begin("netdumphost")) { Serial.println("Error setting up MDNS responder!"); }
filesystem->begin();
webServer.on("/list",
[]() {
webServer.on("/list", []() {
Dir dir = filesystem->openDir("/");
String d = "<h1>File list</h1>";
while (dir.next()) {
d.concat("<li>" + dir.fileName() + "</li>");
}
webServer.send(200, "text.html", d);
}
);
});
webServer.on("/req",
[]() {
webServer.on("/req", []() {
static int rq = 0;
String a = "<h1>You are connected, Number of requests = " + String(rq++) + "</h1>";
webServer.send(200, "text/html", a);
}
);
});
webServer.on("/reset",
[]() {
webServer.on("/reset", []() {
nd.reset();
tracefile.close();
tcpServer.close();
webServer.send(200, "text.html", "<h1>Netdump session reset</h1>");
}
);
});
webServer.serveStatic("/", *filesystem, "/");
webServer.begin();
startSerial(SerialOption::AllFull); // Serial output examples, use enum SerialOption for selection
startSerial(SerialOption::AllFull); // Serial output examples, use enum SerialOption for selection
// startTcpDump(); // tcpdump option
// startTracefile(); // output to SPIFFS or LittleFS
@ -132,18 +115,18 @@ void setup(void) {
nd.setCallback(
[](Packet p)
{
Serial.printf("PKT : %s : ",p.sourceIP().toString().c_str());
for ( auto pp : p.allPacketTypes())
{
Serial.printf("%s ",pp.toString().c_str());
packetCount[pp]++;
}
Serial.printf("\r\n CNT ");
for (auto pc : packetCount)
{
Serial.printf("%s %d ", pc.first.toString().c_str(),pc.second);
}
Serial.printf("\r\n");
Serial.printf("PKT : %s : ",p.sourceIP().toString().c_str());
for ( auto pp : p.allPacketTypes())
{
Serial.printf("%s ",pp.toString().c_str());
packetCount[pp]++;
}
Serial.printf("\r\n CNT ");
for (auto pc : packetCount)
{
Serial.printf("%s %d ", pc.first.toString().c_str(),pc.second);
}
Serial.printf("\r\n");
}
);
*/
@ -153,4 +136,3 @@ void loop(void) {
webServer.handleClient();
MDNS.update();
}