update micropython

add m5stack.py
add m5ui.py
This commit is contained in:
sakabin
2018-12-04 14:06:15 +08:00
parent 42bd073503
commit 070e06db00
585 changed files with 50170 additions and 55186 deletions
+3
View File
@@ -52,3 +52,6 @@ xtensa-esp32-elf/
xtensa-esp32-elf_psram/
backup.sh
\.vscode/
+242 -10
View File
@@ -1,24 +1,256 @@
# MicroPython for ESP32
# License information
## License information
All the source code in this repository is released under MIT or Apache v2.0 license, with the exceptions mentioned bellow.
<br>
All the source code in this repository is released under MIT or Apache v2.0 license.
All the sources related to **MicroPython** are under **MIT** license.
**esp-idf** on which this port is based, is released under **Apache v2.0** license.
**esp-idf** on which this port is based, is released under **Apache v2.0** license ([details](http://esp-idf.readthedocs.io/en/latest/COPYRIGHT.html)).
All the sources created/modified by the repository owner are released under **MIT** license and contains the following copyright notice:<br>
*Copyright (c) 2018 LoBo (https://github.com/loboris)*
> All the sources created/modified by the repository owner are released under **MIT** license and contains the following copyright notice:<br>
> *Copyright (c) 2018 LoBo (https://github.com/loboris)*
Most of the source files contains license and copyright notice, please check the individual files for more information.<br>
Also check the license information in individual components directories.
Also check the license information in individual components directories.<br>
---
The only exception to the MIT/Apache licensing is the **quickmail** library (*MicroPython_BUILD/components/quickmail*) which is licensed under **GNU GPL** v3.0+ license.
```
The MIT License (MIT)
Copyright (c) 2018, LoBo (https://github.com/loboris)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
---
```
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
---
In case you don't want to use GPL licensed code, the library (it's directory) can be **removed** (deleted) from the repository clone/fork, leaving the project only **MIT/Apache** licensed.
To build the project without quickmail support disable<br>
`→ MicroPython → Modules → MAIL support in Curl module` in **menuconfig**
+25 -12
View File
@@ -26,7 +26,7 @@
</outputEntries>
</builder>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.746622695" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option id="gnu.c.compiler.option.include.paths.1930340268" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1930340268" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/vfs/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/newlib/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/esp32/include&quot;"/>
@@ -36,6 +36,8 @@
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/log/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/lwip/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/lwip/include/lwip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/lwip/include/lwip/port&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/lwip/include/lwip/netif/ppp&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/tcpip_adapter/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/sdmmc/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/fatfs/src&quot;"/>
@@ -44,26 +46,32 @@
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/wear_levelling/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/soc/esp32/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/heap/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/port/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/app_update/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mdns/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/ethernet/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/esp_adc_cal/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/nghttp/port/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/bluedroid/api/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/bluedroid/api/include/api&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/mbedtls/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/esp_http_client/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MicroPython_BUILD}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MicroPython_BUILD/build/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MicroPython_BUILD/components/micropython/genhdr}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MicroPython_BUILD/build/genhdr}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/bluedroid/api/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${PWD}/../Tools/xtensa-esp32-elf/bin&quot;"/>
<listOptionValue builtIn="false" value="&quot;${PWD}/../Tools/xtensa-esp32-elf/xtensa-esp32-elf/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/esp_https_ota/include&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.507238637" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.507238637" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BUILD_TIME=100000"/>
<listOptionValue builtIn="false" value="LED_ACT=5"/>
<listOptionValue builtIn="false" value="LWIP_DNS=1"/>
<listOptionValue builtIn="false" value="LWIP_SOCKET=1"/>
<listOptionValue builtIn="false" value="IDF_USEHEAP=1"/>
<listOptionValue builtIn="false" value="HAVE_CONFIG_H"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.827066523" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
@@ -117,7 +125,6 @@
<buildTargets>
<target name="BUILD" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-j8 all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -125,7 +132,6 @@
</target>
<target name="FLASH" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>flash</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -133,7 +139,6 @@
</target>
<target name="CLEAN" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -141,13 +146,14 @@
</target>
<target name="BUILD (verbose)" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildTarget>-v all</buildTarget>
<buildTarget>-v -f16 all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="FLASH - 8MB" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-f8 flash</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -155,6 +161,7 @@
</target>
<target name="FLASH - 16MB" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-f16 flash</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -177,14 +184,13 @@
<target name="CLEAN &amp; BUILD" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-j8 clean all</buildTarget>
<buildTarget>-j8 -f16 clean all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="CLEAN, BUILD &amp; FLASH" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-j8 clean all flash</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@@ -193,7 +199,14 @@
<target name="Menuconfig" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mate-terminal</buildCommand>
<buildArguments>--working-directory="${PWD}" -e "./BUILD.sh menuconfig" &amp;</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="CLEAN &amp; BUILD (verbose)" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/BUILD.sh</buildCommand>
<buildArguments/>
<buildTarget>-j8 -v clean all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
+6 -1
View File
@@ -22,9 +22,12 @@ build/
patches/
partitions_mpy.csv
*.id
qstrdefs.generated.h
/partitions_mpy.csv
/sdkconfig
sdkconfig.old
sdkconfig.lobo
_sdkconfig.saved
sdkconfig.fw_esp32
sdkconfig.fw_esp32_ota
@@ -32,6 +35,8 @@ sdkconfig.fw_psram
sdkconfig.fw_psram_ota
sdkconfig.fw_all
sdkconfig.fw_psram_all
sdkconfig.fw_psram_all_bt
make_firmwares.sh
make_firmware_archives.sh
mncfg_exit.txt
+29
View File
@@ -30,4 +30,33 @@
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
<filteredResources>
<filter>
<id>1519906740649</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-true-false-components/mkfatfs</arguments>
</matcher>
</filter>
<filter>
<id>1519906740652</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-true-false-components/mkspiffs</arguments>
</matcher>
</filter>
<filter>
<id>1519906740654</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-components/mpy_cross_build</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
@@ -4,8 +4,8 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1072481106224612254" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1072297972298084254" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@@ -18,13 +18,15 @@ org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={lau
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"}
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
@@ -69,4 +71,6 @@ org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
org.eclipse.cdt.qt.core.qtproblem=Warning
org.eclipse.cdt.qt.core.qtproblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_ON_FILE_OPEN\=>true,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>null}
useParentScope=false
+30 -8
View File
@@ -20,23 +20,30 @@
# makefatfs - create FatFS image
# flashfatfs - create and flash FatFS image to ESP32
# copyfatfs - flash prebuilt FatFS image to ESP32
# makelfsfs - create LittleFS image
# flashlfsfs - create and flash LittleFS image to ESP32
# copylfsfs - flash prebuilt LittleFS image to ESP32
# size - display static memory footprint of the firmware
# size-components - display detailed memory footprint of the firmware
# size-files - display detailed memory footprint of the firmware
# miniterm - start pySerial command line program miniterm
# monitor - start esp-idf terminal emulator
# Options:
# -jN - make with multicore option, N should be the number of cores used
# -v | --verbose - enable verbose output, default: quiet output
# -f8 | --flashsize8 - declare the Flash size of 8 MB
# -f16 | --flashsize16 - declare the Flash size of 16 MB
# -fs <FS_size> | --fssize=<FS_size> - declare the size of Flash file system in KB
# -v | --verbose - enable verbose output, default: quiet output
# -f8 | --flashsize8 - declare the Flash size of 8 MB
# -f16 | --flashsize16 - declare the Flash size of 16 MB
# -fs <FS_size> | --fssize=<FS_size> - declare the size of Flash file system in KB
# default: fit the Flash size
# -a <app_size> | --appsize=<app_size> - declare the size of application partition in KB
# -a <app_size> | --appsize=<app_size> - declare the size of application partition in KB
# default: auto detect needed size
# the actual size will be 128 KB smaller then the declared size
# -p <comm_port> | --port=<comm_port> - overwritte configured comm port, use the specified instead
# -b <bdrate> | --bdrate=<bdrate> - overwritte configured baud rate, use the specified instead
# Note:
# Multiple commands can be given
# Multiple options and commands can be given
# #################################################################
@@ -45,7 +52,8 @@
#=======================
TOOLS_VER=ver20180228.id
TOOLS_VER=ver20180827.id
BUILD_VER=ver20180904.id
#=======================
# -----------------------------
@@ -61,6 +69,8 @@ FORCE_3PART="no"
POSITIONAL_ARGS=()
BUILD_TYPE=""
BUILD_BASE_DIR=${PWD}
BUILD_COMPORT=""
BUILD_BDRATE=""
# ---------------------------------------
# Include functions used in build process
@@ -87,6 +97,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
# Goto base repository directory
cd ../
# -----------------------------------
@@ -173,11 +184,21 @@ export CROSS_COMPILE=xtensa-esp32-elf-
for arg in "${POSITIONAL_ARGS[@]}"
do
if [ "${arg}" == "all" ] || [ "${arg}" == "flash" ] || [ "${arg}" == "makefs" ] || [ "${arg}" == "flashfs" ] || [ "${arg}" == "makefatfs" ] || [ "${arg}" == "flashfatfs" ]; then
if [ "${arg}" == "menuconfig" ]; then
check_config
result=$?
if [ $result -eq 1 ]; then
make menuconfig 2>/dev/null
fi
fi
if [ "${arg}" == "all" ] || [ "${arg}" == "flash" ] || [ "${arg}" == "makefs" ] || [ "${arg}" == "flashfs" ] || [ "${arg}" == "makefatfs" ] || [ "${arg}" == "flashfatfs" ] || [ "${arg}" == "makelfsfs" ] || [ "${arg}" == "flashlfsfs" ]; then
set_partitions ${APP_SIZE}
if [ $? -ne 0 ]; then
exit 1
fi
if [ "${arg}" == "all" ] || [ "${arg}" == "flash" ]; then
check_config
fi
fi
if [ "${arg}" == "flash" ]; then
@@ -206,6 +227,7 @@ do
if [ $result -eq 0 ]; then
echo "OK."
if [ "${arg}" == "all" ]; then
set_partitions ${APP_SIZE}
echo "--------------------------------"
echo "Build complete."
echo "You can now run ./BUILD.sh flash"
+35 -5
View File
@@ -5,18 +5,20 @@
PROJECT_NAME := MicroPython
# ##########################################################################
# Variables for creating/flashing spiffs image file
# ###########################################################################
# Variables for creating/flashing image file
ifeq ($(OS),Windows_NT)
MKSPIFFS_BIN="mkspiffs.exe"
MKFATFS_BIN="mkfatfs.exe"
MKLITTLEFS_BIN="mklfs.exe"
else
MKSPIFFS_BIN="mkspiffs"
MKFATFS_BIN="mkfatfs"
MKLITTLEFS_BIN="mklfs"
endif
FILESYS_SIZE = $(shell echo $$(( $(CONFIG_MICROPY_INTERNALFS_SIZE) * 1024 )))
INTERNALFS_IMAGE_COMPONENT_PATH := $(PWD)/components/internalfs_image
# ##########################################################################
# ###########################################################################
echo_flash_cmd:
@@ -48,7 +50,35 @@ copyfs:
@echo "-----------------------------"
@echo "$(INTERNALFS_IMAGE_COMPONENT_PATH)/spiffs_image.img"
@echo "-----------------------------"
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(INTERNALFS_IMAGE_COMPONENT_PATH)/spiffs_image.img
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(INTERNALFS_IMAGE_COMPONENT_PATH)/internalfs_image.img
makelfsfs:
@echo "Making LittleFS image; Flash address: $(CONFIG_MICROPY_INTERNALFS_START), Size: $(CONFIG_MICROPY_INTERNALFS_SIZE) KB ..."
$(PROJECT_PATH)/components/mklittlefs/$(MKLITTLEFS_BIN) -b $(CONFIG_MICROPY_BLOCK_SIZE) -c $(CONFIG_MICROPY_BLOCK_COUNT) $(CONFIG_MICROPY_USE_WL) $(INTERNALFS_IMAGE_COMPONENT_PATH)/image $(BUILD_DIR_BASE)/lfs_image.img
@echo "--------------------------"
@echo "To flash to ESP32 execute:"
@echo "--------------------------"
@echo "$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(BUILD_DIR_BASE)/lfs_image.img)"
@echo "--------------------------------"
@echo "or execute ./BUILD.sh flashlfsfs"
@echo "--------------------------------"
flashlfsfs:
@echo "Making LittleFS image; Flash address: $(CONFIG_MICROPY_INTERNALFS_START), Size: $(CONFIG_MICROPY_INTERNALFS_SIZE) KB ..."
$(PROJECT_PATH)/components/mklittlefs/$(MKLITTLEFS_BIN) -b $(CONFIG_MICROPY_BLOCK_SIZE) -c $(CONFIG_MICROPY_BLOCK_COUNT) $(CONFIG_MICROPY_USE_WL) $(INTERNALFS_IMAGE_COMPONENT_PATH)/image $(BUILD_DIR_BASE)/lfs_image.img
@echo "----------------------"
@echo "Flashing the image ..."
@echo "----------------------"
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(BUILD_DIR_BASE)/lfs_image.img
@echo "----------------------"
copylfsfs:
@echo "-----------------------------------"
@echo "Flashing default LittleFS image ..."
@echo "-----------------------------------"
@echo "$(INTERNALFS_IMAGE_COMPONENT_PATH)/lfs_image.img"
@echo "-----------------------------"
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(INTERNALFS_IMAGE_COMPONENT_PATH)/internalfs_image.img
makefatfs:
@echo "Making fatfs image; Flash address: $(CONFIG_MICROPY_INTERNALFS_START), Size: $(CONFIG_MICROPY_INTERNALFS_SIZE) KB ..."
@@ -78,6 +108,6 @@ copyfatfs:
@echo "----------------------------"
@echo "$(INTERNALFS_IMAGE_COMPONENT_PATH)/fatfs_image.img"
@echo "-----------------------------"
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(INTERNALFS_IMAGE_COMPONENT_PATH)/fatfs_image.img
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_MICROPY_INTERNALFS_START) $(INTERNALFS_IMAGE_COMPONENT_PATH)/internalfs_image.img
include $(IDF_PATH)/make/project.mk
+173 -15
View File
@@ -1,6 +1,7 @@
fs_type_fat="no"
fs_fat_sect=4096
fs_use_wl=""
linplatform=""
linprocessor=""
linmachine=""
@@ -29,6 +30,20 @@ get_arguments() {
;;
-fs|--fssize)
FS_SIZE="$2"
shift # past argument
shift # past value
;;
-p|--port)
BUILD_COMPORT="$2"
BUILD_COMPORT=" ESPPORT=${BUILD_COMPORT}"
shift # past argument
shift # past value
;;
-b|--bdrate)
BUILD_BDRATE="$2"
BUILD_BDRATE=" ESPBAUD=${BUILD_BDRATE}"
shift # past argument
shift # past value
;;
@@ -74,14 +89,33 @@ get_bin_size() {
#----------------------
get_config_flash_sz() {
local cfg_fsfat=$(grep -e CONFIG_MICROPY_USE_SPIFFS=y sdkconfig)
if [ "${cfg_fsfat}" == "" ]; then
local cfg_fsfat=$(grep -e CONFIG_LITTLEFLASH_USE_WEAR_LEVELING=y sdkconfig)
if [ "${cfg_fsfat}" != "" ]; then
fs_use_wl="-w"
fi
cfg_fsfat=$(grep -e CONFIG_MICROPY_FILESYSTEM_TYPE=1 sdkconfig)
if [ "${cfg_fsfat}" == "CONFIG_MICROPY_FILESYSTEM_TYPE=1" ]; then
# FatFS
fs_type_fat="yes"
cfg_fsfat=$(grep -e CONFIG_WL_SECTOR_SIZE_512=y sdkconfig)
if [ "${cfg_fsfat}" == "CONFIG_WL_SECTOR_SIZE_512=y" ]; then
fs_fat_sect=512
fi
else
cfg_fsfat=$(grep -e CONFIG_MICROPY_FILESYSTEM_TYPE=2 sdkconfig)
if [ "${cfg_fsfat}" == "CONFIG_MICROPY_FILESYSTEM_TYPE=2" ]; then
# LittleFS
fs_type_fat="yes"
cfg_fsfat=$(grep -e CONFIG_WL_SECTOR_SIZE_512=y sdkconfig)
if [ "${cfg_fsfat}" == "CONFIG_WL_SECTOR_SIZE_512=y" ]; then
if [ "${fs_use_wl}" == "-w" ]; then
fs_fat_sect=512
fi
fi
fi
fi
if [ ${FLASH_SIZE} -eq 4 ]; then
# Flash size was not set by options, check config file
local cfg_flashsz=$(grep -e CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y sdkconfig)
@@ -96,6 +130,26 @@ get_config_flash_sz() {
fi
}
#---------------
check_config() {
# If BT is enabled, check and modify, if needed, some configuration
local TMPVAR1=""
local USE_RFCOMM=$(grep -e CONFIG_MICROPY_USE_RFCOMM=y sdkconfig)
local USE_BT=$(grep -e CONFIG_MICROPY_USE_BLUETOOTH=y sdkconfig)
if [ "${USE_RFCOMM}" == "CONFIG_MICROPY_USE_RFCOMM=y" ] || [ "${USE_BT}" == "CONFIG_MICROPY_USE_BLUETOOTH=y" ]; then
# change to RELEASE optimization level to decrease IRAM usage
TMPVAR1=$(grep -e CONFIG_OPTIMIZATION_LEVEL_DEBUG=y sdkconfig)
if [ "${TMPVAR1}" == "CONFIG_OPTIMIZATION_LEVEL_DEBUG=y" ]; then
sed --in-place='.bak1' 's/CONFIG_OPTIMIZATION_LEVEL_DEBUG=y/CONFIG_OPTIMIZATION_LEVEL_DEBUG=/g' sdkconfig
sed --in-place='.bak2' 's/CONFIG_OPTIMIZATION_LEVEL_RELEASE=/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/g' sdkconfig
rm -f sdkconfig.bak1 > /dev/null 2>&1
rm -f sdkconfig.bak2 > /dev/null 2>&1
return 1
fi
fi
return 0
}
#-----------------
set_partitions() {
@@ -156,7 +210,7 @@ set_partitions() {
fi
echo "# -------------------------------------------------------" > partitions_mpy.csv
echo "# - Partition layout generaded by BUILD.sh script -" >> partitions_mpy.csv
echo "# - Partition layout generated by BUILD.sh script -" >> partitions_mpy.csv
echo "# -------------------------------------------------------" >> partitions_mpy.csv
echo "# Name, Type, SubType, Offset, Size, Flags" >> partitions_mpy.csv
echo "# -------------------------------------------------------" >> partitions_mpy.csv
@@ -199,7 +253,7 @@ set_partitions() {
fi
echo "# -------------------------------------------------------" > partitions_mpy.csv
echo "# - Partition layout generaded by BUILD.sh script -" >> partitions_mpy.csv
echo "# - Partition layout generated by BUILD.sh script -" >> partitions_mpy.csv
echo "# -------------------------------------------------------" >> partitions_mpy.csv
echo "# Name, Type, SubType, Offset, Size, Flags" >> partitions_mpy.csv
echo "# -------------------------------------------------------" >> partitions_mpy.csv
@@ -209,8 +263,13 @@ set_partitions() {
echo "internalfs, data, ${PART_SUB_TYPE} , ${fs_size}K," >> partitions_mpy.csv
fi
fs_start_hex=$(printf "%x\n" $fs_start)
local fs_sector_count=$(( ($fs_size * 1024) / $fs_fat_sect ))
export CONFIG_MICROPY_INTERNALFS_START="0x${fs_start_hex}"
export CONFIG_MICROPY_INTERNALFS_SIZE=${fs_size}
export CONFIG_MICROPY_BLOCK_SIZE=${fs_fat_sect}
export CONFIG_MICROPY_BLOCK_COUNT=${fs_sector_count}
export CONFIG_MICROPY_USE_WL=${fs_use_wl}
return 0
}
@@ -259,6 +318,7 @@ check_OS() {
fi
MK_SPIFFS_BIN="mkspiffs.exe"
MK_FATFS_BIN="mkfatfs.exe"
MK_LITTLEFS_BIN="mklfs.exe"
else
if [ "${machine}" == "Linux" ]; then
linplatform="$(uname -i)"
@@ -267,6 +327,7 @@ check_OS() {
fi
MK_SPIFFS_BIN="mkspiffs"
MK_FATFS_BIN="mkfatfs"
MK_LITTLEFS_BIN="mklfs"
fi
return 0
}
@@ -278,9 +339,9 @@ check_OS() {
# =================================================
#--------------------
check_Environment() {
# ----------------------------------------
# Remove directories from previous version
# ----------------------------------------
# --------------------------------------------------
# Remove directories from early MicroPython versions
# --------------------------------------------------
if [ -d "esp-idf" ]; then
rm -rf esp-idf/ > /dev/null 2>&1
rmdir esp-idf > /dev/null 2>&1
@@ -330,6 +391,9 @@ check_Environment() {
rm -f *.id > /dev/null 2>&1
touch ${TOOLS_VER}
echo "toolchains & esp-idf version" > ${TOOLS_VER}
rm -f ${BUILD_BASE_DIR}/*.id > /dev/null 2>&1
touch ${BUILD_BASE_DIR}/${BUILD_VER}
echo "Build ID, do not delete this file" > ${BUILD_BASE_DIR}/${BUILD_VER}
# remove executables
rm -f ${BUILD_BASE_DIR}/components/mpy_cross_build/mpy-cross/mpy-cross > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/components/mpy_cross_build/mpy-cross/mpy-cross.exe > /dev/null 2>&1
@@ -339,12 +403,30 @@ check_Environment() {
rm -f ${BUILD_BASE_DIR}/components/mkspiffs/src/mkspiffs.exe > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/components/mkfatfs/src/mkfatfs > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/components/mkfatfs/src/mkfatfs.exe > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/components/mklittlefs/mklfs > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/components/mklittlefs/mklfs.exe > /dev/null 2>&1
# remove build directory and configs
cp -f ${BUILD_BASE_DIR}/sdkconfig ${BUILD_BASE_DIR}/_sdkconfig.saved > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/sdkconfig > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/sdkconfig.old > /dev/null 2>&1
rm -rf ${BUILD_BASE_DIR}/build/ > /dev/null 2>&1
rmdir ${BUILD_BASE_DIR}/build > /dev/null 2>&1
else
# -----------------------
# Check the build version
# -----------------------
if [ ! -f "${BUILD_BASE_DIR}/${BUILD_VER}" ]; then
echo "Build updated, running menuconfig is needed..."
rm -f ${BUILD_BASE_DIR}/*.id > /dev/null 2>&1
touch ${BUILD_BASE_DIR}/${BUILD_VER}
echo "Build ID, do not delete this file" > ${BUILD_BASE_DIR}/${BUILD_VER}
# remove build directory and configs
cp -f ${BUILD_BASE_DIR}/sdkconfig ${BUILD_BASE_DIR}/_sdkconfig.saved > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/sdkconfig > /dev/null 2>&1
rm -f ${BUILD_BASE_DIR}/sdkconfig.old > /dev/null 2>&1
rm -rf ${BUILD_BASE_DIR}/build/ > /dev/null 2>&1
rmdir ${BUILD_BASE_DIR}/build > /dev/null 2>&1
fi
fi
if [ ! -d "esp-idf" ]; then
@@ -366,6 +448,9 @@ check_Environment() {
elif [ "${linplatform}" == "armv7l" ] || [ "${linprocessor}" == "armv7l" ] || [ "${linmachine}" == "armv7l" ]; then
echo "unpacking ${machine}/xtensa-esp32-elf (arm)"
tar -xf ${machine}/xtensa-esp32-elf_arm.tar.xz > /dev/null 2>&1
elif [ "${linmachine}" == "aarch64" ]; then
echo "unpacking ${machine}/xtensa-esp32-elf (aarch64)"
tar -xf ${machine}/xtensa-esp32-elf_aarch64.tar.xz > /dev/null 2>&1
else
echo "unpacking ${machine}/xtensa-esp32-elf"
tar -xf ${machine}/xtensa-esp32-elf.tar.xz > /dev/null 2>&1
@@ -482,6 +567,33 @@ build_MKFatFS() {
return 0
}
# ===============================================================
# Build mklfs program which creates LittleFS image from directory
# ===============================================================
#----------------
build_MKlfsFS() {
if [ ! -f "components/mklittlefs/${MK_LITTLEFS_BIN}" ]; then
export CROSS_COMPILE=""
export PATH=${orig_PATH}
export BUILD_DIR_BASE=${BUILD_BASE_DIR}/build
echo "==============="
echo "Building mklfs"
make -C components/mklittlefs > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "OK."
echo "==============="
else
echo "FAILED"
echo "==============="
return 1
fi
export PATH=${xtensa_PATH}
export CROSS_COMPILE=xtensa-esp32-elf-
fi
return 0
}
# ===================
# Check build command
@@ -539,21 +651,28 @@ executeCommand() {
echo "========================================="
echo "Flashing MicroPython firmware to ESP32..."
echo "========================================="
make ${J_OPTION} ${arg} 2>/dev/null
make ${J_OPTION} ${arg}${BUILD_COMPORT}${BUILD_BDRATE} 2>/dev/null
# ---------------------------------
elif [ "${arg}" == "erase" ]; then
echo "======================"
echo "Erasing ESP32 Flash..."
echo "======================"
make erase_flash
make erase_flash${BUILD_COMPORT}${BUILD_BDRATE}
# ------------------------------------
elif [ "${arg}" == "miniterm" ]; then
echo "====================="
echo "Executing miniterm..."
echo "====================="
make simple_monitor${BUILD_COMPORT}
# ----------------------------------
elif [ "${arg}" == "monitor" ]; then
echo "============================"
echo "Executing esp-idf monitor..."
echo "============================"
make monitor
make monitor${BUILD_COMPORT}
# ---------------------------------
elif [ "${arg}" == "clean" ]; then
@@ -586,6 +705,11 @@ executeCommand() {
echo "** Restored 'sdkconfig' **'"
fi
make menuconfig 2>/dev/null
check_config
result=$?
if [ $result -eq 1 ]; then
make menuconfig 2>/dev/null
fi
# ---------------------------------
elif [ "${arg}" == "makefs" ]; then
@@ -645,6 +769,35 @@ executeCommand() {
echo "========================================"
make copyfatfs
# ------------------------------------
elif [ "${arg}" == "makelfsfs" ]; then
build_MKlfsFS
if [ $? -ne 0 ]; then
return 1
fi
echo "=========================="
echo "Creating LittleFS image..."
echo "=========================="
make makelfsfs
# -------------------------------------
elif [ "${arg}" == "flashlfsfs" ]; then
build_MKlfsFS
if [ $? -ne 0 ]; then
return 1
fi
echo "==================================="
echo "Flashing LittleFS image to ESP32..."
echo "==================================="
make flashlfsfs
# -------------------------------------
elif [ "${arg}" == "copylfsfs" ]; then
echo "==========================================="
echo "Flashing default LittleFS image to ESP32..."
echo "==========================================="
make copylfsfs
# -------------------------------
elif [ "${arg}" == "size" ]; then
echo "======================================="
@@ -659,8 +812,8 @@ executeCommand() {
echo "========================================="
make ${arg} 2>/dev/null
# -----------------------------------
elif [ "${arg}" == "firmware" ] || [ "${arg}" == "firmwareall" ]; then
# -------------------------------------------------------------------------------------------------------
elif [ "${arg}" == "firmware" ] || [ "${arg}" == "firmwareall" ] || [ "${arg}" == "firmwareallbt" ]; then
echo "======================="
echo "Saving the firmware ..."
echo "======================="
@@ -675,6 +828,13 @@ executeCommand() {
esp32dir="esp32_all"
fi
fi
if [ "${arg}" == "firmwareallbt" ]; then
if [ "${BUILD_TYPE}" != "" ]; then
esp32dir="esp32_psram_all_bt"
else
esp32dir="esp32_all_bt"
fi
fi
local useota=$(grep -e CONFIG_MICROPY_USE_OTA=y sdkconfig)
if [ "${useota}" == "CONFIG_MICROPY_USE_OTA=y" ]; then
esp32dir="${esp32dir}_ota"
@@ -685,9 +845,7 @@ executeCommand() {
cp -f partitions_mpy.csv firmware/${esp32dir} > /dev/null 2>&1
cp -f build/phy_init_data.bin firmware/${esp32dir} > /dev/null 2>&1
cp -f sdkconfig firmware/${esp32dir} > /dev/null 2>&1
echo "#!/bin/bash" > firmware/${esp32dir}/flash.sh
make echo_flash_cmd >> firmware/${esp32dir}/flash.sh 2>/dev/null
chmod +x firmware/${esp32dir}/flash.sh > /dev/null 2>&1
rm -f firmware/${esp32dir}/flash.sh > /dev/null 2>&1
return 0
# -------------------------------
@@ -30,6 +30,8 @@
* https://cool.haxx.se/mailman/listinfo/curl-library/
*/
#include "sdkconfig.h"
#define SIZEOF_CURL_OFF_T 4
#ifdef CURL_NO_OLDIES
@@ -218,7 +220,7 @@ typedef int (*curl_xferinfo_callback)(void *clientp,
#ifndef CURL_MAX_READ_SIZE
/* The maximum receive buffer size configurable via CURLOPT_BUFFERSIZE. */
#define CURL_MAX_READ_SIZE 524288
#define CURL_MAX_READ_SIZE 16384
#endif
#ifndef CURL_MAX_WRITE_SIZE
@@ -228,8 +230,12 @@ typedef int (*curl_xferinfo_callback)(void *clientp,
time for those who feel adventurous. The practical minimum is about
400 bytes since libcurl uses a buffer of this size as a scratch area
(unrelated to network send operations). */
#ifdef CONFIG_MICROPY_CURL_MAX_WRITE_SIZE
#define CURL_MAX_WRITE_SIZE CONFIG_MICROPY_CURL_MAX_WRITE_SIZE
#else
#define CURL_MAX_WRITE_SIZE 16384
#endif
#endif
#ifndef CURL_MAX_HTTP_HEADER
/* The only reason to have a max limit for this is to avoid the risk of a bad
@@ -1409,11 +1409,13 @@ void Curl_conncontrol(struct connectdata *conn,
bool closeit = (ctrl == CONNCTRL_CONNECTION) ||
((ctrl == CONNCTRL_STREAM) && !(conn->handler->flags & PROTOPT_STREAM));
if((ctrl == CONNCTRL_STREAM) &&
(conn->handler->flags & PROTOPT_STREAM))
DEBUGF(infof(conn->data, "Kill stream: %s\n", reason));
(conn->handler->flags & PROTOPT_STREAM)) {
//DEBUGF(infof(conn->data, "Kill stream: %s\n", reason));
DEBUGF(infof(conn->data, "Kill stream\n"));
}
else if(closeit != conn->bits.close) {
DEBUGF(infof(conn->data, "Marked for [%s]: %s\n",
closeit?"closure":"keep alive", reason));
//DEBUGF(infof(conn->data, "Marked for [%s]: %s\n", closeit?"closure":"keep alive", reason));
DEBUGF(infof(conn->data, "Marked for [%s]\n", closeit?"closure":"keep alive"));
conn->bits.close = closeit; /* the only place in the source code that
should assign this bit */
}
+2 -2
View File
@@ -395,7 +395,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
sshc->state = nowstate;
}
/*
// ==== LoBo ===============================================
int access (const char *file, int type)
@@ -446,7 +446,7 @@ return 0;
}
// ==== LoBo ===============================================
*/
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
static int sshkeycallback(struct Curl_easy *easy,
@@ -31,3 +31,6 @@
# Debug files
*.dSYM/
*.su
build
examples/**/build
examples/**/sdkconfig*
+172 -2
View File
@@ -1,5 +1,175 @@
[![](https://travis-ci.org/tuanpmt/espmqtt.svg?branch=master)](https://travis-ci.org/tuanpmt/espmqtt)
[![](http://hits.dwyl.io/tuanpmt/espmqtt.svg)](http://hits.dwyl.io/tuanpmt/espmqtt)
[![Twitter Follow](https://img.shields.io/twitter/follow/tuanpmt.svg?style=social&label=Follow)](https://twitter.com/tuanpmt)
![GitHub contributors](https://img.shields.io/github/contributors/tuanpmt/espmqtt.svg)
# ESP32 MQTT Library
This is component based on ESP-IDF for ESP32
## Features
Full documentation and sample project: https://github.com/tuanpmt/esp32-mqtt
- Based on: https://github.com/tuanpmt/esp_mqtt
- Support MQTT over TCP, SSL with mbedtls, MQTT over Websocket, MQTT over Websocket Secure
- Easy to setup with URI
- Multiple instances (Multiple clients in one application)
- Support subscribing, publishing, authentication, will messages, keep alive pings and all 3 QoS levels (it should be a fully functional client).
## How to use
Clone this component to [ESP-IDF](https://github.com/espressif/esp-idf) project (as submodule):
```
git submodule add https://github.com/tuanpmt/espmqtt.git components/espmqtt
```
Or run a sample (make sure you have installed the [toolchain](http://esp-idf.readthedocs.io/en/latest/get-started/index.html#setup-toolchain)):
```
git clone https://github.com/tuanpmt/espmqtt.git
cd espmqtt/examples/mqtt_tcp
make menuconfig
make flash monitor
```
## Documentation
### URI
- Curently support `mqtt`, `mqtts`, `ws`, `wss` schemes
- MQTT over TCP samples:
+ `mqtt://iot.eclipse.org`: MQTT over TCP, default port 1883:
+ `mqtt://iot.eclipse.org:1884` MQTT over TCP, port 1884:
+ `mqtt://username:password@iot.eclipse.org:1884` MQTT over TCP, port 1884, with username and password
- MQTT over SSL samples:
+ `mqtts://iot.eclipse.org`: MQTT over SSL, port 8883
+ `mqtts://iot.eclipse.org:8884`: MQTT over SSL, port 8884
- MQTT over Websocket samples:
+ `ws://iot.eclipse.org:80/ws`
- MQTT over Websocket Secure samples:
+ `wss://iot.eclipse.org:443/ws`
- Minimal configurations:
```c
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtt://iot.eclipse.org",
.event_handle = mqtt_event_handler,
// .user_context = (void *)your_context
};
```
- If there are any options related to the URI in `esp_mqtt_client_config_t`, the option defined by the URI will be overridden. Sample:
```c
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtt://iot.eclipse.org:1234",
.event_handle = mqtt_event_handler,
.port = 4567,
};
//MQTT client will connect to iot.eclipse.org using port 4567
```
### SSL
- Get Certification from server, example: `iot.eclipse.org` `openssl s_client -showcerts -connect iot.eclipse.org:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >iot_eclipse_org.pem`
- Check the sample application: `examples/mqtt_ssl`
- Configuration:
```cpp
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtts://iot.eclipse.org:8883",
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
};
```
### More options for `esp_mqtt_client_config_t`
- `event_handle` for MQTT events
- `host`: MQTT server domain (ipv4 as string)
- `port`: MQTT server port
- `client_id`: default client id is `ESP32_%CHIPID%`
- `username`: MQTT username
- `password`: MQTT password
- `lwt_topic, lwt_msg, lwt_qos, lwt_retain, lwt_msg_len`: are mqtt lwt options, default NULL
- `disable_clean_session`: mqtt clean session, default clean_session is true
- `keepalive`: (value in seconds) mqtt keepalive, default is 120 seconds
- `disable_auto_reconnect`: this mqtt client will reconnect to server (when errors/disconnect). Set `disable_auto_reconnect=true` to disable
- `user_context` pass user context to this option, then can receive that context in `event->user_context`
- `task_prio, task_stack` for MQTT task, default priority is 5, and task_stack = 6144 bytes (or default task stack can be set via `make menucofig`).
- `buffer_size` for MQTT send/receive buffer, default is 1024
- `cert_pem` pointer to CERT file for server verify (with SSL), default is NULL, not required to verify the server
- `transport`: override URI transport
+ `MQTT_TRANSPORT_OVER_TCP`: MQTT over TCP, using scheme: `mqtt`
+ `MQTT_TRANSPORT_OVER_SSL`: MQTT over SSL, using scheme: `mqtts`
+ `MQTT_TRANSPORT_OVER_WS`: MQTT over Websocket, using scheme: `ws`
+ `MQTT_TRANSPORT_OVER_WSS`: MQTT over Websocket Secure, using scheme: `wss`
### Change settings in `menuconfig`
```
make menuconfig
-> Component config -> ESPMQTT Configuration
```
## Example
Check `examples/mqtt_tcp` and `examples/mqtt_ssl` project. In Short:
```cpp
static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
{
esp_mqtt_client_handle_t client = event->client;
int msg_id;
// your_context_t *context = event->context;
switch (event->event_id) {
case MQTT_EVENT_CONNECTED:
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
break;
case MQTT_EVENT_DISCONNECTED:
ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
break;
case MQTT_EVENT_SUBSCRIBED:
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
break;
case MQTT_EVENT_UNSUBSCRIBED:
ESP_LOGI(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id);
break;
case MQTT_EVENT_PUBLISHED:
ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id);
break;
case MQTT_EVENT_DATA:
ESP_LOGI(TAG, "MQTT_EVENT_DATA");
printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
printf("DATA=%.*s\r\n", event->data_len, event->data);
break;
case MQTT_EVENT_ERROR:
ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
break;
}
return ESP_OK;
}
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtt://iot.eclipse.org",
.event_handle = mqtt_event_handler,
// .user_context = (void *)your_context
};
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
esp_mqtt_client_start(client);
```
## License
[@tuanpmt](https://twitter.com/tuanpmt)
Apache License
@@ -6,8 +6,5 @@
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the SDK documents if you need to do this.
#
COMPONENT_ADD_INCLUDEDIRS := include
#COMPONENT_PRIV_INCLUDEDIRS :=
#EXTRA_CFLAGS := -DICACHE_RODATA_ATTR
CFLAGS += -Wno-error=implicit-function-declaration -Wno-error=format= -DHAVE_CONFIG_H
COMPONENT_SRCDIRS := . lib
COMPONENT_PRIV_INCLUDEDIRS := lib/include
@@ -1,203 +0,0 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Boris Lovosevic (https://github.com/loboris)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
* Mqtt Module using MQTT task.
* Based on ESP32 MQTT Library by Tuan PM, https://github.com/tuanpmt/espmqtt
* Adapted for MicroPython by Boris Lovosevic, https://github.com/loboris
*
*/
#ifndef _MQTT_H_
#define _MQTT_H_
#include "sdkconfig.h"
#ifdef CONFIG_MICROPY_USE_MQTT
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "mqtt_msg.h"
#include "ringbuf.h"
#include "openssl/ssl.h"
// Constants not defined in menuconfig
#define CONFIG_MQTT_MAX_HOST_LEN 64
#define CONFIG_MQTT_MAX_CLIENT_LEN 32
#define CONFIG_MQTT_MAX_USERNAME_LEN 32
#define CONFIG_MQTT_MAX_PASSWORD_LEN 32
#define CONFIG_MQTT_MAX_LWT_TOPIC 32
#define CONFIG_MQTT_MAX_LWT_MSG 32
#define CONFIG_MQTT_MAX_TASKNAME_LEN 16
// Mqtt client status constants
#define MQTT_STATUS_DISCONNECTED 0
#define MQTT_STATUS_CONNECTED 1
#define MQTT_STATUS_STOPPING 2
#define MQTT_STATUS_STOPPED 4
#define MQTT_SENDING_TYPE_NONE 0
#define MQTT_SENDING_TYPE_PUBLISH 1
#define MQTT_SENDING_TYPE_SUBSCRIBE 2
#define MQTT_SENDING_TYPE_UNSUBSCRIBE 3
#define MQTT_SENDING_TYPE_PING 4
typedef struct mqtt_client mqtt_client;
typedef struct mqtt_event_data_t mqtt_event_data_t;
/**
* \return True on connect success, false on error
*/
typedef bool (* mqtt_connect_callback)(mqtt_client *client);
/**
*/
typedef void (* mqtt_disconnect_callback)(mqtt_client *client);
/**
* \param[out] buffer Pointer to buffer to fill
* \param[in] len Number of bytes to read
* \param[in] timeout_ms Time to wait for completion, or 0 for no timeout
* \return Number of bytes read, less than 0 on error
*/
typedef int (* mqtt_read_callback)(mqtt_client *client, void *buffer, int len, int timeout_ms);
/**
* \param[in] buffer Pointer to buffer to write
* \param[in] len Number of bytes to write
* \param[in] timeout_ms Time to wait for completion, or 0 for no timeout
* \return Number of bytes written, less than 0 on error
*/
typedef int (* mqtt_write_callback)(mqtt_client *client, const void *buffer, int len, int timeout_ms);
typedef void (* mqtt_event_callback)(mqtt_client *client, mqtt_event_data_t *event_data);
typedef struct mqtt_settings {
mqtt_connect_callback connect_cb;
mqtt_disconnect_callback disconnect_cb;
mqtt_read_callback read_cb;
mqtt_write_callback write_cb;
mqtt_event_callback connected_cb;
mqtt_event_callback disconnected_cb;
mqtt_event_callback subscribe_cb;
mqtt_event_callback unsubscribe_cb;
mqtt_event_callback publish_cb;
mqtt_event_callback data_cb;
void *mpy_connected_cb;
void *mpy_disconnected_cb;
void *mpy_subscribed_cb;
void *mpy_unsubscribed_cb;
void *mpy_published_cb;
void *mpy_data_cb;
char host[CONFIG_MQTT_MAX_HOST_LEN];
uint16_t port;
char client_id[CONFIG_MQTT_MAX_CLIENT_LEN];
char username[CONFIG_MQTT_MAX_USERNAME_LEN];
char password[CONFIG_MQTT_MAX_PASSWORD_LEN];
char lwt_topic[CONFIG_MQTT_MAX_LWT_TOPIC];
char lwt_msg[CONFIG_MQTT_MAX_LWT_MSG];
uint32_t lwt_msg_len;
uint32_t lwt_qos;
uint32_t lwt_retain;
uint32_t clean_session;
uint32_t keepalive;
bool auto_reconnect;
bool use_ssl;
TaskHandle_t xMqttTask;
TaskHandle_t xMqttSendingTask;
uint32_t xMqttTask_stacksize;
uint32_t xMqttSendingTask_stacksize;
} mqtt_settings;
typedef struct mqtt_event_data_t
{
uint8_t type;
const char* topic;
const char* data;
uint16_t topic_length;
uint16_t data_length;
uint32_t data_offset;
uint32_t data_total_length;
} mqtt_event_data_t;
typedef struct mqtt_state_t
{
uint16_t port;
int auto_reconnect;
mqtt_connect_info_t* connect_info;
uint8_t* in_buffer;
uint8_t* out_buffer;
int in_buffer_length;
int out_buffer_length;
uint16_t message_length;
uint16_t message_length_read;
mqtt_message_t* outbound_message;
mqtt_connection_t mqtt_connection;
uint16_t pending_msg_id;
int pending_msg_type;
int sending_msg_type;
int pending_publish_qos;
} mqtt_state_t;
typedef struct mqtt_client {
int socket;
SSL_CTX *ctx;
SSL *ssl;
mqtt_settings *settings;
mqtt_state_t mqtt_state;
mqtt_connect_info_t connect_info;
QueueHandle_t xSendingQueue;
RINGBUF send_rb;
uint32_t keepalive_tick;
uint8_t status;
uint8_t subs_flag;
uint8_t unsubs_flag;
uint8_t *msgbuf;
uint8_t *topicbuf;
bool terminate_mqtt;
char *name;
} mqtt_client;
const char *MQTT_TAG;
int mqtt_start(mqtt_client *client);
void mqtt_stop(mqtt_client* client);
void mqtt_task(void *pvParameters);
void mqtt_subscribe(mqtt_client *client, const char *topic, uint8_t qos);
void mqtt_unsubscribe(mqtt_client *client, const char *topic);
int mqtt_publish(mqtt_client* client, const char *topic, const char *data, int len, int qos, int retain);
void mqtt_free(mqtt_client *client);
#endif
#endif
+167
View File
@@ -0,0 +1,167 @@
/*
* This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo
*
* Apache License Version 2.0
*
* Slightly modified mqtt library from https://github.com/tuanpmt/espmqtt
*
* Copyright (c) 2018 tuanpm (https://github.com/tuanpmt/espmqtt)
* Copyright (c) 2018 LoBo (https://github.com/loboris)
*/
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _MQTT_CLIENT_H_
#define _MQTT_CLIENT_H_
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "esp_err.h"
#include "platform.h"
#include "mqtt_config.h"
#include "mqtt_msg.h"
#include "transport.h"
#include "transport_tcp.h"
#include "transport_ssl.h"
#include "transport_ws.h"
#include "platform.h"
#include "mqtt_outbox.h"
typedef struct esp_mqtt_client* esp_mqtt_client_handle_t;
typedef enum {
MQTT_EVENT_ERROR = 0,
MQTT_EVENT_CONNECTED,
MQTT_EVENT_DISCONNECTED,
MQTT_EVENT_SUBSCRIBED,
MQTT_EVENT_UNSUBSCRIBED,
MQTT_EVENT_PUBLISHED,
MQTT_EVENT_DATA,
} esp_mqtt_event_id_t;
typedef enum {
MQTT_TRANSPORT_UNKNOWN = 0x0,
MQTT_TRANSPORT_OVER_TCP,
MQTT_TRANSPORT_OVER_SSL,
MQTT_TRANSPORT_OVER_WS,
MQTT_TRANSPORT_OVER_WSS
} esp_mqtt_transport_t;
typedef enum {
MQTT_STATE_ERROR = -1,
MQTT_STATE_UNKNOWN = 0,
MQTT_STATE_INIT,
MQTT_STATE_CONNECTED,
MQTT_STATE_WAIT_TIMEOUT,
} mqtt_client_state_t;
typedef struct {
esp_mqtt_event_id_t event_id;
esp_mqtt_client_handle_t client;
void *user_context;
char *data;
int data_len;
int total_data_len;
int current_data_offset;
char *topic;
int topic_len;
int msg_id;
int type;
} esp_mqtt_event_t;
typedef esp_mqtt_event_t* esp_mqtt_event_handle_t;
typedef esp_err_t (* mqtt_event_callback_t)(esp_mqtt_event_handle_t event);
typedef struct {
mqtt_event_callback_t event_handle;
char host[MQTT_MAX_HOST_LEN];
char uri[MQTT_MAX_HOST_LEN];
uint32_t port;
char client_id[MQTT_MAX_CLIENT_LEN];
char username[MQTT_MAX_USERNAME_LEN];
char password[MQTT_MAX_PASSWORD_LEN];
char lwt_topic[MQTT_MAX_LWT_TOPIC];
char lwt_msg[MQTT_MAX_LWT_MSG];
int lwt_qos;
int lwt_retain;
int lwt_msg_len;
int disable_clean_session;
int keepalive;
bool disable_auto_reconnect;
void *user_context;
int task_prio;
int task_stack;
int buffer_size;
const char *cert_pem;
esp_mqtt_transport_t transport;
} esp_mqtt_client_config_t;
typedef struct mqtt_state
{
mqtt_connect_info_t *connect_info;
uint8_t *in_buffer;
uint8_t *out_buffer;
int in_buffer_length;
int out_buffer_length;
uint16_t message_length;
uint16_t message_length_read;
mqtt_message_t *outbound_message;
mqtt_connection_t mqtt_connection;
uint16_t pending_msg_id;
int pending_msg_type;
int pending_publish_qos;
int pending_msg_count;
} mqtt_state_t;
typedef struct {
mqtt_event_callback_t event_handle;
int task_stack;
int task_prio;
char *uri;
char *host;
char *path;
char *scheme;
int port;
bool auto_reconnect;
void *user_context;
int network_timeout_ms;
} mqtt_config_storage_t;
struct esp_mqtt_client {
transport_list_handle_t transport_list;
transport_handle_t transport;
mqtt_config_storage_t *config;
mqtt_state_t mqtt_state;
mqtt_connect_info_t connect_info;
mqtt_client_state_t state;
long long keepalive_tick;
long long reconnect_tick;
int wait_timeout_ms;
int auto_reconnect;
esp_mqtt_event_t event;
bool run;
outbox_handle_t outbox;
EventGroupHandle_t status_bits;
void *mpy_mqtt_obj;
};
extern const char *MQTT_TAG;
esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *config);
esp_err_t esp_mqtt_client_set_uri(esp_mqtt_client_handle_t client, const char *uri);
esp_err_t esp_mqtt_client_start(esp_mqtt_client_handle_t client);
esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client);
esp_err_t esp_mqtt_client_subscribe(esp_mqtt_client_handle_t client, const char *topic, int qos);
esp_err_t esp_mqtt_client_unsubscribe(esp_mqtt_client_handle_t client, const char *topic);
int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain);
esp_err_t esp_mqtt_client_destroy(esp_mqtt_client_handle_t client);
#endif
@@ -0,0 +1,68 @@
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
* Tuan PM <tuanpm at live dot com>
*/
#ifndef _MQTT_CONFIG_H_
#define _MQTT_CONFIG_H_
#include "sdkconfig.h"
#define MQTT_PROTOCOL_311 CONFIG_MQTT_PROTOCOL_311
#define MQTT_RECONNECT_TIMEOUT_MS (10*1000)
#if CONFIG_MQTT_BUFFER_SIZE
#define MQTT_BUFFER_SIZE_BYTE CONFIG_MQTT_BUFFER_SIZE
#else
#define MQTT_BUFFER_SIZE_BYTE 1024
#endif
#define MQTT_MAX_HOST_LEN 64
#define MQTT_MAX_CLIENT_LEN 32
#define MQTT_MAX_USERNAME_LEN 32
#define MQTT_MAX_PASSWORD_LEN 65
#define MQTT_MAX_LWT_TOPIC 32
#define MQTT_MAX_LWT_MSG 128
#define MQTT_TASK_PRIORITY 5
#if CONFIG_MQTT_TASK_STACK_SIZE
#define MQTT_TASK_STACK CONFIG_MQTT_TASK_STACK_SIZE
#else
#define MQTT_TASK_STACK (6*1024)
#endif
#define MQTT_KEEPALIVE_TICK (120)
#define MQTT_CMD_QUEUE_SIZE (10)
#define MQTT_NETWORK_TIMEOUT_MS (10000)
#ifdef CONFIG_MQTT_TCP_DEFAULT_PORT
#define MQTT_TCP_DEFAULT_PORT CONFIG_MQTT_TCP_DEFAULT_PORT
#else
#define MQTT_TCP_DEFAULT_PORT 1883
#endif
#ifdef CONFIG_MQTT_SSL_DEFAULT_PORT
#define MQTT_SSL_DEFAULT_PORT CONFIG_MQTT_SSL_DEFAULT_PORT
#else
#define MQTT_SSL_DEFAULT_PORT 8883
#endif
#ifdef CONFIG_MQTT_WS_DEFAULT_PORT
#define MQTT_WS_DEFAULT_PORT CONFIG_MQTT_WS_DEFAULT_PORT
#else
#define MQTT_WS_DEFAULT_PORT 80
#endif
#ifdef MQTT_WSS_DEFAULT_PORT
#define MQTT_WSS_DEFAULT_PORT CONFIG_MQTT_WSS_DEFAULT_PORT
#else
#define MQTT_WSS_DEFAULT_PORT 443
#endif
#define MQTT_ENABLE_SSL CONFIG_MQTT_TRANSPORT_SSL
#define MQTT_ENABLE_WS CONFIG_MQTT_TRANSPORT_WEBSOCKET
#define MQTT_ENABLE_WSS CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE
#define OUTBOX_EXPIRED_TIMEOUT_MS (30*1000)
#define OUTBOX_MAX_SIZE (4*1024)
#endif
@@ -1,23 +0,0 @@
#ifndef _RING_BUF_H_
#define _RING_BUF_H_
#include <stdint.h>
typedef struct{
uint8_t* p_o; /**< Original pointer */
uint8_t* volatile p_r; /**< Read pointer */
uint8_t* volatile p_w; /**< Write pointer */
volatile int32_t fill_cnt; /**< Number of filled slots */
int32_t size; /**< Buffer size */
int32_t block_size;
}RINGBUF;
int32_t rb_init(RINGBUF *r, uint8_t* buf, int32_t size, int32_t block_size);
int32_t rb_put(RINGBUF *r, uint8_t* c);
int32_t rb_get(RINGBUF *r, uint8_t* c);
int32_t rb_available(RINGBUF *r);
uint32_t rb_read(RINGBUF *r, uint8_t *buf, int len);
uint32_t rb_write(RINGBUF *r, uint8_t *buf, int len);
#endif

Some files were not shown because too many files have changed in this diff Show More