Skip to content

Commit

Permalink
Compatible with ESP32 up to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyu-Zhao committed Aug 11, 2022
1 parent f47a59b commit ebebdea
Show file tree
Hide file tree
Showing 136 changed files with 110,902 additions and 84,846 deletions.
168 changes: 168 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
...

17 changes: 17 additions & 0 deletions .github/workflows/Arduino-Lint-Check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Arduino Lint Check
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
compliance: strict
project-type: all
8 changes: 4 additions & 4 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
strategy:
matrix:
path:
- check: './example' # path to include
exclude: './examples/Advanced/Display' # path to exclude
- check: './' # path to include
exclude: '(Fonts|utility)' # path to exclude
# - check: 'src'
# exclude: ''
# exclude: '(Fonts)' # Exclude file paths containing "Fonts"
# - check: 'examples'
# exclude: ''
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.5.0
uses: jidicula/clang-format-action@v4.8.0
with:
clang-format-version: '13'
check-path: ${{ matrix.path['check'] }}
Expand Down
4 changes: 3 additions & 1 deletion examples/Advanced/HallSensor/HallSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ void showSignal() {
}
}

void loop(void) { showSignal(); }
void loop(void) {
showSignal();
}
3 changes: 2 additions & 1 deletion examples/Advanced/MultiTask/MultiTask.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ void setup() {
xTaskCreatePinnedToCore(task3, "task3", 4096, NULL, 3, NULL, 0);
}

void loop() {}
void loop() {
}
3 changes: 2 additions & 1 deletion examples/Advanced/QRCode/QRCode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ void setup() {
// characters. 请根据字符数量选择合适的二维码版本
}

void loop() {}
void loop() {
}
3 changes: 2 additions & 1 deletion examples/Advanced/Storage/Counter/Counter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ void setup() {
delay(10000); // delay 10. 延迟10s
ESP.restart(); // Restart. 重启
}
void loop() {}
void loop() {
}
3 changes: 2 additions & 1 deletion examples/Advanced/Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ void setup() {
}
}

void loop() {}
void loop() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ void setup() {
}
}

void loop() {}
void loop() {
}
34 changes: 25 additions & 9 deletions examples/Advanced/WIFI/WiFiSetting/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ WebServer::WebServer(IPAddress addr, int port)
_headerKeysCount(0),
_currentHeaders(0),
_contentLength(0),
_chunked(false) {}
_chunked(false) {
}

WebServer::WebServer(int port)
: _server(port),
Expand All @@ -69,7 +70,8 @@ WebServer::WebServer(int port)
_headerKeysCount(0),
_currentHeaders(0),
_contentLength(0),
_chunked(false) {}
_chunked(false) {
}

WebServer::~WebServer() {
if (_currentHeaders) delete[] _currentHeaders;
Expand Down Expand Up @@ -227,9 +229,13 @@ void WebServer::handleClient() {
}
}

void WebServer::close() { _server.end(); }
void WebServer::close() {
_server.end();
}

void WebServer::stop() { close(); }
void WebServer::stop() {
close();
}

void WebServer::sendHeader(const String& name, const String& value,
bool first) {
Expand Down Expand Up @@ -378,7 +384,9 @@ String WebServer::argName(int i) {
return String();
}

int WebServer::args() { return _currentArgCount; }
int WebServer::args() {
return _currentArgCount;
}

bool WebServer::hasArg(String name) {
for (int i = 0; i < _currentArgCount; ++i) {
Expand Down Expand Up @@ -416,7 +424,9 @@ String WebServer::headerName(int i) {
return String();
}

int WebServer::headers() { return _headerKeysCount; }
int WebServer::headers() {
return _headerKeysCount;
}

bool WebServer::hasHeader(String name) {
for (int i = 0; i < _headerKeysCount; ++i) {
Expand All @@ -427,11 +437,17 @@ bool WebServer::hasHeader(String name) {
return false;
}

String WebServer::hostHeader() { return _hostHeader; }
String WebServer::hostHeader() {
return _hostHeader;
}

void WebServer::onFileUpload(THandlerFunction fn) { _fileUploadHandler = fn; }
void WebServer::onFileUpload(THandlerFunction fn) {
_fileUploadHandler = fn;
}

void WebServer::onNotFound(THandlerFunction fn) { _notFoundHandler = fn; }
void WebServer::onNotFound(THandlerFunction fn) {
_notFoundHandler = fn;
}

void WebServer::_handleRequest() {
bool handled = false;
Expand Down
25 changes: 17 additions & 8 deletions examples/Advanced/WIFI/WiFiSetting/WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE };

#define HTTP_DOWNLOAD_UNIT_SIZE 1460
#define HTTP_UPLOAD_BUFLEN 2048
#define HTTP_MAX_DATA_WAIT 1000 // ms to wait for the client to send the
// request
#define HTTP_MAX_POST_WAIT 1000 // ms to wait for POST data to arrive
#define HTTP_MAX_SEND_WAIT 5000 // ms to wait for data chunk to be ACKed
#define HTTP_MAX_DATA_WAIT \
1000 // ms to wait for the client to send the
// request
#define HTTP_MAX_POST_WAIT 1000 // ms to wait for POST data to arrive
#define HTTP_MAX_SEND_WAIT 5000 // ms to wait for data chunk to be ACKed
#define HTTP_MAX_CLOSE_WAIT \
2000 // ms to wait for the client to close the connection

Expand Down Expand Up @@ -103,10 +104,18 @@ class WebServer {
// assigned
void onFileUpload(THandlerFunction fn); // handle file uploads

String uri() { return _currentUri; }
HTTPMethod method() { return _currentMethod; }
WiFiClient client() { return _currentClient; }
HTTPUpload& upload() { return _currentUpload; }
String uri() {
return _currentUri;
}
HTTPMethod method() {
return _currentMethod;
}
WiFiClient client() {
return _currentClient;
}
HTTPUpload& upload() {
return _currentUpload;
}

String arg(String name); // get request argument value by name
String arg(int i); // get request argument value by number
Expand Down
Loading

0 comments on commit ebebdea

Please sign in to comment.