First working version
initial Running vversion
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
# Clang format version: 18.1.3
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCaseColons: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Always
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakArrays: false
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 160
|
||||
CommentPragmas: ""
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: ^"(llvm|llvm-c|clang|clang-c)/
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: ^(<|"(gtest|gmock|isl|json)/)
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: .*
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: ""
|
||||
IncludeIsMainSourceRegex: ""
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: true
|
||||
IndentExternBlock: NoIndent
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: false
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: true
|
||||
InsertBraces: true
|
||||
InsertNewlineAtEOF: true
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtEOF: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
Language: Cpp
|
||||
LineEnding: LF
|
||||
MacroBlockBegin: ""
|
||||
MacroBlockEnd: ""
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PPIndentWidth: -1
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakScopeResolution: 500
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SkipMacroDefinitionBody: false
|
||||
SortIncludes: Never
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: true
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
InConditionalStatements: false
|
||||
InCStyleCasts: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 2
|
||||
UseTab: Never
|
||||
VerilogBreakBetweenInstancePorts: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
BracedInitializerIndentWidth: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
[codespell]
|
||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
|
||||
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
|
||||
ignore-words-list = ba,licence
|
||||
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore
|
||||
builtin = clear,informal,en-GB_to_en-US
|
||||
check-filenames =
|
||||
check-hidden =
|
||||
@@ -0,0 +1,60 @@
|
||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/.editorconfig
|
||||
# See: https://editorconfig.org/
|
||||
# The formatting style defined in this file is the official standardized style to be used in all Arduino Tooling
|
||||
# projects and should not be modified.
|
||||
# Note: indent style for each file type is defined even when it matches the universal config in order to make it clear
|
||||
# that this type has an official style.
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{adoc,asc,asciidoc}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.{bash,sh}]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.{go,mod}]
|
||||
indent_style = tab
|
||||
|
||||
[*.java]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.{js,jsx,json,jsonc,json5,ts,tsx}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.{md,mdx,mkdn,mdown,markdown}]
|
||||
indent_size = unset
|
||||
indent_style = space
|
||||
|
||||
[*.proto]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.svg]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[{.gitconfig,.gitmodules}]
|
||||
indent_style = tab
|
||||
@@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
.lh
|
||||
/.pio
|
||||
/.vscode
|
||||
|
||||
/logs
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
FROM gitpod/workspace-python-3.11
|
||||
USER gitpod
|
||||
@@ -0,0 +1,9 @@
|
||||
tasks:
|
||||
- command: pip install --upgrade pip && pip install -U platformio && platformio run
|
||||
|
||||
image:
|
||||
file: .gitpod.Dockerfile
|
||||
|
||||
vscode:
|
||||
extensions:
|
||||
- shardulm94.trailing-spaces
|
||||
@@ -0,0 +1,42 @@
|
||||
exclude: |
|
||||
(?x)(
|
||||
^\.github\/|
|
||||
LICENSE\.md$
|
||||
)
|
||||
|
||||
default_language_version:
|
||||
# force all unspecified python hooks to run python3
|
||||
python: python3
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: "v5.0.0"
|
||||
hooks:
|
||||
# Generic checks
|
||||
- id: check-case-conflict
|
||||
- id: check-symlinks
|
||||
- id: debug-statements
|
||||
- id: destroyed-symlinks
|
||||
- id: detect-private-key
|
||||
- id: end-of-file-fixer
|
||||
exclude: ^.*\.(bin|BIN)$
|
||||
- id: mixed-line-ending
|
||||
args: [--fix=lf]
|
||||
- id: trailing-whitespace
|
||||
args: [--markdown-linebreak-ext=md]
|
||||
exclude: ^platformio\.ini$
|
||||
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: "v2.3.0"
|
||||
hooks:
|
||||
# Spell checking
|
||||
- id: codespell
|
||||
exclude: ^.*\.(svd|SVD)$
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: "v18.1.3"
|
||||
hooks:
|
||||
# C/C++ formatting
|
||||
- id: clang-format
|
||||
types_or: [c, c++]
|
||||
exclude: ^.*\/build_opt\.h$
|
||||
@@ -0,0 +1,15 @@
|
||||
set(COMPONENT_SRCDIRS
|
||||
"src"
|
||||
)
|
||||
|
||||
set(COMPONENT_ADD_INCLUDEDIRS
|
||||
"src"
|
||||
)
|
||||
|
||||
set(COMPONENT_REQUIRES
|
||||
"arduino-esp32"
|
||||
)
|
||||
|
||||
register_component()
|
||||
|
||||
target_compile_options(${COMPONENT_TARGET} PRIVATE -fno-rtti)
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socioeconomic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
https://sidweb.nl/cms3/en/contact.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -0,0 +1,30 @@
|
||||
menu "AsyncTCP Configuration"
|
||||
|
||||
choice ASYNC_TCP_RUNNING_CORE
|
||||
bool "Core on which AsyncTCP's thread is running"
|
||||
default ASYNC_TCP_RUN_CORE1
|
||||
help
|
||||
Select on which core AsyncTCP is running
|
||||
|
||||
config ASYNC_TCP_RUN_CORE0
|
||||
bool "CORE 0"
|
||||
config ASYNC_TCP_RUN_CORE1
|
||||
bool "CORE 1"
|
||||
config ASYNC_TCP_RUN_NO_AFFINITY
|
||||
bool "BOTH"
|
||||
|
||||
endchoice
|
||||
|
||||
config ASYNC_TCP_RUNNING_CORE
|
||||
int
|
||||
default 0 if ASYNC_TCP_RUN_CORE0
|
||||
default 1 if ASYNC_TCP_RUN_CORE1
|
||||
default -1 if ASYNC_TCP_RUN_NO_AFFINITY
|
||||
|
||||
config ASYNC_TCP_USE_WDT
|
||||
bool "Enable WDT for the AsyncTCP task"
|
||||
default "y"
|
||||
help
|
||||
Enable WDT for the AsyncTCP task, so it will trigger if a handler is locking the thread.
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -0,0 +1,55 @@
|
||||

