release espressif32 Arduino core 3.0.3 based on IDF 5.1.4
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
# Number of days of inactivity before an issue becomes stale
|
|
||||||
daysUntilStale: 30
|
|
||||||
# Number of days of inactivity before a stale issue is closed
|
|
||||||
daysUntilClose: 7
|
|
||||||
# Issues with these labels will never be considered stale
|
|
||||||
exemptLabels:
|
|
||||||
- bug
|
|
||||||
- known issue
|
|
||||||
- feature
|
|
||||||
- enhancement
|
|
||||||
- board request
|
|
||||||
- package update
|
|
||||||
# Label to use when marking an issue as stale
|
|
||||||
staleLabel: stale
|
|
||||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
|
||||||
markComment: >
|
|
||||||
This issue has been automatically marked as stale because it has not had
|
|
||||||
recent activity. Please provide more details or it will be closed if no
|
|
||||||
further activity occurs. Thank you for your contributions.
|
|
||||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
|
||||||
closeComment: false
|
|
||||||
@@ -1,21 +1,26 @@
|
|||||||
name: Examples
|
name: Examples
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
workflow_dispatch: # Manually start a workflow
|
||||||
|
push:
|
||||||
|
paths-ignore:
|
||||||
|
- '.github/**' # Ignore changes towards the .github directory
|
||||||
|
- '**.md' # Do no build if *.md files changes
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-22.04, windows-2022, macos-14]
|
||||||
example:
|
example:
|
||||||
- "examples/arduino-ble5-advertising"
|
|
||||||
- "examples/arduino-blink"
|
- "examples/arduino-blink"
|
||||||
|
- "examples/arduino-rmt-blink"
|
||||||
- "examples/arduino-usb-keyboard"
|
- "examples/arduino-usb-keyboard"
|
||||||
- "examples/arduino-wifiscan"
|
- "examples/arduino-wifiscan"
|
||||||
- "examples/espidf-arduino-blink"
|
- "examples/espidf-arduino-blink"
|
||||||
- "examples/espidf-arduino-wifiscan"
|
- "examples/espidf-arduino-littlefs"
|
||||||
- "examples/espidf-ble-eddystone"
|
- "examples/espidf-blink"
|
||||||
- "examples/espidf-coap-server"
|
- "examples/espidf-coap-server"
|
||||||
- "examples/espidf-exceptions"
|
- "examples/espidf-exceptions"
|
||||||
- "examples/espidf-hello-world"
|
- "examples/espidf-hello-world"
|
||||||
@@ -23,20 +28,21 @@ jobs:
|
|||||||
- "examples/espidf-peripherals-uart"
|
- "examples/espidf-peripherals-uart"
|
||||||
- "examples/espidf-peripherals-usb"
|
- "examples/espidf-peripherals-usb"
|
||||||
- "examples/espidf-storage-sdcard"
|
- "examples/espidf-storage-sdcard"
|
||||||
- "examples/espidf-storage-spiffs"
|
- "examples/espidf-ulp"
|
||||||
- "examples/espidf-ulp-adc"
|
- "examples/espidf-ulp-riscv"
|
||||||
- "examples/espidf-ulp-pulse"
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: "recursive"
|
submodules: "recursive"
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.9"
|
python-version: "3.11"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install wheel
|
||||||
pip install -U https://github.com/platformio/platformio/archive/develop.zip
|
pip install -U https://github.com/platformio/platformio/archive/develop.zip
|
||||||
pio pkg install --global --platform symlink://.
|
pio pkg install --global --platform symlink://.
|
||||||
- name: Build examples
|
- name: Build examples
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: Create zip file with recursive source clone for release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 51*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release_zips:
|
||||||
|
name: Create release zip file
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Create a recursive clone source zip
|
||||||
|
uses: pioarduino/github-actions/release_zips@release_idf
|
||||||
|
env:
|
||||||
|
RELEASE_PROJECT_NAME: platform-espressif32
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
name: "Unit Testing"
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
python-version: [3.9]
|
|
||||||
example:
|
|
||||||
- "examples/espidf-hello-world"
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v3
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U https://github.com/platformio/platformio/archive/develop.zip
|
|
||||||
pio pkg install --global --platform symlink://.
|
|
||||||
- name: Build test
|
|
||||||
run: |
|
|
||||||
pio test -d ${{ matrix.example }} --without-uploading --without-testing
|
|
||||||
@@ -1 +1,2 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Espressif 32: development platform for [PlatformIO](https://platformio.org)
|
# Fork of Platformio Espressif 32: development platform for [PlatformIO](https://platformio.org)
|
||||||
|
|
||||||
[](https://github.com/platformio/platform-espressif32/actions)
|
[](https://github.com/pioarduino/platform-espressif32/actions)
|
||||||
|
|
||||||
ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and Bluetooth. ESP32 integrates an antenna switch, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules.
|
ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and Bluetooth. ESP32 integrates an antenna switch, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules.
|
||||||
|
|
||||||
@@ -13,14 +13,13 @@ ESP32 is a series of low-cost, low-power system on a chip microcontrollers with
|
|||||||
2. Create PlatformIO project and configure a platform option in [platformio.ini](https://docs.platformio.org/page/projectconf.html) file:
|
2. Create PlatformIO project and configure a platform option in [platformio.ini](https://docs.platformio.org/page/projectconf.html) file:
|
||||||
|
|
||||||
## Stable version
|
## Stable version
|
||||||
|
espressif Arduino 3.0.2 and IDF 5.1.4
|
||||||
|
|
||||||
See `platform` [documentation](https://docs.platformio.org/en/latest/projectconf/sections/env/options/platform/platform.html#projectconf-env-platform) for details.
|
See `platform` [documentation](https://docs.platformio.org/en/latest/projectconf/sections/env/options/platform/platform.html#projectconf-env-platform) for details.
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[env:stable]
|
[env:stable]
|
||||||
; recommended to pin to a version, see https://github.com/platformio/platform-espressif32/releases
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/2024.07.00/platform-espressif32.zip
|
||||||
; platform = espressif32 @ ^6.0.1
|
|
||||||
platform = espressif32
|
|
||||||
board = ...
|
board = ...
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
@@ -29,7 +28,7 @@ board = ...
|
|||||||
|
|
||||||
```ini
|
```ini
|
||||||
[env:development]
|
[env:development]
|
||||||
platform = https://github.com/platformio/platform-espressif32.git
|
platform = https://github.com/pioarduino/platform-espressif32.git#Arduino/IDF51
|
||||||
board = ...
|
board = ...
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"ldscript": "esp32s3_out.ld",
|
|
||||||
"memory_type": "qio_opi",
|
"memory_type": "qio_opi",
|
||||||
"partitions": "default_16MB.csv"
|
"partitions": "esp_sr_16.csv"
|
||||||
},
|
},
|
||||||
"core": "esp32",
|
"core": "esp32",
|
||||||
"extra_flags": [
|
"extra_flags": [
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"f_cpu": "120000000L",
|
||||||
|
"f_flash": "60000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32c2",
|
||||||
|
"variant": "esp32c2"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32c2.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif ESP32-C2-DevKitM-1",
|
||||||
|
"upload": {
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 278528,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 460800
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp8684/esp8684-devkitm-1/user_guide.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
@@ -4,12 +4,17 @@
|
|||||||
"f_cpu": "160000000L",
|
"f_cpu": "160000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
"mcu": "esp32c6"
|
"mcu": "esp32c6",
|
||||||
|
"variant": "esp32c6"
|
||||||
},
|
},
|
||||||
"connectivity": [
|
"connectivity": [
|
||||||
"wifi"
|
"wifi"
|
||||||
],
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32c6.cfg"
|
||||||
|
},
|
||||||
"frameworks": [
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
"espidf"
|
"espidf"
|
||||||
],
|
],
|
||||||
"name": "Espressif ESP32-C6-DevKitC-1",
|
"name": "Espressif ESP32-C6-DevKitC-1",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"openocd_target": "esp32c6.cfg"
|
"openocd_target": "esp32c6.cfg"
|
||||||
},
|
},
|
||||||
"frameworks": [
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
"espidf"
|
"espidf"
|
||||||
],
|
],
|
||||||
"name": "Espressif ESP32-C6-DevKitM-1",
|
"name": "Espressif ESP32-C6-DevKitM-1",
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"f_cpu": "96000000L",
|
||||||
|
"f_flash": "64000000L",
|
||||||
|
"f_image": "48000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32h2",
|
||||||
|
"variant": "esp32h2",
|
||||||
|
"hwids": [
|
||||||
|
[
|
||||||
|
"0x303A",
|
||||||
|
"0x1001"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"bluetooth",
|
||||||
|
"zigbee"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32h2.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif ESP32-H2-DevKit",
|
||||||
|
"upload": {
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 460800
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32h2/esp32-h2-devkitm-1/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"arduino":{
|
||||||
|
"ldscript": "esp32_out.ld"
|
||||||
|
},
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": "-DARDUINO_ESP32_DEV -DARDUINO_USB_CDC_ON_BOOT=0 -DCORE32SOLO1",
|
||||||
|
"f_cpu": "80000000L",
|
||||||
|
"f_flash": "40000000L",
|
||||||
|
"flash_mode": "dio",
|
||||||
|
"mcu": "esp32",
|
||||||
|
"variant": "esp32"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth",
|
||||||
|
"ethernet",
|
||||||
|
"can"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32-solo-1.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif Generic ESP32-solo1 4M Flash",
|
||||||
|
"upload": {
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 460800
|
||||||
|
},
|
||||||
|
"url": "https://en.wikipedia.org/wiki/ESP32",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
@@ -110,14 +110,14 @@ env.Append(
|
|||||||
" ".join(
|
" ".join(
|
||||||
[
|
[
|
||||||
"riscv32-esp-elf-objcopy"
|
"riscv32-esp-elf-objcopy"
|
||||||
if mcu in ("esp32c3", "esp32c6")
|
if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2")
|
||||||
else "xtensa-%s-elf-objcopy" % mcu,
|
else "xtensa-%s-elf-objcopy" % mcu,
|
||||||
"--input-target",
|
"--input-target",
|
||||||
"binary",
|
"binary",
|
||||||
"--output-target",
|
"--output-target",
|
||||||
"elf32-littleriscv" if mcu in ("esp32c3","esp32c6") else "elf32-xtensa-le",
|
"elf32-littleriscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2") else "elf32-xtensa-le",
|
||||||
"--binary-architecture",
|
"--binary-architecture",
|
||||||
"riscv" if mcu in ("esp32c3","esp32c6") else "xtensa",
|
"riscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2") else "xtensa",
|
||||||
"--rename-section",
|
"--rename-section",
|
||||||
".data=.rodata.embedded",
|
".data=.rodata.embedded",
|
||||||
"$SOURCE",
|
"$SOURCE",
|
||||||
|
|||||||
@@ -36,4 +36,3 @@ if "espidf" not in env.subst("$PIOFRAMEWORK"):
|
|||||||
SConscript(
|
SConscript(
|
||||||
join(DefaultEnvironment().PioPlatform().get_package_dir(
|
join(DefaultEnvironment().PioPlatform().get_package_dir(
|
||||||
"framework-arduinoespressif32"), "tools", "platformio-build.py"))
|
"framework-arduinoespressif32"), "tools", "platformio-build.py"))
|
||||||
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")})
|
|
||||||
|
|||||||
@@ -67,15 +67,7 @@ IDF5 = (
|
|||||||
IDF_ENV_VERSION = "1.0.0"
|
IDF_ENV_VERSION = "1.0.0"
|
||||||
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
||||||
TOOLCHAIN_DIR = platform.get_package_dir(
|
TOOLCHAIN_DIR = platform.get_package_dir(
|
||||||
"toolchain-riscv32-esp"
|
"toolchain-%s" % ("riscv32-esp" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xtensa-%s" % mcu))
|
||||||
if mcu in ("esp32c3", "esp32c6")
|
|
||||||
else (
|
|
||||||
(
|
|
||||||
"toolchain-xtensa-esp-elf"
|
|
||||||
if "arduino" not in env.subst("$PIOFRAMEWORK")
|
|
||||||
else "toolchain-xtensa-%s" % mcu
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +83,7 @@ if (
|
|||||||
):
|
):
|
||||||
print("Warning! Debugging an IDF project requires PlatformIO Core >= 6.1.11!")
|
print("Warning! Debugging an IDF project requires PlatformIO Core >= 6.1.11!")
|
||||||
|
|
||||||
# Arduino framework as a component is not compatible with ESP-IDF >=4.1
|
# Arduino framework as a component is not compatible with ESP-IDF >5.2
|
||||||
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||||
ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
||||||
# Possible package names in 'package@version' format is not compatible with CMake
|
# Possible package names in 'package@version' format is not compatible with CMake
|
||||||
@@ -256,7 +248,7 @@ def populate_idf_env_vars(idf_env):
|
|||||||
os.path.dirname(get_python_exe()),
|
os.path.dirname(get_python_exe()),
|
||||||
]
|
]
|
||||||
|
|
||||||
if mcu not in ("esp32c3", "esp32c6"):
|
if mcu not in ("esp32c2", "esp32c3", "esp32c6","esp32h2"):
|
||||||
additional_packages.append(
|
additional_packages.append(
|
||||||
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
||||||
)
|
)
|
||||||
@@ -511,7 +503,7 @@ def extract_linker_script_fragments_backup(framework_components_dir, sdk_config)
|
|||||||
sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
||||||
env.Exit(1)
|
env.Exit(1)
|
||||||
|
|
||||||
if mcu in ("esp32c3", "esp32c6"):
|
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
||||||
result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
||||||
|
|
||||||
# Add extra linker fragments
|
# Add extra linker fragments
|
||||||
@@ -1201,6 +1193,7 @@ def install_python_deps():
|
|||||||
return
|
return
|
||||||
|
|
||||||
deps = {
|
deps = {
|
||||||
|
"wheel": ">=0.35.1",
|
||||||
# https://github.com/platformio/platformio-core/issues/4614
|
# https://github.com/platformio/platformio-core/issues/4614
|
||||||
"urllib3": "<2",
|
"urllib3": "<2",
|
||||||
# https://github.com/platformio/platform-espressif32/issues/635
|
# https://github.com/platformio/platform-espressif32/issues/635
|
||||||
@@ -1606,7 +1599,7 @@ env.Prepend(
|
|||||||
(
|
(
|
||||||
board.get(
|
board.get(
|
||||||
"upload.bootloader_offset",
|
"upload.bootloader_offset",
|
||||||
"0x0" if mcu in ("esp32c3", "esp32c6", "esp32s3") else "0x1000",
|
"0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else "0x1000",
|
||||||
),
|
),
|
||||||
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
||||||
),
|
),
|
||||||
@@ -1717,7 +1710,7 @@ env["BUILDERS"]["ElfToBin"].action = action
|
|||||||
#
|
#
|
||||||
|
|
||||||
ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
||||||
if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c3", "esp32c6"):
|
if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
||||||
env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -34,14 +34,11 @@ ULP_BUILD_DIR = os.path.join(
|
|||||||
def prepare_ulp_env_vars(env):
|
def prepare_ulp_env_vars(env):
|
||||||
ulp_env.PrependENVPath("IDF_PATH", FRAMEWORK_DIR)
|
ulp_env.PrependENVPath("IDF_PATH", FRAMEWORK_DIR)
|
||||||
|
|
||||||
toolchain_path = platform.get_package_dir(
|
|
||||||
"toolchain-xtensa-esp-elf"
|
|
||||||
if "arduino" not in env.subst("$PIOFRAMEWORK")
|
|
||||||
else "toolchain-xtensa-%s" % idf_variant
|
|
||||||
)
|
|
||||||
|
|
||||||
additional_packages = [
|
additional_packages = [
|
||||||
toolchain_path,
|
os.path.join(
|
||||||
|
platform.get_package_dir("toolchain-xtensa-%s" % idf_variant),
|
||||||
|
"bin",
|
||||||
|
),
|
||||||
os.path.join(
|
os.path.join(
|
||||||
platform.get_package_dir("toolchain-esp32ulp"),
|
platform.get_package_dir("toolchain-esp32ulp"),
|
||||||
"bin",
|
"bin",
|
||||||
|
|||||||
+48
-53
@@ -22,10 +22,14 @@ from SCons.Script import (
|
|||||||
|
|
||||||
from platformio.util import get_serial_ports
|
from platformio.util import get_serial_ports
|
||||||
|
|
||||||
|
env = DefaultEnvironment()
|
||||||
|
platform = env.PioPlatform()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Helpers
|
# Helpers
|
||||||
#
|
#
|
||||||
|
|
||||||
|
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
||||||
|
|
||||||
def BeforeUpload(target, source, env):
|
def BeforeUpload(target, source, env):
|
||||||
upload_options = {}
|
upload_options = {}
|
||||||
@@ -58,7 +62,6 @@ def _get_board_memory_type(env):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _normalize_frequency(frequency):
|
def _normalize_frequency(frequency):
|
||||||
frequency = str(frequency).replace("L", "")
|
frequency = str(frequency).replace("L", "")
|
||||||
return str(int(int(frequency) / 1000000)) + "m"
|
return str(int(int(frequency) / 1000000)) + "m"
|
||||||
@@ -76,7 +79,6 @@ def _get_board_f_image(env):
|
|||||||
|
|
||||||
return _get_board_f_flash(env)
|
return _get_board_f_flash(env)
|
||||||
|
|
||||||
|
|
||||||
def _get_board_f_boot(env):
|
def _get_board_f_boot(env):
|
||||||
board_config = env.BoardConfig()
|
board_config = env.BoardConfig()
|
||||||
if "build.f_boot" in board_config:
|
if "build.f_boot" in board_config:
|
||||||
@@ -86,7 +88,7 @@ def _get_board_f_boot(env):
|
|||||||
|
|
||||||
|
|
||||||
def _get_board_flash_mode(env):
|
def _get_board_flash_mode(env):
|
||||||
if ["arduino"] == env.get("PIOFRAMEWORK") and _get_board_memory_type(env) in (
|
if _get_board_memory_type(env) in (
|
||||||
"opi_opi",
|
"opi_opi",
|
||||||
"opi_qspi",
|
"opi_qspi",
|
||||||
):
|
):
|
||||||
@@ -101,7 +103,7 @@ def _get_board_flash_mode(env):
|
|||||||
def _get_board_boot_mode(env):
|
def _get_board_boot_mode(env):
|
||||||
memory_type = env.BoardConfig().get("build.arduino.memory_type", "")
|
memory_type = env.BoardConfig().get("build.arduino.memory_type", "")
|
||||||
build_boot = env.BoardConfig().get("build.boot", "$BOARD_FLASH_MODE")
|
build_boot = env.BoardConfig().get("build.boot", "$BOARD_FLASH_MODE")
|
||||||
if ["arduino"] == env.get("PIOFRAMEWORK") and memory_type in ("opi_opi", "opi_qspi"):
|
if memory_type in ("opi_opi", "opi_qspi"):
|
||||||
build_boot = "opi"
|
build_boot = "opi"
|
||||||
return build_boot
|
return build_boot
|
||||||
|
|
||||||
@@ -128,9 +130,8 @@ def _parse_partitions(env):
|
|||||||
return
|
return
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
# The first offset is 0x9000 because partition table is flashed to 0x8000 and
|
next_offset = 0
|
||||||
# occupies an entire flash sector, which size is 0x1000
|
bound = int(board.get("upload.offset_address", "0x10000"), 16) # default 0x10000
|
||||||
next_offset = 0x9000
|
|
||||||
with open(partitions_csv) as fp:
|
with open(partitions_csv) as fp:
|
||||||
for line in fp.readlines():
|
for line in fp.readlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@@ -139,22 +140,23 @@ def _parse_partitions(env):
|
|||||||
tokens = [t.strip() for t in line.split(",")]
|
tokens = [t.strip() for t in line.split(",")]
|
||||||
if len(tokens) < 5:
|
if len(tokens) < 5:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
bound = 0x10000 if tokens[1] in ("0", "app") else 4
|
|
||||||
calculated_offset = (next_offset + bound - 1) & ~(bound - 1)
|
|
||||||
partition = {
|
partition = {
|
||||||
"name": tokens[0],
|
"name": tokens[0],
|
||||||
"type": tokens[1],
|
"type": tokens[1],
|
||||||
"subtype": tokens[2],
|
"subtype": tokens[2],
|
||||||
"offset": tokens[3] or calculated_offset,
|
"offset": tokens[3] or next_offset,
|
||||||
"size": tokens[4],
|
"size": tokens[4],
|
||||||
"flags": tokens[5] if len(tokens) > 5 else None
|
"flags": tokens[5] if len(tokens) > 5 else None
|
||||||
}
|
}
|
||||||
result.append(partition)
|
result.append(partition)
|
||||||
next_offset = _parse_size(partition["offset"]) + _parse_size(
|
next_offset = _parse_size(partition["offset"])
|
||||||
partition["size"]
|
if (partition["subtype"] == "ota_0"):
|
||||||
)
|
bound = next_offset
|
||||||
|
next_offset = (next_offset + bound - 1) & ~(bound - 1)
|
||||||
|
# Configure application partition offset
|
||||||
|
env.Replace(ESP32_APP_OFFSET=str(hex(bound)))
|
||||||
|
# Propagate application offset to debug configurations
|
||||||
|
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": str(hex(bound))})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -181,17 +183,13 @@ def _update_max_upload_size(env):
|
|||||||
"table! Default partition will be used!" % custom_app_partition_name
|
"table! Default partition will be used!" % custom_app_partition_name
|
||||||
)
|
)
|
||||||
|
|
||||||
# Otherwise, one of the `factory` or `ota_0` partitions is used to determine
|
|
||||||
# available memory size. If both partitions are set, we should prefer the `factory`,
|
|
||||||
# but there are cases (e.g. Adafruit's `partitions-4MB-tinyuf2.csv`) that uses the
|
|
||||||
# `factory` partition for their UF2 bootloader. So let's use the first match
|
|
||||||
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#subtype
|
|
||||||
for p in partitions.values():
|
for p in partitions.values():
|
||||||
if p["type"] in ("0", "app") and p["subtype"] in ("factory", "ota_0"):
|
if p["type"] in ("0", "app") and p["subtype"] in ("ota_0"):
|
||||||
board.update("upload.maximum_size", _parse_size(p["size"]))
|
board.update("upload.maximum_size", _parse_size(p["size"]))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _to_unix_slashes(path):
|
def _to_unix_slashes(path):
|
||||||
return path.replace("\\", "/")
|
return path.replace("\\", "/")
|
||||||
|
|
||||||
@@ -204,7 +202,7 @@ def _to_unix_slashes(path):
|
|||||||
def fetch_fs_size(env):
|
def fetch_fs_size(env):
|
||||||
fs = None
|
fs = None
|
||||||
for p in _parse_partitions(env):
|
for p in _parse_partitions(env):
|
||||||
if p["type"] == "data" and p["subtype"] in ("spiffs", "fat"):
|
if p["type"] == "data" and p["subtype"] in ("spiffs", "fat", "littlefs"):
|
||||||
fs = p
|
fs = p
|
||||||
if not fs:
|
if not fs:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
@@ -230,13 +228,11 @@ def __fetch_fs_size(target, source, env):
|
|||||||
return (target, source)
|
return (target, source)
|
||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
|
||||||
platform = env.PioPlatform()
|
|
||||||
board = env.BoardConfig()
|
board = env.BoardConfig()
|
||||||
mcu = board.get("build.mcu", "esp32")
|
mcu = board.get("build.mcu", "esp32")
|
||||||
toolchain_arch = "xtensa-%s" % mcu
|
toolchain_arch = "xtensa-%s" % mcu
|
||||||
filesystem = board.get("build.filesystem", "spiffs")
|
filesystem = board.get("build.filesystem", "spiffs")
|
||||||
if mcu in ("esp32c3", "esp32c6"):
|
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
||||||
toolchain_arch = "riscv32-esp"
|
toolchain_arch = "riscv32-esp"
|
||||||
|
|
||||||
if "INTEGRATION_EXTRA_DATA" not in env:
|
if "INTEGRATION_EXTRA_DATA" not in env:
|
||||||
@@ -257,15 +253,14 @@ env.Replace(
|
|||||||
GDB=join(
|
GDB=join(
|
||||||
platform.get_package_dir(
|
platform.get_package_dir(
|
||||||
"tool-riscv32-esp-elf-gdb"
|
"tool-riscv32-esp-elf-gdb"
|
||||||
if mcu in ("esp32c3", "esp32c6")
|
if mcu in ("esp32c2", "esp32c3", "esp32c6")
|
||||||
else "tool-xtensa-esp-elf-gdb"
|
else "tool-xtensa-esp-elf-gdb"
|
||||||
)
|
)
|
||||||
or "",
|
or "",
|
||||||
"bin",
|
"bin",
|
||||||
"%s-elf-gdb" % toolchain_arch,
|
"%s-elf-gdb" % toolchain_arch,
|
||||||
) if env.get("PIOFRAMEWORK") == ["espidf"] else "%s-elf-gdb" % toolchain_arch,
|
),
|
||||||
OBJCOPY=join(
|
OBJCOPY=join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
|
||||||
platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
|
|
||||||
RANLIB="%s-elf-gcc-ranlib" % toolchain_arch,
|
RANLIB="%s-elf-gcc-ranlib" % toolchain_arch,
|
||||||
SIZETOOL="%s-elf-size" % toolchain_arch,
|
SIZETOOL="%s-elf-size" % toolchain_arch,
|
||||||
|
|
||||||
@@ -302,7 +297,7 @@ env.Replace(
|
|||||||
"ESP32_FS_IMAGE_NAME", env.get("ESP32_SPIFFS_IMAGE_NAME", filesystem)
|
"ESP32_FS_IMAGE_NAME", env.get("ESP32_SPIFFS_IMAGE_NAME", filesystem)
|
||||||
),
|
),
|
||||||
|
|
||||||
ESP32_APP_OFFSET=board.get("upload.offset_address", "0x10000"),
|
ESP32_APP_OFFSET=env.get("INTEGRATION_EXTRA_DATA").get("application_offset"),
|
||||||
|
|
||||||
PROGSUFFIX=".elf"
|
PROGSUFFIX=".elf"
|
||||||
)
|
)
|
||||||
@@ -315,7 +310,7 @@ env.Append(
|
|||||||
BUILDERS=dict(
|
BUILDERS=dict(
|
||||||
ElfToBin=Builder(
|
ElfToBin=Builder(
|
||||||
action=env.VerboseAction(" ".join([
|
action=env.VerboseAction(" ".join([
|
||||||
'"$PYTHONEXE" "$OBJCOPY"',
|
'"$PYTHONEXE" "$OBJCOPY"',
|
||||||
"--chip", mcu, "elf2image",
|
"--chip", mcu, "elf2image",
|
||||||
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
||||||
"--flash_freq", "${__get_board_f_image(__env__)}",
|
"--flash_freq", "${__get_board_f_image(__env__)}",
|
||||||
@@ -335,7 +330,7 @@ env.Append(
|
|||||||
"-b",
|
"-b",
|
||||||
"$FS_BLOCK",
|
"$FS_BLOCK",
|
||||||
]
|
]
|
||||||
if filesystem in ("spiffs", "littlefs")
|
if filesystem in ("littlefs", "spiffs")
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
+ ["$TARGET"]
|
+ ["$TARGET"]
|
||||||
@@ -388,9 +383,6 @@ if env.get("PIOMAINPROG"):
|
|||||||
env.VerboseAction(
|
env.VerboseAction(
|
||||||
lambda source, target, env: _update_max_upload_size(env),
|
lambda source, target, env: _update_max_upload_size(env),
|
||||||
"Retrieving maximum program size $SOURCES"))
|
"Retrieving maximum program size $SOURCES"))
|
||||||
# remove after PIO Core 3.6 release
|
|
||||||
elif set(["checkprogsize", "upload"]) & set(COMMAND_LINE_TARGETS):
|
|
||||||
_update_max_upload_size(env)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Print binary size
|
# Target: Print binary size
|
||||||
@@ -432,9 +424,7 @@ if upload_protocol == "espota":
|
|||||||
"See https://docs.platformio.org/page/platforms/"
|
"See https://docs.platformio.org/page/platforms/"
|
||||||
"espressif32.html#over-the-air-ota-update\n")
|
"espressif32.html#over-the-air-ota-update\n")
|
||||||
env.Replace(
|
env.Replace(
|
||||||
UPLOADER=join(
|
UPLOADER=join(FRAMEWORK_DIR,"tools", "espota.py"),
|
||||||
platform.get_package_dir("framework-arduinoespressif32") or "",
|
|
||||||
"tools", "espota.py"),
|
|
||||||
UPLOADERFLAGS=["--debug", "--progress", "-i", "$UPLOAD_PORT"],
|
UPLOADERFLAGS=["--debug", "--progress", "-i", "$UPLOAD_PORT"],
|
||||||
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS -f $SOURCE'
|
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS -f $SOURCE'
|
||||||
)
|
)
|
||||||
@@ -455,7 +445,7 @@ elif upload_protocol == "esptool":
|
|||||||
"write_flash", "-z",
|
"write_flash", "-z",
|
||||||
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
||||||
"--flash_freq", "${__get_board_f_image(__env__)}",
|
"--flash_freq", "${__get_board_f_image(__env__)}",
|
||||||
"--flash_size", board.get("upload.flash_size", "detect")
|
"--flash_size", "detect"
|
||||||
],
|
],
|
||||||
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $ESP32_APP_OFFSET $SOURCE'
|
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $ESP32_APP_OFFSET $SOURCE'
|
||||||
)
|
)
|
||||||
@@ -473,7 +463,7 @@ elif upload_protocol == "esptool":
|
|||||||
"write_flash", "-z",
|
"write_flash", "-z",
|
||||||
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
"--flash_mode", "${__get_board_flash_mode(__env__)}",
|
||||||
"--flash_freq", "${__get_board_f_image(__env__)}",
|
"--flash_freq", "${__get_board_f_image(__env__)}",
|
||||||
"--flash_size", board.get("upload.flash_size", "detect"),
|
"--flash_size", "detect",
|
||||||
"$FS_START"
|
"$FS_START"
|
||||||
],
|
],
|
||||||
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $SOURCE',
|
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $SOURCE',
|
||||||
@@ -484,7 +474,6 @@ elif upload_protocol == "esptool":
|
|||||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
elif upload_protocol == "dfu":
|
elif upload_protocol == "dfu":
|
||||||
|
|
||||||
hwids = board.get("build.hwids", [["0x2341", "0x0070"]])
|
hwids = board.get("build.hwids", [["0x2341", "0x0070"]])
|
||||||
@@ -508,6 +497,7 @@ elif upload_protocol == "dfu":
|
|||||||
|
|
||||||
|
|
||||||
elif upload_protocol in debug_tools:
|
elif upload_protocol in debug_tools:
|
||||||
|
_parse_partitions(env)
|
||||||
openocd_args = ["-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)]
|
openocd_args = ["-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)]
|
||||||
openocd_args.extend(
|
openocd_args.extend(
|
||||||
debug_tools.get(upload_protocol).get("server").get("arguments", []))
|
debug_tools.get(upload_protocol).get("server").get("arguments", []))
|
||||||
@@ -520,9 +510,7 @@ elif upload_protocol in debug_tools:
|
|||||||
% (
|
% (
|
||||||
"$FS_START"
|
"$FS_START"
|
||||||
if "uploadfs" in COMMAND_LINE_TARGETS
|
if "uploadfs" in COMMAND_LINE_TARGETS
|
||||||
else board.get(
|
else env.get("INTEGRATION_EXTRA_DATA").get("application_offset")
|
||||||
"upload.offset_address", "$ESP32_APP_OFFSET"
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -562,6 +550,21 @@ env.AddPlatformTarget("uploadfs", target_firm, upload_actions, "Upload Filesyste
|
|||||||
env.AddPlatformTarget(
|
env.AddPlatformTarget(
|
||||||
"uploadfsota", target_firm, upload_actions, "Upload Filesystem Image OTA")
|
"uploadfsota", target_firm, upload_actions, "Upload Filesystem Image OTA")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target: Erase Flash and Upload
|
||||||
|
#
|
||||||
|
|
||||||
|
env.AddPlatformTarget(
|
||||||
|
"erase_upload",
|
||||||
|
target_firm,
|
||||||
|
[
|
||||||
|
env.VerboseAction(BeforeUpload, "Looking for upload port..."),
|
||||||
|
env.VerboseAction("$ERASECMD", "Erasing..."),
|
||||||
|
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
||||||
|
],
|
||||||
|
"Erase Flash and Upload",
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Erase Flash
|
# Target: Erase Flash
|
||||||
#
|
#
|
||||||
@@ -570,20 +573,12 @@ env.AddPlatformTarget(
|
|||||||
"erase",
|
"erase",
|
||||||
None,
|
None,
|
||||||
[
|
[
|
||||||
env.VerboseAction(env.AutodetectUploadPort, "Looking for serial port..."),
|
env.VerboseAction(BeforeUpload, "Looking for upload port..."),
|
||||||
env.VerboseAction("$ERASECMD", "Erasing...")
|
env.VerboseAction("$ERASECMD", "Erasing...")
|
||||||
],
|
],
|
||||||
"Erase Flash",
|
"Erase Flash",
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
|
||||||
# Information about obsolete method of specifying linker scripts
|
|
||||||
#
|
|
||||||
|
|
||||||
if any("-Wl,-T" in f for f in env.get("LINKFLAGS", [])):
|
|
||||||
print("Warning! '-Wl,-T' option for specifying linker scripts is deprecated. "
|
|
||||||
"Please use 'board_build.ldscript' option in your 'platformio.ini' file.")
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Override memory inspection behavior
|
# Override memory inspection behavior
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
How to build PlatformIO based project
|
|
||||||
=====================================
|
|
||||||
|
|
||||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
|
||||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
|
||||||
3. Extract ZIP archive
|
|
||||||
4. Run these commands:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# Change directory to example
|
|
||||||
$ cd platform-espressif32/examples/arduino-ble5-advertising
|
|
||||||
|
|
||||||
# Build project
|
|
||||||
$ pio run
|
|
||||||
|
|
||||||
# Upload firmware
|
|
||||||
$ pio run --target upload
|
|
||||||
|
|
||||||
# Build specific environment
|
|
||||||
$ pio run -e esp32-c3-devkitm-1
|
|
||||||
|
|
||||||
# Upload firmware for the specific environment
|
|
||||||
$ pio run -e esp32-c3-devkitm-1 --target upload
|
|
||||||
|
|
||||||
# Clean build files
|
|
||||||
$ pio run --target clean
|
|
||||||
```
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
; 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
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:esp32-c3-devkitm-1]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32-c3-devkitm-1
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
Simple BLE5 multi advertising example on esp32 C3/S3
|
|
||||||
only ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED can be used for periodic advertising
|
|
||||||
|
|
||||||
author: chegewara
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <BLEDevice.h>
|
|
||||||
#include <BLEAdvertising.h>
|
|
||||||
|
|
||||||
|
|
||||||
esp_ble_gap_ext_adv_params_t ext_adv_params_2M = {
|
|
||||||
.type = ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED,
|
|
||||||
.interval_min = 0x40,
|
|
||||||
.interval_max = 0x40,
|
|
||||||
.channel_map = ADV_CHNL_ALL,
|
|
||||||
.own_addr_type = BLE_ADDR_TYPE_RANDOM,
|
|
||||||
.filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
|
|
||||||
.primary_phy = ESP_BLE_GAP_PHY_1M,
|
|
||||||
.max_skip = 0,
|
|
||||||
.secondary_phy = ESP_BLE_GAP_PHY_2M,
|
|
||||||
.sid = 1,
|
|
||||||
.scan_req_notif = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t raw_scan_rsp_data_2m[] = {
|
|
||||||
0x02, 0x01, 0x06,
|
|
||||||
0x02, 0x0a, 0xeb,
|
|
||||||
0x12, 0x09, 'E', 'S', 'P', '_', 'M', 'U', 'L', 'T', 'I', '_', 'A',
|
|
||||||
'D', 'V', '_', '2', 'M', 0X0
|
|
||||||
};
|
|
||||||
|
|
||||||
static esp_ble_gap_periodic_adv_params_t periodic_adv_params = {
|
|
||||||
.interval_min = 0x320, // 1000 ms interval
|
|
||||||
.interval_max = 0x640,
|
|
||||||
.properties = 0, // Do not include TX power
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t periodic_adv_raw_data[] = {
|
|
||||||
0x02, 0x01, 0x06,
|
|
||||||
0x02, 0x0a, 0xeb,
|
|
||||||
0x03, 0x03, 0xab, 0xcd,
|
|
||||||
0x11, 0x09, 'E', 'S', 'P', '_', 'P', 'E', 'R', 'I', 'O', 'D', 'I',
|
|
||||||
'C', '_', 'A', 'D', 'V'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t addr_2m[6] = {0xc0, 0xde, 0x52, 0x00, 0x00, 0x02};
|
|
||||||
|
|
||||||
BLEMultiAdvertising advert(1); // max number of advertisement data
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(115200);
|
|
||||||
Serial.println("Multi-Advertising...");
|
|
||||||
|
|
||||||
BLEDevice::init("");
|
|
||||||
|
|
||||||
advert.setAdvertisingParams(0, &ext_adv_params_2M);
|
|
||||||
advert.setAdvertisingData(0, sizeof(raw_scan_rsp_data_2m), &raw_scan_rsp_data_2m[0]);
|
|
||||||
advert.setInstanceAddress(0, addr_2m);
|
|
||||||
advert.setDuration(0, 0, 0);
|
|
||||||
|
|
||||||
delay(100);
|
|
||||||
advert.start();
|
|
||||||
advert.setPeriodicAdvertisingParams(0, &periodic_adv_params);
|
|
||||||
advert.setPeriodicAdvertisingData(0, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0]);
|
|
||||||
advert.startPeriodicAdvertising(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
delay(2000);
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
How to build PlatformIO based project
|
How to build PlatformIO based project
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html)
|
||||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||||
3. Extract ZIP archive
|
3. Extract ZIP archive
|
||||||
4. Run these commands:
|
4. Run these commands:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
; Library options: dependencies, extra library storages
|
; Library options: dependencies, extra library storages
|
||||||
;
|
;
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:esp-wrover-kit]
|
[env:esp-wrover-kit]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -13,39 +13,16 @@ framework = arduino
|
|||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags =
|
build_flags =
|
||||||
; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
|
-DLED_BUILTIN=2
|
||||||
-D LED_BUILTIN=2
|
|
||||||
|
|
||||||
[env:esp32doit-devkit-v1]
|
[env:esp32-c6-devkitc-1]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = esp32doit-devkit-v1
|
board = esp32-c6-devkitc-1
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:lolin32]
|
[env:esp32-h2-devkitm-1]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = lolin32
|
board = esp32-h2-devkitm-1
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:lolin_c3_mini]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = lolin_c3_mini
|
|
||||||
monitor_speed = 115200
|
|
||||||
|
|
||||||
[env:esp32-s3-devkitc-1]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = esp32-s3-devkitc-1
|
|
||||||
monitor_speed = 115200
|
|
||||||
|
|
||||||
[env:arduino_nano_esp32]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = arduino_nano_esp32
|
|
||||||
|
|
||||||
[env:adafruit_qtpy_esp32s3_n4r2]
|
|
||||||
platform = espressif32
|
|
||||||
board = adafruit_qtpy_esp32s3_n4r2
|
|
||||||
framework = arduino
|
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// Set LED_BUILTIN if it is not defined by Arduino framework
|
// Set LED_BUILTIN if it is not defined by Arduino framework
|
||||||
#ifndef LED_BUILTIN
|
// #define LED_BUILTIN 2
|
||||||
#define LED_BUILTIN 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
[env:esp32-s2]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
build_flags = -DBUILTIN_RGBLED_PIN=18
|
||||||
|
-DNR_OF_LEDS=1
|
||||||
|
|
||||||
|
[env:esp32-s3]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
build_flags = -DBUILTIN_RGBLED_PIN=48
|
||||||
|
-DNR_OF_LEDS=1
|
||||||
|
|
||||||
|
[env:esp32-c3]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
build_flags = -DBUILTIN_RGBLED_PIN=8
|
||||||
|
-DNR_OF_LEDS=1
|
||||||
|
|
||||||
|
[env:esp32-c6]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino
|
||||||
|
board = esp32-c6-devkitm-1
|
||||||
|
build_flags = -DBUILTIN_RGBLED_PIN=8
|
||||||
|
-DNR_OF_LEDS=1
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
// Copyright 2023 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.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This example demonstrates usage of RGB LED driven by RMT
|
||||||
|
*
|
||||||
|
* The output is a visual WS2812 RGB LED color moving in a 8 x 4 LED matrix
|
||||||
|
* Parameters can be changed by the user. In a single LED circuit, it will just blink.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The effect seen in ESP32C3, ESP32S2 and ESP32S3 is like a Blink of RGB LED
|
||||||
|
//#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
//#define BUILTIN_RGBLED_PIN 18
|
||||||
|
//#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
//#define BUILTIN_RGBLED_PIN 48 // 48 or 38
|
||||||
|
//#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
|
//#define BUILTIN_RGBLED_PIN 8
|
||||||
|
//#else
|
||||||
|
//#define BUILTIN_RGBLED_PIN 21 // ESP32 has no builtin RGB LED
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#define NR_OF_LEDS 8*4
|
||||||
|
#define NR_OF_ALL_BITS 24*NR_OF_LEDS
|
||||||
|
|
||||||
|
//
|
||||||
|
// Note: This example uses Neopixel LED board, 32 LEDs chained one
|
||||||
|
// after another, each RGB LED has its 24 bit value
|
||||||
|
// for color configuration (8b for each color)
|
||||||
|
//
|
||||||
|
// Bits encoded as pulses as follows:
|
||||||
|
//
|
||||||
|
// "0":
|
||||||
|
// +-------+ +--
|
||||||
|
// | | |
|
||||||
|
// | | |
|
||||||
|
// | | |
|
||||||
|
// ---| |--------------|
|
||||||
|
// + + +
|
||||||
|
// | 0.4us | 0.85 0us |
|
||||||
|
//
|
||||||
|
// "1":
|
||||||
|
// +-------------+ +--
|
||||||
|
// | | |
|
||||||
|
// | | |
|
||||||
|
// | | |
|
||||||
|
// | | |
|
||||||
|
// ---+ +-------+
|
||||||
|
// | 0.8us | 0.4us |
|
||||||
|
|
||||||
|
rmt_data_t led_data[NR_OF_ALL_BITS];
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
if (!rmtInit(BUILTIN_RGBLED_PIN, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
|
||||||
|
Serial.println("init sender failed\n");
|
||||||
|
}
|
||||||
|
Serial.println("real tick set to: 100ns");
|
||||||
|
}
|
||||||
|
|
||||||
|
int color[] = { 0x55, 0x11, 0x77 }; // Green Red Blue values
|
||||||
|
int led_index = 0;
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Init data with only one led ON
|
||||||
|
int led, col, bit;
|
||||||
|
int i=0;
|
||||||
|
for (led=0; led<NR_OF_LEDS; led++) {
|
||||||
|
for (col=0; col<3; col++ ) {
|
||||||
|
for (bit=0; bit<8; bit++){
|
||||||
|
if ( (color[col] & (1<<(7-bit))) && (led == led_index) ) {
|
||||||
|
led_data[i].level0 = 1;
|
||||||
|
led_data[i].duration0 = 8;
|
||||||
|
led_data[i].level1 = 0;
|
||||||
|
led_data[i].duration1 = 4;
|
||||||
|
} else {
|
||||||
|
led_data[i].level0 = 1;
|
||||||
|
led_data[i].duration0 = 4;
|
||||||
|
led_data[i].level1 = 0;
|
||||||
|
led_data[i].duration1 = 8;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// make the led travel in the pannel
|
||||||
|
if ((++led_index)>=NR_OF_LEDS) {
|
||||||
|
led_index = 0;
|
||||||
|
}
|
||||||
|
// Send the data and wait until it is done
|
||||||
|
rmtWrite(BUILTIN_RGBLED_PIN, led_data, NR_OF_ALL_BITS, RMT_WAIT_FOR_EVER);
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
@@ -14,6 +14,3 @@ monitor_speed = 115200
|
|||||||
|
|
||||||
[env:esp32-s2-saola-1]
|
[env:esp32-s2-saola-1]
|
||||||
board = esp32-s2-saola-1
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
[env:esp32-s2-kaluga-1]
|
|
||||||
board = esp32-s2-kaluga-1
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
How to build PlatformIO based project
|
How to build PlatformIO based project
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html)
|
||||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||||
3. Extract ZIP archive
|
3. Extract ZIP archive
|
||||||
4. Run these commands:
|
4. Run these commands:
|
||||||
|
|||||||
@@ -5,28 +5,10 @@
|
|||||||
; Library options: dependencies, extra library storages
|
; Library options: dependencies, extra library storages
|
||||||
;
|
;
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = esp32dev
|
|
||||||
monitor_speed = 115200
|
|
||||||
|
|
||||||
[env:esp-wrover-kit]
|
[env:esp-wrover-kit]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:espea32]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = espea32
|
|
||||||
monitor_speed = 115200
|
|
||||||
|
|
||||||
[env:esp320]
|
|
||||||
platform = espressif32
|
|
||||||
framework = arduino
|
|
||||||
board = esp320
|
|
||||||
monitor_speed = 115200
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cmake_minimum_required(VERSION 3.16.0)
|
cmake_minimum_required(VERSION 3.16.0)
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(espidf-arduino-wifiscan)
|
project(espidf-arduino-blink)
|
||||||
|
|||||||
@@ -11,14 +11,20 @@
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino, espidf
|
framework = arduino, espidf
|
||||||
build_flags =
|
build_flags =
|
||||||
-D CONFIG_BLINK_GPIO=2
|
-DCONFIG_BLINK_GPIO=2
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||||
|
|
||||||
[env:esp32dev]
|
; FixMe: Linker error only with S3 and arduino,espidf
|
||||||
board = esp32dev
|
;[env:esp32-s3]
|
||||||
|
;board = 4d_systems_esp32s3_gen4_r8n16
|
||||||
|
;build_flags =
|
||||||
|
; -DCONFIG_BLINK_GPIO=2
|
||||||
|
; -DARDUINO_PARTITION_esp_sr_16
|
||||||
|
|
||||||
[env:espea32]
|
[env:esp32-c6-devkitm-1]
|
||||||
board = espea32
|
board = esp32-c6-devkitm-1
|
||||||
|
|
||||||
[env:esp320]
|
|
||||||
board = esp320
|
|
||||||
|
|||||||
@@ -1,5 +1,157 @@
|
|||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPI RAM config
|
||||||
|
#
|
||||||
|
CONFIG_SPIRAM_MODE_OCT=y
|
||||||
|
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||||
|
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
|
||||||
|
CONFIG_SPIRAM_SPEED_80M=y
|
||||||
|
CONFIG_SPIRAM_SPEED=80
|
||||||
|
CONFIG_SPIRAM_USE_MALLOC=y
|
||||||
|
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
|
||||||
|
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
||||||
|
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0
|
||||||
|
|
||||||
CONFIG_AUTOSTART_ARDUINO=y
|
CONFIG_AUTOSTART_ARDUINO=y
|
||||||
# CONFIG_WS2812_LED_ENABLE is not set
|
# CONFIG_WS2812_LED_ENABLE is not set
|
||||||
|
CONFIG_ARDUHAL_ESP_LOG=y
|
||||||
|
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||||
|
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
|
||||||
|
CONFIG_BT_BLE_BLUFI_ENABLE=y
|
||||||
|
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
|
||||||
|
CONFIG_BT_BTC_TASK_STACK_SIZE=8192
|
||||||
|
CONFIG_BT_BTU_TASK_STACK_SIZE=8192
|
||||||
|
CONFIG_BLE_MESH=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
|
CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y
|
||||||
|
CONFIG_COMPILER_WARN_WRITE_STRINGS=y
|
||||||
|
CONFIG_ESP_HTTPS_SERVER_ENABLE=y
|
||||||
|
CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y
|
||||||
|
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
||||||
|
CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
|
||||||
|
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
|
||||||
|
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048
|
||||||
|
CONFIG_ESP_TASK_WDT_PANIC=y
|
||||||
|
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096
|
||||||
|
CONFIG_ESP_WIFI_FTM_ENABLE=y
|
||||||
|
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8
|
||||||
|
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8
|
||||||
|
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16
|
||||||
|
CONFIG_ESP_WIFI_CSI_ENABLED=y
|
||||||
|
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
|
||||||
|
# CONFIG_ESP_WIFI_IRAM_OPT is not set
|
||||||
|
# CONFIG_ESP_WIFI_RX_IRAM_OPT is not set
|
||||||
|
CONFIG_ETH_SPI_ETHERNET_DM9051=y
|
||||||
|
CONFIG_ETH_SPI_ETHERNET_W5500=y
|
||||||
|
CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y
|
||||||
|
CONFIG_FATFS_CODEPAGE_850=y
|
||||||
|
CONFIG_FATFS_LFN_STACK=y
|
||||||
|
# CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set
|
||||||
|
CONFIG_FATFS_API_ENCODING_UTF_8=y
|
||||||
|
CONFIG_FATFS_USE_LABEL=y
|
||||||
|
# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set
|
||||||
|
CONFIG_FMB_TIMER_PORT_ENABLED=y
|
||||||
CONFIG_FREERTOS_HZ=1000
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||||
|
# CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION is not set
|
||||||
|
CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024
|
||||||
|
CONFIG_HEAP_POISONING_LIGHT=y
|
||||||
|
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
|
||||||
|
CONFIG_HTTPD_WS_SUPPORT=y
|
||||||
|
# CONFIG_LOG_COLORS is not set
|
||||||
|
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
|
||||||
|
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
|
||||||
|
CONFIG_LWIP_TCP_SYNMAXRTX=6
|
||||||
|
CONFIG_LWIP_TCP_MSS=1436
|
||||||
|
CONFIG_LWIP_TCP_RTO_TIME=3000
|
||||||
|
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096
|
||||||
|
CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y
|
||||||
|
CONFIG_LWIP_MAX_SOCKETS=16
|
||||||
|
CONFIG_LWIP_IP_FORWARD=y
|
||||||
|
CONFIG_LWIP_IPV4_NAPT=y
|
||||||
|
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=n
|
||||||
|
CONFIG_LWIP_DHCP_OPTIONS_LEN=128
|
||||||
|
CONFIG_LWIP_SNTP_MAX_SERVERS=3
|
||||||
|
CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000
|
||||||
|
CONFIG_LWIP_DHCP_GET_NTP_SRV=y
|
||||||
|
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||||
|
CONFIG_LWIP_IPV6_DHCP6=y
|
||||||
|
CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=2
|
||||||
|
CONFIG_LWIP_PPP_SUPPORT=y
|
||||||
|
CONFIG_LWIP_PPP_NOTIFY_PHASE_SUPPORT=y
|
||||||
|
CONFIG_LWIP_PPP_PAP_SUPPORT=y
|
||||||
|
CONFIG_LWIP_PPP_ENABLE_IPV6=n
|
||||||
CONFIG_MBEDTLS_PSK_MODES=y
|
CONFIG_MBEDTLS_PSK_MODES=y
|
||||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||||
|
CONFIG_MBEDTLS_CAMELLIA_C=y
|
||||||
|
# CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set
|
||||||
|
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
|
||||||
|
CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
|
||||||
|
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048
|
||||||
|
CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y
|
||||||
|
CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10
|
||||||
|
CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2
|
||||||
|
CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096
|
||||||
|
# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set
|
||||||
|
# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set
|
||||||
|
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
|
||||||
|
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0
|
||||||
|
CONFIG_ESP_RMAKER_SKIP_VERSION_CHECK=y
|
||||||
|
CONFIG_ESP_RMAKER_USER_ID_CHECK=y
|
||||||
|
CONFIG_ESP_INSIGHTS_ENABLED=y
|
||||||
|
CONFIG_ESP_INSIGHTS_COREDUMP_ENABLE=n
|
||||||
|
CONFIG_ESP_INSIGHTS_TRANSPORT_HTTPS=y
|
||||||
|
CONFIG_DIAG_LOG_DROP_WIFI_LOGS=y
|
||||||
|
CONFIG_DIAG_ENABLE_METRICS=y
|
||||||
|
CONFIG_DIAG_ENABLE_HEAP_METRICS=y
|
||||||
|
CONFIG_DIAG_ENABLE_WIFI_METRICS=y
|
||||||
|
CONFIG_DIAG_ENABLE_VARIABLES=y
|
||||||
|
CONFIG_DIAG_ENABLE_NETWORK_VARIABLES=y
|
||||||
|
CONFIG_ESP_COREDUMP_ENABLE=y
|
||||||
|
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n
|
||||||
|
CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=y
|
||||||
|
CONFIG_ESP_COREDUMP_CHECKSUM_CRC32=y
|
||||||
|
CONFIG_ESP_COREDUMP_MAX_TASKS_NUM=64
|
||||||
|
CONFIG_ESP_COREDUMP_STACK_SIZE=1024
|
||||||
|
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
|
||||||
|
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
|
||||||
|
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
|
||||||
|
|
||||||
|
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||||
|
CONFIG_SR_WN_WN9_HIESP=y
|
||||||
|
CONFIG_SR_MN_CN_NONE=y
|
||||||
|
CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8=y
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID0=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID1=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID2=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID3=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID4=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID5=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID6=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID7=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID8=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID9=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID10=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID11=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID12=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID13=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID14=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID15=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID16=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID17=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID18=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID19=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID20=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID21=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID22=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID23=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID24=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID25=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID26=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID27=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID28=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID29=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID30=""
|
||||||
|
CONFIG_EN_SPEECH_COMMAND_ID31=""
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void blink_task(void *pvParameter)
|
|||||||
Technical Reference for a list of pads and their default
|
Technical Reference for a list of pads and their default
|
||||||
functions.)
|
functions.)
|
||||||
*/
|
*/
|
||||||
gpio_pad_select_gpio(BLINK_GPIO);
|
esp_rom_gpio_pad_select_gpio(BLINK_GPIO);
|
||||||
/* Set the GPIO as a push/pull output */
|
/* Set the GPIO as a push/pull output */
|
||||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.pio
|
||||||
|
.vscode
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16.0)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(espidf-arduino-littlefs)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Arduino_IDF_LittleFS
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
aaa
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
bbb
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9000, 0x5000,
|
||||||
|
otadata, data, ota, 0xe000, 0x2000,
|
||||||
|
app0, app, ota_0, 0x10000, 0x140000,
|
||||||
|
app1, app, ota_1, 0x150000,0x140000,
|
||||||
|
spiffs, data, spiffs, 0x290000,0x160000,
|
||||||
|
coredump, data, coredump,0x3F0000,0x10000,
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino, espidf
|
||||||
|
monitor_speed = 115200
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||||
|
|
||||||
|
[env:esp32dev]
|
||||||
|
board = esp32dev
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
board_build.partitions = partitions_custom.csv
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CONFIG_AUTOSTART_ARDUINO=y
|
||||||
|
# CONFIG_WS2812_LED_ENABLE is not set
|
||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_MBEDTLS_PSK_MODES=y
|
||||||
|
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
|
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# This file was automatically generated for projects
|
||||||
|
# without default 'CMakeLists.txt' file.
|
||||||
|
|
||||||
|
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
|
||||||
|
|
||||||
|
idf_component_register(SRCS ${app_sources})
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
#include "FS.h"
|
||||||
|
#include <LittleFS.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
/* You only need to format LittleFS the first time you run a
|
||||||
|
test or else use the LITTLEFS plugin to create a partition
|
||||||
|
https://github.com/lorol/arduino-esp32littlefs-plugin */
|
||||||
|
|
||||||
|
#define FORMAT_LITTLEFS_IF_FAILED true
|
||||||
|
|
||||||
|
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
|
||||||
|
Serial.printf("Listing directory: %s\r\n", dirname);
|
||||||
|
|
||||||
|
File root = fs.open(dirname);
|
||||||
|
if(!root){
|
||||||
|
Serial.println("- failed to open directory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!root.isDirectory()){
|
||||||
|
Serial.println(" - not a directory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = root.openNextFile();
|
||||||
|
while(file){
|
||||||
|
if(file.isDirectory()){
|
||||||
|
Serial.print(" DIR : ");
|
||||||
|
|
||||||
|
Serial.print(file.name());
|
||||||
|
time_t t= file.getLastWrite();
|
||||||
|
struct tm * tmstruct = localtime(&t);
|
||||||
|
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec);
|
||||||
|
|
||||||
|
if(levels){
|
||||||
|
listDir(fs, file.name(), levels -1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Serial.print(" FILE: ");
|
||||||
|
Serial.print(file.name());
|
||||||
|
Serial.print(" SIZE: ");
|
||||||
|
|
||||||
|
Serial.print(file.size());
|
||||||
|
time_t t= file.getLastWrite();
|
||||||
|
struct tm * tmstruct = localtime(&t);
|
||||||
|
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec);
|
||||||
|
}
|
||||||
|
file = root.openNextFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void createDir(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Creating Dir: %s\n", path);
|
||||||
|
if(fs.mkdir(path)){
|
||||||
|
Serial.println("Dir created");
|
||||||
|
} else {
|
||||||
|
Serial.println("mkdir failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeDir(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Removing Dir: %s\n", path);
|
||||||
|
if(fs.rmdir(path)){
|
||||||
|
Serial.println("Dir removed");
|
||||||
|
} else {
|
||||||
|
Serial.println("rmdir failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void readFile(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Reading file: %s\r\n", path);
|
||||||
|
|
||||||
|
File file = fs.open(path);
|
||||||
|
if(!file || file.isDirectory()){
|
||||||
|
Serial.println("- failed to open file for reading");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("- read from file:");
|
||||||
|
while(file.available()){
|
||||||
|
Serial.write(file.read());
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||||
|
Serial.printf("Writing file: %s\r\n", path);
|
||||||
|
|
||||||
|
File file = fs.open(path, FILE_WRITE);
|
||||||
|
if(!file){
|
||||||
|
Serial.println("- failed to open file for writing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(file.print(message)){
|
||||||
|
Serial.println("- file written");
|
||||||
|
} else {
|
||||||
|
Serial.println("- write failed");
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendFile(fs::FS &fs, const char * path, const char * message){
|
||||||
|
Serial.printf("Appending to file: %s\r\n", path);
|
||||||
|
|
||||||
|
File file = fs.open(path, FILE_APPEND);
|
||||||
|
if(!file){
|
||||||
|
Serial.println("- failed to open file for appending");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(file.print(message)){
|
||||||
|
Serial.println("- message appended");
|
||||||
|
} else {
|
||||||
|
Serial.println("- append failed");
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
||||||
|
Serial.printf("Renaming file %s to %s\r\n", path1, path2);
|
||||||
|
if (fs.rename(path1, path2)) {
|
||||||
|
Serial.println("- file renamed");
|
||||||
|
} else {
|
||||||
|
Serial.println("- rename failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void deleteFile(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Deleting file: %s\r\n", path);
|
||||||
|
if(fs.remove(path)){
|
||||||
|
Serial.println("- file deleted");
|
||||||
|
} else {
|
||||||
|
Serial.println("- delete failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SPIFFS-like write and delete file
|
||||||
|
|
||||||
|
// See: https://github.com/esp8266/Arduino/blob/master/libraries/LittleFS/src/LittleFS.cpp#L60
|
||||||
|
void writeFile2(fs::FS &fs, const char * path, const char * message){
|
||||||
|
if(!fs.exists(path)){
|
||||||
|
if (strchr(path, '/')) {
|
||||||
|
Serial.printf("Create missing folders of: %s\r\n", path);
|
||||||
|
char *pathStr = strdup(path);
|
||||||
|
if (pathStr) {
|
||||||
|
char *ptr = strchr(pathStr, '/');
|
||||||
|
while (ptr) {
|
||||||
|
*ptr = 0;
|
||||||
|
fs.mkdir(pathStr);
|
||||||
|
*ptr = '/';
|
||||||
|
ptr = strchr(ptr+1, '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(pathStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.printf("Writing file to: %s\r\n", path);
|
||||||
|
File file = fs.open(path, FILE_WRITE);
|
||||||
|
if(!file){
|
||||||
|
Serial.println("- failed to open file for writing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(file.print(message)){
|
||||||
|
Serial.println("- file written");
|
||||||
|
} else {
|
||||||
|
Serial.println("- write failed");
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// See: https://github.com/esp8266/Arduino/blob/master/libraries/LittleFS/src/LittleFS.h#L149
|
||||||
|
void deleteFile2(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Deleting file and empty folders on path: %s\r\n", path);
|
||||||
|
|
||||||
|
if(fs.remove(path)){
|
||||||
|
Serial.println("- file deleted");
|
||||||
|
} else {
|
||||||
|
Serial.println("- delete failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pathStr = strdup(path);
|
||||||
|
if (pathStr) {
|
||||||
|
char *ptr = strrchr(pathStr, '/');
|
||||||
|
if (ptr) {
|
||||||
|
Serial.printf("Removing all empty folders on path: %s\r\n", path);
|
||||||
|
}
|
||||||
|
while (ptr) {
|
||||||
|
*ptr = 0;
|
||||||
|
fs.rmdir(pathStr);
|
||||||
|
ptr = strrchr(pathStr, '/');
|
||||||
|
}
|
||||||
|
free(pathStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testFileIO(fs::FS &fs, const char * path){
|
||||||
|
Serial.printf("Testing file I/O with %s\r\n", path);
|
||||||
|
|
||||||
|
static uint8_t buf[512];
|
||||||
|
size_t len = 0;
|
||||||
|
File file = fs.open(path, FILE_WRITE);
|
||||||
|
if(!file){
|
||||||
|
Serial.println("- failed to open file for writing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
Serial.print("- writing" );
|
||||||
|
uint32_t start = millis();
|
||||||
|
for(i=0; i<2048; i++){
|
||||||
|
if ((i & 0x001F) == 0x001F){
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
file.write(buf, 512);
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
uint32_t end = millis() - start;
|
||||||
|
Serial.printf(" - %u bytes written in %u ms\r\n", 2048 * 512, (unsigned int)end);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
file = fs.open(path);
|
||||||
|
start = millis();
|
||||||
|
end = start;
|
||||||
|
i = 0;
|
||||||
|
if(file && !file.isDirectory()){
|
||||||
|
len = file.size();
|
||||||
|
size_t flen = len;
|
||||||
|
start = millis();
|
||||||
|
Serial.print("- reading" );
|
||||||
|
while(len){
|
||||||
|
size_t toRead = len;
|
||||||
|
if(toRead > 512){
|
||||||
|
toRead = 512;
|
||||||
|
}
|
||||||
|
file.read(buf, toRead);
|
||||||
|
if ((i++ & 0x001F) == 0x001F){
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
len -= toRead;
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
end = millis() - start;
|
||||||
|
Serial.printf("- %u bytes read in %u ms\r\n", flen, (unsigned int)end);
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
Serial.println("- failed to open file for reading");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
Serial.begin(115200);
|
||||||
|
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
|
||||||
|
Serial.println("LittleFS Mount Failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
listDir(LittleFS, "/", 0);
|
||||||
|
createDir(LittleFS, "/mydir");
|
||||||
|
writeFile(LittleFS, "/mydir/hello2.txt", "Hello2");
|
||||||
|
//writeFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
|
||||||
|
writeFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
|
||||||
|
listDir(LittleFS, "/", 3);
|
||||||
|
deleteFile(LittleFS, "/mydir/hello2.txt");
|
||||||
|
//deleteFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
|
||||||
|
deleteFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
|
||||||
|
removeDir(LittleFS, "/mydir");
|
||||||
|
listDir(LittleFS, "/", 3);
|
||||||
|
writeFile(LittleFS, "/hello.txt", "Hello ");
|
||||||
|
appendFile(LittleFS, "/hello.txt", "World!\r\n");
|
||||||
|
readFile(LittleFS, "/hello.txt");
|
||||||
|
renameFile(LittleFS, "/hello.txt", "/foo.txt");
|
||||||
|
readFile(LittleFS, "/foo.txt");
|
||||||
|
deleteFile(LittleFS, "/foo.txt");
|
||||||
|
testFileIO(LittleFS, "/test.txt");
|
||||||
|
deleteFile(LittleFS, "/test.txt");
|
||||||
|
|
||||||
|
Serial.println( "Test complete" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -11,9 +11,12 @@
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino, espidf
|
framework = arduino, espidf
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
board_build.esp-idf.preserve_source_file_extension = yes
|
||||||
[env:esp32dev]
|
board_build.embed_txtfiles =
|
||||||
board = esp32dev
|
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||||
|
|
||||||
[env:esp-wrover-kit]
|
[env:esp-wrover-kit]
|
||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ CONFIG_AUTOSTART_ARDUINO=y
|
|||||||
CONFIG_FREERTOS_HZ=1000
|
CONFIG_FREERTOS_HZ=1000
|
||||||
CONFIG_MBEDTLS_PSK_MODES=y
|
CONFIG_MBEDTLS_PSK_MODES=y
|
||||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
|
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||||
# Example config
|
# Example config
|
||||||
CONFIG_EXAMPLE_WIFI_SSID="MYSSID"
|
CONFIG_EXAMPLE_WIFI_SSID="MYSSID"
|
||||||
CONFIG_EXAMPLE_WIFI_PASSWORD="MYPASS"
|
CONFIG_EXAMPLE_WIFI_PASSWORD="MYPASS"
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
.pio
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
|
||||||
# in this exact order for cmake to work correctly
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
||||||
project(ble_eddystone_demo)
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
How to build PlatformIO based project
|
|
||||||
=====================================
|
|
||||||
|
|
||||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
|
||||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
|
||||||
3. Extract ZIP archive
|
|
||||||
4. Run these commands:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# Change directory to example
|
|
||||||
$ cd platform-espressif32/examples/espidf-ble-eddystone
|
|
||||||
|
|
||||||
# Build project
|
|
||||||
$ pio run
|
|
||||||
|
|
||||||
# Upload firmware
|
|
||||||
$ pio run --target upload
|
|
||||||
|
|
||||||
# Build specific environment
|
|
||||||
$ pio run -e esp32dev
|
|
||||||
|
|
||||||
# Upload firmware for the specific environment
|
|
||||||
$ pio run -e esp32dev --target upload
|
|
||||||
|
|
||||||
# Clean build files
|
|
||||||
$ pio run --target clean
|
|
||||||
```
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
; 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
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
platform = espressif32
|
|
||||||
framework = espidf
|
|
||||||
board = esp32dev
|
|
||||||
monitor_speed = 115200
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# Override some defaults so BT stack is enabled
|
|
||||||
# and WiFi disabled by default in this example
|
|
||||||
CONFIG_BT_ENABLED=y
|
|
||||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
|
||||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
|
||||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
idf_component_register(SRCS "esp_eddystone_api.c"
|
|
||||||
"esp_eddystone_demo.c"
|
|
||||||
INCLUDE_DIRS "")
|
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* This file is used to decode eddystone information.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "esp_gap_ble_api.h"
|
|
||||||
#include "esp_eddystone_protocol.h"
|
|
||||||
#include "esp_eddystone_api.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Declare static functions */
|
|
||||||
static esp_err_t esp_eddystone_uid_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
|
||||||
static esp_err_t esp_eddystone_url_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
|
||||||
static char* esp_eddystone_resolve_url_scheme(const uint8_t* url_start, const uint8_t* url_end);
|
|
||||||
static esp_err_t esp_eddystone_tlm_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
|
||||||
static esp_err_t esp_eddystone_get_inform(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
|
||||||
|
|
||||||
/* Eddystone-URL scheme prefixes */
|
|
||||||
static const char* eddystone_url_prefix[4] = {
|
|
||||||
"http://www.",
|
|
||||||
"https://www.",
|
|
||||||
"http://",
|
|
||||||
"https://"
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Eddystone-URL HTTP URL encoding */
|
|
||||||
static const char* eddystone_url_encoding[14] = {
|
|
||||||
".com/",
|
|
||||||
".org/",
|
|
||||||
".edu/",
|
|
||||||
".net/",
|
|
||||||
".info/",
|
|
||||||
".biz/",
|
|
||||||
".gov/",
|
|
||||||
".com",
|
|
||||||
".org",
|
|
||||||
".edu",
|
|
||||||
".net",
|
|
||||||
".info",
|
|
||||||
".biz",
|
|
||||||
".gov"
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************** Eddystone-UID **************
|
|
||||||
Byte offset Field Description
|
|
||||||
0 Frame Type Value = 0x00
|
|
||||||
1 Ranging Data Calibrated Tx power at 0 m
|
|
||||||
2 NID[0] 10-byte Namespace
|
|
||||||
3 NID[1]
|
|
||||||
4 NID[2]
|
|
||||||
5 NID[3]
|
|
||||||
6 NID[4]
|
|
||||||
7 NID[5]
|
|
||||||
8 NID[6]
|
|
||||||
9 NID[7]
|
|
||||||
10 NID[8]
|
|
||||||
11 NID[9]
|
|
||||||
12 BID[0] 6-byte Instance
|
|
||||||
13 BID[1]
|
|
||||||
14 BID[2]
|
|
||||||
15 BID[3]
|
|
||||||
16 BID[4]
|
|
||||||
17 BID[5]
|
|
||||||
18 RFU Reserved for future use, must be0x00
|
|
||||||
19 RFU Reserved for future use, must be0x00
|
|
||||||
*********************************************/
|
|
||||||
/* decode and store received UID */
|
|
||||||
static esp_err_t esp_eddystone_uid_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
uint8_t pos = 0;
|
|
||||||
//1-byte Ranging Data + 10-byte Namespace + 6-byte Instance
|
|
||||||
if((len != EDDYSTONE_UID_DATA_LEN) && (len != (EDDYSTONE_UID_RFU_LEN+EDDYSTONE_UID_DATA_LEN))) {
|
|
||||||
//ERROR:uid len wrong
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res->inform.uid.ranging_data = buf[pos++];
|
|
||||||
for(int i=0; i<EDDYSTONE_UID_NAMESPACE_LEN; i++) {
|
|
||||||
res->inform.uid.namespace_id[i] = buf[pos++];
|
|
||||||
}
|
|
||||||
for(int i=0; i<EDDYSTONE_UID_INSTANCE_LEN; i++) {
|
|
||||||
res->inform.uid.instance_id[i] = buf[pos++];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* resolve received URL to url_res pointer */
|
|
||||||
static char* esp_eddystone_resolve_url_scheme(const uint8_t *url_start, const uint8_t *url_end)
|
|
||||||
{
|
|
||||||
int pos = 0;
|
|
||||||
static char url_buf[100] = {0};
|
|
||||||
const uint8_t *p = url_start;
|
|
||||||
|
|
||||||
pos += sprintf(&url_buf[pos], "%s", eddystone_url_prefix[*p++]);
|
|
||||||
|
|
||||||
for (; p <= url_end; p++) {
|
|
||||||
if (esp_eddystone_is_char_invalid((*p))) {
|
|
||||||
pos += sprintf(&url_buf[pos], "%s", eddystone_url_encoding[*p]);
|
|
||||||
} else {
|
|
||||||
pos += sprintf(&url_buf[pos], "%c", *p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************** Eddystone-URL *************
|
|
||||||
Frame Specification
|
|
||||||
Byte offset Field Description
|
|
||||||
0 Frame Type Value = 0x10
|
|
||||||
1 TX Power Calibrated Tx power at 0 m
|
|
||||||
2 URL Scheme Encoded Scheme Prefix
|
|
||||||
3+ Encoded URL Length 1-17
|
|
||||||
*******************************************************/
|
|
||||||
/* decode and store received URL, the pointer url_res points to the resolved url */
|
|
||||||
static esp_err_t esp_eddystone_url_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
char *url_res = NULL;
|
|
||||||
uint8_t pos = 0;
|
|
||||||
if(len-EDDYSTONE_URL_TX_POWER_LEN > EDDYSTONE_URL_MAX_LEN) {
|
|
||||||
//ERROR:too long url
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res->inform.url.tx_power = buf[pos++];
|
|
||||||
url_res = esp_eddystone_resolve_url_scheme(buf+pos, buf+len-1);
|
|
||||||
memcpy(&res->inform.url.url, url_res, strlen(url_res));
|
|
||||||
res->inform.url.url[strlen(url_res)] = '\0';
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************** eddystone-tlm ***************
|
|
||||||
* Unencrypted TLM Frame Specification
|
|
||||||
Byte offset Field Description
|
|
||||||
0 Frame Type Value = 0x20
|
|
||||||
1 Version TLM version, value = 0x00
|
|
||||||
2 VBATT[0] Battery voltage, 1 mV/bit
|
|
||||||
3 VBATT[1]
|
|
||||||
4 TEMP[0] Beacon temperature
|
|
||||||
5 TEMP[1]
|
|
||||||
6 ADV_CNT[0] Advertising PDU count
|
|
||||||
7 ADV_CNT[1]
|
|
||||||
8 ADV_CNT[2]
|
|
||||||
9 ADV_CNT[3]
|
|
||||||
10 SEC_CNT[0] Time since power-on or reboot
|
|
||||||
11 SEC_CNT[1]
|
|
||||||
12 SEC_CNT[2]
|
|
||||||
13 SEC_CNT[3]
|
|
||||||
************************************************/
|
|
||||||
/* decode and store received TLM */
|
|
||||||
static esp_err_t esp_eddystone_tlm_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
uint8_t pos = 0;
|
|
||||||
if(len > EDDYSTONE_TLM_DATA_LEN) {
|
|
||||||
//ERROR:TLM too long
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res->inform.tlm.version = buf[pos++];
|
|
||||||
res->inform.tlm.battery_voltage = big_endian_read_16(buf, pos);
|
|
||||||
pos += 2;
|
|
||||||
uint16_t temp = big_endian_read_16(buf, pos);
|
|
||||||
int8_t temp_integral = (int8_t)((temp >> 8) & 0xff);
|
|
||||||
float temp_decimal = (temp & 0xff) / 256.0;
|
|
||||||
res->inform.tlm.temperature = temp_integral + temp_decimal;
|
|
||||||
pos += 2;
|
|
||||||
res->inform.tlm.adv_count = big_endian_read_32(buf, pos);
|
|
||||||
pos += 4;
|
|
||||||
res->inform.tlm.time = big_endian_read_32(buf, pos);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static esp_err_t esp_eddystone_get_inform(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
static esp_err_t ret=-1;
|
|
||||||
switch(res->common.frame_type)
|
|
||||||
{
|
|
||||||
case EDDYSTONE_FRAME_TYPE_UID: {
|
|
||||||
ret = esp_eddystone_uid_received(buf, len, res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EDDYSTONE_FRAME_TYPE_URL: {
|
|
||||||
ret = esp_eddystone_url_received(buf, len, res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EDDYSTONE_FRAME_TYPE_TLM: {
|
|
||||||
ret = esp_eddystone_tlm_received(buf, len, res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
if (len == 0 || buf == NULL || res == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
uint8_t pos=0;
|
|
||||||
while(res->common.srv_data_type != EDDYSTONE_SERVICE_UUID)
|
|
||||||
{
|
|
||||||
pos++;
|
|
||||||
if(pos >= len ) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
uint8_t ad_type = buf[pos++];
|
|
||||||
switch(ad_type)
|
|
||||||
{
|
|
||||||
case ESP_BLE_AD_TYPE_FLAG: {
|
|
||||||
res->common.flags = buf[pos++];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESP_BLE_AD_TYPE_16SRV_CMPL: {
|
|
||||||
uint16_t uuid = little_endian_read_16(buf, pos);
|
|
||||||
if(uuid != EDDYSTONE_SERVICE_UUID) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res->common.srv_uuid = uuid;
|
|
||||||
pos += 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESP_BLE_AD_TYPE_SERVICE_DATA: {
|
|
||||||
uint16_t type = little_endian_read_16(buf, pos);
|
|
||||||
pos += 2;
|
|
||||||
uint8_t frame_type = buf[pos++];
|
|
||||||
if(type != EDDYSTONE_SERVICE_UUID || !(frame_type == EDDYSTONE_FRAME_TYPE_UID || frame_type == EDDYSTONE_FRAME_TYPE_URL ||
|
|
||||||
frame_type == EDDYSTONE_FRAME_TYPE_TLM)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res->common.srv_data_type = type;
|
|
||||||
res->common.frame_type = frame_type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return esp_eddystone_get_inform(buf+pos, len-pos, res);
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __ESP_EDDYSTONE_API_H__
|
|
||||||
#define __ESP_EDDYSTONE_API_H__
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct {
|
|
||||||
uint8_t flags; /*<! AD flags data */
|
|
||||||
uint16_t srv_uuid; /*<! complete list of 16-bit service uuid*/
|
|
||||||
uint16_t srv_data_type; /*<! service data type */
|
|
||||||
uint8_t frame_type; /*<! Eddystone UID, URL or TLM */
|
|
||||||
} common;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
/*<! Eddystone-UID */
|
|
||||||
int8_t ranging_data; /*<! calibrated Tx power at 0m */
|
|
||||||
uint8_t namespace_id[10];
|
|
||||||
uint8_t instance_id[6];
|
|
||||||
} uid;
|
|
||||||
struct {
|
|
||||||
/*<! Eddystone-URL */
|
|
||||||
int8_t tx_power; /*<! calibrated Tx power at 0m */
|
|
||||||
char url[EDDYSTONE_URL_MAX_LEN]; /*<! the decoded URL */
|
|
||||||
} url;
|
|
||||||
struct {
|
|
||||||
/*<! Eddystone-TLM */
|
|
||||||
uint8_t version; /*<! TLM version,0x00 for now */
|
|
||||||
uint16_t battery_voltage; /*<! battery voltage in mV */
|
|
||||||
float temperature; /*<! beacon temperature in degrees Celsius */
|
|
||||||
uint32_t adv_count; /*<! adv pdu count since power-up */
|
|
||||||
uint32_t time; /*<! time since power-up, a 0.1 second resolution counter */
|
|
||||||
} tlm;
|
|
||||||
} inform;
|
|
||||||
} esp_eddystone_result_t;
|
|
||||||
|
|
||||||
/* utils */
|
|
||||||
static inline uint16_t little_endian_read_16(const uint8_t *buffer, uint8_t pos)
|
|
||||||
{
|
|
||||||
return ((uint16_t)buffer[pos]) | (((uint16_t)buffer[(pos)+1]) << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint16_t big_endian_read_16(const uint8_t *buffer, uint8_t pos)
|
|
||||||
{
|
|
||||||
return (((uint16_t)buffer[pos]) << 8) | ((uint16_t)buffer[(pos)+1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t big_endian_read_32(const uint8_t *buffer, uint8_t pos)
|
|
||||||
{
|
|
||||||
return (((uint32_t)buffer[pos]) << 24) | (((uint32_t)buffer[(pos)+1]) << 16) | (((uint32_t)buffer[(pos)+2]) << 8) | ((uint32_t)buffer[(pos)+3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The esp eddystone API.
|
|
||||||
* This function is called to decode eddystone information from adv_data.
|
|
||||||
* The res points to the result struct.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
|
||||||
|
|
||||||
//bool esp_eddystone_is_eddystone_packet(.....);
|
|
||||||
|
|
||||||
#endif /* __ESP_EDDYSTONE_API_H__ */
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* This file is used for eddystone receiver.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_bt_defs.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_gatt_defs.h"
|
|
||||||
#include "esp_gattc_api.h"
|
|
||||||
#include "esp_gap_ble_api.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
|
|
||||||
#include "esp_eddystone_protocol.h"
|
|
||||||
#include "esp_eddystone_api.h"
|
|
||||||
|
|
||||||
static const char* DEMO_TAG = "EDDYSTONE_DEMO";
|
|
||||||
|
|
||||||
/* declare static functions */
|
|
||||||
static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param);
|
|
||||||
static void esp_eddystone_show_inform(const esp_eddystone_result_t* res);
|
|
||||||
|
|
||||||
static esp_ble_scan_params_t ble_scan_params = {
|
|
||||||
.scan_type = BLE_SCAN_TYPE_ACTIVE,
|
|
||||||
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
|
|
||||||
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
|
|
||||||
.scan_interval = 0x50,
|
|
||||||
.scan_window = 0x30,
|
|
||||||
.scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE
|
|
||||||
};
|
|
||||||
|
|
||||||
static void esp_eddystone_show_inform(const esp_eddystone_result_t* res)
|
|
||||||
{
|
|
||||||
switch(res->common.frame_type)
|
|
||||||
{
|
|
||||||
case EDDYSTONE_FRAME_TYPE_UID: {
|
|
||||||
ESP_LOGI(DEMO_TAG, "Eddystone UID inform:");
|
|
||||||
ESP_LOGI(DEMO_TAG, "Measured power(RSSI at 0m distance):%d dbm", res->inform.uid.ranging_data);
|
|
||||||
ESP_LOGI(DEMO_TAG, "EDDYSTONE_DEMO: Namespace ID:0x");
|
|
||||||
esp_log_buffer_hex(DEMO_TAG, res->inform.uid.namespace_id, 10);
|
|
||||||
ESP_LOGI(DEMO_TAG, "EDDYSTONE_DEMO: Instance ID:0x");
|
|
||||||
esp_log_buffer_hex(DEMO_TAG, res->inform.uid.instance_id, 6);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EDDYSTONE_FRAME_TYPE_URL: {
|
|
||||||
ESP_LOGI(DEMO_TAG, "Eddystone URL inform:");
|
|
||||||
ESP_LOGI(DEMO_TAG, "Measured power(RSSI at 0m distance):%d dbm", res->inform.url.tx_power);
|
|
||||||
ESP_LOGI(DEMO_TAG, "URL: %s", res->inform.url.url);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EDDYSTONE_FRAME_TYPE_TLM: {
|
|
||||||
ESP_LOGI(DEMO_TAG, "Eddystone TLM inform:");
|
|
||||||
ESP_LOGI(DEMO_TAG, "version: %d", res->inform.tlm.version);
|
|
||||||
ESP_LOGI(DEMO_TAG, "battery voltage: %d mV", res->inform.tlm.battery_voltage);
|
|
||||||
ESP_LOGI(DEMO_TAG, "beacon temperature in degrees Celsius: %6.1f", res->inform.tlm.temperature);
|
|
||||||
ESP_LOGI(DEMO_TAG, "adv pdu count since power-up: %d", res->inform.tlm.adv_count);
|
|
||||||
ESP_LOGI(DEMO_TAG, "time since power-up: %d s", (res->inform.tlm.time)/10);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param)
|
|
||||||
{
|
|
||||||
esp_err_t err;
|
|
||||||
|
|
||||||
switch(event)
|
|
||||||
{
|
|
||||||
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: {
|
|
||||||
uint32_t duration = 0;
|
|
||||||
esp_ble_gap_start_scanning(duration);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT: {
|
|
||||||
if((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
|
|
||||||
ESP_LOGE(DEMO_TAG,"Scan start failed: %s", esp_err_to_name(err));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ESP_LOGI(DEMO_TAG,"Start scanning...");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESP_GAP_BLE_SCAN_RESULT_EVT: {
|
|
||||||
esp_ble_gap_cb_param_t* scan_result = (esp_ble_gap_cb_param_t*)param;
|
|
||||||
switch(scan_result->scan_rst.search_evt)
|
|
||||||
{
|
|
||||||
case ESP_GAP_SEARCH_INQ_RES_EVT: {
|
|
||||||
esp_eddystone_result_t eddystone_res;
|
|
||||||
memset(&eddystone_res, 0, sizeof(eddystone_res));
|
|
||||||
esp_err_t ret = esp_eddystone_decode(scan_result->scan_rst.ble_adv, scan_result->scan_rst.adv_data_len, &eddystone_res);
|
|
||||||
if (ret) {
|
|
||||||
// error:The received data is not an eddystone frame packet or a correct eddystone frame packet.
|
|
||||||
// just return
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// The received adv data is a correct eddystone frame packet.
|
|
||||||
// Here, we get the eddystone infomation in eddystone_res, we can use the data in res to do other things.
|
|
||||||
// For example, just print them:
|
|
||||||
ESP_LOGI(DEMO_TAG, "--------Eddystone Found----------");
|
|
||||||
esp_log_buffer_hex("EDDYSTONE_DEMO: Device address:", scan_result->scan_rst.bda, ESP_BD_ADDR_LEN);
|
|
||||||
ESP_LOGI(DEMO_TAG, "RSSI of packet:%d dbm", scan_result->scan_rst.rssi);
|
|
||||||
esp_eddystone_show_inform(&eddystone_res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:{
|
|
||||||
if((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
|
|
||||||
ESP_LOGE(DEMO_TAG,"Scan stop failed: %s", esp_err_to_name(err));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ESP_LOGI(DEMO_TAG,"Stop scan successfully");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void esp_eddystone_appRegister(void)
|
|
||||||
{
|
|
||||||
esp_err_t status;
|
|
||||||
|
|
||||||
ESP_LOGI(DEMO_TAG,"Register callback");
|
|
||||||
|
|
||||||
/*<! register the scan callback function to the gap module */
|
|
||||||
if((status = esp_ble_gap_register_callback(esp_gap_cb)) != ESP_OK) {
|
|
||||||
ESP_LOGE(DEMO_TAG,"gap register error: %s", esp_err_to_name(status));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void esp_eddystone_init(void)
|
|
||||||
{
|
|
||||||
esp_bluedroid_init();
|
|
||||||
esp_bluedroid_enable();
|
|
||||||
esp_eddystone_appRegister();
|
|
||||||
}
|
|
||||||
|
|
||||||
void app_main(void)
|
|
||||||
{
|
|
||||||
ESP_ERROR_CHECK(nvs_flash_init());
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
esp_bt_controller_init(&bt_cfg);
|
|
||||||
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
|
|
||||||
esp_eddystone_init();
|
|
||||||
|
|
||||||
/*<! set scan parameters */
|
|
||||||
esp_ble_gap_set_scan_params(&ble_scan_params);
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ESP_EDDYSTONE_PROTOCOL_H__
|
|
||||||
#define __ESP_EDDYSTONE_PROTOCOL_H__
|
|
||||||
|
|
||||||
#include "stdbool.h"
|
|
||||||
#include "stdint.h"
|
|
||||||
|
|
||||||
/* Eddystone definitions */
|
|
||||||
#define EDDYSTONE_SERVICE_UUID 0xFEAA
|
|
||||||
|
|
||||||
#define EDDYSTONE_FRAME_TYPE_UID 0x00
|
|
||||||
#define EDDYSTONE_FRAME_TYPE_URL 0x10
|
|
||||||
#define EDDYSTONE_FRAME_TYPE_TLM 0x20
|
|
||||||
#define EDDYSTONE_FRAME_TYPE_EID 0x30
|
|
||||||
//UID
|
|
||||||
#define EDDYSTONE_UID_RANG_DATA_LEN 1
|
|
||||||
#define EDDYSTONE_UID_NAMESPACE_LEN 10
|
|
||||||
#define EDDYSTONE_UID_INSTANCE_LEN 6
|
|
||||||
#define EDDYSTONE_UID_RFU_LEN 2
|
|
||||||
#define EDDYSTONE_UID_DATA_LEN (EDDYSTONE_UID_RANG_DATA_LEN + EDDYSTONE_UID_NAMESPACE_LEN + EDDYSTONE_UID_INSTANCE_LEN)
|
|
||||||
//TLM
|
|
||||||
#define EDDYSTONE_TLM_VERSION_LEN 1
|
|
||||||
#define EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN 2
|
|
||||||
#define EDDYSTONE_TLM_TEMPERATURE_LEN 2
|
|
||||||
#define EDDYSTONE_TLM_ADV_COUNT_LEN 4
|
|
||||||
#define EDDYSTONE_TLM_TIME_LEN 4
|
|
||||||
#define EDDYSTONE_TLM_DATA_LEN (EDDYSTONE_TLM_VERSION_LEN + EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN + \
|
|
||||||
EDDYSTONE_TLM_TEMPERATURE_LEN + EDDYSTONE_TLM_ADV_COUNT_LEN + EDDYSTONE_TLM_TIME_LEN)
|
|
||||||
//URL
|
|
||||||
#define EDDYSTONE_URL_SCHEME_LEN 1
|
|
||||||
#define EDDYSTONE_URL_ENCODED_MAX_LEN 17
|
|
||||||
#define EDDYSTONE_URL_MAX_LEN (EDDYSTONE_URL_SCHEME_LEN + EDDYSTONE_URL_ENCODED_MAX_LEN)
|
|
||||||
#define EDDYSTONE_URL_TX_POWER_LEN 1
|
|
||||||
|
|
||||||
|
|
||||||
/* Eddystone UID frame */
|
|
||||||
typedef struct {
|
|
||||||
int8_t ranging_data; /*<! calibrated Tx power at 0m */
|
|
||||||
uint8_t namespace_id[10];
|
|
||||||
uint8_t instance_id[6];
|
|
||||||
uint8_t reserved[2];
|
|
||||||
} __attribute__((packed))esp_eddystone_uid_t;
|
|
||||||
|
|
||||||
/* Eddystone URL frame */
|
|
||||||
typedef struct {
|
|
||||||
int8_t tx_power; /*<! calibrated Tx power at 0m */
|
|
||||||
uint8_t url_scheme; /*<! encoded scheme prefix */
|
|
||||||
uint8_t encoded_url[0]; /*<! length 1-17 */
|
|
||||||
} __attribute__((packed))esp_eddystone_url_t;
|
|
||||||
|
|
||||||
/* Eddystone TLM frame */
|
|
||||||
typedef struct {
|
|
||||||
uint8_t version; /*<! TLM version,0x00 for now */
|
|
||||||
uint16_t batt; /*<! battery voltage, 1mV/bit */
|
|
||||||
uint16_t temp; /*<! beacon temperature */
|
|
||||||
uint32_t adv_count; /*<! adv pdu count since power-on or reboot */
|
|
||||||
uint32_t time; /*<! time sence power-on or reboot, a 0.1 second resolution counter */
|
|
||||||
} __attribute__((packed)) esp_eddystone_tlm_t;
|
|
||||||
|
|
||||||
/* AD Structure of flags */
|
|
||||||
typedef struct {
|
|
||||||
uint8_t len;
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t flags;
|
|
||||||
} __attribute__((packed)) esp_eddystone_flags_t;
|
|
||||||
|
|
||||||
/* AD Structure of complete 16-bit service uuid */
|
|
||||||
typedef struct {
|
|
||||||
uint8_t len;
|
|
||||||
uint8_t type;
|
|
||||||
uint16_t uuid; /*<! complete list of 16-bit service UUIDs data type value */
|
|
||||||
} __attribute__((packed)) esp_eddystone_uuid_t;
|
|
||||||
|
|
||||||
/* AD Structure of eddystone frame*/
|
|
||||||
typedef struct {
|
|
||||||
uint8_t len; /*<! length of eddystone data */
|
|
||||||
uint8_t type; /*<! service data type,must be 0x16 */
|
|
||||||
uint16_t uuid; /*<! 16-bit eddystone uuid */
|
|
||||||
uint8_t frame_type;
|
|
||||||
union {
|
|
||||||
esp_eddystone_uid_t uid;
|
|
||||||
esp_eddystone_url_t url;
|
|
||||||
esp_eddystone_tlm_t tlm;
|
|
||||||
} u[0];
|
|
||||||
} __attribute__((packed)) esp_eddystone_frame_t;
|
|
||||||
|
|
||||||
/* eddystone packet type */
|
|
||||||
typedef struct {
|
|
||||||
esp_eddystone_flags_t flags;
|
|
||||||
esp_eddystone_uuid_t uuid;
|
|
||||||
esp_eddystone_frame_t frame;
|
|
||||||
} __attribute__((packed)) esp_eddystone_packet_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* URLs are written only with the graphic printable characters of the US-ASCII coded character set.
|
|
||||||
* The octets 00-20 and 7F-FF hexadecimal are not used.
|
|
||||||
* See “Excluded US-ASCII Characters” in RFC 2936.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static inline bool esp_eddystone_is_char_invalid(int ch)
|
|
||||||
{
|
|
||||||
return (ch >= 0x00 && ch <= 0x20) || (ch >= 0x7f && ch <= 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __ESP_EDDYSTONE_PROTOCOL_H__ */
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cmake_minimum_required(VERSION 3.16.0)
|
cmake_minimum_required(VERSION 3.16.0)
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(espidf-ulp-pulse-new)
|
project(espidf-blink)
|
||||||
@@ -8,7 +8,7 @@ How to build PlatformIO based project
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Change directory to example
|
# Change directory to example
|
||||||
$ cd platform-espressif32/examples/espidf-ulp-adc
|
$ cd platform-espressif32/examples/espidf-blink
|
||||||
|
|
||||||
# Build project
|
# Build project
|
||||||
$ pio run
|
$ pio run
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
|
# Blink Example
|
||||||
|
|
||||||
|
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||||
|
|
||||||
|
This example demonstrates how to blink a LED using GPIO or using the [led_strip](https://components.espressif.com/component/espressif/led_strip) component for the addressable LED, i.e. [WS2812](http://www.world-semi.com/Certifications/WS2812B.html).
|
||||||
|
|
||||||
|
The `led_strip` is installed via [component manager](main/idf_component.yml).
|
||||||
|
|
||||||
|
## How to Use Example
|
||||||
|
|
||||||
|
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
|
||||||
|
|
||||||
|
### Hardware Required
|
||||||
|
|
||||||
|
* A development board with Espressif SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
|
||||||
|
* A USB cable for Power supply and programming
|
||||||
|
|
||||||
|
Some development boards use an addressable LED instead of a regular one. These development boards include:
|
||||||
|
|
||||||
|
| Board | LED type | Pin |
|
||||||
|
| -------------------- | -------------------- | -------------------- |
|
||||||
|
| ESP32-C3-DevKitC-1 | Addressable | GPIO8 |
|
||||||
|
| ESP32-C3-DevKitM-1 | Addressable | GPIO8 |
|
||||||
|
| ESP32-S2-DevKitM-1 | Addressable | GPIO18 |
|
||||||
|
| ESP32-S2-Saola-1 | Addressable | GPIO18 |
|
||||||
|
| ESP32-S3-DevKitC-1 | Addressable | GPIO48 |
|
||||||
|
|
||||||
|
See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
|
||||||
|
|
||||||
|
### Configure the Project
|
||||||
|
|
||||||
|
Open the project configuration menu (`idf.py menuconfig`).
|
||||||
|
|
||||||
|
In the `Example Configuration` menu:
|
||||||
|
|
||||||
|
* Select the LED type in the `Blink LED type` option.
|
||||||
|
* Use `GPIO` for regular LED blink.
|
||||||
|
* Set the GPIO number used for the signal in the `Blink GPIO number` option.
|
||||||
|
* Set the blinking period in the `Blink period in ms` option.
|
||||||
|
|
||||||
|
### Build and Flash
|
||||||
|
|
||||||
|
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
|
||||||
|
|
||||||
|
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||||
|
|
||||||
|
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||||
|
|
||||||
|
## Example Output
|
||||||
|
|
||||||
|
As you run the example, you will see the LED blinking, according to the previously defined period. For the addressable LED, you can also change the LED color by setting the `led_strip_set_pixel(led_strip, 0, 16, 16, 16);` (LED Strip, Pixel Number, Red, Green, Blue) with values from 0 to 255 in the [source file](main/blink_example_main.c).
|
||||||
|
|
||||||
|
```text
|
||||||
|
I (315) example: Example configured to blink addressable LED!
|
||||||
|
I (325) example: Turning the LED OFF!
|
||||||
|
I (1325) example: Turning the LED ON!
|
||||||
|
I (2325) example: Turning the LED OFF!
|
||||||
|
I (3325) example: Turning the LED ON!
|
||||||
|
I (4325) example: Turning the LED OFF!
|
||||||
|
I (5325) example: Turning the LED ON!
|
||||||
|
I (6325) example: Turning the LED OFF!
|
||||||
|
I (7325) example: Turning the LED ON!
|
||||||
|
I (8325) example: Turning the LED OFF!
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: The color order could be different according to the LED model.
|
||||||
|
|
||||||
|
The pixel number indicates the pixel position in the LED strip. For a single LED, use 0.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
* If the LED isn't blinking, check the GPIO or the LED type selection in the `Example Configuration` menu.
|
||||||
|
|
||||||
|
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:esp32dev]
|
||||||
|
platform = espressif32
|
||||||
|
framework = espidf
|
||||||
|
board = esp32dev
|
||||||
|
monitor_speed = 115200
|
||||||
|
build_flags =
|
||||||
|
; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
|
||||||
|
-D CONFIG_BLINK_GPIO=2
|
||||||
|
-D CONFIG_BLINK_LED_GPIO=2
|
||||||
|
-D CONFIG_BLINK_PERIOD=1000
|
||||||
|
|
||||||
|
[env:esp32-c2-devkitm-1]
|
||||||
|
platform = espressif32
|
||||||
|
framework = espidf
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
monitor_speed = 115200
|
||||||
|
build_flags =
|
||||||
|
-D CONFIG_BLINK_GPIO=8
|
||||||
|
-D CONFIG_BLINK_LED_GPIO=8
|
||||||
|
-D CONFIG_BLINK_PERIOD=1000
|
||||||
|
|
||||||
|
[env:esp32-c6-devkitc-1]
|
||||||
|
platform = espressif32
|
||||||
|
framework = espidf
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
monitor_speed = 115200
|
||||||
|
build_flags =
|
||||||
|
-D CONFIG_BLINK_GPIO=2
|
||||||
|
-D CONFIG_BLINK_LED_GPIO=2
|
||||||
|
-D CONFIG_BLINK_PERIOD=1000
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
|
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "blink.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/* Blink 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 "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
//#include "led_strip.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
static const char *TAG = "example";
|
||||||
|
|
||||||
|
/* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
|
||||||
|
or you can edit the following line and set a number here.
|
||||||
|
*/
|
||||||
|
#define BLINK_GPIO CONFIG_BLINK_GPIO
|
||||||
|
|
||||||
|
static uint8_t s_led_state = 0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_BLINK_LED_RMT
|
||||||
|
|
||||||
|
static led_strip_handle_t led_strip;
|
||||||
|
|
||||||
|
static void blink_led(void)
|
||||||
|
{
|
||||||
|
/* If the addressable LED is enabled */
|
||||||
|
if (s_led_state) {
|
||||||
|
/* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
|
||||||
|
led_strip_set_pixel(led_strip, 0, 16, 16, 16);
|
||||||
|
/* Refresh the strip to send data */
|
||||||
|
led_strip_refresh(led_strip);
|
||||||
|
} else {
|
||||||
|
/* Set all LED off to clear all pixels */
|
||||||
|
led_strip_clear(led_strip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void configure_led(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Example configured to blink addressable LED!");
|
||||||
|
/* LED strip initialization with the GPIO and pixels number*/
|
||||||
|
led_strip_config_t strip_config = {
|
||||||
|
.strip_gpio_num = BLINK_GPIO,
|
||||||
|
.max_leds = 1, // at least one LED on board
|
||||||
|
};
|
||||||
|
led_strip_rmt_config_t rmt_config = {
|
||||||
|
.resolution_hz = 10 * 1000 * 1000, // 10MHz
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
|
||||||
|
/* Set all LED off to clear all pixels */
|
||||||
|
led_strip_clear(led_strip);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif CONFIG_BLINK_LED_GPIO
|
||||||
|
|
||||||
|
static void blink_led(void)
|
||||||
|
{
|
||||||
|
/* Set the GPIO level according to the state (LOW or HIGH)*/
|
||||||
|
gpio_set_level(BLINK_GPIO, s_led_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void configure_led(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
|
||||||
|
gpio_reset_pin(BLINK_GPIO);
|
||||||
|
/* Set the GPIO as a push/pull output */
|
||||||
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Configure the peripheral according to the LED type */
|
||||||
|
configure_led();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
|
||||||
|
blink_led();
|
||||||
|
/* Toggle the LED state */
|
||||||
|
s_led_state = !s_led_state;
|
||||||
|
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -16,11 +16,5 @@ board_build.embed_txtfiles =
|
|||||||
src/certs/coap_server.crt
|
src/certs/coap_server.crt
|
||||||
src/certs/coap_server.key
|
src/certs/coap_server.key
|
||||||
|
|
||||||
[env:nano32]
|
|
||||||
board = nano32
|
|
||||||
|
|
||||||
[env:esp-wrover-kit]
|
[env:esp-wrover-kit]
|
||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
board = esp32dev
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -12,11 +12,5 @@ platform = espressif32
|
|||||||
framework = espidf
|
framework = espidf
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
board = esp32dev
|
|
||||||
|
|
||||||
[env:esp-wrover-kit]
|
[env:esp-wrover-kit]
|
||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
|
|
||||||
[env:lolin32]
|
|
||||||
board = lolin32
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -20,8 +20,3 @@ board = esp32-s2-kaluga-1
|
|||||||
|
|
||||||
[env:esp32-c3-devkitm-1]
|
[env:esp32-c3-devkitm-1]
|
||||||
board = esp32-c3-devkitm-1
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
[env:esp32-c6-devkitc-1]
|
|
||||||
board = esp32-c6-devkitc-1
|
|
||||||
board_build.cmake_extra_args =
|
|
||||||
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32c6"
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
|
|
||||||
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -15,11 +15,5 @@ monitor_speed = 115200
|
|||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
|
|
||||||
[env:nano32]
|
|
||||||
board = nano32
|
|
||||||
|
|
||||||
[env:espea32]
|
|
||||||
board = espea32
|
|
||||||
|
|
||||||
[env:esp32-s2-saola-1]
|
[env:esp32-s2-saola-1]
|
||||||
board = esp32-s2-saola-1
|
board = esp32-s2-saola-1
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -12,11 +12,5 @@ platform = espressif32
|
|||||||
framework = espidf
|
framework = espidf
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:pocket_32]
|
|
||||||
board = pocket_32
|
|
||||||
|
|
||||||
[env:odroid_esp32]
|
[env:odroid_esp32]
|
||||||
board = odroid_esp32
|
board = odroid_esp32
|
||||||
|
|
||||||
[env:featheresp32]
|
|
||||||
board = featheresp32
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
@@ -12,11 +12,5 @@ platform = espressif32
|
|||||||
framework = espidf
|
framework = espidf
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:esp32thing]
|
|
||||||
board = esp32thing
|
|
||||||
|
|
||||||
[env:esp32-gateway]
|
|
||||||
board = esp32-gateway
|
|
||||||
|
|
||||||
[env:heltec_wifi_kit_32]
|
[env:heltec_wifi_kit_32]
|
||||||
board = heltec_wifi_kit_32
|
board = heltec_wifi_kit_32
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
.pio
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
How to build PlatformIO based project
|
|
||||||
=====================================
|
|
||||||
|
|
||||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
|
||||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
|
||||||
3. Extract ZIP archive
|
|
||||||
4. Run these commands:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# Change directory to example
|
|
||||||
$ cd platform-espressif32/examples/espidf-storage-spiffs
|
|
||||||
|
|
||||||
# Build project
|
|
||||||
$ pio run
|
|
||||||
|
|
||||||
# Upload firmware
|
|
||||||
$ pio run --target upload
|
|
||||||
|
|
||||||
# Upload SPIFFS image
|
|
||||||
$ pio run --target uploadfs
|
|
||||||
|
|
||||||
# Clean build files
|
|
||||||
$ pio run --target clean
|
|
||||||
```
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Hello World from SPIFFS.
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
|
||||||
to be shared between several project source files. You request the use of a
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
|
||||||
and error-prone. With a header file, the related declarations appear
|
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# Name, Type, SubType, Offset, Size, Flags
|
|
||||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
|
||||||
nvs, data, nvs, 0x9000, 0x6000,
|
|
||||||
phy_init, data, phy, 0xf000, 0x1000,
|
|
||||||
factory, app, factory, 0x10000, 1M,
|
|
||||||
spiffs, data, spiffs, , 0xF0000,
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
|
|
||||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
idf_component_register(SRCS "spiffs_example_main.c"
|
|
||||||
INCLUDE_DIRS ".")
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
menu "SPIFFS Example menu"
|
|
||||||
|
|
||||||
config EXAMPLE_SPIFFS_CHECK_ON_START
|
|
||||||
bool "Run SPIFFS_check on every start-up"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
If this config item is set, esp_spiffs_check() will be run on every start-up.
|
|
||||||
Slow on large flash sizes.
|
|
||||||
endmenu
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
/* SPIFFS 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_spiffs.h"
|
|
||||||
|
|
||||||
static const char *TAG = "example";
|
|
||||||
|
|
||||||
void app_main(void)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Initializing SPIFFS");
|
|
||||||
|
|
||||||
esp_vfs_spiffs_conf_t conf = {
|
|
||||||
.base_path = "/spiffs",
|
|
||||||
.partition_label = NULL,
|
|
||||||
.max_files = 5,
|
|
||||||
.format_if_mount_failed = true
|
|
||||||
};
|
|
||||||
|
|
||||||
// Use settings defined above to initialize and mount SPIFFS filesystem.
|
|
||||||
// Note: esp_vfs_spiffs_register is an all-in-one convenience function.
|
|
||||||
esp_err_t ret = esp_vfs_spiffs_register(&conf);
|
|
||||||
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
if (ret == ESP_FAIL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to mount or format filesystem");
|
|
||||||
} else if (ret == ESP_ERR_NOT_FOUND) {
|
|
||||||
ESP_LOGE(TAG, "Failed to find SPIFFS partition");
|
|
||||||
} else {
|
|
||||||
ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLE_SPIFFS_CHECK_ON_START
|
|
||||||
ESP_LOGI(TAG, "Performing SPIFFS_check().");
|
|
||||||
ret = esp_spiffs_check(conf.partition_label);
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
ESP_LOGE(TAG, "SPIFFS_check() failed (%s)", esp_err_to_name(ret));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ESP_LOGI(TAG, "SPIFFS_check() successful");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t total = 0, used = 0;
|
|
||||||
ret = esp_spiffs_info(conf.partition_label, &total, &used);
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret));
|
|
||||||
esp_spiffs_format(conf.partition_label);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
// Check consistency of reported partiton size info.
|
|
||||||
if (used > total) {
|
|
||||||
ESP_LOGW(TAG, "Number of used bytes cannot be larger than total. Performing SPIFFS_check().");
|
|
||||||
ret = esp_spiffs_check(conf.partition_label);
|
|
||||||
// Could be also used to mend broken files, to clean unreferenced pages, etc.
|
|
||||||
// More info at https://github.com/pellepl/spiffs/wiki/FAQ#powerlosses-contd-when-should-i-run-spiffs_check
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
ESP_LOGE(TAG, "SPIFFS_check() failed (%s)", esp_err_to_name(ret));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ESP_LOGI(TAG, "SPIFFS_check() successful");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use POSIX and C standard library functions to work with files.
|
|
||||||
// First create a file.
|
|
||||||
ESP_LOGI(TAG, "Opening file");
|
|
||||||
FILE* f = fopen("/spiffs/hello.txt", "w");
|
|
||||||
if (f == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to open file for writing");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fprintf(f, "Hello World!\n");
|
|
||||||
fclose(f);
|
|
||||||
ESP_LOGI(TAG, "File written");
|
|
||||||
|
|
||||||
// Check if destination file exists before renaming
|
|
||||||
struct stat st;
|
|
||||||
if (stat("/spiffs/foo.txt", &st) == 0) {
|
|
||||||
// Delete it if it exists
|
|
||||||
unlink("/spiffs/foo.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename original file
|
|
||||||
ESP_LOGI(TAG, "Renaming file");
|
|
||||||
if (rename("/spiffs/hello.txt", "/spiffs/foo.txt") != 0) {
|
|
||||||
ESP_LOGE(TAG, "Rename failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open renamed file for reading
|
|
||||||
ESP_LOGI(TAG, "Reading file");
|
|
||||||
f = fopen("/spiffs/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 SPIFFS
|
|
||||||
esp_vfs_spiffs_unregister(conf.partition_label);
|
|
||||||
ESP_LOGI(TAG, "SPIFFS unmounted");
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.pio
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < https://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choose 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to be 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
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user