Merge branch 'release/v0.6.0'
This commit is contained in:
+5
-1
@@ -5,10 +5,14 @@ python:
|
||||
env:
|
||||
- PLATFORMIO_PROJECT_DIR=examples/arduino-blink
|
||||
- PLATFORMIO_PROJECT_DIR=examples/arduino-wifiscan
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-ble-adv
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-coap-server
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-hello-world
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-http-request
|
||||
- PLATFORMIO_PROJECT_DIR=examples/simba-blink
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-peripherals-uart
|
||||
- PLATFORMIO_PROJECT_DIR=examples/espidf-storage-sdcard
|
||||
- PLATFORMIO_PROJECT_DIR=examples/pumbaa-blink
|
||||
- PLATFORMIO_PROJECT_DIR=examples/simba-blink
|
||||
|
||||
install:
|
||||
- pip install -U https://github.com/platformio/platformio/archive/develop.zip
|
||||
|
||||
+5
-1
@@ -4,10 +4,14 @@ environment:
|
||||
matrix:
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/arduino-blink"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/arduino-wifiscan"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-ble-adv"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-coap-server"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-hello-world"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-http-request"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/simba-blink"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-peripherals-uart"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/espidf-storage-sdcard"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/pumbaa-blink"
|
||||
- PLATFORMIO_PROJECT_DIR: "examples/simba-blink"
|
||||
|
||||
install:
|
||||
- cmd: git submodule update --init --recursive
|
||||
|
||||
+185
-42
@@ -20,8 +20,8 @@ Espressif IoT Development Framework for ESP32 MCU
|
||||
https://github.com/espressif/esp-idf
|
||||
"""
|
||||
|
||||
from os import listdir
|
||||
from os.path import isdir, join
|
||||
from os import listdir, walk
|
||||
from os.path import basename, isdir, isfile, join
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
|
||||
@@ -35,36 +35,115 @@ FRAMEWORK_VERSION = platform.get_package_version(
|
||||
"framework-espidf")
|
||||
|
||||
|
||||
def parse_mk(path):
|
||||
result = {}
|
||||
variable = None
|
||||
multi = False
|
||||
with open(path) as fp:
|
||||
for line in fp.readlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
# remove inline comments
|
||||
if " # " in line:
|
||||
line = line[:line.index(" # ")]
|
||||
if not multi and "=" in line:
|
||||
variable, line = line.split("=", 1)
|
||||
if variable.endswith((":", "+")):
|
||||
variable = variable[:-1]
|
||||
variable = variable.strip()
|
||||
line = line.strip()
|
||||
if not variable or not line:
|
||||
continue
|
||||
multi = line.endswith('\\')
|
||||
if multi:
|
||||
line = line[:-1].strip()
|
||||
if variable not in result:
|
||||
result[variable] = []
|
||||
result[variable].extend([l.strip() for l in line.split()])
|
||||
if not multi:
|
||||
variable = None
|
||||
return result
|
||||
|
||||
|
||||
def build_component(path):
|
||||
envsafe = env.Clone()
|
||||
src_filter = "+<*> -<test> -<tests>"
|
||||
if isfile(join(path, "component.mk")):
|
||||
params = parse_mk(join(path, "component.mk"))
|
||||
if params.get("COMPONENT_PRIV_INCLUDEDIRS"):
|
||||
inc_dirs = params.get("COMPONENT_PRIV_INCLUDEDIRS")
|
||||
envsafe.Prepend(
|
||||
CPPPATH=[join(path, d) for d in inc_dirs])
|
||||
if params.get("CFLAGS"):
|
||||
envsafe.Append(CCFLAGS=params.get("CFLAGS"))
|
||||
if params.get("COMPONENT_OBJS"):
|
||||
src_filter = "-<*>"
|
||||
for f in params.get("COMPONENT_OBJS"):
|
||||
src_filter += " +<%s>" % f.replace(".o", ".c")
|
||||
elif params.get("COMPONENT_SRCDIRS"):
|
||||
src_filter = "-<*>"
|
||||
src_dirs = params.get("COMPONENT_SRCDIRS")
|
||||
if "." in src_dirs:
|
||||
src_dirs.remove(".")
|
||||
src_filter += " +<*.c*>"
|
||||
for f in src_dirs:
|
||||
src_filter += " +<%s/*.c*>" % f
|
||||
|
||||
return envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "%s" % basename(path)), path,
|
||||
src_filter=src_filter
|
||||
)
|
||||
|
||||
|
||||
def build_espidf_bootloader():
|
||||
envsafe = env.Clone()
|
||||
envsafe.Append(CPPDEFINES=[("BOOTLOADER_BUILD", 1)])
|
||||
envsafe.Replace(
|
||||
CPPDEFINES=["ESP_PLATFORM", ("BOOTLOADER_BUILD", 1)],
|
||||
|
||||
LIBPATH=[
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "ld"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "lib"),
|
||||
join(FRAMEWORK_DIR, "components", "bootloader", "src", "main")
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-nostdlib",
|
||||
"-Wl,-static",
|
||||
"-u", "call_user_start_cpu0",
|
||||
"-Wl,-static",
|
||||
"-Wl,--gc-sections",
|
||||
"-T", "esp32.bootloader.ld",
|
||||
"-T", "esp32.rom.ld"
|
||||
"-T", "esp32.rom.ld",
|
||||
"-T", "esp32.bootloader.rom.ld"
|
||||
]
|
||||
),
|
||||
|
||||
envsafe.Append(CCFLAGS=["-fstrict-volatile-bitfields"])
|
||||
envsafe.Append(
|
||||
CPPPATH=[
|
||||
join(FRAMEWORK_DIR, "components", "esp32")
|
||||
]
|
||||
)
|
||||
|
||||
envsafe.Replace(
|
||||
LIBS=[
|
||||
envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "bootloaderSupport"),
|
||||
join(FRAMEWORK_DIR, "components", "bootloader_support")
|
||||
),
|
||||
envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "bootloaderLog"),
|
||||
join(FRAMEWORK_DIR, "components", "log")
|
||||
), "gcc"
|
||||
),
|
||||
envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "bootloaderSPIFlash"),
|
||||
join(FRAMEWORK_DIR, "components", "spi_flash"),
|
||||
src_filter="-<*> +<spi_flash_rom_patch.c>"
|
||||
),
|
||||
envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "bootloaderMicroEcc"),
|
||||
join(FRAMEWORK_DIR, "components", "micro-ecc"),
|
||||
src_filter="+<*> -<micro-ecc/test>"
|
||||
),
|
||||
"rtc", "gcc", "stdc++"
|
||||
]
|
||||
)
|
||||
|
||||
@@ -80,27 +159,53 @@ def build_espidf_bootloader():
|
||||
env.Prepend(
|
||||
CPPPATH=[
|
||||
join("$PROJECTSRC_DIR"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "xtensa-debug-module", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "app_update", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "bootloader_support", "include"),
|
||||
join(FRAMEWORK_DIR, "components",
|
||||
"bootloader_support", "include_priv"),
|
||||
join(FRAMEWORK_DIR, "components", "bt", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "coap", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "coap", "port", "include", "coap"),
|
||||
join(FRAMEWORK_DIR, "components", "coap", "libcoap", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "coap",
|
||||
"libcoap", "include", "coap"),
|
||||
join(FRAMEWORK_DIR, "components", "cxx", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "driver", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "driver", "include", "driver"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "ethernet", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "expat", "include", "expat"),
|
||||
join(FRAMEWORK_DIR, "components", "expat", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "fatfs", "src"),
|
||||
join(FRAMEWORK_DIR, "components", "freertos", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "freertos", "include", "freertos"),
|
||||
join(FRAMEWORK_DIR, "components", "json", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "json", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "log", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "newlib", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "nvs_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "spi_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "tcpip_adapter", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip"),
|
||||
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip", "port"),
|
||||
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip", "posix"),
|
||||
join(FRAMEWORK_DIR, "components", "expat", "include", "expat"),
|
||||
join(FRAMEWORK_DIR, "components", "expat", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "json", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "json", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "lwip", "apps", "ping"),
|
||||
join(FRAMEWORK_DIR, "components", "mbedtls", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "mbedtls", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "mbedtls", "port", "include")
|
||||
join(FRAMEWORK_DIR, "components", "mdns", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "micro-ecc", "micro-ecc"),
|
||||
join(FRAMEWORK_DIR, "components", "newlib", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "newlib", "platform_include"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "nvs_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "openssl", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "openssl", "include", "internal"),
|
||||
join(FRAMEWORK_DIR, "components", "openssl", "include", "platform"),
|
||||
join(FRAMEWORK_DIR, "components", "openssl", "include", "openssl"),
|
||||
join(FRAMEWORK_DIR, "components", "sdmmc", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "spi_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "tcpip_adapter", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "ulp", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "vfs", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "wpa_supplicant", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "wpa_supplicant", "port", "include")
|
||||
],
|
||||
|
||||
LIBPATH=[
|
||||
@@ -113,17 +218,43 @@ env.Prepend(
|
||||
],
|
||||
|
||||
LIBS=[
|
||||
"hal", "crypto", "core", "net80211", "phy", "rtc", "pp", "wpa",
|
||||
"smartconfig", "btdm_app", "m", "c", "gcc"
|
||||
"btdm_app", "hal", "coexist", "core", "net80211", "phy", "rtc", "pp",
|
||||
"wpa", "wpa2", "wps", "smartconfig", "m", "c", "gcc", "stdc++"
|
||||
]
|
||||
)
|
||||
|
||||
env.Append(
|
||||
LIBSOURCE_DIRS=[
|
||||
join(FRAMEWORK_DIR, "libraries")
|
||||
for root, dirs, _ in walk(join(
|
||||
FRAMEWORK_DIR, "components", "bt", "bluedroid")):
|
||||
for d in dirs:
|
||||
if (d == "include"):
|
||||
env.Append(CPPPATH=[join(root, d)])
|
||||
|
||||
|
||||
env.Prepend(
|
||||
CFLAGS=["-Wno-old-style-declaration"],
|
||||
|
||||
CPPDEFINES=[
|
||||
"WITH_POSIX",
|
||||
("IDF_VER", '\\"%s\\"' %
|
||||
platform.get_package_version("framework-espidf"))
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-Wall",
|
||||
"-Werror=all",
|
||||
"-Wno-error=deprecated-declarations",
|
||||
"-Wextra",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-sign-compare",
|
||||
"-Wno-error=unused-function"
|
||||
],
|
||||
|
||||
LIBSOURCE_DIRS=[join(FRAMEWORK_DIR, "libraries")]
|
||||
)
|
||||
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"-u", "__cxa_guard_dummy",
|
||||
"-T", "esp32.common.ld",
|
||||
"-T", "esp32.rom.ld",
|
||||
"-T", "esp32.peripherals.ld"
|
||||
@@ -131,7 +262,7 @@ env.Append(
|
||||
|
||||
UPLOADERFLAGS=[
|
||||
"0x1000", join("$BUILD_DIR", "bootloader.bin"),
|
||||
"0x4000", join("$BUILD_DIR", "partitions_table.bin"),
|
||||
"0x8000", join("$BUILD_DIR", "partitions_table.bin"),
|
||||
"0x10000"
|
||||
]
|
||||
)
|
||||
@@ -142,15 +273,15 @@ env.Append(
|
||||
|
||||
partition_table = env.Command(
|
||||
join("$BUILD_DIR", "partitions_table.bin"),
|
||||
join(FRAMEWORK_DIR, "components",
|
||||
"partition_table", "partitions_singleapp.csv"),
|
||||
'"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
|
||||
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py")
|
||||
)
|
||||
join(FRAMEWORK_DIR, "components", "partition_table",
|
||||
"partitions_singleapp.csv"),
|
||||
env.VerboseAction('"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
|
||||
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py"),
|
||||
"Generating partitions $TARGET"))
|
||||
|
||||
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
|
||||
|
||||
|
||||
#
|
||||
# Generate linker script
|
||||
#
|
||||
@@ -158,8 +289,9 @@ env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
|
||||
linker_script = env.Command(
|
||||
join("$BUILD_DIR", "esp32_out.ld"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "ld", "esp32.ld"),
|
||||
"$CC -I$PROJECTSRC_DIR -C -P -x c -E $SOURCE -o $TARGET"
|
||||
)
|
||||
env.VerboseAction(
|
||||
"$CC -I$PROJECTSRC_DIR -C -P -x c -E $SOURCE -o $TARGET",
|
||||
"Generating LD script $TARGET"))
|
||||
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
|
||||
|
||||
@@ -177,16 +309,27 @@ env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", env.ElfToBin(
|
||||
libs = []
|
||||
|
||||
ignore_dirs = (
|
||||
"bootloader", "esptool_py", "idf_test", "newlib", "partition_table")
|
||||
"bootloader",
|
||||
"bootloader_support",
|
||||
"esptool_py",
|
||||
"idf_test",
|
||||
"partition_table",
|
||||
"nghttp",
|
||||
"spi_flash"
|
||||
)
|
||||
|
||||
for d in listdir(join(FRAMEWORK_DIR, "components")):
|
||||
if d in ignore_dirs:
|
||||
continue
|
||||
if isdir(join(FRAMEWORK_DIR, "components", d)):
|
||||
libs.append(env.BuildLibrary(
|
||||
join("$BUILD_DIR", "%s" % d),
|
||||
join(FRAMEWORK_DIR, "components", d),
|
||||
src_filter="+<*> -<test>"
|
||||
))
|
||||
component_dir = join(FRAMEWORK_DIR, "components", d)
|
||||
if isdir(component_dir):
|
||||
libs.append(build_component(component_dir))
|
||||
|
||||
|
||||
libs.append(env.BuildLibrary(
|
||||
join("$BUILD_DIR", "spi_flash"),
|
||||
join(FRAMEWORK_DIR, "components", "spi_flash"),
|
||||
src_filter="+<*> -<test>"
|
||||
))
|
||||
|
||||
env.Prepend(LIBS=libs)
|
||||
|
||||
@@ -49,7 +49,6 @@ env.Replace(
|
||||
"-g3",
|
||||
"-nostdlib",
|
||||
"-Wpointer-arith",
|
||||
"-Wno-error=unused-function",
|
||||
"-Wno-error=unused-but-set-variable",
|
||||
"-Wno-error=unused-variable",
|
||||
"-mlongcalls",
|
||||
@@ -162,7 +161,6 @@ target_upload = env.Alias(
|
||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")])
|
||||
env.AlwaysBuild(target_upload)
|
||||
|
||||
|
||||
#
|
||||
# Default targets
|
||||
#
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
@@ -0,0 +1,65 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/en/stable/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -0,0 +1,38 @@
|
||||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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.
|
||||
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. `Install PlatformIO <http://docs.platformio.org/en/stable/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-espressif8266/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-espressif32/examples/espidf-ble-adv
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organised `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
See additional options for PlatformIO Library Dependency Finder `lib_*`:
|
||||
|
||||
http://docs.platformio.org/en/stable/projectconf.html#lib-install
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:nano32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = nano32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:espea32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = espea32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
@@ -0,0 +1,219 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "bt.h"
|
||||
#include <string.h>
|
||||
|
||||
#define HCI_H4_CMD_PREAMBLE_SIZE (4)
|
||||
|
||||
/* HCI Command opcode group field(OGF) */
|
||||
#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */
|
||||
#define HCI_GRP_BLE_CMDS (0x08 << 10)
|
||||
|
||||
#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
|
||||
#define HCI_BLE_WRITE_ADV_ENABLE (0x000A | HCI_GRP_BLE_CMDS)
|
||||
#define HCI_BLE_WRITE_ADV_PARAMS (0x0006 | HCI_GRP_BLE_CMDS)
|
||||
#define HCI_BLE_WRITE_ADV_DATA (0x0008 | HCI_GRP_BLE_CMDS)
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE (1)
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS (15)
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA (31)
|
||||
|
||||
#define BD_ADDR_LEN (6) /* Device address length */
|
||||
typedef uint8_t bd_addr_t[BD_ADDR_LEN]; /* Device address */
|
||||
|
||||
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)((u16) >> 8);}
|
||||
#define UINT8_TO_STREAM(p, u8) {*(p)++ = (uint8_t)(u8);}
|
||||
#define BDADDR_TO_STREAM(p, a) {int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (uint8_t) a[BD_ADDR_LEN - 1 - ijk];}
|
||||
#define ARRAY_TO_STREAM(p, a, len) {int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (uint8_t) a[ijk];}
|
||||
|
||||
enum {
|
||||
H4_TYPE_COMMAND = 1,
|
||||
H4_TYPE_ACL = 2,
|
||||
H4_TYPE_SCO = 3,
|
||||
H4_TYPE_EVENT = 4
|
||||
};
|
||||
|
||||
static uint8_t hci_cmd_buf[128];
|
||||
|
||||
/*
|
||||
* @brief: BT controller callback function, used to notify the upper layer that
|
||||
* controller is ready to receive command
|
||||
*/
|
||||
static void controller_rcv_pkt_ready(void)
|
||||
{
|
||||
printf("controller rcv pkt ready\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief: BT controller callback function, to transfer data packet to upper
|
||||
* controller is ready to receive command
|
||||
*/
|
||||
static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
{
|
||||
printf("host rcv pkt: ");
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
printf("%02x", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static esp_vhci_host_callback_t vhci_host_cb = {
|
||||
controller_rcv_pkt_ready,
|
||||
host_rcv_pkt
|
||||
};
|
||||
|
||||
static uint16_t make_cmd_reset(uint8_t *buf)
|
||||
{
|
||||
UINT8_TO_STREAM (buf, H4_TYPE_COMMAND);
|
||||
UINT16_TO_STREAM (buf, HCI_RESET);
|
||||
UINT8_TO_STREAM (buf, 0);
|
||||
return HCI_H4_CMD_PREAMBLE_SIZE;
|
||||
}
|
||||
|
||||
static uint16_t make_cmd_ble_set_adv_enable (uint8_t *buf, uint8_t adv_enable)
|
||||
{
|
||||
UINT8_TO_STREAM (buf, H4_TYPE_COMMAND);
|
||||
UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_ENABLE);
|
||||
UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE);
|
||||
UINT8_TO_STREAM (buf, adv_enable);
|
||||
return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE;
|
||||
}
|
||||
|
||||
static uint16_t make_cmd_ble_set_adv_param (uint8_t *buf, uint16_t adv_int_min, uint16_t adv_int_max,
|
||||
uint8_t adv_type, uint8_t addr_type_own,
|
||||
uint8_t addr_type_dir, bd_addr_t direct_bda,
|
||||
uint8_t channel_map, uint8_t adv_filter_policy)
|
||||
{
|
||||
UINT8_TO_STREAM (buf, H4_TYPE_COMMAND);
|
||||
UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_PARAMS);
|
||||
UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS );
|
||||
|
||||
UINT16_TO_STREAM (buf, adv_int_min);
|
||||
UINT16_TO_STREAM (buf, adv_int_max);
|
||||
UINT8_TO_STREAM (buf, adv_type);
|
||||
UINT8_TO_STREAM (buf, addr_type_own);
|
||||
UINT8_TO_STREAM (buf, addr_type_dir);
|
||||
BDADDR_TO_STREAM (buf, direct_bda);
|
||||
UINT8_TO_STREAM (buf, channel_map);
|
||||
UINT8_TO_STREAM (buf, adv_filter_policy);
|
||||
return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS;
|
||||
}
|
||||
|
||||
|
||||
static uint16_t make_cmd_ble_set_adv_data(uint8_t *buf, uint8_t data_len, uint8_t *p_data)
|
||||
{
|
||||
UINT8_TO_STREAM (buf, H4_TYPE_COMMAND);
|
||||
UINT16_TO_STREAM (buf, HCI_BLE_WRITE_ADV_DATA);
|
||||
UINT8_TO_STREAM (buf, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1);
|
||||
|
||||
memset(buf, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA);
|
||||
|
||||
if (p_data != NULL && data_len > 0) {
|
||||
if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (buf, data_len);
|
||||
|
||||
ARRAY_TO_STREAM (buf, p_data, data_len);
|
||||
}
|
||||
return HCI_H4_CMD_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1;
|
||||
}
|
||||
|
||||
static void hci_cmd_send_reset(void)
|
||||
{
|
||||
uint16_t sz = make_cmd_reset (hci_cmd_buf);
|
||||
esp_vhci_host_send_packet(hci_cmd_buf, sz);
|
||||
}
|
||||
|
||||
static void hci_cmd_send_ble_adv_start(void)
|
||||
{
|
||||
uint16_t sz = make_cmd_ble_set_adv_enable (hci_cmd_buf, 1);
|
||||
esp_vhci_host_send_packet(hci_cmd_buf, sz);
|
||||
}
|
||||
|
||||
static void hci_cmd_send_ble_set_adv_param(void)
|
||||
{
|
||||
uint16_t adv_intv_min = 256; // 160ms
|
||||
uint16_t adv_intv_max = 256; // 160ms
|
||||
uint8_t adv_type = 0; // connectable undirected advertising (ADV_IND)
|
||||
uint8_t own_addr_type = 0; // Public Device Address
|
||||
uint8_t peer_addr_type = 0; // Public Device Address
|
||||
uint8_t peer_addr[6] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85};
|
||||
uint8_t adv_chn_map = 0x07; // 37, 38, 39
|
||||
uint8_t adv_filter_policy = 0; // Process All Conn and Scan
|
||||
|
||||
uint16_t sz = make_cmd_ble_set_adv_param(hci_cmd_buf,
|
||||
adv_intv_min,
|
||||
adv_intv_max,
|
||||
adv_type,
|
||||
own_addr_type,
|
||||
peer_addr_type,
|
||||
peer_addr,
|
||||
adv_chn_map,
|
||||
adv_filter_policy);
|
||||
esp_vhci_host_send_packet(hci_cmd_buf, sz);
|
||||
}
|
||||
|
||||
static void hci_cmd_send_ble_set_adv_data(void)
|
||||
{
|
||||
char *adv_name = "ESP-BLE-HELLO";
|
||||
uint8_t name_len = (uint8_t)strlen(adv_name);
|
||||
uint8_t adv_data[31] = {0x02, 0x01, 0x06, 0x0, 0x09};
|
||||
uint8_t adv_data_len;
|
||||
|
||||
adv_data[3] = name_len + 1;
|
||||
for (int i = 0; i < name_len; i++) {
|
||||
adv_data[5 + i] = (uint8_t)adv_name[i];
|
||||
}
|
||||
adv_data_len = 5 + name_len;
|
||||
|
||||
uint16_t sz = make_cmd_ble_set_adv_data(hci_cmd_buf, adv_data_len, (uint8_t *)adv_data);
|
||||
esp_vhci_host_send_packet(hci_cmd_buf, sz);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief: send HCI commands to perform BLE advertising;
|
||||
*/
|
||||
void bleAdvtTask(void *pvParameters)
|
||||
{
|
||||
int cmd_cnt = 0;
|
||||
bool send_avail = false;
|
||||
esp_vhci_host_register_callback(&vhci_host_cb);
|
||||
printf("BLE advt task start\n");
|
||||
while (1) {
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
send_avail = esp_vhci_host_check_send_available();
|
||||
if (send_avail) {
|
||||
switch (cmd_cnt) {
|
||||
case 0: hci_cmd_send_reset(); ++cmd_cnt; break;
|
||||
case 1: hci_cmd_send_ble_set_adv_param(); ++cmd_cnt; break;
|
||||
case 2: hci_cmd_send_ble_set_adv_data(); ++cmd_cnt; break;
|
||||
case 3: hci_cmd_send_ble_adv_start(); ++cmd_cnt; break;
|
||||
}
|
||||
}
|
||||
printf("BLE Advertise, flag_send_avail: %d, cmd_sent: %d\n", send_avail, cmd_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void app_main()
|
||||
{
|
||||
esp_bt_controller_init();
|
||||
xTaskCreatePinnedToCore(&bleAdvtTask, "bleAdvtTask", 2048, NULL, 5, NULL, 0);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
*
|
||||
* Automatically generated file; DO NOT EDIT.
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
@@ -0,0 +1,3 @@
|
||||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
@@ -0,0 +1,65 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/en/stable/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -0,0 +1,38 @@
|
||||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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.
|
||||
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. `Install PlatformIO <http://docs.platformio.org/en/stable/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-espressif8266/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-espressif32/examples/espidf-coap-server
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organised `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
See additional options for PlatformIO Library Dependency Finder `lib_*`:
|
||||
|
||||
http://docs.platformio.org/en/stable/projectconf.html#lib-install
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:nano32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = nano32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:espea32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = espea32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
@@ -0,0 +1,192 @@
|
||||
/* CoAP server Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event_loop.h"
|
||||
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#include "coap.h"
|
||||
|
||||
/* The examples use simple WiFi configuration that you can set via
|
||||
'make menuconfig'.
|
||||
|
||||
If you'd rather not, just change the below entries to strings with
|
||||
the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
|
||||
*/
|
||||
#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID
|
||||
#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD
|
||||
|
||||
#define COAP_DEFAULT_TIME_SEC 5
|
||||
#define COAP_DEFAULT_TIME_USEC 0
|
||||
|
||||
static EventGroupHandle_t wifi_event_group;
|
||||
|
||||
/* The event group allows multiple bits for each event,
|
||||
but we only care about one event - are we connected
|
||||
to the AP with an IP? */
|
||||
const static int CONNECTED_BIT = BIT0;
|
||||
|
||||
const static char *TAG = "CoAP_server";
|
||||
|
||||
static coap_async_state_t *async = NULL;
|
||||
|
||||
static void
|
||||
send_async_response(coap_context_t *ctx, const coap_endpoint_t *local_if)
|
||||
{
|
||||
coap_pdu_t *response;
|
||||
unsigned char buf[3];
|
||||
const char* response_data = "Hello World!";
|
||||
size_t size = sizeof(coap_hdr_t) + 20;
|
||||
response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, size);
|
||||
response->hdr->id = coap_new_message_id(ctx);
|
||||
if (async->tokenlen)
|
||||
coap_add_token(response, async->tokenlen, async->token);
|
||||
coap_add_option(response, COAP_OPTION_CONTENT_TYPE, coap_encode_var_bytes(buf, COAP_MEDIATYPE_TEXT_PLAIN), buf);
|
||||
coap_add_data (response, strlen(response_data), (unsigned char *)response_data);
|
||||
|
||||
if (coap_send(ctx, local_if, &async->peer, response) == COAP_INVALID_TID) {
|
||||
|
||||
}
|
||||
coap_delete_pdu(response);
|
||||
coap_async_state_t *tmp;
|
||||
coap_remove_async(ctx, async->id, &tmp);
|
||||
coap_free_async(async);
|
||||
async = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The resource handler
|
||||
*/
|
||||
static void
|
||||
async_handler(coap_context_t *ctx, struct coap_resource_t *resource,
|
||||
const coap_endpoint_t *local_interface, coap_address_t *peer,
|
||||
coap_pdu_t *request, str *token, coap_pdu_t *response)
|
||||
{
|
||||
async = coap_register_async(ctx, peer, request, COAP_ASYNC_SEPARATE | COAP_ASYNC_CONFIRM, (void*)"no data");
|
||||
}
|
||||
|
||||
static void coap_demo_thread(void *p)
|
||||
{
|
||||
coap_context_t* ctx = NULL;
|
||||
coap_address_t serv_addr;
|
||||
coap_resource_t* resource = NULL;
|
||||
fd_set readfds;
|
||||
struct timeval tv;
|
||||
int flags = 0;
|
||||
|
||||
while (1) {
|
||||
/* Wait for the callback to set the CONNECTED_BIT in the
|
||||
event group.
|
||||
*/
|
||||
xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
|
||||
false, true, portMAX_DELAY);
|
||||
ESP_LOGI(TAG, "Connected to AP");
|
||||
|
||||
/* Prepare the CoAP server socket */
|
||||
coap_address_init(&serv_addr);
|
||||
serv_addr.addr.sin.sin_family = AF_INET;
|
||||
serv_addr.addr.sin.sin_addr.s_addr = INADDR_ANY;
|
||||
serv_addr.addr.sin.sin_port = htons(COAP_DEFAULT_PORT);
|
||||
ctx = coap_new_context(&serv_addr);
|
||||
if (ctx) {
|
||||
flags = fcntl(ctx->sockfd, F_GETFL, 0);
|
||||
fcntl(ctx->sockfd, F_SETFL, flags|O_NONBLOCK);
|
||||
|
||||
tv.tv_usec = COAP_DEFAULT_TIME_USEC;
|
||||
tv.tv_sec = COAP_DEFAULT_TIME_SEC;
|
||||
/* Initialize the resource */
|
||||
resource = coap_resource_init((unsigned char *)"Espressif", 9, 0);
|
||||
if (resource){
|
||||
coap_register_handler(resource, COAP_REQUEST_GET, async_handler);
|
||||
coap_add_resource(ctx, resource);
|
||||
/*For incoming connections*/
|
||||
for (;;) {
|
||||
FD_ZERO(&readfds);
|
||||
FD_CLR( ctx->sockfd, &readfds);
|
||||
FD_SET( ctx->sockfd, &readfds);
|
||||
|
||||
int result = select( FD_SETSIZE, &readfds, 0, 0, &tv );
|
||||
if (result > 0){
|
||||
if (FD_ISSET( ctx->sockfd, &readfds ))
|
||||
coap_read(ctx);
|
||||
} else if (result < 0){
|
||||
break;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "select timeout");
|
||||
}
|
||||
|
||||
if (async) {
|
||||
send_async_response(ctx, ctx->endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coap_free_context(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
|
||||
{
|
||||
switch(event->event_id) {
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
/* This is a workaround as ESP32 WiFi libs don't currently
|
||||
auto-reassociate. */
|
||||
esp_wifi_connect();
|
||||
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void wifi_conn_init(void)
|
||||
{
|
||||
tcpip_adapter_init();
|
||||
wifi_event_group = xEventGroupCreate();
|
||||
ESP_ERROR_CHECK( esp_event_loop_init(wifi_event_handler, NULL) );
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = EXAMPLE_WIFI_SSID,
|
||||
.password = EXAMPLE_WIFI_PASS,
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
|
||||
ESP_ERROR_CHECK( esp_wifi_start() );
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
nvs_flash_init();
|
||||
wifi_conn_init();
|
||||
|
||||
xTaskCreate(coap_demo_thread, "coap", 2048, NULL, 5, NULL);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
*
|
||||
* Automatically generated file; DO NOT EDIT.
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
@@ -4,50 +4,95 @@
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "80m"
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_FREERTOS_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x0
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 4
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESP32_ENABLE_STACK_WIFI 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_WARN 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_WIFI_SSID "myssid"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 2
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_WIFI_PASSWORD "myssid"
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESPTOOLPY_BAUD_921600B 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
@@ -4,48 +4,95 @@
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "80m"
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_FREERTOS_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x0
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 4
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESP32_ENABLE_STACK_WIFI 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_WARN 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 2
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESPTOOLPY_BAUD_921600B 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
@@ -0,0 +1,3 @@
|
||||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
@@ -0,0 +1,65 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/en/stable/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -0,0 +1,38 @@
|
||||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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.
|
||||
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. `Install PlatformIO <http://docs.platformio.org/en/stable/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-espressif8266/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-espressif32/examples/espidf-peripherals-uart
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organised `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
See additional options for PlatformIO Library Dependency Finder `lib_*`:
|
||||
|
||||
http://docs.platformio.org/en/stable/projectconf.html#lib-install
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:nano32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = nano32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:espea32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = espea32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
@@ -0,0 +1,183 @@
|
||||
/* Uart Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "driver/uart.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/uart_struct.h"
|
||||
static const char *TAG = "uart_example";
|
||||
|
||||
/**
|
||||
* Test code brief
|
||||
* This example shows how to configure uart settings and install uart driver.
|
||||
*
|
||||
* uart_evt_test() is an example that read and write data on UART0, and handler some of the special events.
|
||||
* - port: UART0
|
||||
* - rx buffer: on
|
||||
* - tx buffer: on
|
||||
* - flow control: off
|
||||
* - event queue: on
|
||||
* - pin assignment: txd(default), rxd(default)
|
||||
*
|
||||
* uart_echo_test() is an example that read and write data on UART1, with hardware flow control turning on.
|
||||
* - port: UART1
|
||||
* - rx buffer: on
|
||||
* - tx buffer: off
|
||||
* - flow control: on
|
||||
* - event queue: off
|
||||
* - pin assignment: txd(io4), rxd(io5), rts(18), cts(19)
|
||||
*/
|
||||
|
||||
#define BUF_SIZE (1024)
|
||||
#define ECHO_TEST_TXD (4)
|
||||
#define ECHO_TEST_RXD (5)
|
||||
#define ECHO_TEST_RTS (18)
|
||||
#define ECHO_TEST_CTS (19)
|
||||
|
||||
QueueHandle_t uart0_queue;
|
||||
void uart_task(void *pvParameters)
|
||||
{
|
||||
int uart_num = (int) pvParameters;
|
||||
uart_event_t event;
|
||||
size_t buffered_size;
|
||||
uint8_t* dtmp = (uint8_t*) malloc(BUF_SIZE);
|
||||
for(;;) {
|
||||
//Waiting for UART event.
|
||||
if(xQueueReceive(uart0_queue, (void * )&event, (portTickType)portMAX_DELAY)) {
|
||||
ESP_LOGI(TAG, "uart[%d] event:", uart_num);
|
||||
switch(event.type) {
|
||||
//Event of UART receving data
|
||||
/*We'd better handler data event fast, there would be much more data events than
|
||||
other types of events. If we take too much time on data event, the queue might
|
||||
be full.
|
||||
in this example, we don't process data in event, but read data outside.*/
|
||||
case UART_DATA:
|
||||
uart_get_buffered_data_len(uart_num, &buffered_size);
|
||||
ESP_LOGI(TAG, "data, len: %d; buffered len: %d", event.size, buffered_size);
|
||||
break;
|
||||
//Event of HW FIFO overflow detected
|
||||
case UART_FIFO_OVF:
|
||||
ESP_LOGI(TAG, "hw fifo overflow\n");
|
||||
//If fifo overflow happened, you should consider adding flow control for your application.
|
||||
//We can read data out out the buffer, or directly flush the rx buffer.
|
||||
uart_flush(uart_num);
|
||||
break;
|
||||
//Event of UART ring buffer full
|
||||
case UART_BUFFER_FULL:
|
||||
ESP_LOGI(TAG, "ring buffer full\n");
|
||||
//If buffer full happened, you should consider encreasing your buffer size
|
||||
//We can read data out out the buffer, or directly flush the rx buffer.
|
||||
uart_flush(uart_num);
|
||||
break;
|
||||
//Event of UART RX break detected
|
||||
case UART_BREAK:
|
||||
ESP_LOGI(TAG, "uart rx break\n");
|
||||
break;
|
||||
//Event of UART parity check error
|
||||
case UART_PARITY_ERR:
|
||||
ESP_LOGI(TAG, "uart parity error\n");
|
||||
break;
|
||||
//Event of UART frame error
|
||||
case UART_FRAME_ERR:
|
||||
ESP_LOGI(TAG, "uart frame error\n");
|
||||
break;
|
||||
//UART_PATTERN_DET
|
||||
case UART_PATTERN_DET:
|
||||
ESP_LOGI(TAG, "uart pattern detected\n");
|
||||
break;
|
||||
//Others
|
||||
default:
|
||||
ESP_LOGI(TAG, "uart event type: %d\n", event.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(dtmp);
|
||||
dtmp = NULL;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void uart_evt_test()
|
||||
{
|
||||
int uart_num = UART_NUM_0;
|
||||
uart_config_t uart_config = {
|
||||
.baud_rate = 115200,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
.rx_flow_ctrl_thresh = 122,
|
||||
};
|
||||
//Set UART parameters
|
||||
uart_param_config(uart_num, &uart_config);
|
||||
//Set UART log level
|
||||
esp_log_level_set(TAG, ESP_LOG_INFO);
|
||||
//Install UART driver, and get the queue.
|
||||
uart_driver_install(uart_num, BUF_SIZE * 2, BUF_SIZE * 2, 10, &uart0_queue, 0);
|
||||
//Set UART pins,(-1: default pin, no change.)
|
||||
//For UART0, we can just use the default pins.
|
||||
//uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
//Set uart pattern detect function.
|
||||
uart_enable_pattern_det_intr(uart_num, '+', 3, 10000, 10, 10);
|
||||
//Create a task to handler UART event from ISR
|
||||
xTaskCreate(uart_task, "uart_task", 2048, (void*)uart_num, 12, NULL);
|
||||
//process data
|
||||
uint8_t* data = (uint8_t*) malloc(BUF_SIZE);
|
||||
do {
|
||||
int len = uart_read_bytes(uart_num, data, BUF_SIZE, 100 / portTICK_RATE_MS);
|
||||
if(len > 0) {
|
||||
ESP_LOGI(TAG, "uart read : %d", len);
|
||||
uart_write_bytes(uart_num, (const char*)data, len);
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//an example of echo test with hardware flow control on UART1
|
||||
void uart_echo_test()
|
||||
{
|
||||
int uart_num = UART_NUM_1;
|
||||
uart_config_t uart_config = {
|
||||
.baud_rate = 115200,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
|
||||
.rx_flow_ctrl_thresh = 122,
|
||||
};
|
||||
//Configure UART1 parameters
|
||||
uart_param_config(uart_num, &uart_config);
|
||||
//Set UART1 pins(TX: IO4, RX: I05, RTS: IO18, CTS: IO19)
|
||||
uart_set_pin(uart_num, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS);
|
||||
//Install UART driver( We don't need an event queue here)
|
||||
//In this example we don't even use a buffer for sending data.
|
||||
uart_driver_install(uart_num, BUF_SIZE * 2, 0, 0, NULL, 0);
|
||||
|
||||
uint8_t* data = (uint8_t*) malloc(BUF_SIZE);
|
||||
while(1) {
|
||||
//Read data from UART
|
||||
int len = uart_read_bytes(uart_num, data, BUF_SIZE, 20 / portTICK_RATE_MS);
|
||||
//Write data back to UART
|
||||
uart_write_bytes(uart_num, (const char*) data, len);
|
||||
}
|
||||
}
|
||||
|
||||
void app_main()
|
||||
{
|
||||
//A uart read/write example without event queue;
|
||||
xTaskCreate(uart_echo_test, "uart_echo_test", 1024, NULL, 10, NULL);
|
||||
|
||||
//A uart example with event queue.
|
||||
uart_evt_test();
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
*
|
||||
* Automatically generated file; DO NOT EDIT.
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
@@ -0,0 +1,3 @@
|
||||
.pioenvs
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
@@ -0,0 +1,65 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/en/stable/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -0,0 +1,38 @@
|
||||
.. Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||
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.
|
||||
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. `Install PlatformIO <http://docs.platformio.org/en/stable/installation.html>`_
|
||||
2. Download `development platform with examples <https://github.com/platformio/platform-espressif8266/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-espressif32/examples/espidf-storage-sdcard
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organised `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
See additional options for PlatformIO Library Dependency Finder `lib_*`:
|
||||
|
||||
http://docs.platformio.org/en/stable/projectconf.html#lib-install
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/en/stable/projectconf.html
|
||||
|
||||
[env:nano32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = nano32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:espea32]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = espea32
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
|
||||
@@ -0,0 +1,107 @@
|
||||
/* SD card and FAT filesystem example.
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "driver/sdmmc_host.h"
|
||||
#include "driver/sdmmc_defs.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
|
||||
static const char* TAG = "example";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing SD card");
|
||||
|
||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||
|
||||
// To use 1-line SD mode, uncomment the following line:
|
||||
// host.flags = SDMMC_HOST_FLAG_1BIT;
|
||||
|
||||
// This initializes the slot without card detect (CD) and write protect (WP) signals.
|
||||
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
|
||||
// Options for mounting the filesystem.
|
||||
// If format_if_mount_failed is set to true, SD card will be partitioned and formatted
|
||||
// in case when mounting fails.
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = 5
|
||||
};
|
||||
|
||||
// Use settings defined above to initialize SD card and mount FAT filesystem.
|
||||
// Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
|
||||
// Please check its source code and implement error recovery when developing
|
||||
// production applications.
|
||||
sdmmc_card_t* card;
|
||||
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true.");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize the card (%d). Make sure SD card lines have pull-up resistors in place.", ret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Card has been initialized, print its properties
|
||||
sdmmc_card_print_info(stdout, card);
|
||||
|
||||
// Use POSIX and C standard library functions to work with files.
|
||||
// First create a file.
|
||||
ESP_LOGI(TAG, "Opening file");
|
||||
FILE* f = fopen("/sdcard/hello.txt", "w");
|
||||
if (f == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
fprintf(f, "Hello %s!\n", card->cid.name);
|
||||
fclose(f);
|
||||
ESP_LOGI(TAG, "File written");
|
||||
|
||||
// Check if destination file exists before renaming
|
||||
struct stat st;
|
||||
if (stat("/sdcard/foo.txt", &st) == 0) {
|
||||
// Delete it if it exists
|
||||
unlink("/sdcard/foo.txt");
|
||||
}
|
||||
|
||||
// Rename original file
|
||||
ESP_LOGI(TAG, "Renaming file");
|
||||
if (rename("/sdcard/hello.txt", "/sdcard/foo.txt") != 0) {
|
||||
ESP_LOGE(TAG, "Rename failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Open renamed file for reading
|
||||
ESP_LOGI(TAG, "Reading file");
|
||||
f = fopen("/sdcard/foo.txt", "r");
|
||||
if (f == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to open file for reading");
|
||||
return;
|
||||
}
|
||||
char line[64];
|
||||
fgets(line, sizeof(line), f);
|
||||
fclose(f);
|
||||
// strip newline
|
||||
char* pos = strchr(line, '\n');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
}
|
||||
ESP_LOGI(TAG, "Read from file: '%s'", line);
|
||||
|
||||
// All done, unmount partition and disable SDMMC host peripheral
|
||||
esp_vfs_fat_sdmmc_unmount();
|
||||
ESP_LOGI(TAG, "Card unmounted");
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
*
|
||||
* Automatically generated file; DO NOT EDIT.
|
||||
* Espressif IoT Development Framework Configuration
|
||||
*
|
||||
*/
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB"
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 115200
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_115200B 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_MBEDTLS_MPI_USE_INTERRUPT 1
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 3072
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
|
||||
#define CONFIG_SPI_FLASH_ENABLE_COUNTERS 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 0
|
||||
#define CONFIG_PHY_DATA_OFFSET 0xf000
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 100
|
||||
#define CONFIG_LOG_COLORS 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 3
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_TCP_MAXRTX 12
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP32_WIFI_RX_BUFFER_NUM 25
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/platformio/platform-espressif32.git"
|
||||
},
|
||||
"version": "0.5.1",
|
||||
"version": "0.6.0",
|
||||
"packageRepositories": [
|
||||
"https://dl.bintray.com/platformio/dl-packages/manifest.json",
|
||||
"https://sourceforge.net/projects/platformio-storage/files/packages/manifest.json/download",
|
||||
@@ -51,7 +51,7 @@
|
||||
"framework-espidf": {
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"version": "~1.90.0"
|
||||
"version": "~1.200.0"
|
||||
},
|
||||
"framework-simba": {
|
||||
"type": "framework",
|
||||
|
||||
Reference in New Issue
Block a user