|
||||
|
||||
# AsyncTCP
|
||||
|
||||
[](https://opensource.org/license/lgpl-3-0/)
|
||||
[](https://github.com/ESP32Async/AsyncTCP/actions/workflows/ci.yml)
|
||||
[](https://registry.platformio.org/libraries/ESP32Async/AsyncTCP)
|
||||
|
||||
Discord Server: [https://discord.gg/X7zpGdyUcY](https://discord.gg/X7zpGdyUcY)
|
||||
|
||||
## Async TCP Library for ESP32 Arduino
|
||||
|
||||
This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP32 MCUs.
|
||||
|
||||
This library is the base for [ESPAsyncWebServer](https://github.com/ESP32Async/ESPAsyncWebServer)
|
||||
|
||||
## How to install
|
||||
|
||||
The library can be downloaded from the releases page at [https://github.com/ESP32Async/AsyncTCP/releases](https://github.com/ESP32Async/AsyncTCP/releases).
|
||||
|
||||
It is also deployed in these registries:
|
||||
|
||||
- Arduino Library Registry: [https://github.com/arduino/library-registry](https://github.com/arduino/library-registry)
|
||||
|
||||
- ESP Component Registry [https://components.espressif.com/components/esp32async/asynctcp/](https://components.espressif.com/components/esp32async/asynctcp/)
|
||||
|
||||
- PlatformIO Registry: [https://registry.platformio.org/libraries/esp32async/AsyncTCP](https://registry.platformio.org/libraries/esp32async/AsyncTCP)
|
||||
|
||||
- Use: `lib_deps=ESP32Async/AsyncTCP` to point to latest version
|
||||
- Use: `lib_deps=ESP32Async/AsyncTCP @ ^<x.y.z>` to point to latest version with the same major version
|
||||
- Use: `lib_deps=ESP32Async/AsyncTCP @ <x.y.z>` to always point to the same version (reproductible build)
|
||||
|
||||
## AsyncClient and AsyncServer
|
||||
|
||||
The base classes on which everything else is built. They expose all possible scenarios, but are really raw and require more skills to use.
|
||||
|
||||
## Important recommendations
|
||||
|
||||
Most of the crashes are caused by improper configuration of the library for the project.
|
||||
Here are some recommendations to avoid them.
|
||||
|
||||
I personally use the following configuration in my projects:
|
||||
|
||||
```c++
|
||||
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000 // (keep default)
|
||||
-D CONFIG_ASYNC_TCP_PRIORITY=10 // (keep default)
|
||||
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64 // (keep default)
|
||||
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 // force async_tcp task to be on same core as the app (default is core 0)
|
||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096 // reduce the stack size (default is 16K)
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
- ESP32
|
||||
- Arduino Core 2.x and 3.x
|
||||
@@ -0,0 +1,25 @@
|
||||
board_manager:
|
||||
additional_urls:
|
||||
- https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
|
||||
directories:
|
||||
builtin.libraries: ./src/
|
||||
build_cache:
|
||||
compilations_before_purge: 10
|
||||
ttl: 720h0m0s
|
||||
daemon:
|
||||
port: "50051"
|
||||
library:
|
||||
enable_unsafe_install: false
|
||||
logging:
|
||||
file: ""
|
||||
format: text
|
||||
level: info
|
||||
metrics:
|
||||
addr: :9090
|
||||
enabled: true
|
||||
output:
|
||||
no_color: false
|
||||
sketch:
|
||||
always_export_binaries: false
|
||||
updater:
|
||||
enable_notification: true
|
||||
@@ -0,0 +1,25 @@
|
||||
board_manager:
|
||||
additional_urls:
|
||||
- https://espressif.github.io/arduino-esp32/package_esp32_index.json
|
||||
directories:
|
||||
builtin.libraries: ./src/
|
||||
build_cache:
|
||||
compilations_before_purge: 10
|
||||
ttl: 720h0m0s
|
||||
daemon:
|
||||
port: "50051"
|
||||
library:
|
||||
enable_unsafe_install: false
|
||||
logging:
|
||||
file: ""
|
||||
format: text
|
||||
level: info
|
||||
metrics:
|
||||
addr: :9090
|
||||
enabled: true
|
||||
output:
|
||||
no_color: false
|
||||
sketch:
|
||||
always_export_binaries: false
|
||||
updater:
|
||||
enable_notification: true
|
||||
@@ -0,0 +1,3 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS := src
|
||||
COMPONENT_SRCDIRS := src
|
||||
CXXFLAGS += -fno-rtti
|
||||
@@ -0,0 +1,168 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
/*
|
||||
This example demonstrates how to send data to a remote server asynchronously.
|
||||
Run on the remote computer: nc -l -p 1234
|
||||
|
||||
You should see in the logs:
|
||||
|
||||
Connected!
|
||||
Will send 5760 bytes...
|
||||
Acked 1436 bytes in 19 ms
|
||||
Will send 1436 bytes...
|
||||
Acked 1436 bytes in 2 ms
|
||||
Will send 996 bytes...
|
||||
Waiting for acks...
|
||||
Acked 1436 bytes in 1 ms
|
||||
Acked 1436 bytes in 5 ms
|
||||
Acked 1452 bytes in 17 ms
|
||||
Acked 996 bytes in 28 ms
|
||||
Buffer received - next send in 2 sec
|
||||
Will send 5760 bytes...
|
||||
Acked 1436 bytes in 14 ms
|
||||
Will send 1436 bytes...
|
||||
Acked 1436 bytes in 2 ms
|
||||
Acked 1436 bytes in 0 ms
|
||||
Acked 1452 bytes in 1 ms
|
||||
Will send 996 bytes...
|
||||
Waiting for acks...
|
||||
Acked 1436 bytes in 3 ms
|
||||
Acked 996 bytes in 18 ms
|
||||
Buffer received - next send in 2 sec
|
||||
|
||||
And in the remote terminal 3072 characters sent [......... ...........] and so on.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <StreamString.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#define WIFI_SSID "IoT"
|
||||
#define WIFI_PASSWORD ""
|
||||
|
||||
#define REMOTE_IP "192.168.125.116"
|
||||
#define REMOTE_PORT 1234
|
||||
|
||||
#define BUFFER_SIZE 8 * 1024
|
||||
|
||||
static char buffer[BUFFER_SIZE] = {0};
|
||||
static size_t bufferPos = 0;
|
||||
|
||||
// 0 == disconnected
|
||||
// 1 == connecting
|
||||
// 2 == connected
|
||||
static uint8_t state = 0;
|
||||
|
||||
// number of bytes waiting for a ack
|
||||
static size_t waitingAck = 0;
|
||||
|
||||
static AsyncClient client;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// connect to WiFi
|
||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
}
|
||||
Serial.println("Connected to WiFi!");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
// fill buffer
|
||||
buffer[0] = '[';
|
||||
for (size_t i = 1; i < BUFFER_SIZE - 1; i++) {
|
||||
buffer[i] = '.';
|
||||
}
|
||||
buffer[BUFFER_SIZE - 1] = ']';
|
||||
|
||||
// register a callback when the client disconnects
|
||||
client.onDisconnect([](void *arg, AsyncClient *client) {
|
||||
Serial.printf("Disconnected.\n");
|
||||
state = 0;
|
||||
});
|
||||
|
||||
// register a callback when an error occurs
|
||||
client.onError([](void *arg, AsyncClient *client, int8_t error) {
|
||||
Serial.printf("Error: %s\n", client->errorToString(error));
|
||||
});
|
||||
|
||||
// register a callback when data arrives, to accumulate it
|
||||
client.onData([](void *arg, AsyncClient *client, void *data, size_t len) {
|
||||
Serial.printf("Received %u bytes...\n", len);
|
||||
Serial.write((uint8_t *)data, len);
|
||||
});
|
||||
|
||||
// register a callback when we are connected
|
||||
client.onConnect([](void *arg, AsyncClient *client) {
|
||||
Serial.printf("Connected!\n");
|
||||
state = 2;
|
||||
});
|
||||
|
||||
client.onAck([](void *arg, AsyncClient *client, size_t len, uint32_t time) {
|
||||
Serial.printf("Acked %u bytes in %" PRIu32 " ms\n", len, time);
|
||||
assert(waitingAck >= len);
|
||||
waitingAck -= len;
|
||||
});
|
||||
|
||||
client.setRxTimeout(20000);
|
||||
client.setNoDelay(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
switch (state) {
|
||||
case 0:
|
||||
{
|
||||
Serial.printf("Connecting...\n");
|
||||
if (!client.connect(REMOTE_IP, REMOTE_PORT)) {
|
||||
Serial.printf("Failed to connect!\n");
|
||||
delay(1000); // to not flood logs
|
||||
} else {
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
Serial.printf("Still connecting...\n");
|
||||
delay(500); // to not flood logs
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
// fill PCB space until we can
|
||||
size_t willSend;
|
||||
while (bufferPos < BUFFER_SIZE && (willSend = client.write(buffer + bufferPos, BUFFER_SIZE - bufferPos))) {
|
||||
Serial.printf("Will send %u bytes...\n", willSend);
|
||||
bufferPos += willSend;
|
||||
waitingAck += willSend;
|
||||
}
|
||||
|
||||
// we have sent the whole buffer ?
|
||||
if (bufferPos >= BUFFER_SIZE) {
|
||||
// wait for acks, or send again after 2 sec
|
||||
if (waitingAck) {
|
||||
Serial.printf("Waiting for acks...\n");
|
||||
delay(100);
|
||||
} else {
|
||||
Serial.printf("Buffer received - next send in 2 sec\n");
|
||||
delay(2000);
|
||||
bufferPos = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
// Run a server at the root of the project with:
|
||||
// > python3 -m http.server 3333
|
||||
// Now you can open a browser and test it works by visiting http://192.168.125.122:3333/ or http://192.168.125.122:3333/README.md
|
||||
#define HOST "192.168.125.122"
|
||||
#define PORT 3333
|
||||
|
||||
// WiFi SSID to connect to
|
||||
#define WIFI_SSID "IoT"
|
||||
|
||||
// 16 slots on esp32 (CONFIG_LWIP_MAX_ACTIVE_TCP)
|
||||
#define MAX_CLIENTS CONFIG_LWIP_MAX_ACTIVE_TCP
|
||||
// #define MAX_CLIENTS 1
|
||||
|
||||
size_t permits = MAX_CLIENTS;
|
||||
|
||||
void makeRequest() {
|
||||
if (!permits) {
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.printf("** permits: %d\n", permits);
|
||||
|
||||
AsyncClient *client = new AsyncClient;
|
||||
|
||||
client->onError([](void *arg, AsyncClient *client, int8_t error) {
|
||||
Serial.printf("** error occurred %s \n", client->errorToString(error));
|
||||
client->close(true);
|
||||
delete client;
|
||||
});
|
||||
|
||||
client->onConnect([](void *arg, AsyncClient *client) {
|
||||
permits--;
|
||||
Serial.printf("** client has been connected: %" PRIu16 "\n", client->localPort());
|
||||
|
||||
client->onDisconnect([](void *arg, AsyncClient *client) {
|
||||
Serial.printf("** client has been disconnected: %" PRIu16 "\n", client->localPort());
|
||||
client->close(true);
|
||||
delete client;
|
||||
|
||||
permits++;
|
||||
makeRequest();
|
||||
});
|
||||
|
||||
client->onData([](void *arg, AsyncClient *client, void *data, size_t len) {
|
||||
Serial.printf("** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
|
||||
});
|
||||
|
||||
client->write("GET /README.md HTTP/1.1\r\nHost: " HOST "\r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
|
||||
});
|
||||
|
||||
if (client->connect(HOST, PORT)) {
|
||||
} else {
|
||||
Serial.println("** connection failed");
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
continue;
|
||||
}
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(WIFI_SSID);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("** connected to WiFi");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
for (size_t i = 0; i < MAX_CLIENTS; i++) {
|
||||
makeRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(1000);
|
||||
Serial.printf("** free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <StreamString.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#define WIFI_SSID "IoT"
|
||||
#define WIFI_PASSWORD ""
|
||||
|
||||
void fetchAsync(const char *host, std::function<void(const StreamString *)> onDone) {
|
||||
Serial.printf("[%s] Fetching: http://%s...\n", host, host);
|
||||
|
||||
// buffer where we will accumulate the received data
|
||||
StreamString *content = new StreamString();
|
||||
|
||||
// reserve enough space to avoid reallocations
|
||||
content->reserve(32 * 1024);
|
||||
|
||||
// create a new client
|
||||
AsyncClient *client = new AsyncClient();
|
||||
|
||||
// register a callback when the client disconnects
|
||||
client->onDisconnect([content, host, onDone](void *arg, AsyncClient *client) {
|
||||
Serial.printf("[%s] Disconnected.\n", host);
|
||||
onDone(content);
|
||||
delete client;
|
||||
delete content;
|
||||
});
|
||||
|
||||
// register a callback when an error occurs
|
||||
client->onError([host, onDone](void *arg, AsyncClient *client, int8_t error) {
|
||||
Serial.printf("[%s] Error: %s\n", host, client->errorToString(error));
|
||||
});
|
||||
|
||||
// register a callback when data arrives, to accumulate it
|
||||
client->onData([host, content](void *arg, AsyncClient *client, void *data, size_t len) {
|
||||
Serial.printf("[%s] Received %u bytes...\n", host, len);
|
||||
content->write((const uint8_t *)data, len);
|
||||
});
|
||||
|
||||
// register a callback when we are connected
|
||||
client->onConnect([host](void *arg, AsyncClient *client) {
|
||||
Serial.printf("[%s] Connected!\n", host);
|
||||
|
||||
// send request
|
||||
client->write("GET / HTTP/1.1\r\n");
|
||||
client->write("Host: ");
|
||||
client->write(host);
|
||||
client->write("\r\n");
|
||||
client->write("User-Agent: ESP32\r\n");
|
||||
client->write("Connection: close\r\n");
|
||||
client->write("\r\n");
|
||||
});
|
||||
|
||||
Serial.printf("[%s] Connecting...\n", host);
|
||||
|
||||
client->setRxTimeout(20000);
|
||||
// client->setAckTimeout(10000);
|
||||
client->setNoDelay(true);
|
||||
|
||||
if (!client->connect(host, 80)) {
|
||||
Serial.printf("[%s] Failed to connect!\n", host);
|
||||
delete client;
|
||||
delete content;
|
||||
onDone(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// connect to WiFi
|
||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
}
|
||||
Serial.println("Connected to WiFi!");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
// fetch asynchronously 2 websites:
|
||||
|
||||
// equivalent to curl -v --raw http://www.google.com/
|
||||
fetchAsync("www.google.com", [](const StreamString *content) {
|
||||
if (content) {
|
||||
Serial.printf("[www.google.com] Fetched website:\n%s\n", content->c_str());
|
||||
} else {
|
||||
Serial.println("[www.google.com] Failed to fetch website!");
|
||||
}
|
||||
});
|
||||
|
||||
// equivalent to curl -v --raw http://www.time.org/
|
||||
fetchAsync("www.time.org", [](const StreamString *content) {
|
||||
if (content) {
|
||||
Serial.printf("[www.time.org] Fetched website:\n%s\n", content->c_str());
|
||||
} else {
|
||||
Serial.println("[www.time.org] Failed to fetch website!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
description: "Async TCP Library for ESP32 Arduino"
|
||||
url: "https://github.com/ESP32Async/AsyncTCP"
|
||||
license: "LGPL-3.0-or-later"
|
||||
tags:
|
||||
- arduino
|
||||
files:
|
||||
exclude:
|
||||
- "idf_component_examples/"
|
||||
- "idf_component_examples/**/*"
|
||||
- "examples/"
|
||||
- "examples/**/*"
|
||||
- ".gitignore"
|
||||
- ".clang-format"
|
||||
- ".gitpod.Dockerfile"
|
||||
- ".gitpod.yml"
|
||||
- ".codespellrc"
|
||||
- ".editorconfig"
|
||||
- ".pre-commit-config.yaml"
|
||||
- "arduino-cli.yaml"
|
||||
- "arduino-cli-dev.yaml"
|
||||
- "CODE_OF_CONDUCT.md"
|
||||
- "component.mk"
|
||||
- "library.json"
|
||||
- "library.properties"
|
||||
- "platformio.ini"
|
||||
- "pre-commit.requirements.txt"
|
||||
dependencies:
|
||||
espressif/arduino-esp32:
|
||||
version: "^3.1.1"
|
||||
require: public
|
||||
examples:
|
||||
- path: ./idf_component_examples/client
|
||||
@@ -0,0 +1,8 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(main)
|
||||
@@ -0,0 +1 @@
|
||||
### Basic example to show how AsyncTCP client works
|
||||
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "main.cpp"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,6 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
esp32async/asynctcp:
|
||||
version: "*"
|
||||
override_path: "../../../"
|
||||
pre_release: true
|
||||
@@ -0,0 +1,80 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "AsyncTCP.h"
|
||||
#include "WiFi.h"
|
||||
|
||||
// Run a server at the root of the project with:
|
||||
// > python3 -m http.server 3333
|
||||
// Now you can open a browser and test it works by visiting http://192.168.125.122:3333/ or http://192.168.125.122:3333/README.md
|
||||
#define HOST "192.168.125.122"
|
||||
#define PORT 3333
|
||||
|
||||
// WiFi SSID to connect to
|
||||
#define WIFI_SSID "*********"
|
||||
#define WIFI_PASS "*********"
|
||||
|
||||
bool client_running = false;
|
||||
|
||||
void makeRequest() {
|
||||
client_running = true;
|
||||
AsyncClient *client = new AsyncClient;
|
||||
if (client == nullptr) {
|
||||
Serial.println("** could not allocate client");
|
||||
client_running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
client->onError([](void *arg, AsyncClient *client, int8_t error) {
|
||||
Serial.printf("** error occurred %s \n", client->errorToString(error));
|
||||
client->close(true);
|
||||
delete client;
|
||||
client_running = false;
|
||||
});
|
||||
|
||||
client->onConnect([](void *arg, AsyncClient *client) {
|
||||
Serial.printf("** client has been connected: %" PRIu16 "\n", client->localPort());
|
||||
|
||||
client->onDisconnect([](void *arg, AsyncClient *client) {
|
||||
Serial.printf("** client has been disconnected: %" PRIu16 "\n", client->localPort());
|
||||
client->close(true);
|
||||
delete client;
|
||||
client_running = false;
|
||||
});
|
||||
|
||||
client->onData([](void *arg, AsyncClient *client, void *data, size_t len) {
|
||||
Serial.printf("** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
|
||||
});
|
||||
|
||||
client->write("GET /README.md HTTP/1.1\r\nHost: " HOST "\r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
|
||||
});
|
||||
|
||||
if (!client->connect(HOST, PORT)) {
|
||||
Serial.println("** connection failed");
|
||||
client_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Connecting to ");
|
||||
Serial.print(WIFI_SSID);
|
||||
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("Connected to WiFi. IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!client_running) {
|
||||
makeRequest();
|
||||
}
|
||||
delay(1000);
|
||||
Serial.printf("** free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Arduino ESP32
|
||||
#
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
# end of Arduino ESP32
|
||||
|
||||
#
|
||||
# FREERTOS
|
||||
#
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
# end of FREERTOS
|
||||
# end of Component config
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "AsyncTCP",
|
||||
"version": "3.3.8",
|
||||
"description": "Asynchronous TCP Library for ESP32",
|
||||
"keywords": "async,tcp",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ESP32Async/AsyncTCP.git"
|
||||
},
|
||||
"authors":
|
||||
{
|
||||
"name": "ESP32Async",
|
||||
"maintainer": true
|
||||
},
|
||||
"license": "LGPL-3.0",
|
||||
"frameworks": "arduino",
|
||||
"platforms": [
|
||||
"espressif32",
|
||||
"libretiny"
|
||||
],
|
||||
"export": {
|
||||
"include": [
|
||||
"examples",
|
||||
"src",
|
||||
"library.json",
|
||||
"library.properties",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
name=Async TCP
|
||||
includes=AsyncTCP.h
|
||||
version=3.3.8
|
||||
author=ESP32Async
|
||||
maintainer=ESP32Async
|
||||
sentence=Async TCP Library for ESP32
|
||||
paragraph=Async TCP Library for ESP32
|
||||
category=Other
|
||||
url=https://github.com/ESP32Async/AsyncTCP.git
|
||||
architectures=*
|
||||
license=LGPL-3.0
|
||||
@@ -0,0 +1,45 @@
|
||||
[platformio]
|
||||
default_envs = arduino-2, arduino-3
|
||||
lib_dir = .
|
||||
; src_dir = examples/Client
|
||||
; src_dir = examples/FetchWebsite
|
||||
src_dir = examples/AsyncSend
|
||||
|
||||
[env]
|
||||
framework = arduino
|
||||
build_flags =
|
||||
-Wall -Wextra
|
||||
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
|
||||
-D CONFIG_ASYNC_TCP_PRIORITY=10
|
||||
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64
|
||||
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
|
||||
-D CONFIG_ARDUHAL_LOG_COLORS
|
||||
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
upload_protocol = esptool
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder, log2file
|
||||
board = esp32dev
|
||||
|
||||
[env:arduino-2]
|
||||
platform = espressif32@6.10.0
|
||||
|
||||
[env:arduino-3]
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip
|
||||
|
||||
[env:arduino-3-latest]
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip
|
||||
|
||||
; CI
|
||||
|
||||
[env:ci-arduino-2]
|
||||
platform = espressif32@6.10.0
|
||||
board = ${sysenv.PIO_BOARD}
|
||||
|
||||
[env:ci-arduino-3]
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip
|
||||
board = ${sysenv.PIO_BOARD}
|
||||
|
||||
[env:ci-arduino-3-latest]
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip
|
||||
board = ${sysenv.PIO_BOARD}
|
||||
@@ -0,0 +1 @@
|
||||
pre-commit==4.1.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,335 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
#ifndef ASYNCTCP_H_
|
||||
#define ASYNCTCP_H_
|
||||
|
||||
#include "AsyncTCPVersion.h"
|
||||
#define ASYNCTCP_FORK_ESP32Async
|
||||
|
||||
#include "IPAddress.h"
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
#include "IPv6Address.h"
|
||||
#endif
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include <functional>
|
||||
|
||||
#ifndef LIBRETINY
|
||||
#include "sdkconfig.h"
|
||||
extern "C" {
|
||||
#include "freertos/semphr.h"
|
||||
#include "lwip/pbuf.h"
|
||||
}
|
||||
#else
|
||||
extern "C" {
|
||||
#include <lwip/pbuf.h>
|
||||
#include <semphr.h>
|
||||
}
|
||||
#define CONFIG_ASYNC_TCP_RUNNING_CORE -1 // any available core
|
||||
#endif
|
||||
|
||||
// If core is not defined, then we are running in Arduino or PIO
|
||||
#ifndef CONFIG_ASYNC_TCP_RUNNING_CORE
|
||||
#define CONFIG_ASYNC_TCP_RUNNING_CORE -1 // any available core
|
||||
#endif
|
||||
|
||||
// guard AsyncTCP task with watchdog
|
||||
#ifndef CONFIG_ASYNC_TCP_USE_WDT
|
||||
#define CONFIG_ASYNC_TCP_USE_WDT 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ASYNC_TCP_STACK_SIZE
|
||||
#define CONFIG_ASYNC_TCP_STACK_SIZE 8192 * 2
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ASYNC_TCP_PRIORITY
|
||||
#define CONFIG_ASYNC_TCP_PRIORITY 10
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ASYNC_TCP_QUEUE_SIZE
|
||||
#define CONFIG_ASYNC_TCP_QUEUE_SIZE 64
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ASYNC_TCP_MAX_ACK_TIME
|
||||
#define CONFIG_ASYNC_TCP_MAX_ACK_TIME 5000
|
||||
#endif
|
||||
|
||||
class AsyncClient;
|
||||
|
||||
#define ASYNC_WRITE_FLAG_COPY 0x01 // will allocate new buffer to hold the data while sending (else will hold reference to the data given)
|
||||
#define ASYNC_WRITE_FLAG_MORE 0x02 // will not send PSH flag, meaning that there should be more data to be sent before the application should react.
|
||||
|
||||
typedef std::function<void(void *, AsyncClient *)> AcConnectHandler;
|
||||
typedef std::function<void(void *, AsyncClient *, size_t len, uint32_t time)> AcAckHandler;
|
||||
typedef std::function<void(void *, AsyncClient *, int8_t error)> AcErrorHandler;
|
||||
typedef std::function<void(void *, AsyncClient *, void *data, size_t len)> AcDataHandler;
|
||||
typedef std::function<void(void *, AsyncClient *, struct pbuf *pb)> AcPacketHandler;
|
||||
typedef std::function<void(void *, AsyncClient *, uint32_t time)> AcTimeoutHandler;
|
||||
|
||||
struct tcp_pcb;
|
||||
struct ip_addr;
|
||||
|
||||
class AsyncClient {
|
||||
public:
|
||||
AsyncClient(tcp_pcb *pcb = 0);
|
||||
~AsyncClient();
|
||||
|
||||
AsyncClient &operator=(const AsyncClient &other);
|
||||
AsyncClient &operator+=(const AsyncClient &other);
|
||||
|
||||
bool operator==(const AsyncClient &other) const;
|
||||
|
||||
bool operator!=(const AsyncClient &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
bool connect(const IPAddress &ip, uint16_t port);
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
bool connect(const IPv6Address &ip, uint16_t port);
|
||||
#endif
|
||||
bool connect(const char *host, uint16_t port);
|
||||
/**
|
||||
* @brief close connection
|
||||
*
|
||||
* @param now - ignored
|
||||
*/
|
||||
void close(bool now = false);
|
||||
// same as close()
|
||||
void stop() {
|
||||
close(false);
|
||||
};
|
||||
int8_t abort();
|
||||
bool free();
|
||||
|
||||
// ack is not pending
|
||||
bool canSend() const;
|
||||
// TCP buffer space available
|
||||
size_t space() const;
|
||||
|
||||
/**
|
||||
* @brief add data to be send (but do not send yet)
|
||||
* @note add() would call lwip's tcp_write()
|
||||
By default apiflags=ASYNC_WRITE_FLAG_COPY
|
||||
You could try to use apiflags with this flag unset to pass data by reference and avoid copy to socket buffer,
|
||||
but looks like it does not work for Arduino's lwip in ESP32/IDF at least
|
||||
it is enforced in https://github.com/espressif/esp-lwip/blob/0606eed9d8b98a797514fdf6eabb4daf1c8c8cd9/src/core/tcp_out.c#L422C5-L422C30
|
||||
if LWIP_NETIF_TX_SINGLE_PBUF is set, and it is set indeed in IDF
|
||||
https://github.com/espressif/esp-idf/blob/a0f798cfc4bbd624aab52b2c194d219e242d80c1/components/lwip/port/include/lwipopts.h#L744
|
||||
*
|
||||
* @param data
|
||||
* @param size
|
||||
* @param apiflags
|
||||
* @return size_t amount of data that has been copied
|
||||
*/
|
||||
size_t add(const char *data, size_t size, uint8_t apiflags = ASYNC_WRITE_FLAG_COPY);
|
||||
|
||||
/**
|
||||
* @brief send data previously add()'ed
|
||||
*
|
||||
* @return true on success
|
||||
* @return false on error
|
||||
*/
|
||||
bool send();
|
||||
|
||||
/**
|
||||
* @brief add and enqueue data for sending
|
||||
* @note it is same as add() + send()
|
||||
* @note only make sense when canSend() == true
|
||||
*
|
||||
* @param data
|
||||
* @param size
|
||||
* @param apiflags
|
||||
* @return size_t
|
||||
*/
|
||||
size_t write(const char *data, size_t size, uint8_t apiflags = ASYNC_WRITE_FLAG_COPY);
|
||||
|
||||
/**
|
||||
* @brief add and enqueue data for sending
|
||||
* @note treats data as null-terminated string
|
||||
*
|
||||
* @param data
|
||||
* @return size_t
|
||||
*/
|
||||
size_t write(const char *data) {
|
||||
return data == NULL ? 0 : write(data, strlen(data));
|
||||
};
|
||||
|
||||
uint8_t state() const;
|
||||
bool connecting() const;
|
||||
bool connected() const;
|
||||
bool disconnecting() const;
|
||||
bool disconnected() const;
|
||||
|
||||
// disconnected or disconnecting
|
||||
bool freeable() const;
|
||||
|
||||
uint16_t getMss() const;
|
||||
|
||||
uint32_t getRxTimeout() const;
|
||||
// no RX data timeout for the connection in seconds
|
||||
void setRxTimeout(uint32_t timeout);
|
||||
|
||||
uint32_t getAckTimeout() const;
|
||||
// no ACK timeout for the last sent packet in milliseconds
|
||||
void setAckTimeout(uint32_t timeout);
|
||||
|
||||
void setNoDelay(bool nodelay) const;
|
||||
bool getNoDelay();
|
||||
|
||||
void setKeepAlive(uint32_t ms, uint8_t cnt);
|
||||
|
||||
uint32_t getRemoteAddress() const;
|
||||
uint16_t getRemotePort() const;
|
||||
uint32_t getLocalAddress() const;
|
||||
uint16_t getLocalPort() const;
|
||||
#if LWIP_IPV6
|
||||
ip6_addr_t getRemoteAddress6() const;
|
||||
ip6_addr_t getLocalAddress6() const;
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
IPv6Address remoteIP6() const;
|
||||
IPv6Address localIP6() const;
|
||||
#else
|
||||
IPAddress remoteIP6() const;
|
||||
IPAddress localIP6() const;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// compatibility
|
||||
IPAddress remoteIP() const;
|
||||
uint16_t remotePort() const;
|
||||
IPAddress localIP() const;
|
||||
uint16_t localPort() const;
|
||||
|
||||
// set callback - on successful connect
|
||||
void onConnect(AcConnectHandler cb, void *arg = 0);
|
||||
// set callback - disconnected
|
||||
void onDisconnect(AcConnectHandler cb, void *arg = 0);
|
||||
// set callback - ack received
|
||||
void onAck(AcAckHandler cb, void *arg = 0);
|
||||
// set callback - unsuccessful connect or error
|
||||
void onError(AcErrorHandler cb, void *arg = 0);
|
||||
// set callback - data received (called if onPacket is not used)
|
||||
void onData(AcDataHandler cb, void *arg = 0);
|
||||
// set callback - data received
|
||||
// !!! You MUST call ackPacket() or free the pbuf yourself to prevent memory leaks
|
||||
void onPacket(AcPacketHandler cb, void *arg = 0);
|
||||
// set callback - ack timeout
|
||||
void onTimeout(AcTimeoutHandler cb, void *arg = 0);
|
||||
// set callback - every 125ms when connected
|
||||
void onPoll(AcConnectHandler cb, void *arg = 0);
|
||||
|
||||
// ack pbuf from onPacket
|
||||
void ackPacket(struct pbuf *pb);
|
||||
// ack data that you have not acked using the method below
|
||||
size_t ack(size_t len);
|
||||
// will not ack the current packet. Call from onData
|
||||
void ackLater() {
|
||||
_ack_pcb = false;
|
||||
}
|
||||
|
||||
static const char *errorToString(int8_t error);
|
||||
const char *stateToString() const;
|
||||
|
||||
// internal callbacks - Do NOT call any of the functions below in user code!
|
||||
static int8_t _s_poll(void *arg, struct tcp_pcb *tpcb);
|
||||
static int8_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, int8_t err);
|
||||
static int8_t _s_fin(void *arg, struct tcp_pcb *tpcb, int8_t err);
|
||||
static int8_t _s_lwip_fin(void *arg, struct tcp_pcb *tpcb, int8_t err);
|
||||
static void _s_error(void *arg, int8_t err);
|
||||
static int8_t _s_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len);
|
||||
static int8_t _s_connected(void *arg, struct tcp_pcb *tpcb, int8_t err);
|
||||
static void _s_dns_found(const char *name, struct ip_addr *ipaddr, void *arg);
|
||||
static void _tcp_error(void *arg, int8_t err);
|
||||
|
||||
int8_t _recv(tcp_pcb *pcb, pbuf *pb, int8_t err);
|
||||
tcp_pcb *pcb() {
|
||||
return _pcb;
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class AsyncServer;
|
||||
|
||||
bool _connect(ip_addr_t addr, uint16_t port);
|
||||
|
||||
tcp_pcb *_pcb;
|
||||
int8_t _closed_slot;
|
||||
|
||||
AcConnectHandler _connect_cb;
|
||||
void *_connect_cb_arg;
|
||||
AcConnectHandler _discard_cb;
|
||||
void *_discard_cb_arg;
|
||||
AcAckHandler _sent_cb;
|
||||
void *_sent_cb_arg;
|
||||
AcErrorHandler _error_cb;
|
||||
void *_error_cb_arg;
|
||||
AcDataHandler _recv_cb;
|
||||
void *_recv_cb_arg;
|
||||
AcPacketHandler _pb_cb;
|
||||
void *_pb_cb_arg;
|
||||
AcTimeoutHandler _timeout_cb;
|
||||
void *_timeout_cb_arg;
|
||||
AcConnectHandler _poll_cb;
|
||||
void *_poll_cb_arg;
|
||||
|
||||
bool _ack_pcb;
|
||||
uint32_t _tx_last_packet;
|
||||
uint32_t _rx_ack_len;
|
||||
uint32_t _rx_last_packet;
|
||||
uint32_t _rx_timeout;
|
||||
uint32_t _rx_last_ack;
|
||||
uint32_t _ack_timeout;
|
||||
uint16_t _connect_port;
|
||||
|
||||
int8_t _close();
|
||||
void _free_closed_slot();
|
||||
bool _allocate_closed_slot();
|
||||
int8_t _connected(tcp_pcb *pcb, int8_t err);
|
||||
void _error(int8_t err);
|
||||
int8_t _poll(tcp_pcb *pcb);
|
||||
int8_t _sent(tcp_pcb *pcb, uint16_t len);
|
||||
int8_t _fin(tcp_pcb *pcb, int8_t err);
|
||||
int8_t _lwip_fin(tcp_pcb *pcb, int8_t err);
|
||||
void _dns_found(struct ip_addr *ipaddr);
|
||||
|
||||
public:
|
||||
AsyncClient *prev;
|
||||
AsyncClient *next;
|
||||
};
|
||||
|
||||
class AsyncServer {
|
||||
public:
|
||||
AsyncServer(IPAddress addr, uint16_t port);
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
AsyncServer(IPv6Address addr, uint16_t port);
|
||||
#endif
|
||||
AsyncServer(uint16_t port);
|
||||
~AsyncServer();
|
||||
void onClient(AcConnectHandler cb, void *arg);
|
||||
void begin();
|
||||
void end();
|
||||
void setNoDelay(bool nodelay);
|
||||
bool getNoDelay() const;
|
||||
uint8_t status() const;
|
||||
|
||||
// Do not use any of the functions below!
|
||||
static int8_t _s_accept(void *arg, tcp_pcb *newpcb, int8_t err);
|
||||
static int8_t _s_accepted(void *arg, AsyncClient *client);
|
||||
|
||||
protected:
|
||||
uint16_t _port;
|
||||
bool _bind4 = false;
|
||||
bool _bind6 = false;
|
||||
IPAddress _addr;
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
IPv6Address _addr6;
|
||||
#endif
|
||||
bool _noDelay;
|
||||
tcp_pcb *_pcb;
|
||||
AcConnectHandler _connect_cb;
|
||||
void *_connect_cb_arg;
|
||||
|
||||
int8_t _accept(tcp_pcb *newpcb, int8_t err);
|
||||
int8_t _accepted(AsyncClient *client);
|
||||
};
|
||||
|
||||
#endif /* ASYNCTCP_H_ */
|
||||
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Major version number (X.x.x) */
|
||||
#define ASYNCTCP_VERSION_MAJOR 3
|
||||
/** Minor version number (x.X.x) */
|
||||
#define ASYNCTCP_VERSION_MINOR 3
|
||||
/** Patch version number (x.x.X) */
|
||||
#define ASYNCTCP_VERSION_PATCH 8
|
||||
|
||||
/**
|
||||
* Macro to convert version number into an integer
|
||||
*
|
||||
* To be used in comparisons, such as ASYNCTCP_VERSION >= ASYNCTCP_VERSION_VAL(2, 0, 0)
|
||||
*/
|
||||
#define ASYNCTCP_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||
|
||||
/**
|
||||
* Current version, as an integer
|
||||
*
|
||||
* To be used in comparisons, such as ASYNCTCP_VERSION_NUM >= ASYNCTCP_VERSION_VAL(2, 0, 0)
|
||||
*/
|
||||
#define ASYNCTCP_VERSION_NUM ASYNCTCP_VERSION_VAL(ASYNCTCP_VERSION_MAJOR, ASYNCTCP_VERSION_MINOR, ASYNCTCP_VERSION_PATCH)
|
||||
|
||||
/**
|
||||
* Current version, as string
|
||||
*/
|
||||
#define df2xstr(s) #s
|
||||
#define df2str(s) df2xstr(s)
|
||||
#define ASYNCTCP_VERSION df2str(ASYNCTCP_VERSION_MAJOR) "." df2str(ASYNCTCP_VERSION_MINOR) "." df2str(ASYNCTCP_VERSION_PATCH)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user