forked from espressif/arduino-esp32
Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5e2bb12ca | |||
f4acac4c2b | |||
5137fc5c80 | |||
03066e42ef | |||
cd5257ad78 | |||
ee6336a312 | |||
61f71930e9 | |||
ec40c4c96f | |||
2bda4a9617 | |||
91b9fae111 | |||
2a1fde7736 | |||
a12d609b22 | |||
73576674b8 | |||
007a93ec7e | |||
a5f3fc6fad | |||
65e256c40a | |||
fa55a2c91d | |||
a070884441 | |||
a9c8b46b1a | |||
6954150176 | |||
548f712df2 | |||
56ce580b0e | |||
509d31ba51 | |||
9e32cec9a2 | |||
3376ea1bd5 | |||
1c7e329140 | |||
c17b212cd0 | |||
7dbda4988b | |||
d1134fd45e | |||
d5fdd715ef | |||
ca7106e97e | |||
87e5787cf7 | |||
c13d11e7d1 | |||
b0d8d4dd44 | |||
05de017bd5 | |||
e1548e9b7e | |||
c29ec9da3d | |||
b3783fba95 | |||
a22ec4a978 | |||
20498cf8b1 | |||
02e51728c4 | |||
d2816b2f32 | |||
2e32022611 | |||
74ffdac74a | |||
4ee17ec3ee | |||
476660f763 | |||
f558e69181 | |||
5bf3aab527 | |||
1aced120ba | |||
7d7824701f | |||
89feacb813 | |||
aae6f24a37 | |||
43b781a158 | |||
e055b28d1a | |||
714ba948e6 | |||
e57de64a3c | |||
fd5a2f08f9 | |||
e9389e3122 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -24,7 +24,7 @@ https://github.com/me-no-dev/EspExceptionDecoder
|
||||
|
||||
### Hardware:
|
||||
Board: ?ESP32 Dev Module? ?node32? ?ttgo_lora?
|
||||
Core Installation version: ?1.0.0? ?1.0.1-rc4? ?1.0.1? ?1.0.1-git?
|
||||
Core Installation version: ?1.0.0? ?1.0.1-rc4? ?1.0.1? ?1.0.1-git? ?1.0.2? ?1.0.3?
|
||||
IDE name: ?Arduino IDE? ?Platform.io? ?IDF component?
|
||||
Flash Frequency: ?40Mhz?
|
||||
PSRAM enabled: ?no? ?yes?
|
||||
|
64
.github/stale.yml
vendored
Normal file
64
.github/stale.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 60
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 14
|
||||
|
||||
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
||||
onlyLabels: []
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- "to be implemented"
|
||||
- "for reference"
|
||||
- "move to PR"
|
||||
- "enhancement"
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: false
|
||||
|
||||
# Set to true to ignore issues with an assignee (defaults to false)
|
||||
exemptAssignees: false
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed in 14 days if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
closeComment: >
|
||||
This stale issue has been automatically closed. Thank you for your contributions.
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 30
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
|
||||
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
|
||||
# pulls:
|
||||
# daysUntilStale: 30
|
||||
# markComment: >
|
||||
# This pull request has been automatically marked as stale because it has not had
|
||||
# recent activity. It will be closed if no further activity occurs. Thank you
|
||||
# for your contributions.
|
||||
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - confirmed
|
426
.github/workflows/main.yml
vendored
Normal file
426
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,426 @@
|
||||
name: ESP32 Arduino CI
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
|
||||
build-arduino-0:
|
||||
name: Build Arduino IDE Tests 0
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
ESP32_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 0 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-1:
|
||||
name: Build Arduino IDE Tests 1
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 1 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-2:
|
||||
name: Build Arduino IDE Tests 2
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 2 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-3:
|
||||
name: Build Arduino IDE Tests 3
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 3 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-4:
|
||||
name: Build Arduino IDE Tests 4
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 4 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-5:
|
||||
name: Build Arduino IDE Tests 5
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 5 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-6:
|
||||
name: Build Arduino IDE Tests 6
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 6 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-7:
|
||||
name: Build Arduino IDE Tests 7
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 7 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-8:
|
||||
name: Build Arduino IDE Tests 8
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 8 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-9:
|
||||
name: Build Arduino IDE Tests 9
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 9 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-10:
|
||||
name: Build Arduino IDE Tests 10
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 10 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-11:
|
||||
name: Build Arduino IDE Tests 11
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 11 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-12:
|
||||
name: Build Arduino IDE Tests 12
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 12 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-13:
|
||||
name: Build Arduino IDE Tests 13
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 13 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-14:
|
||||
name: Build Arduino IDE Tests 14
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 14 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-15:
|
||||
name: Build Arduino IDE Tests 15
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 15 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-16:
|
||||
name: Build Arduino IDE Tests 16
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 16 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
build-arduino-17:
|
||||
name: Build Arduino IDE Tests 17
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-arduino-ide.sh
|
||||
- name: Test Arduino IDE
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/test-arduino-ide.sh 17 18
|
||||
- name: Sketch Sizes
|
||||
run: cat size.log
|
||||
|
||||
|
||||
build-platformio:
|
||||
name: Build PlatformIO Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Pull submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Run CMake Check
|
||||
run: ./tools/check_cmakelists.sh
|
||||
|
||||
- name: Install Python Wheel
|
||||
run: pip install wheel
|
||||
- name: Install GCC Toolchain
|
||||
run: cd tools && python get.py
|
||||
- name: Install PlatformIO
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
run: ./tools/prep-platformio.sh
|
||||
- name: Test PlatformIO
|
||||
run: ./tools/test-platformio.sh
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -5,3 +5,10 @@ tools/esptool.exe
|
||||
tools/mkspiffs/mkspiffs
|
||||
tools/mkspiffs/mkspiffs.exe
|
||||
.DS_Store
|
||||
|
||||
#Ignore files built by Visual Studio/Visual Micro
|
||||
[Dd]ebug*/
|
||||
[Rr]elease*/
|
||||
.vs/
|
||||
__vm/
|
||||
*.vcxproj*
|
||||
|
@ -209,3 +209,8 @@ set(COMPONENT_REQUIRES spi_flash mbedtls mdns ethernet)
|
||||
set(COMPONENT_PRIV_REQUIRES fatfs nvs_flash app_update spiffs bootloader_support openssl bt)
|
||||
|
||||
register_component()
|
||||
|
||||
set_source_files_properties(libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransport_mqtt_common.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-maybe-uninitialized
|
||||
)
|
||||
|
@ -232,6 +232,12 @@ config ARDUINO_SELECTIVE_ESPmDNS
|
||||
select ARDUINO_SELECTIVE_WiFi
|
||||
default y
|
||||
|
||||
config ARDUINO_SELECTIVE_FFat
|
||||
bool "Enable FFat"
|
||||
depends on ARDUINO_SELECTIVE_COMPILATION
|
||||
select ARDUINO_SELECTIVE_FS
|
||||
default y
|
||||
|
||||
config ARDUINO_SELECTIVE_FS
|
||||
bool "Enable FS"
|
||||
depends on ARDUINO_SELECTIVE_COMPILATION
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
[Latest development release  ](https://github.com/espressif/arduino-esp32/releases/latest/) 
|
||||
|
||||
Most of the framework is implemented. Most noticable is the missing analogWrite. While analogWrite is on it's way, there are a few other options that you can use:
|
||||
Most of the framework is implemented. Most noticeable is the missing analogWrite. While analogWrite is on it's way, there are a few other options that you can use:
|
||||
- 16 channels [LEDC](cores/esp32/esp32-hal-ledc.h) which is PWM
|
||||
- 8 channels [SigmaDelta](cores/esp32/esp32-hal-sigmadelta.h) which uses SigmaDelta modulation
|
||||
- 2 channels [DAC](cores/esp32/esp32-hal-dac.h) which gives real analog output
|
||||
|
227
boards.txt
227
boards.txt
@ -44,6 +44,8 @@ esp32.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIF
|
||||
esp32.menu.PartitionScheme.default.build.partitions=default
|
||||
esp32.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
|
||||
esp32.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
|
||||
esp32.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
|
||||
esp32.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
|
||||
esp32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
|
||||
esp32.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||
esp32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
|
||||
@ -104,6 +106,9 @@ esp32.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
esp32.menu.FlashSize.4M=4MB (32Mb)
|
||||
esp32.menu.FlashSize.4M.build.flash_size=4MB
|
||||
esp32.menu.FlashSize.8M=8MB (64Mb)
|
||||
esp32.menu.FlashSize.8M.build.flash_size=8MB
|
||||
esp32.menu.FlashSize.8M.build.partitions=default_8MB
|
||||
esp32.menu.FlashSize.2M=2MB (16Mb)
|
||||
esp32.menu.FlashSize.2M.build.flash_size=2MB
|
||||
esp32.menu.FlashSize.2M.build.partitions=minimal
|
||||
@ -225,7 +230,6 @@ esp32wrover.menu.DebugLevel.verbose=Verbose
|
||||
esp32wrover.menu.DebugLevel.verbose.build.code_debug=5
|
||||
|
||||
##############################################################
|
||||
|
||||
pico32.name=ESP32 Pico Kit
|
||||
|
||||
pico32.upload.tool=esptool_py
|
||||
@ -279,6 +283,110 @@ pico32.menu.DebugLevel.verbose.build.code_debug=5
|
||||
|
||||
##############################################################
|
||||
|
||||
tinypico.name=TinyPICO
|
||||
|
||||
tinypico.upload.tool=esptool_py
|
||||
tinypico.upload.maximum_size=1310720
|
||||
tinypico.upload.maximum_data_size=327680
|
||||
tinypico.upload.wait_for_upload_port=true
|
||||
|
||||
tinypico.serial.disableDTR=true
|
||||
tinypico.serial.disableRTS=true
|
||||
|
||||
tinypico.build.mcu=esp32
|
||||
tinypico.build.core=esp32
|
||||
tinypico.build.variant=pico32
|
||||
tinypico.build.board=ESP32_PICO
|
||||
|
||||
tinypico.build.f_cpu=240000000L
|
||||
tinypico.build.flash_size=4MB
|
||||
tinypico.build.flash_freq=80m
|
||||
tinypico.build.flash_mode=dio
|
||||
tinypico.build.boot=dio
|
||||
tinypico.build.partitions=default
|
||||
tinypico.build.defines=
|
||||
|
||||
tinypico.menu.UploadSpeed.921600=921600
|
||||
tinypico.menu.UploadSpeed.921600.upload.speed=921600
|
||||
tinypico.menu.UploadSpeed.115200=115200
|
||||
tinypico.menu.UploadSpeed.115200.upload.speed=115200
|
||||
tinypico.menu.UploadSpeed.256000.windows=256000
|
||||
tinypico.menu.UploadSpeed.256000.upload.speed=256000
|
||||
tinypico.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||
tinypico.menu.UploadSpeed.230400=230400
|
||||
tinypico.menu.UploadSpeed.230400.upload.speed=230400
|
||||
tinypico.menu.UploadSpeed.460800.linux=460800
|
||||
tinypico.menu.UploadSpeed.460800.macosx=460800
|
||||
tinypico.menu.UploadSpeed.460800.upload.speed=460800
|
||||
tinypico.menu.UploadSpeed.512000.windows=512000
|
||||
tinypico.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
tinypico.menu.FlashMode.qio=QIO
|
||||
tinypico.menu.FlashMode.qio.build.flash_mode=dio
|
||||
tinypico.menu.FlashMode.qio.build.boot=qio
|
||||
tinypico.menu.FlashMode.dio=DIO
|
||||
tinypico.menu.FlashMode.dio.build.flash_mode=dio
|
||||
tinypico.menu.FlashMode.dio.build.boot=dio
|
||||
|
||||
tinypico.menu.FlashFreq.80=80MHz
|
||||
tinypico.menu.FlashFreq.80.build.flash_freq=80m
|
||||
tinypico.menu.FlashFreq.40=40MHz
|
||||
tinypico.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
tinypico.menu.PSRAM.enabled=Enabled
|
||||
tinypico.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
|
||||
tinypico.menu.PSRAM.disabled=Disabled
|
||||
tinypico.menu.PSRAM.disabled.build.defines=
|
||||
|
||||
tinypico.menu.DebugLevel.none=None
|
||||
tinypico.menu.DebugLevel.none.build.code_debug=0
|
||||
tinypico.menu.DebugLevel.error=Error
|
||||
tinypico.menu.DebugLevel.error.build.code_debug=1
|
||||
tinypico.menu.DebugLevel.warn=Warn
|
||||
tinypico.menu.DebugLevel.warn.build.code_debug=2
|
||||
tinypico.menu.DebugLevel.info=Info
|
||||
tinypico.menu.DebugLevel.info.build.code_debug=3
|
||||
tinypico.menu.DebugLevel.debug=Debug
|
||||
tinypico.menu.DebugLevel.debug.build.code_debug=4
|
||||
tinypico.menu.DebugLevel.verbose=Verbose
|
||||
tinypico.menu.DebugLevel.verbose.build.code_debug=5
|
||||
|
||||
##############################################################
|
||||
magicbit.name=MagicBit
|
||||
|
||||
magicbit.upload.tool=esptool_py
|
||||
magicbit.upload.maximum_size=1310720
|
||||
magicbit.upload.maximum_data_size=327680
|
||||
magicbit.upload.wait_for_upload_port=true
|
||||
|
||||
magicbit.serial.disableDTR=true
|
||||
magicbit.serial.disableRTS=true
|
||||
|
||||
magicbit.build.mcu=esp32
|
||||
magicbit.build.core=esp32
|
||||
magicbit.build.variant=magicbit
|
||||
magicbit.build.board=ESP32_DEV
|
||||
|
||||
magicbit.build.f_cpu=240000000L
|
||||
magicbit.build.flash_size=4MB
|
||||
magicbit.build.flash_freq=40m
|
||||
magicbit.build.flash_mode=dio
|
||||
magicbit.build.boot=dio
|
||||
magicbit.build.partitions=default
|
||||
|
||||
magicbit.menu.CPUFreq.240=240MHz (WiFi/BT)
|
||||
magicbit.menu.CPUFreq.240.build.f_cpu=240000000L
|
||||
magicbit.menu.CPUFreq.160=160MHz (WiFi/BT)
|
||||
magicbit.menu.CPUFreq.160.build.f_cpu=160000000L
|
||||
magicbit.menu.CPUFreq.80=80MHz (WiFi/BT)
|
||||
magicbit.menu.CPUFreq.80.build.f_cpu=80000000L
|
||||
magicbit.menu.CPUFreq.40=40MHz (40MHz XTAL)
|
||||
|
||||
magicbit.menu.UploadSpeed.921600=921600
|
||||
magicbit.menu.UploadSpeed.921600.upload.speed=921600
|
||||
magicbit.menu.UploadSpeed.115200=115200
|
||||
magicbit.menu.UploadSpeed.115200.upload.speed=115200
|
||||
##############################################################
|
||||
turta_iot_node.name=Turta IoT Node
|
||||
|
||||
turta_iot_node.upload.tool=esptool_py
|
||||
@ -1953,6 +2061,121 @@ esp32-poe.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||
|
||||
##############################################################
|
||||
|
||||
esp32-poe-iso.name=OLIMEX ESP32-PoE-ISO
|
||||
|
||||
esp32-poe-iso.upload.tool=esptool_py
|
||||
esp32-poe-iso.upload.maximum_size=1310720
|
||||
esp32-poe-iso.upload.maximum_data_size=327680
|
||||
esp32-poe-iso.upload.wait_for_upload_port=true
|
||||
|
||||
esp32-poe-iso.serial.disableDTR=true
|
||||
esp32-poe-iso.serial.disableRTS=true
|
||||
|
||||
esp32-poe-iso.build.mcu=esp32
|
||||
esp32-poe-iso.build.core=esp32
|
||||
esp32-poe-iso.build.variant=esp32-poe-iso
|
||||
esp32-poe-iso.build.board=ESP32_POE_ISO
|
||||
|
||||
esp32-poe-iso.build.f_cpu=240000000L
|
||||
esp32-poe-iso.build.flash_mode=dio
|
||||
esp32-poe-iso.build.flash_size=4MB
|
||||
esp32-poe-iso.build.boot=dio
|
||||
esp32-poe-iso.build.partitions=default
|
||||
esp32-poe-iso.build.defines=
|
||||
|
||||
esp32-poe-iso.menu.FlashFreq.80=80MHz
|
||||
esp32-poe-iso.menu.FlashFreq.80.build.flash_freq=80m
|
||||
esp32-poe-iso.menu.FlashFreq.40=40MHz
|
||||
esp32-poe-iso.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
|
||||
esp32-poe-iso.menu.UploadSpeed.115200=115200
|
||||
esp32-poe-iso.menu.UploadSpeed.115200.upload.speed=115200
|
||||
|
||||
esp32-poe-iso.menu.PartitionScheme.default=Default
|
||||
esp32-poe-iso.menu.PartitionScheme.default.build.partitions=default
|
||||
esp32-poe-iso.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||
esp32-poe-iso.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||
esp32-poe-iso.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||
esp32-poe-iso.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||
esp32-poe-iso.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||
esp32-poe-iso.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||
|
||||
##############################################################
|
||||
|
||||
esp32-DevKitLipo.name=OLIMEX ESP32-DevKit-LiPo
|
||||
|
||||
esp32-DevKitLipo.upload.tool=esptool_py
|
||||
esp32-DevKitLipo.upload.maximum_size=1310720
|
||||
esp32-DevKitLipo.upload.maximum_data_size=327680
|
||||
esp32-DevKitLipo.upload.wait_for_upload_port=true
|
||||
|
||||
esp32-DevKitLipo.serial.disableDTR=true
|
||||
esp32-DevKitLipo.serial.disableRTS=true
|
||||
|
||||
esp32-DevKitLipo.build.mcu=esp32
|
||||
esp32-DevKitLipo.build.core=esp32
|
||||
esp32-DevKitLipo.build.variant=esp32-devkit-lipo
|
||||
esp32-DevKitLipo.build.board=ESP32_DEVKIT_LIPO
|
||||
|
||||
esp32-DevKitLipo.build.f_cpu=240000000L
|
||||
esp32-DevKitLipo.build.flash_size=4MB
|
||||
esp32-DevKitLipo.build.flash_freq=40m
|
||||
esp32-DevKitLipo.build.flash_mode=dio
|
||||
esp32-DevKitLipo.build.boot=dio
|
||||
esp32-DevKitLipo.build.partitions=default
|
||||
esp32-DevKitLipo.build.defines=
|
||||
|
||||
esp32-DevKitLipo.menu.PartitionScheme.default=Default
|
||||
esp32-DevKitLipo.menu.PartitionScheme.default.build.partitions=default
|
||||
esp32-DevKitLipo.menu.PartitionScheme.minimal=Minimal (2MB FLASH)
|
||||
esp32-DevKitLipo.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||
esp32-DevKitLipo.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||
esp32-DevKitLipo.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||
esp32-DevKitLipo.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||
esp32-DevKitLipo.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA)
|
||||
esp32-DevKitLipo.menu.PartitionScheme.huge_app.build.partitions=huge_app
|
||||
esp32-DevKitLipo.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
|
||||
esp32-DevKitLipo.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||
esp32-DevKitLipo.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||
esp32-DevKitLipo.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||
esp32-DevKitLipo.menu.PartitionScheme.fatflash=16M Fat
|
||||
esp32-DevKitLipo.menu.PartitionScheme.fatflash.build.partitions=ffat
|
||||
|
||||
esp32-DevKitLipo.menu.FlashMode.qio=QIO
|
||||
esp32-DevKitLipo.menu.FlashMode.qio.build.flash_mode=dio
|
||||
esp32-DevKitLipo.menu.FlashMode.qio.build.boot=qio
|
||||
esp32-DevKitLipo.menu.FlashMode.dio=DIO
|
||||
esp32-DevKitLipo.menu.FlashMode.dio.build.flash_mode=dio
|
||||
esp32-DevKitLipo.menu.FlashMode.dio.build.boot=dio
|
||||
esp32-DevKitLipo.menu.FlashMode.qout=QOUT
|
||||
esp32-DevKitLipo.menu.FlashMode.qout.build.flash_mode=dout
|
||||
esp32-DevKitLipo.menu.FlashMode.qout.build.boot=qout
|
||||
esp32-DevKitLipo.menu.FlashMode.dout=DOUT
|
||||
esp32-DevKitLipo.menu.FlashMode.dout.build.flash_mode=dout
|
||||
esp32-DevKitLipo.menu.FlashMode.dout.build.boot=dout
|
||||
|
||||
esp32-DevKitLipo.menu.FlashFreq.80=80MHz
|
||||
esp32-DevKitLipo.menu.FlashFreq.80.build.flash_freq=80m
|
||||
esp32-DevKitLipo.menu.FlashFreq.40=40MHz
|
||||
esp32-DevKitLipo.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
esp32-DevKitLipo.menu.UploadSpeed.921600=921600
|
||||
esp32-DevKitLipo.menu.UploadSpeed.921600.upload.speed=921600
|
||||
esp32-DevKitLipo.menu.UploadSpeed.115200=115200
|
||||
esp32-DevKitLipo.menu.UploadSpeed.115200.upload.speed=115200
|
||||
esp32-DevKitLipo.menu.UploadSpeed.256000.windows=256000
|
||||
esp32-DevKitLipo.menu.UploadSpeed.256000.upload.speed=256000
|
||||
esp32-DevKitLipo.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||
esp32-DevKitLipo.menu.UploadSpeed.230400=230400
|
||||
esp32-DevKitLipo.menu.UploadSpeed.230400.upload.speed=230400
|
||||
esp32-DevKitLipo.menu.UploadSpeed.460800.linux=460800
|
||||
esp32-DevKitLipo.menu.UploadSpeed.460800.macosx=460800
|
||||
esp32-DevKitLipo.menu.UploadSpeed.460800.upload.speed=460800
|
||||
esp32-DevKitLipo.menu.UploadSpeed.512000.windows=512000
|
||||
esp32-DevKitLipo.menu.UploadSpeed.512000.upload.speed=512000
|
||||
##############################################################
|
||||
|
||||
espino32.name=ThaiEasyElec's ESPino32
|
||||
|
||||
espino32.upload.tool=esptool_py
|
||||
@ -2582,7 +2805,7 @@ heltec_wifi_lora_32_V2.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.8M=8MB (64Mb)
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.8M.build.flash_size=8MB
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.2M.build.partitions=default_8MB
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.8M.build.partitions=default_8MB
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.4M=4MB (32Mb)
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.4M.build.flash_size=4MB
|
||||
heltec_wifi_lora_32_V2.menu.FlashSize.2M=2MB (16Mb)
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
uint32_t getMaxAllocPsram();
|
||||
|
||||
uint8_t getChipRevision();
|
||||
uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; }
|
||||
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
|
||||
uint32_t getCycleCount();
|
||||
const char * getSdkVersion();
|
||||
|
||||
|
@ -52,7 +52,7 @@ size_t Print::printf(const char *format, ...)
|
||||
va_list copy;
|
||||
va_start(arg, format);
|
||||
va_copy(copy, arg);
|
||||
size_t len = vsnprintf(NULL, 0, format, arg);
|
||||
size_t len = vsnprintf(NULL, 0, format, copy);
|
||||
va_end(copy);
|
||||
if(len >= sizeof(loc_buf)){
|
||||
temp = new char[len+1];
|
||||
|
@ -65,9 +65,12 @@ long random(long howsmall, long howbig)
|
||||
return random(diff) + howsmall;
|
||||
}
|
||||
|
||||
long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||
{
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
long map(long x, long in_min, long in_max, long out_min, long out_max) {
|
||||
long divisor = (in_max - in_min);
|
||||
if(divisor == 0){
|
||||
return -1; //AVR returns -1, SAM returns 0
|
||||
}
|
||||
return (x - in_min) * (out_max - out_min) / divisor + out_min;
|
||||
}
|
||||
|
||||
unsigned int makeWord(unsigned int w)
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <pgmspace.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// An inherited class for holding the result of a concatenation. These
|
||||
// result objects are assumed to be writable by subsequent concatenations.
|
||||
@ -35,7 +36,8 @@ class StringSumHelper;
|
||||
// an abstract class used as a means to proide a unique pointer type
|
||||
// but really has no body
|
||||
class __FlashStringHelper;
|
||||
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
|
||||
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
|
||||
#define F(string_literal) (FPSTR(PSTR(string_literal)))
|
||||
|
||||
// The string class
|
||||
class String {
|
||||
|
@ -1270,7 +1270,7 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis)
|
||||
|
||||
i2c->dev->ctr.trans_start=1; // go for it
|
||||
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
portTickType tBefore=xTaskGetTickCount();
|
||||
#endif
|
||||
|
||||
@ -1278,7 +1278,7 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis)
|
||||
|
||||
uint32_t eBits = xEventGroupWaitBits(i2c->i2c_event,EVENT_DONE,pdFALSE,pdTRUE,ticksTimeOut);
|
||||
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
portTickType tAfter=xTaskGetTickCount();
|
||||
#endif
|
||||
|
||||
|
@ -343,6 +343,8 @@ void uartFlush(uart_t* uart)
|
||||
READ_PERI_REG(UART_FIFO_REG(uart->num));
|
||||
}
|
||||
|
||||
xQueueReset(uart->queue);
|
||||
|
||||
UART_MUTEX_UNLOCK();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ typedef unsigned long prog_uint32_t;
|
||||
#define PROGMEM
|
||||
#define PGM_P const char *
|
||||
#define PGM_VOID_P const void *
|
||||
#define FPSTR(p) ((const char *)(p))
|
||||
#define PSTR(s) (s)
|
||||
#define _SFR_BYTE(n) (n)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
Installation instructions for using PlatformIO
|
||||
=================================================
|
||||
|
||||
- [What is PlatformIO?](http://docs.platformio.org/en/latest/what-is-platformio.html?utm_source=github&utm_medium=arduino-esp32)
|
||||
- [PlatformIO IDE](http://platformio.org/platformio-ide?utm_source=github&utm_medium=arduino-esp32)
|
||||
- [PlatformIO Core](http://docs.platformio.org/en/latest/core.html?utm_source=github&utm_medium=arduino-esp32) (command line tool)
|
||||
- [Advanced usage](http://docs.platformio.org/en/latest/platforms/espressif32.html?utm_source=github&utm_medium=arduino-esp32) -
|
||||
- [What is PlatformIO?](https://docs.platformio.org/en/latest/what-is-platformio.html?utm_source=github&utm_medium=arduino-esp32)
|
||||
- [PlatformIO IDE](https://platformio.org/platformio-ide?utm_source=github&utm_medium=arduino-esp32)
|
||||
- [PlatformIO Core](https://docs.platformio.org/en/latest/core.html?utm_source=github&utm_medium=arduino-esp32) (command line tool)
|
||||
- [Advanced usage](https://docs.platformio.org/en/latest/platforms/espressif32.html?utm_source=github&utm_medium=arduino-esp32) -
|
||||
custom settings, uploading to SPIFFS, Over-the-Air (OTA), staging version
|
||||
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/en/latest/ide.html?utm_source=github&utm_medium=arduino-esp32) -
|
||||
- [Integration with Cloud and Standalone IDEs](https://docs.platformio.org/en/latest/ide.html?utm_source=github&utm_medium=arduino-esp32) -
|
||||
Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode
|
||||
- [Project Examples](http://docs.platformio.org/en/latest/platforms/espressif32.html?utm_source=github&utm_medium=arduino-esp32#examples)
|
||||
- [Project Examples](https://docs.platformio.org/en/latest/platforms/espressif32.html?utm_source=github&utm_medium=arduino-esp32#examples)
|
||||
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name":"AsyncUDP",
|
||||
"description":"Asynchronous UDP Library for ESP32",
|
||||
"keywords":"async,udp,server,client,multicast,broadcast",
|
||||
"authors":
|
||||
{
|
||||
"name": "Hristo Gochkov",
|
||||
"maintainer": true
|
||||
},
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/me-no-dev/ESPAsyncUDP.git"
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms":"espressif"
|
||||
}
|
@ -682,9 +682,10 @@ void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t po
|
||||
if(_handler) {
|
||||
AsyncUDPPacket packet(this, this_pb, addr, port, netif);
|
||||
_handler(packet);
|
||||
}
|
||||
} else {
|
||||
pbuf_free(this_pb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncUDP::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port, struct netif * netif)
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include "esp32-hal-log.h"
|
||||
#endif
|
||||
@ -83,13 +84,11 @@ esp_bd_addr_t *BLEAddress::getNative() {
|
||||
* @return The string representation of the address.
|
||||
*/
|
||||
std::string BLEAddress::toString() {
|
||||
std::stringstream stream;
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[0] << ':';
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[1] << ':';
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[2] << ':';
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[3] << ':';
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[4] << ':';
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex << (int) ((uint8_t*) (m_address))[5];
|
||||
return stream.str();
|
||||
auto size = 18;
|
||||
char *res = (char*)malloc(size);
|
||||
snprintf(res, size, "%02x:%02x:%02x:%02x:%02x:%02x", m_address[0], m_address[1], m_address[2], m_address[3], m_address[4], m_address[5]);
|
||||
std::string ret(res);
|
||||
free(res);
|
||||
return ret;
|
||||
} // toString
|
||||
#endif
|
||||
|
@ -484,23 +484,29 @@ void BLEAdvertisedDevice::setTXPower(int8_t txPower) {
|
||||
* @return A string representation of this device.
|
||||
*/
|
||||
std::string BLEAdvertisedDevice::toString() {
|
||||
std::stringstream ss;
|
||||
ss << "Name: " << getName() << ", Address: " << getAddress().toString();
|
||||
std::string res = "Name: " + getName() + ", Address: " + getAddress().toString();
|
||||
if (haveAppearance()) {
|
||||
ss << ", appearance: " << getAppearance();
|
||||
char val[6];
|
||||
snprintf(val, sizeof(val), "%d", getAppearance());
|
||||
res += ", appearance: ";
|
||||
res += val;
|
||||
}
|
||||
if (haveManufacturerData()) {
|
||||
char *pHex = BLEUtils::buildHexData(nullptr, (uint8_t*)getManufacturerData().data(), getManufacturerData().length());
|
||||
ss << ", manufacturer data: " << pHex;
|
||||
res += ", manufacturer data: ";
|
||||
res += pHex;
|
||||
free(pHex);
|
||||
}
|
||||
if (haveServiceUUID()) {
|
||||
ss << ", serviceUUID: " << getServiceUUID().toString();
|
||||
res += ", serviceUUID: " + getServiceUUID().toString();
|
||||
}
|
||||
if (haveTXPower()) {
|
||||
ss << ", txPower: " << (int)getTXPower();
|
||||
char val[4];
|
||||
snprintf(val, sizeof(val), "%d", getTXPower());
|
||||
res += ", txPower: ";
|
||||
res += val;
|
||||
}
|
||||
return ss.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
uint8_t* BLEAdvertisedDevice::getPayload() {
|
||||
|
@ -262,7 +262,7 @@ void BLEAdvertising::stop() {
|
||||
|
||||
void BLEAdvertising::setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t type)
|
||||
{
|
||||
log_v(">> setPrivateAddress")
|
||||
log_v(">> setPrivateAddress");
|
||||
|
||||
m_advParams.own_addr_type = type;
|
||||
esp_err_t errRc = esp_ble_gap_set_rand_addr((uint8_t*)addr);
|
||||
@ -271,7 +271,7 @@ void BLEAdvertising::setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t ty
|
||||
log_e("esp_ble_gap_set_rand_addr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||
return;
|
||||
}
|
||||
log_v("<< setPrivateAddress")
|
||||
log_v("<< setPrivateAddress");
|
||||
} // setPrivateAddress
|
||||
|
||||
/**
|
||||
@ -505,7 +505,7 @@ void BLEAdvertising::handleGAPEvent(
|
||||
}
|
||||
case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: {
|
||||
log_i("STOP advertising");
|
||||
start();
|
||||
//start();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#define NULL_HANDLE (0xffff)
|
||||
|
||||
static BLECharacteristicCallbacks defaultCallback; //null-object-pattern
|
||||
|
||||
/**
|
||||
* @brief Construct a characteristic
|
||||
@ -40,7 +41,7 @@ BLECharacteristic::BLECharacteristic(BLEUUID uuid, uint32_t properties) {
|
||||
m_bleUUID = uuid;
|
||||
m_handle = NULL_HANDLE;
|
||||
m_properties = (esp_gatt_char_prop_t)0;
|
||||
m_pCallbacks = nullptr;
|
||||
m_pCallbacks = &defaultCallback;
|
||||
|
||||
setBroadcastProperty((properties & PROPERTY_BROADCAST) != 0);
|
||||
setReadProperty((properties & PROPERTY_READ) != 0);
|
||||
@ -220,9 +221,7 @@ void BLECharacteristic::handleGATTServerEvent(
|
||||
case ESP_GATTS_EXEC_WRITE_EVT: {
|
||||
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
|
||||
m_value.commit();
|
||||
if (m_pCallbacks != nullptr) {
|
||||
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
|
||||
}
|
||||
} else {
|
||||
m_value.cancel();
|
||||
}
|
||||
@ -307,7 +306,7 @@ void BLECharacteristic::handleGATTServerEvent(
|
||||
}
|
||||
} // Response needed
|
||||
|
||||
if (m_pCallbacks != nullptr && param->write.is_prep != true) {
|
||||
if (param->write.is_prep != true) {
|
||||
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
|
||||
}
|
||||
} // Match on handles.
|
||||
@ -378,6 +377,10 @@ void BLECharacteristic::handleGATTServerEvent(
|
||||
}
|
||||
} else { // read.is_long == false
|
||||
|
||||
// If is.long is false then this is the first (or only) request to read data, so invoke the callback
|
||||
// Invoke the read callback.
|
||||
m_pCallbacks->onRead(this);
|
||||
|
||||
std::string value = m_value.getValue();
|
||||
|
||||
if (value.length() + 1 > maxOffset) {
|
||||
@ -392,10 +395,6 @@ void BLECharacteristic::handleGATTServerEvent(
|
||||
rsp.attr_value.offset = 0;
|
||||
memcpy(rsp.attr_value.value, value.data(), rsp.attr_value.len);
|
||||
}
|
||||
|
||||
if (m_pCallbacks != nullptr) { // If is.long is false then this is the first (or only) request to read data, so invoke the callback
|
||||
m_pCallbacks->onRead(this); // Invoke the read callback.
|
||||
}
|
||||
}
|
||||
rsp.attr_value.handle = param->read.handle;
|
||||
rsp.attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE;
|
||||
@ -480,10 +479,13 @@ void BLECharacteristic::notify(bool is_notification) {
|
||||
assert(getService() != nullptr);
|
||||
assert(getService()->getServer() != nullptr);
|
||||
|
||||
m_pCallbacks->onNotify(this); // Invoke the notify callback.
|
||||
|
||||
GeneralUtils::hexDump((uint8_t*)m_value.getValue().data(), m_value.getValue().length());
|
||||
|
||||
if (getService()->getServer()->getConnectedCount() == 0) {
|
||||
log_v("<< notify: No connected clients.");
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_NO_CLIENT, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -494,12 +496,14 @@ void BLECharacteristic::notify(bool is_notification) {
|
||||
if(is_notification) {
|
||||
if (p2902 != nullptr && !p2902->getNotifications()) {
|
||||
log_v("<< notifications disabled; ignoring");
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_NOTIFY_DISABLED, 0); // Invoke the notify callback.
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (p2902 != nullptr && !p2902->getIndications()) {
|
||||
log_v("<< indications disabled; ignoring");
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_DISABLED, 0); // Invoke the notify callback.
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -510,7 +514,7 @@ void BLECharacteristic::notify(bool is_notification) {
|
||||
}
|
||||
|
||||
size_t length = m_value.getValue().length();
|
||||
if(!is_notification)
|
||||
if(!is_notification) // is indication
|
||||
m_semaphoreConfEvt.take("indicate");
|
||||
esp_err_t errRc = ::esp_ble_gatts_send_indicate(
|
||||
getService()->getServer()->getGattsIf(),
|
||||
@ -519,10 +523,23 @@ void BLECharacteristic::notify(bool is_notification) {
|
||||
if (errRc != ESP_OK) {
|
||||
log_e("<< esp_ble_gatts_send_ %s: rc=%d %s",is_notification?"notify":"indicate", errRc, GeneralUtils::errorToString(errRc));
|
||||
m_semaphoreConfEvt.give();
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_GATT, errRc); // Invoke the notify callback.
|
||||
return;
|
||||
}
|
||||
if(!is_notification)
|
||||
m_semaphoreConfEvt.wait("indicate");
|
||||
if(!is_notification){ // is indication
|
||||
if(!m_semaphoreConfEvt.timedWait("indicate", indicationTimeout)){
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_TIMEOUT, 0); // Invoke the notify callback.
|
||||
} else {
|
||||
auto code = (esp_gatt_status_t) m_semaphoreConfEvt.value();
|
||||
if(code == ESP_GATT_OK) {
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::SUCCESS_INDICATE, code); // Invoke the notify callback.
|
||||
} else {
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_FAILURE, code);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::SUCCESS_NOTIFY, 0); // Invoke the notify callback.
|
||||
}
|
||||
}
|
||||
log_v("<< notify");
|
||||
} // Notify
|
||||
@ -551,7 +568,11 @@ void BLECharacteristic::setBroadcastProperty(bool value) {
|
||||
*/
|
||||
void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
|
||||
log_v(">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
|
||||
if (pCallbacks != nullptr){
|
||||
m_pCallbacks = pCallbacks;
|
||||
} else {
|
||||
m_pCallbacks = &defaultCallback;
|
||||
}
|
||||
log_v("<< setCallbacks");
|
||||
} // setCallbacks
|
||||
|
||||
@ -628,7 +649,9 @@ void BLECharacteristic::setValue(uint8_t* data, size_t length) {
|
||||
log_e("Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
|
||||
return;
|
||||
}
|
||||
m_semaphoreSetValue.take();
|
||||
m_value.setValue(data, length);
|
||||
m_semaphoreSetValue.give();
|
||||
log_v("<< setValue");
|
||||
} // setValue
|
||||
|
||||
@ -715,17 +738,18 @@ void BLECharacteristic::setWriteProperty(bool value) {
|
||||
* @return A string representation of the characteristic.
|
||||
*/
|
||||
std::string BLECharacteristic::toString() {
|
||||
std::stringstream stringstream;
|
||||
stringstream << std::hex << std::setfill('0');
|
||||
stringstream << "UUID: " << m_bleUUID.toString() + ", handle: 0x" << std::setw(2) << m_handle;
|
||||
stringstream << " " <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_READ) ? "Read " : "") <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE) ? "Write " : "") <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE_NR) ? "WriteNoResponse " : "") <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_BROADCAST) ? "Broadcast " : "") <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_NOTIFY) ? "Notify " : "") <<
|
||||
((m_properties & ESP_GATT_CHAR_PROP_BIT_INDICATE) ? "Indicate " : "");
|
||||
return stringstream.str();
|
||||
std::string res = "UUID: " + m_bleUUID.toString() + ", handle : 0x";
|
||||
char hex[5];
|
||||
snprintf(hex, sizeof(hex), "%04x", m_handle);
|
||||
res += hex;
|
||||
res += " ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_READ) res += "Read ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE) res += "Write ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE_NR) res += "WriteNoResponse ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_BROADCAST) res += "Broadcast ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_NOTIFY) res += "Notify ";
|
||||
if (m_properties & ESP_GATT_CHAR_PROP_BIT_INDICATE) res += "Indicate ";
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
@ -751,4 +775,27 @@ void BLECharacteristicCallbacks::onWrite(BLECharacteristic* pCharacteristic) {
|
||||
log_d("BLECharacteristicCallbacks", "<< onWrite");
|
||||
} // onWrite
|
||||
|
||||
|
||||
/**
|
||||
* @brief Callback function to support a Notify request.
|
||||
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
||||
*/
|
||||
void BLECharacteristicCallbacks::onNotify(BLECharacteristic* pCharacteristic) {
|
||||
log_d("BLECharacteristicCallbacks", ">> onNotify: default");
|
||||
log_d("BLECharacteristicCallbacks", "<< onNotify");
|
||||
} // onNotify
|
||||
|
||||
|
||||
/**
|
||||
* @brief Callback function to support a Notify/Indicate Status report.
|
||||
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
||||
* @param [in] s Status of the notification/indication
|
||||
* @param [in] code Additional code of underlying errors
|
||||
*/
|
||||
void BLECharacteristicCallbacks::onStatus(BLECharacteristic* pCharacteristic, Status s, uint32_t code) {
|
||||
log_d("BLECharacteristicCallbacks", ">> onStatus: default");
|
||||
log_d("BLECharacteristicCallbacks", "<< onStatus");
|
||||
} // onStatus
|
||||
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
|
@ -90,6 +90,8 @@ public:
|
||||
static const uint32_t PROPERTY_INDICATE = 1<<4;
|
||||
static const uint32_t PROPERTY_WRITE_NR = 1<<5;
|
||||
|
||||
static const uint32_t indicationTimeout = 1000;
|
||||
|
||||
private:
|
||||
|
||||
friend class BLEServer;
|
||||
@ -117,6 +119,7 @@ private:
|
||||
void setHandle(uint16_t handle);
|
||||
FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt");
|
||||
FreeRTOS::Semaphore m_semaphoreConfEvt = FreeRTOS::Semaphore("ConfEvt");
|
||||
FreeRTOS::Semaphore m_semaphoreSetValue = FreeRTOS::Semaphore("SetValue");
|
||||
}; // BLECharacteristic
|
||||
|
||||
|
||||
@ -129,9 +132,22 @@ private:
|
||||
*/
|
||||
class BLECharacteristicCallbacks {
|
||||
public:
|
||||
typedef enum {
|
||||
SUCCESS_INDICATE,
|
||||
SUCCESS_NOTIFY,
|
||||
ERROR_INDICATE_DISABLED,
|
||||
ERROR_NOTIFY_DISABLED,
|
||||
ERROR_GATT,
|
||||
ERROR_NO_CLIENT,
|
||||
ERROR_INDICATE_TIMEOUT,
|
||||
ERROR_INDICATE_FAILURE
|
||||
}Status;
|
||||
|
||||
virtual ~BLECharacteristicCallbacks();
|
||||
virtual void onRead(BLECharacteristic* pCharacteristic);
|
||||
virtual void onWrite(BLECharacteristic* pCharacteristic);
|
||||
virtual void onNotify(BLECharacteristic* pCharacteristic);
|
||||
virtual void onStatus(BLECharacteristic* pCharacteristic, Status s, uint32_t code);
|
||||
};
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
#endif /* COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_ */
|
||||
|
@ -116,17 +116,18 @@ void BLECharacteristicMap::setByUUID(BLECharacteristic* pCharacteristic, BLEUUID
|
||||
* @return A string representation of the characteristic map.
|
||||
*/
|
||||
std::string BLECharacteristicMap::toString() {
|
||||
std::stringstream stringStream;
|
||||
stringStream << std::hex << std::setfill('0');
|
||||
std::string res;
|
||||
int count = 0;
|
||||
char hex[5];
|
||||
for (auto &myPair: m_uuidMap) {
|
||||
if (count > 0) {
|
||||
stringStream << "\n";
|
||||
}
|
||||
if (count > 0) {res += "\n";}
|
||||
snprintf(hex, sizeof(hex), "%04x", myPair.first->getHandle());
|
||||
count++;
|
||||
stringStream << "handle: 0x" << std::setw(2) << myPair.first->getHandle() << ", uuid: " + myPair.first->getUUID().toString();
|
||||
res += "handle: 0x";
|
||||
res += hex;
|
||||
res += ", uuid: " + myPair.first->getUUID().toString();
|
||||
}
|
||||
return stringStream.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -184,10 +184,11 @@ void BLEClient::gattClientEventHandler(
|
||||
if (m_pClientCallbacks != nullptr) {
|
||||
m_pClientCallbacks->onDisconnect(this);
|
||||
}
|
||||
BLEDevice::removePeerDevice(m_appId, true);
|
||||
esp_ble_gattc_app_unregister(m_gattc_if);
|
||||
m_semaphoreOpenEvt.give(ESP_GATT_IF_NONE);
|
||||
m_semaphoreRssiCmplEvt.give();
|
||||
m_semaphoreSearchCmplEvt.give(1);
|
||||
BLEDevice::removePeerDevice(m_appId, true);
|
||||
break;
|
||||
} // ESP_GATTC_DISCONNECT_EVT
|
||||
|
||||
@ -515,14 +516,13 @@ uint16_t BLEClient::getMTU() {
|
||||
* @return A string representation of this client.
|
||||
*/
|
||||
std::string BLEClient::toString() {
|
||||
std::ostringstream ss;
|
||||
ss << "peer address: " << m_peerAddress.toString();
|
||||
ss << "\nServices:\n";
|
||||
std::string res = "peer address: " + m_peerAddress.toString();
|
||||
res += "\nServices:\n";
|
||||
for (auto &myPair : m_servicesMap) {
|
||||
ss << myPair.second->toString() << "\n";
|
||||
res += myPair.second->toString() + "\n";
|
||||
// myPair.second is the value
|
||||
}
|
||||
return ss.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "BLEExceptions.h"
|
||||
//#include "BLEExceptions.h"
|
||||
#include "BLERemoteService.h"
|
||||
#include "BLEService.h"
|
||||
#include "BLEAddress.h"
|
||||
|
@ -255,10 +255,10 @@ void BLEDescriptor::setAccessPermissions(esp_gatt_perm_t perm) {
|
||||
* @return A string representation of the descriptor.
|
||||
*/
|
||||
std::string BLEDescriptor::toString() {
|
||||
std::stringstream stringstream;
|
||||
stringstream << std::hex << std::setfill('0');
|
||||
stringstream << "UUID: " << m_bleUUID.toString() + ", handle: 0x" << std::setw(2) << m_handle;
|
||||
return stringstream.str();
|
||||
char hex[5];
|
||||
snprintf(hex, sizeof(hex), "%04x", m_handle);
|
||||
std::string res = "UUID: " + m_bleUUID.toString() + ", handle: 0x" + hex;
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -90,17 +90,18 @@ void BLEDescriptorMap::setByHandle(uint16_t handle, BLEDescriptor* pDescriptor)
|
||||
* @return A string representation of the descriptor map.
|
||||
*/
|
||||
std::string BLEDescriptorMap::toString() {
|
||||
std::stringstream stringStream;
|
||||
stringStream << std::hex << std::setfill('0');
|
||||
std::string res;
|
||||
char hex[5];
|
||||
int count = 0;
|
||||
for (auto &myPair : m_uuidMap) {
|
||||
if (count > 0) {
|
||||
stringStream << "\n";
|
||||
}
|
||||
if (count > 0) {res += "\n";}
|
||||
snprintf(hex, sizeof(hex), "%04x", myPair.first->getHandle());
|
||||
count++;
|
||||
stringStream << "handle: 0x" << std::setw(2) << myPair.first->getHandle() << ", uuid: " + myPair.first->getUUID().toString();
|
||||
res += "handle: 0x";
|
||||
res += hex;
|
||||
res += ", uuid: " + myPair.first->getUUID().toString();
|
||||
}
|
||||
return stringStream.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -479,9 +479,8 @@ gatts_event_handler BLEDevice::m_customGattsHandler = nullptr;
|
||||
* @return A string representation of the nature of this device.
|
||||
*/
|
||||
/* STATIC */ std::string BLEDevice::toString() {
|
||||
std::ostringstream oss;
|
||||
oss << "BD Address: " << getAddress().toString();
|
||||
return oss.str();
|
||||
std::string res = "BD Address: " + getAddress().toString();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "sdkconfig.h"
|
||||
#if defined(CONFIG_BT_ENABLED)
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include "esp32-hal-log.h"
|
||||
#include "BLEEddystoneTLM.h"
|
||||
|
||||
@ -54,62 +54,44 @@ uint32_t BLEEddystoneTLM::getTime() {
|
||||
} // getTime
|
||||
|
||||
std::string BLEEddystoneTLM::toString() {
|
||||
std::stringstream ss;
|
||||
std::string out = "";
|
||||
uint32_t rawsec;
|
||||
ss << "Version ";
|
||||
ss << std::dec << m_eddystoneData.version;
|
||||
ss << "\n";
|
||||
uint32_t rawsec = ENDIAN_CHANGE_U32(m_eddystoneData.tmil);
|
||||
char val[6];
|
||||
|
||||
ss << "Battery Voltage ";
|
||||
ss << std::dec << ENDIAN_CHANGE_U16(m_eddystoneData.volt);
|
||||
ss << " mV\n";
|
||||
out += "Version " + m_eddystoneData.version;
|
||||
out += "\n";
|
||||
out += "Battery Voltage " + ENDIAN_CHANGE_U16(m_eddystoneData.volt);
|
||||
out += " mV\n";
|
||||
|
||||
ss << "Temperature ";
|
||||
ss << (float) m_eddystoneData.temp;
|
||||
ss << " °C\n";
|
||||
out += "Temperature ";
|
||||
snprintf(val, sizeof(val), "%d", m_eddystoneData.temp);
|
||||
out += val;
|
||||
out += ".0 °C\n";
|
||||
|
||||
ss << "Adv. Count ";
|
||||
ss << std::dec << ENDIAN_CHANGE_U32(m_eddystoneData.advCount);
|
||||
out += "Adv. Count ";
|
||||
snprintf(val, sizeof(val), "%d", ENDIAN_CHANGE_U32(m_eddystoneData.advCount));
|
||||
out += val;
|
||||
out += "\n";
|
||||
|
||||
ss << "\n";
|
||||
out += "Time ";
|
||||
|
||||
ss << "Time ";
|
||||
snprintf(val, sizeof(val), "%04d", rawsec / 864000);
|
||||
out += val;
|
||||
out += ".";
|
||||
|
||||
rawsec = ENDIAN_CHANGE_U32(m_eddystoneData.tmil);
|
||||
std::stringstream buffstream;
|
||||
buffstream << "0000";
|
||||
buffstream << std::dec << rawsec / 864000;
|
||||
std::string buff = buffstream.str();
|
||||
snprintf(val, sizeof(val), "%02d", (rawsec / 36000) % 24);
|
||||
out += val;
|
||||
out += ":";
|
||||
|
||||
ss << buff.substr(buff.length() - 4, buff.length());
|
||||
ss << ".";
|
||||
snprintf(val, sizeof(val), "%02d", (rawsec / 600) % 60);
|
||||
out += val;
|
||||
out += ":";
|
||||
|
||||
buffstream.str("");
|
||||
buffstream.clear();
|
||||
buffstream << "00";
|
||||
buffstream << std::dec << (rawsec / 36000) % 24;
|
||||
buff = buffstream.str();
|
||||
ss << buff.substr(buff.length()-2, buff.length());
|
||||
ss << ":";
|
||||
snprintf(val, sizeof(val), "%02d", (rawsec / 10) % 60);
|
||||
out += val;
|
||||
out += "\n";
|
||||
|
||||
buffstream.str("");
|
||||
buffstream.clear();
|
||||
buffstream << "00";
|
||||
buffstream << std::dec << (rawsec / 600) % 60;
|
||||
buff = buffstream.str();
|
||||
ss << buff.substr(buff.length() - 2, buff.length());
|
||||
ss << ":";
|
||||
|
||||
buffstream.str("");
|
||||
buffstream.clear();
|
||||
buffstream << "00";
|
||||
buffstream << std::dec << (rawsec / 10) % 60;
|
||||
buff = buffstream.str();
|
||||
ss << buff.substr(buff.length() - 2, buff.length());
|
||||
ss << "\n";
|
||||
|
||||
return ss.str();
|
||||
return out;
|
||||
} // toString
|
||||
|
||||
/**
|
||||
|
@ -5,5 +5,5 @@
|
||||
* Author: kolban
|
||||
*/
|
||||
|
||||
#include "BLEExceptions.h"
|
||||
//#include "BLEExceptions.h"
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <esp_err.h>
|
||||
|
||||
#include <sstream>
|
||||
#include "BLEExceptions.h"
|
||||
//#include "BLEExceptions.h"
|
||||
#include "BLEUtils.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "BLERemoteDescriptor.h"
|
||||
@ -39,6 +39,7 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(
|
||||
m_charProp = charProp;
|
||||
m_pRemoteService = pRemoteService;
|
||||
m_notifyCallback = nullptr;
|
||||
m_rawData = nullptr;
|
||||
|
||||
retrieveDescriptors(); // Get the descriptors for this characteristic
|
||||
log_v("<< BLERemoteCharacteristic");
|
||||
@ -399,7 +400,7 @@ std::string BLERemoteCharacteristic::readValue() {
|
||||
// Check to see that we are connected.
|
||||
if (!getRemoteService()->getClient()->isConnected()) {
|
||||
log_e("Disconnected");
|
||||
throw BLEDisconnectedException();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
m_semaphoreReadCharEvt.take("readValue");
|
||||
@ -500,11 +501,16 @@ void BLERemoteCharacteristic::removeDescriptors() {
|
||||
* @return a String representation.
|
||||
*/
|
||||
std::string BLERemoteCharacteristic::toString() {
|
||||
std::ostringstream ss;
|
||||
ss << "Characteristic: uuid: " << m_uuid.toString() <<
|
||||
", handle: " << getHandle() << " 0x" << std::hex << getHandle() <<
|
||||
", props: " << BLEUtils::characteristicPropertiesToString(m_charProp);
|
||||
return ss.str();
|
||||
std::string res = "Characteristic: uuid: " + m_uuid.toString();
|
||||
char val[6];
|
||||
res += ", handle: ";
|
||||
snprintf(val, sizeof(val), "%d", getHandle());
|
||||
res += val;
|
||||
res += " 0x";
|
||||
snprintf(val, sizeof(val), "%04x", getHandle());
|
||||
res += val;
|
||||
res += ", props: " + BLEUtils::characteristicPropertiesToString(m_charProp);
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
@ -545,7 +551,7 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
|
||||
// Check to see that we are connected.
|
||||
if (!getRemoteService()->getClient()->isConnected()) {
|
||||
log_e("Disconnected");
|
||||
throw BLEDisconnectedException();
|
||||
return;
|
||||
}
|
||||
|
||||
m_semaphoreWriteCharEvt.take("writeValue");
|
||||
|
@ -55,7 +55,7 @@ std::string BLERemoteDescriptor::readValue() {
|
||||
// Check to see that we are connected.
|
||||
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
|
||||
log_e("Disconnected");
|
||||
throw BLEDisconnectedException();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
m_semaphoreReadDescrEvt.take("readValue");
|
||||
@ -113,9 +113,12 @@ uint32_t BLERemoteDescriptor::readUInt32() {
|
||||
* @retun A string representation of this BLE Remote Descriptor.
|
||||
*/
|
||||
std::string BLERemoteDescriptor::toString() {
|
||||
std::stringstream ss;
|
||||
ss << "handle: " << getHandle() << ", uuid: " << getUUID().toString();
|
||||
return ss.str();
|
||||
char val[6];
|
||||
snprintf(val, sizeof(val), "%d", getHandle());
|
||||
std::string res = "handle: ";
|
||||
res += val;
|
||||
res += ", uuid: " + getUUID().toString();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
@ -130,7 +133,7 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
|
||||
// Check to see that we are connected.
|
||||
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
|
||||
log_e("Disconnected");
|
||||
throw BLEDisconnectedException();
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t errRc = ::esp_ble_gattc_write_char_descr(
|
||||
|
@ -164,7 +164,7 @@ void BLERemoteService::retrieveCharacteristics() {
|
||||
uint16_t offset = 0;
|
||||
esp_gattc_char_elem_t result;
|
||||
while (true) {
|
||||
uint16_t count = 10; // this value is used as in parameter that allows to search max 10 chars with the same uuid
|
||||
uint16_t count = 1; // only room for 1 result allocated, so go one by one
|
||||
esp_gatt_status_t status = ::esp_ble_gattc_get_all_char(
|
||||
getClient()->getGattcIf(),
|
||||
getClient()->getConnId(),
|
||||
@ -317,15 +317,25 @@ void BLERemoteService::setValue(BLEUUID characteristicUuid, std::string value) {
|
||||
* @return A string representation of this remote service.
|
||||
*/
|
||||
std::string BLERemoteService::toString() {
|
||||
std::ostringstream ss;
|
||||
ss << "Service: uuid: " + m_uuid.toString();
|
||||
ss << ", start_handle: " << std::dec << m_startHandle << " 0x" << std::hex << m_startHandle <<
|
||||
", end_handle: " << std::dec << m_endHandle << " 0x" << std::hex << m_endHandle;
|
||||
std::string res = "Service: uuid: " + m_uuid.toString();
|
||||
char val[6];
|
||||
res += ", start_handle: ";
|
||||
snprintf(val, sizeof(val), "%d", m_startHandle);
|
||||
res += val;
|
||||
snprintf(val, sizeof(val), "%04x", m_startHandle);
|
||||
res += " 0x";
|
||||
res += val;
|
||||
res += ", end_handle: ";
|
||||
snprintf(val, sizeof(val), "%d", m_endHandle);
|
||||
res += val;
|
||||
snprintf(val, sizeof(val), "%04x", m_endHandle);
|
||||
res += " 0x";
|
||||
res += val;
|
||||
for (auto &myPair : m_characteristicMap) {
|
||||
ss << "\n" << myPair.second->toString();
|
||||
res += "\n" + myPair.second->toString();
|
||||
// myPair.second is the value
|
||||
}
|
||||
return ss.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -412,4 +412,9 @@ void BLEServer::updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval,
|
||||
conn_params.timeout = timeout; // timeout = 400*10ms = 4000ms
|
||||
esp_ble_gap_update_conn_params(&conn_params);
|
||||
}
|
||||
|
||||
void BLEServer::disconnect(uint16_t connId) {
|
||||
esp_ble_gatts_close(m_gatts_if, connId);
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_ENABLED
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
BLEService* getServiceByUUID(const char* uuid);
|
||||
BLEService* getServiceByUUID(BLEUUID uuid);
|
||||
bool connect(BLEAddress address);
|
||||
void disconnect(uint16_t connId);
|
||||
uint16_t m_appId;
|
||||
void updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t timeout);
|
||||
|
||||
|
@ -381,10 +381,12 @@ BLECharacteristic* BLEService::getCharacteristic(BLEUUID uuid) {
|
||||
* @return A string representation of this service.
|
||||
*/
|
||||
std::string BLEService::toString() {
|
||||
std::stringstream stringStream;
|
||||
stringStream << "UUID: " << getUUID().toString() <<
|
||||
", handle: 0x" << std::hex << std::setfill('0') << std::setw(2) << getHandle();
|
||||
return stringStream.str();
|
||||
std::string res = "UUID: " + getUUID().toString();
|
||||
char hex[5];
|
||||
snprintf(hex, sizeof(hex), "%04x", getHandle());
|
||||
res += ", handle: 0x";
|
||||
res += hex;
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#if defined(CONFIG_BT_ENABLED)
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <iomanip>
|
||||
#include "BLEService.h"
|
||||
|
||||
@ -73,12 +73,15 @@ void BLEServiceMap::setByHandle(uint16_t handle, BLEService* service) {
|
||||
* @return A string representation of the service map.
|
||||
*/
|
||||
std::string BLEServiceMap::toString() {
|
||||
std::stringstream stringStream;
|
||||
stringStream << std::hex << std::setfill('0');
|
||||
std::string res;
|
||||
char hex[5];
|
||||
for (auto &myPair: m_handleMap) {
|
||||
stringStream << "handle: 0x" << std::setw(2) << myPair.first << ", uuid: " + myPair.second->getUUID().toString() << "\n";
|
||||
res += "handle: 0x";
|
||||
snprintf(hex, sizeof(hex), "%04x", myPair.first);
|
||||
res += hex;
|
||||
res += ", uuid: " + myPair.second->getUUID().toString() + "\n";
|
||||
}
|
||||
return stringStream.str();
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
void BLEServiceMap::handleGATTServerEvent(
|
||||
|
@ -349,51 +349,38 @@ BLEUUID BLEUUID::to128() {
|
||||
*/
|
||||
std::string BLEUUID::toString() {
|
||||
if (!m_valueSet) return "<NULL>"; // If we have no value, nothing to format.
|
||||
|
||||
// If the UUIDs are 16 or 32 bit, pad correctly.
|
||||
std::stringstream ss;
|
||||
|
||||
if (m_uuid.len == ESP_UUID_LEN_16) { // If the UUID is 16bit, pad correctly.
|
||||
ss << "0000" <<
|
||||
std::hex <<
|
||||
std::setfill('0') <<
|
||||
std::setw(4) <<
|
||||
m_uuid.uuid.uuid16 <<
|
||||
"-0000-1000-8000-00805f9b34fb";
|
||||
return ss.str(); // Return the string
|
||||
char hex[5];
|
||||
snprintf(hex, sizeof(hex), "%04x", m_uuid.uuid.uuid16);
|
||||
return std::string(hex) + "-0000-1000-8000-00805f9b34fb";
|
||||
} // End 16bit UUID
|
||||
|
||||
if (m_uuid.len == ESP_UUID_LEN_32) { // If the UUID is 32bit, pad correctly.
|
||||
ss << std::hex <<
|
||||
std::setfill('0') <<
|
||||
std::setw(8) <<
|
||||
m_uuid.uuid.uuid32 <<
|
||||
"-0000-1000-8000-00805f9b34fb";
|
||||
return ss.str(); // return the string
|
||||
char hex[9];
|
||||
snprintf(hex, sizeof(hex), "%08x", m_uuid.uuid.uuid32);
|
||||
return std::string(hex) + "-0000-1000-8000-00805f9b34fb";
|
||||
} // End 32bit UUID
|
||||
|
||||
// The UUID is not 16bit or 32bit which means that it is 128bit.
|
||||
//
|
||||
// UUID string format:
|
||||
// AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP
|
||||
ss << std::hex << std::setfill('0') <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[15] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[14] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[13] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[12] << "-" <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[11] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[10] << "-" <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[9] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[8] << "-" <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[7] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[6] << "-" <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[5] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[4] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[3] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[2] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[1] <<
|
||||
std::setw(2) << (int) m_uuid.uuid.uuid128[0];
|
||||
return ss.str();
|
||||
auto size = 35;
|
||||
char *hex = (char *)malloc(size);
|
||||
snprintf(hex, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
m_uuid.uuid.uuid128[15], m_uuid.uuid.uuid128[14],
|
||||
m_uuid.uuid.uuid128[13], m_uuid.uuid.uuid128[12],
|
||||
m_uuid.uuid.uuid128[11], m_uuid.uuid.uuid128[10],
|
||||
m_uuid.uuid.uuid128[9], m_uuid.uuid.uuid128[8],
|
||||
m_uuid.uuid.uuid128[7], m_uuid.uuid.uuid128[6],
|
||||
m_uuid.uuid.uuid128[5], m_uuid.uuid.uuid128[4],
|
||||
m_uuid.uuid.uuid128[3], m_uuid.uuid.uuid128[2],
|
||||
m_uuid.uuid.uuid128[1], m_uuid.uuid.uuid128[0]);
|
||||
std::string res(hex);
|
||||
free(hex);
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
|
@ -604,26 +604,32 @@ static const gattService_t g_gattServices[] = {
|
||||
* @return A string representation of characteristic properties.
|
||||
*/
|
||||
std::string BLEUtils::characteristicPropertiesToString(esp_gatt_char_prop_t prop) {
|
||||
std::stringstream stream;
|
||||
stream <<
|
||||
"broadcast: " << ((prop & ESP_GATT_CHAR_PROP_BIT_BROADCAST)?"1":"0") <<
|
||||
", read: " << ((prop & ESP_GATT_CHAR_PROP_BIT_READ)?"1":"0") <<
|
||||
", write_nr: " << ((prop & ESP_GATT_CHAR_PROP_BIT_WRITE_NR)?"1":"0") <<
|
||||
", write: " << ((prop & ESP_GATT_CHAR_PROP_BIT_WRITE)?"1":"0") <<
|
||||
", notify: " << ((prop & ESP_GATT_CHAR_PROP_BIT_NOTIFY)?"1":"0") <<
|
||||
", indicate: " << ((prop & ESP_GATT_CHAR_PROP_BIT_INDICATE)?"1":"0") <<
|
||||
", auth: " << ((prop & ESP_GATT_CHAR_PROP_BIT_AUTH)?"1":"0");
|
||||
return stream.str();
|
||||
std::string res = "broadcast: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_BROADCAST)?"1":"0");
|
||||
res += ", read: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_READ)?"1":"0");
|
||||
res += ", write_nr: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_WRITE_NR)?"1":"0");
|
||||
res += ", write: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_WRITE)?"1":"0");
|
||||
res += ", notify: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_NOTIFY)?"1":"0");
|
||||
res += ", indicate: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_INDICATE)?"1":"0");
|
||||
res += ", auth: ";
|
||||
res += ((prop & ESP_GATT_CHAR_PROP_BIT_AUTH)?"1":"0");
|
||||
return res;
|
||||
} // characteristicPropertiesToString
|
||||
|
||||
/**
|
||||
* @brief Convert an esp_gatt_id_t to a string.
|
||||
*/
|
||||
static std::string gattIdToString(esp_gatt_id_t gattId) {
|
||||
std::stringstream stream;
|
||||
stream << "uuid: " << BLEUUID(gattId.uuid).toString() << ", inst_id: " << (int)gattId.inst_id;
|
||||
//sprintf(buffer, "uuid: %s, inst_id: %d", uuidToString(gattId.uuid).c_str(), gattId.inst_id);
|
||||
return stream.str();
|
||||
std::string res = "uuid: " + BLEUUID(gattId.uuid).toString() + ", inst_id: ";
|
||||
char val[8];
|
||||
snprintf(val, sizeof(val), "%d", (int)gattId.inst_id);
|
||||
res += val;
|
||||
return res;
|
||||
} // gattIdToString
|
||||
|
||||
|
||||
@ -654,23 +660,23 @@ const char* BLEUtils::addressTypeToString(esp_ble_addr_type_t type) {
|
||||
* @return std::string A string representation of the advertising flags.
|
||||
*/
|
||||
std::string BLEUtils::adFlagsToString(uint8_t adFlags) {
|
||||
std::stringstream ss;
|
||||
std::string res;
|
||||
if (adFlags & (1 << 0)) {
|
||||
ss << "[LE Limited Discoverable Mode] ";
|
||||
res += "[LE Limited Discoverable Mode] ";
|
||||
}
|
||||
if (adFlags & (1 << 1)) {
|
||||
ss << "[LE General Discoverable Mode] ";
|
||||
res += "[LE General Discoverable Mode] ";
|
||||
}
|
||||
if (adFlags & (1 << 2)) {
|
||||
ss << "[BR/EDR Not Supported] ";
|
||||
res += "[BR/EDR Not Supported] ";
|
||||
}
|
||||
if (adFlags & (1 << 3)) {
|
||||
ss << "[Simultaneous LE and BR/EDR to Same Device Capable (Controller)] ";
|
||||
res += "[Simultaneous LE and BR/EDR to Same Device Capable (Controller)] ";
|
||||
}
|
||||
if (adFlags & (1 << 4)) {
|
||||
ss << "[Simultaneous LE and BR/EDR to Same Device Capable (Host)] ";
|
||||
res += "[Simultaneous LE and BR/EDR to Same Device Capable (Host)] ";
|
||||
}
|
||||
return ss.str();
|
||||
return res;
|
||||
} // adFlagsToString
|
||||
|
||||
|
||||
@ -802,13 +808,13 @@ char* BLEUtils::buildHexData(uint8_t* target, uint8_t* source, uint8_t length) {
|
||||
* @return A string representation of a piece of memory.
|
||||
*/
|
||||
std::string BLEUtils::buildPrintData(uint8_t* source, size_t length) {
|
||||
std::ostringstream ss;
|
||||
std::string res;
|
||||
for (int i = 0; i < length; i++) {
|
||||
char c = *source;
|
||||
ss << (isprint(c) ? c : '.');
|
||||
res += (isprint(c) ? c : '.');
|
||||
source++;
|
||||
}
|
||||
return ss.str();
|
||||
return res;
|
||||
} // buildPrintData
|
||||
|
||||
|
||||
@ -1848,14 +1854,22 @@ std::string BLEUtils::gattDescriptorUUIDToString(uint32_t descriptorUUID) {
|
||||
* @return A string representation of an esp_gattc_service_elem_t.
|
||||
*/
|
||||
std::string BLEUtils::gattcServiceElementToString(esp_gattc_service_elem_t* pGATTCServiceElement) {
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "[uuid: " << BLEUUID(pGATTCServiceElement->uuid).toString() <<
|
||||
", start_handle: " << pGATTCServiceElement->start_handle <<
|
||||
" 0x" << std::hex << pGATTCServiceElement->start_handle <<
|
||||
", end_handle: " << std::dec << pGATTCServiceElement->end_handle <<
|
||||
" 0x" << std::hex << pGATTCServiceElement->end_handle << "]";
|
||||
return ss.str();
|
||||
std::string res;
|
||||
char val[6];
|
||||
res += "[uuid: " + BLEUUID(pGATTCServiceElement->uuid).toString() + ", start_handle: ";
|
||||
snprintf(val, sizeof(val), "%d", pGATTCServiceElement->start_handle);
|
||||
res += val;
|
||||
res += " 0x";
|
||||
snprintf(val, sizeof(val), "%04x", pGATTCServiceElement->start_handle);
|
||||
res += val;
|
||||
res += ", end_handle: ";
|
||||
snprintf(val, sizeof(val), "%d", pGATTCServiceElement->end_handle);
|
||||
res += val;
|
||||
res += " 0x";
|
||||
snprintf(val, sizeof(val), "%04x", pGATTCServiceElement->end_handle);
|
||||
res += val;
|
||||
res += "]";
|
||||
return res;
|
||||
} // gattcServiceElementToString
|
||||
|
||||
|
||||
|
@ -78,6 +78,38 @@ uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
|
||||
return m_value;
|
||||
} // wait
|
||||
|
||||
/**
|
||||
* @brief Wait for a semaphore to be released in a given period of time by trying to take it and
|
||||
* then releasing it again. The value associated with the semaphore can be taken by value() call after return
|
||||
* @param [in] owner A debug tag.
|
||||
* @param [in] timeoutMs timeout to wait in ms.
|
||||
* @return True if we took the semaphore within timeframe.
|
||||
*/
|
||||
bool FreeRTOS::Semaphore::timedWait(std::string owner, uint32_t timeoutMs) {
|
||||
log_v(">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
|
||||
|
||||
if (m_usePthreads && timeoutMs != portMAX_DELAY) {
|
||||
assert(false); // We apparently don't have a timed wait for pthreads.
|
||||
}
|
||||
|
||||
auto ret = pdTRUE;
|
||||
|
||||
if (m_usePthreads) {
|
||||
pthread_mutex_lock(&m_pthread_mutex);
|
||||
} else {
|
||||
ret = xSemaphoreTake(m_semaphore, timeoutMs);
|
||||
}
|
||||
|
||||
if (m_usePthreads) {
|
||||
pthread_mutex_unlock(&m_pthread_mutex);
|
||||
} else {
|
||||
xSemaphoreGive(m_semaphore);
|
||||
}
|
||||
|
||||
log_v("<< wait: Semaphore %s released: %d", toString().c_str(), ret);
|
||||
return ret;
|
||||
} // wait
|
||||
|
||||
|
||||
FreeRTOS::Semaphore::Semaphore(std::string name) {
|
||||
m_usePthreads = false; // Are we using pThreads or FreeRTOS?
|
||||
@ -202,9 +234,12 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
|
||||
* @return A string representation of the semaphore.
|
||||
*/
|
||||
std::string FreeRTOS::Semaphore::toString() {
|
||||
std::stringstream stringStream;
|
||||
stringStream << "name: "<< m_name << " (0x" << std::hex << std::setfill('0') << (uint32_t)m_semaphore << "), owner: " << m_owner;
|
||||
return stringStream.str();
|
||||
char hex[9];
|
||||
std::string res = "name: " + m_name + " (0x";
|
||||
snprintf(hex, sizeof(hex), "%08x", (uint32_t)m_semaphore);
|
||||
res += hex;
|
||||
res += "), owner: " + m_owner;
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
bool take(uint32_t timeoutMs, std::string owner = "<Unknown>");
|
||||
std::string toString();
|
||||
uint32_t wait(std::string owner = "<Unknown>");
|
||||
bool timedWait(std::string owner = "<Unknown>", uint32_t timeoutMs = portMAX_DELAY);
|
||||
uint32_t value(){ return m_value; };
|
||||
|
||||
private:
|
||||
SemaphoreHandle_t m_semaphore;
|
||||
|
@ -332,9 +332,12 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
|
||||
* @return A string representation of the IP address.
|
||||
*/
|
||||
std::string GeneralUtils::ipToString(uint8_t *ip) {
|
||||
std::stringstream s;
|
||||
s << (int) ip[0] << '.' << (int) ip[1] << '.' << (int) ip[2] << '.' << (int) ip[3];
|
||||
return s.str();
|
||||
auto size = 16;
|
||||
char *val = (char*)malloc(size);
|
||||
snprintf(val, size, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
std::string res(val);
|
||||
free(val);
|
||||
return res;
|
||||
} // ipToString
|
||||
|
||||
|
||||
@ -347,11 +350,14 @@ std::string GeneralUtils::ipToString(uint8_t *ip) {
|
||||
std::vector<std::string> GeneralUtils::split(std::string source, char delimiter) {
|
||||
// See also: https://stackoverflow.com/questions/5167625/splitting-a-c-stdstring-using-tokens-e-g
|
||||
std::vector<std::string> strings;
|
||||
std::istringstream iss(source);
|
||||
std::string s;
|
||||
while (std::getline(iss, s, delimiter)) {
|
||||
strings.push_back(trim(s));
|
||||
std::size_t current, previous = 0;
|
||||
current = source.find(delimiter);
|
||||
while (current != std::string::npos) {
|
||||
strings.push_back(trim(source.substr(previous, current - previous)));
|
||||
previous = current + 1;
|
||||
current = source.find(delimiter, previous);
|
||||
}
|
||||
strings.push_back(trim(source.substr(previous, current - previous)));
|
||||
return strings;
|
||||
} // split
|
||||
|
||||
|
@ -1,37 +1,21 @@
|
||||
/*
|
||||
ESP32 eeprom_class example with EEPROM library
|
||||
|
||||
This simple example demonstrates using EEPROM library to store different data in
|
||||
ESP32 Flash memory in a multiple user-defined EEPROM partition (0x1000 or 4KB max size or less).
|
||||
|
||||
Install 'ESP32 Partiton Manager' ONCE from https://github.com/francis94c/ESP32Partitions
|
||||
And generate different partitions with 'partition_name'
|
||||
Usage: EEPROMClass ANY_OBJECT_NAME("partition_name", size);
|
||||
|
||||
Generated partition that would work perfectly with this example
|
||||
#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,
|
||||
eeprom0, data, 0x99, 0x290000, 0x1000,
|
||||
eeprom1, data, 0x9a, 0x291000, 0x500,
|
||||
eeprom2, data, 0x9b, 0x292000, 0x100,
|
||||
spiffs, data, spiffs, 0x293000, 0x16d000,
|
||||
ESP32 Flash memory in a multiple user-defined EEPROM class objects.
|
||||
|
||||
Created for arduino-esp32 on 25 Dec, 2017
|
||||
by Elochukwu Ifediora (fedy0)
|
||||
converted to nvs by lbernstone - 06/22/2019
|
||||
*/
|
||||
|
||||
#include "EEPROM.h"
|
||||
|
||||
// Instantiate eeprom objects with parameter/argument names and size same as in the partition table
|
||||
// Instantiate eeprom objects with parameter/argument names and sizes
|
||||
EEPROMClass NAMES("eeprom0", 0x500);
|
||||
EEPROMClass HEIGHT("eeprom1", 0x200);
|
||||
EEPROMClass AGE("eeprom2", 0x100);
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println("Testing EEPROMClass\n");
|
||||
if (!NAMES.begin(NAMES.length())) {
|
||||
@ -57,7 +41,7 @@ void setup() {
|
||||
double height = 5.8;
|
||||
uint32_t age = 47;
|
||||
|
||||
// Write: Variables ---> EEPROM partitions
|
||||
// Write: Variables ---> EEPROM stores
|
||||
NAMES.put(0, name);
|
||||
HEIGHT.put(0, height);
|
||||
AGE.put(0, age);
|
||||
@ -75,7 +59,7 @@ void setup() {
|
||||
Serial.print("age: "); Serial.println(age);
|
||||
Serial.println("------------------------------------\n");
|
||||
|
||||
// Read: Variables <--- EEPROM partitions
|
||||
// Read: Variables <--- EEPROM stores
|
||||
NAMES.get(0, name);
|
||||
HEIGHT.get(0, height);
|
||||
AGE.get(0, age);
|
||||
@ -87,6 +71,5 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
delay(0xFFFFFFFF);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
name=EEPROM
|
||||
version=1.0
|
||||
version=1.0.3
|
||||
author=Ivan Grokhotkov
|
||||
maintainer=Paolo Becchi <pbecchi@aerobusiness.it>
|
||||
sentence=Enables reading and writing data to the permanent FLASH storage, up to 4kb.
|
||||
sentence=Enables reading and writing data a sequential, addressable FLASH storage
|
||||
paragraph=
|
||||
category=Data Storage
|
||||
url=http://arduino.cc/en/Reference/EEPROM
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "EEPROM.h"
|
||||
#include <nvs.h>
|
||||
#include <esp_partition.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
EEPROMClass::EEPROMClass(void)
|
||||
@ -111,7 +112,7 @@ bool EEPROMClass::begin(size_t size) {
|
||||
log_e("Not enough memory to expand EEPROM!");
|
||||
return false;
|
||||
}
|
||||
memset(key_data, 0, size);
|
||||
memset(key_data, 0xFF, size);
|
||||
if(key_size) {
|
||||
log_i("Expanding EEPROM from %d to %d", key_size, size);
|
||||
// hold data while key is deleted
|
||||
@ -214,6 +215,67 @@ uint16_t EEPROMClass::length ()
|
||||
return _user_defined_size;
|
||||
}
|
||||
|
||||
/*
|
||||
Convert EEPROM partition into nvs blob
|
||||
Call convert before you call begin
|
||||
*/
|
||||
uint16_t EEPROMClass::convert (bool clear, const char* EEPROMname, const char* nvsname)
|
||||
{
|
||||
uint16_t result = 0;
|
||||
const esp_partition_t* mypart = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, EEPROMname);
|
||||
if (mypart == NULL) {
|
||||
log_i("EEPROM partition not found for conversion");
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t size = mypart->size;
|
||||
uint8_t* data = (uint8_t*) malloc(size);
|
||||
if (!data) {
|
||||
log_e("Not enough memory to convert EEPROM!");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (esp_partition_read (mypart, 0, (void *) data, size) != ESP_OK) {
|
||||
log_e("Unable to read EEPROM partition");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bool empty;
|
||||
empty = true;
|
||||
for (int x=0; x<size; x++) {
|
||||
if (data[x] != 0xFF) {
|
||||
empty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
log_i("EEPROM partition is empty, will not convert");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
nvs_handle handle;
|
||||
if (nvs_open(nvsname, NVS_READWRITE, &handle) != ESP_OK) {
|
||||
log_e("Unable to open NVS");
|
||||
goto exit;
|
||||
}
|
||||
esp_err_t err;
|
||||
err = nvs_set_blob(handle, nvsname, data, size);
|
||||
if (err != ESP_OK) {
|
||||
log_e("Unable to add EEPROM data to NVS: %s", esp_err_to_name(err));
|
||||
goto exit;
|
||||
}
|
||||
result = size;
|
||||
|
||||
if (clear) {
|
||||
if (esp_partition_erase_range (mypart, 0, size) != ESP_OK) {
|
||||
log_w("Unable to clear EEPROM partition");
|
||||
}
|
||||
}
|
||||
exit:
|
||||
free(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
Read 'value' from 'address'
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ class EEPROMClass {
|
||||
void end();
|
||||
|
||||
uint8_t * getDataPtr();
|
||||
uint16_t convert(bool clear, const char* EEPROMname = "eeprom", const char* nvsname = "eeprom");
|
||||
|
||||
template<typename T>
|
||||
T &get(int address, T &t) {
|
||||
|
@ -19,7 +19,7 @@ Author:
|
||||
Pranav Cherukupalli <cherukupallip@gmail.com>
|
||||
*/
|
||||
|
||||
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
|
||||
#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
|
||||
#define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */
|
||||
|
||||
RTC_DATA_ATTR int bootCount = 0;
|
||||
|
@ -62,7 +62,7 @@ void loop()
|
||||
for (led=0; led<NR_OF_LEDS; led++) {
|
||||
for (col=0; col<3; col++ ) {
|
||||
for (bit=0; bit<8; bit++){
|
||||
if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) {
|
||||
if ( (color[col] & (1<<(7-bit))) && (led == led_index) ) {
|
||||
led_data[i].level0 = 1;
|
||||
led_data[i].duration0 = 8;
|
||||
led_data[i].level1 = 0;
|
||||
|
@ -96,7 +96,6 @@ void loop(void)
|
||||
req = req.substring(addr_start + 1, addr_end);
|
||||
Serial.print("Request: ");
|
||||
Serial.println(req);
|
||||
client.flush();
|
||||
|
||||
String s;
|
||||
if (req == "/")
|
||||
@ -115,6 +114,7 @@ void loop(void)
|
||||
}
|
||||
client.print(s);
|
||||
|
||||
client.stop();
|
||||
Serial.println("Done with client");
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void F_Fat::end()
|
||||
log_e("Unmounting FFat partition failed! Error: %d", err);
|
||||
return;
|
||||
}
|
||||
_wl_handle = NULL;
|
||||
_wl_handle = 0;
|
||||
_impl->mountpoint(NULL);
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,9 @@ size_t F_Fat::totalBytes()
|
||||
|
||||
BYTE pdrv = ff_diskio_get_pdrv_wl(_wl_handle);
|
||||
char drv[3] = {(char)(48+pdrv), ':', 0};
|
||||
FRESULT res = f_getfree(drv, &free_clust, &fs);
|
||||
if ( f_getfree(drv, &free_clust, &fs) != FR_OK){
|
||||
return 0;
|
||||
}
|
||||
tot_sect = (fs->n_fatent - 2) * fs->csize;
|
||||
sect_size = CONFIG_WL_SECTOR_SIZE;
|
||||
return tot_sect * sect_size;
|
||||
@ -123,7 +125,9 @@ size_t F_Fat::freeBytes()
|
||||
|
||||
BYTE pdrv = ff_diskio_get_pdrv_wl(_wl_handle);
|
||||
char drv[3] = {(char)(48+pdrv), ':', 0};
|
||||
FRESULT res = f_getfree(drv, &free_clust, &fs);
|
||||
if ( f_getfree(drv, &free_clust, &fs) != FR_OK){
|
||||
return 0;
|
||||
}
|
||||
free_sect = free_clust * fs->csize;
|
||||
sect_size = CONFIG_WL_SECTOR_SIZE;
|
||||
return free_sect * sect_size;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <HardwareSerial.h>
|
||||
/**
|
||||
* HTTPClient.cpp
|
||||
*
|
||||
@ -195,6 +196,11 @@ bool HTTPClient::begin(String url, const char* CAcert)
|
||||
}
|
||||
_secure = true;
|
||||
_transportTraits = TransportTraitsPtr(new TLSTraits(CAcert));
|
||||
if(!_transportTraits) {
|
||||
log_e("could not create transport traits");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -215,6 +221,11 @@ bool HTTPClient::begin(String url)
|
||||
return begin(url, (const char*)NULL);
|
||||
}
|
||||
_transportTraits = TransportTraitsPtr(new TransportTraits());
|
||||
if(!_transportTraits) {
|
||||
log_e("could not create transport traits");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // HTTPCLIENT_1_1_COMPATIBLE
|
||||
@ -333,7 +344,8 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, const char* CAcer
|
||||
*/
|
||||
void HTTPClient::end(void)
|
||||
{
|
||||
disconnect();
|
||||
disconnect(false);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
@ -342,7 +354,7 @@ void HTTPClient::end(void)
|
||||
* disconnect
|
||||
* close the TCP socket
|
||||
*/
|
||||
void HTTPClient::disconnect()
|
||||
void HTTPClient::disconnect(bool preserveClient)
|
||||
{
|
||||
if(connected()) {
|
||||
if(_client->available() > 0) {
|
||||
@ -357,7 +369,9 @@ void HTTPClient::disconnect()
|
||||
} else {
|
||||
log_d("tcp stop\n");
|
||||
_client->stop();
|
||||
if(!preserveClient) {
|
||||
_client = nullptr;
|
||||
}
|
||||
#ifdef HTTPCLIENT_1_1_COMPATIBLE
|
||||
if(_tcpDeprecated) {
|
||||
_transportTraits.reset(nullptr);
|
||||
@ -456,6 +470,7 @@ void HTTPClient::setTimeout(uint16_t timeout)
|
||||
void HTTPClient::useHTTP10(bool useHTTP10)
|
||||
{
|
||||
_useHTTP10 = useHTTP10;
|
||||
_reuse = !useHTTP10;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -816,7 +831,8 @@ int HTTPClient::writeToStream(Stream * stream)
|
||||
return returnError(HTTPC_ERROR_ENCODING);
|
||||
}
|
||||
|
||||
end();
|
||||
// end();
|
||||
disconnect(true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -970,9 +986,12 @@ bool HTTPClient::hasHeader(const char* name)
|
||||
*/
|
||||
bool HTTPClient::connect(void)
|
||||
{
|
||||
|
||||
if(connected()) {
|
||||
if(_reuse) {
|
||||
log_d("already connected, reusing connection");
|
||||
} else {
|
||||
log_d("already connected, try reuse!");
|
||||
}
|
||||
while(_client->available() > 0) {
|
||||
_client->read();
|
||||
}
|
||||
@ -980,8 +999,12 @@ bool HTTPClient::connect(void)
|
||||
}
|
||||
|
||||
#ifdef HTTPCLIENT_1_1_COMPATIBLE
|
||||
if(!_client) {
|
||||
if(_transportTraits && !_client) {
|
||||
_tcpDeprecated = _transportTraits->create();
|
||||
if(!_tcpDeprecated) {
|
||||
log_e("failed to create client");
|
||||
return false;
|
||||
}
|
||||
_client = _tcpDeprecated.get();
|
||||
}
|
||||
#endif
|
||||
@ -1080,9 +1103,12 @@ int HTTPClient::handleHeaderResponse()
|
||||
return HTTPC_ERROR_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
_canReuse = _reuse;
|
||||
|
||||
String transferEncoding;
|
||||
_returnCode = -1;
|
||||
_size = -1;
|
||||
|
||||
_transferEncoding = HTTPC_TE_IDENTITY;
|
||||
unsigned long lastDataTime = millis();
|
||||
|
||||
@ -1097,6 +1123,9 @@ int HTTPClient::handleHeaderResponse()
|
||||
log_v("RX: '%s'", headerLine.c_str());
|
||||
|
||||
if(headerLine.startsWith("HTTP/1.")) {
|
||||
if(_canReuse) {
|
||||
_canReuse = (headerLine[sizeof "HTTP/1." - 1] != '0');
|
||||
}
|
||||
_returnCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
|
||||
} else if(headerLine.indexOf(':')) {
|
||||
String headerName = headerLine.substring(0, headerLine.indexOf(':'));
|
||||
@ -1107,8 +1136,10 @@ int HTTPClient::handleHeaderResponse()
|
||||
_size = headerValue.toInt();
|
||||
}
|
||||
|
||||
if(headerName.equalsIgnoreCase("Connection")) {
|
||||
_canReuse = headerValue.equalsIgnoreCase("keep-alive");
|
||||
if(_canReuse && headerName.equalsIgnoreCase("Connection")) {
|
||||
if(headerValue.indexOf("close") >= 0 && headerValue.indexOf("keep-alive") < 0) {
|
||||
_canReuse = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(headerName.equalsIgnoreCase("Transfer-Encoding")) {
|
||||
|
@ -197,7 +197,7 @@ protected:
|
||||
};
|
||||
|
||||
bool beginInternal(String url, const char* expectedProtocol);
|
||||
void disconnect();
|
||||
void disconnect(bool preserveClient = false);
|
||||
void clear();
|
||||
int returnError(int error);
|
||||
bool connect(void);
|
||||
@ -217,7 +217,7 @@ protected:
|
||||
String _host;
|
||||
uint16_t _port = 0;
|
||||
int32_t _connectTimeout = -1;
|
||||
bool _reuse = false;
|
||||
bool _reuse = true;
|
||||
uint16_t _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
|
||||
bool _useHTTP10 = false;
|
||||
bool _secure = false;
|
||||
|
@ -96,7 +96,7 @@ void loop() {
|
||||
client.setCACert(rootCACertificate);
|
||||
|
||||
// Reading data over SSL may be slow, use an adequate timeout
|
||||
client.setTimeout(12000);
|
||||
client.setTimeout(12000 / 1000); // timeout argument is defined in seconds for setTimeout
|
||||
|
||||
// The line below is optional. It can be used to blink the LED on the board during flashing
|
||||
// The LED will be on during download of one buffer of data from the network. The LED will
|
||||
|
@ -20,13 +20,33 @@ extern "C" {
|
||||
#include <dirent.h>
|
||||
#include "esp_spiffs.h"
|
||||
}
|
||||
|
||||
#include "SPIFFS.h"
|
||||
|
||||
using namespace fs;
|
||||
|
||||
SPIFFSFS::SPIFFSFS(FSImplPtr impl)
|
||||
: FS(impl)
|
||||
{}
|
||||
class SPIFFSImpl : public VFSImpl
|
||||
{
|
||||
public:
|
||||
SPIFFSImpl();
|
||||
virtual ~SPIFFSImpl() { }
|
||||
virtual bool exists(const char* path);
|
||||
};
|
||||
|
||||
SPIFFSImpl::SPIFFSImpl()
|
||||
{
|
||||
}
|
||||
|
||||
bool SPIFFSImpl::exists(const char* path)
|
||||
{
|
||||
File f = open(path, "r");
|
||||
return (f == true) && !f.isDirectory();
|
||||
}
|
||||
|
||||
SPIFFSFS::SPIFFSFS() : FS(FSImplPtr(new SPIFFSImpl()))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SPIFFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles)
|
||||
{
|
||||
@ -98,16 +118,5 @@ size_t SPIFFSFS::usedBytes()
|
||||
return used;
|
||||
}
|
||||
|
||||
bool SPIFFSFS::exists(const char* path)
|
||||
{
|
||||
File f = open(path, "r");
|
||||
return (f == true) && !f.isDirectory();
|
||||
}
|
||||
SPIFFSFS SPIFFS;
|
||||
|
||||
bool SPIFFSFS::exists(const String& path)
|
||||
{
|
||||
return exists(path.c_str());
|
||||
}
|
||||
|
||||
|
||||
SPIFFSFS SPIFFS = SPIFFSFS(FSImplPtr(new VFSImpl()));
|
||||
|
@ -22,18 +22,17 @@ namespace fs
|
||||
class SPIFFSFS : public FS
|
||||
{
|
||||
public:
|
||||
SPIFFSFS(FSImplPtr impl);
|
||||
SPIFFSFS();
|
||||
bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10);
|
||||
bool format();
|
||||
size_t totalBytes();
|
||||
size_t usedBytes();
|
||||
void end();
|
||||
bool exists(const char* path);
|
||||
bool exists(const String& path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
extern fs::SPIFFSFS SPIFFS;
|
||||
|
||||
#endif /* _SPIFFS_H_ */
|
||||
|
||||
#endif
|
||||
|
@ -62,7 +62,7 @@ class UpdateClass {
|
||||
If all bytes are written
|
||||
this call will write the config to eboot
|
||||
and return true
|
||||
If there is already an update running but is not finished and !evenIfRemainanig
|
||||
If there is already an update running but is not finished and !evenIfRemaining
|
||||
or there is an error
|
||||
this will clear everything and return false
|
||||
the last error is available through getError()
|
||||
|
@ -189,6 +189,9 @@ bool UpdateClass::_writeBuffer(){
|
||||
//this ensures that partially written firmware will not be bootable
|
||||
_buffer[0] = 0xFF;
|
||||
}
|
||||
if (!_progress && _progress_callback) {
|
||||
_progress_callback(0, _size);
|
||||
}
|
||||
if(!ESP.flashEraseSector((_partition->address + _progress)/SPI_FLASH_SEC_SIZE)){
|
||||
_abort(UPDATE_ERROR_ERASE);
|
||||
return false;
|
||||
@ -204,6 +207,9 @@ bool UpdateClass::_writeBuffer(){
|
||||
_md5.add(_buffer, _bufferLen);
|
||||
_progress += _bufferLen;
|
||||
_bufferLen = 0;
|
||||
if (_progress_callback) {
|
||||
_progress_callback(_progress, _size);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -319,9 +325,6 @@ size_t UpdateClass::writeStream(Stream &data) {
|
||||
_reset();
|
||||
return 0;
|
||||
}
|
||||
if (_progress_callback) {
|
||||
_progress_callback(0, _size);
|
||||
}
|
||||
|
||||
if(_ledPin != -1) {
|
||||
pinMode(_ledPin, OUTPUT);
|
||||
@ -352,12 +355,6 @@ size_t UpdateClass::writeStream(Stream &data) {
|
||||
if((_bufferLen == remaining() || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer())
|
||||
return written;
|
||||
written += toRead;
|
||||
if(_progress_callback) {
|
||||
_progress_callback(_progress, _size);
|
||||
}
|
||||
}
|
||||
if(_progress_callback) {
|
||||
_progress_callback(_size, _size);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
@ -303,6 +303,7 @@ void WebServer::_uploadWriteByte(uint8_t b){
|
||||
}
|
||||
|
||||
int WebServer::_uploadReadByte(WiFiClient& client){
|
||||
if (!client.connected()) return -1;
|
||||
int res = client.read();
|
||||
if(res < 0) {
|
||||
// keep trying until you either read a valid byte or timeout
|
||||
|
@ -302,7 +302,9 @@ void WebServer::handleClient() {
|
||||
// Wait for data from client to become available
|
||||
if (_currentClient.available()) {
|
||||
if (_parseRequest(_currentClient)) {
|
||||
_currentClient.setTimeout(HTTP_MAX_SEND_WAIT);
|
||||
// because HTTP_MAX_SEND_WAIT is expressed in milliseconds,
|
||||
// it must be divided by 1000
|
||||
_currentClient.setTimeout(HTTP_MAX_SEND_WAIT / 1000);
|
||||
_contentLength = CONTENT_LENGTH_NOT_SET;
|
||||
_handleRequest();
|
||||
|
||||
|
@ -197,6 +197,33 @@ IPAddress ETHClass::dnsIP(uint8_t dns_no)
|
||||
return IPAddress(dns_ip.u_addr.ip4.addr);
|
||||
}
|
||||
|
||||
IPAddress ETHClass::broadcastIP()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return IPAddress();
|
||||
}
|
||||
return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
IPAddress ETHClass::networkID()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return IPAddress();
|
||||
}
|
||||
return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
uint8_t ETHClass::subnetCIDR()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return (uint8_t)0;
|
||||
}
|
||||
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
const char * ETHClass::getHostname()
|
||||
{
|
||||
const char * hostname;
|
||||
|
@ -79,6 +79,10 @@ class ETHClass {
|
||||
IPAddress gatewayIP();
|
||||
IPAddress dnsIP(uint8_t dns_no = 0);
|
||||
|
||||
IPAddress broadcastIP();
|
||||
IPAddress networkID();
|
||||
uint8_t subnetCIDR();
|
||||
|
||||
uint8_t * macAddress(uint8_t* mac);
|
||||
String macAddress();
|
||||
|
||||
|
@ -235,6 +235,47 @@ IPAddress WiFiAPClass::softAPIP()
|
||||
return IPAddress(ip.ip.addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the softAP broadcast IP address.
|
||||
* @return IPAddress softAP broadcastIP
|
||||
*/
|
||||
IPAddress WiFiAPClass::softAPBroadcastIP()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return IPAddress();
|
||||
}
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip);
|
||||
return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the softAP network ID.
|
||||
* @return IPAddress softAP networkID
|
||||
*/
|
||||
IPAddress WiFiAPClass::softAPNetworkID()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return IPAddress();
|
||||
}
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip);
|
||||
return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the softAP subnet CIDR.
|
||||
* @return uint8_t softAP subnetCIDR
|
||||
*/
|
||||
uint8_t WiFiAPClass::softAPSubnetCIDR()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return (uint8_t)0;
|
||||
}
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip);
|
||||
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the softAP interface MAC address.
|
||||
|
@ -45,6 +45,10 @@ public:
|
||||
|
||||
IPAddress softAPIP();
|
||||
|
||||
IPAddress softAPBroadcastIP();
|
||||
IPAddress softAPNetworkID();
|
||||
uint8_t softAPSubnetCIDR();
|
||||
|
||||
bool softAPenableIpV6();
|
||||
IPv6Address softAPIPv6();
|
||||
|
||||
|
@ -226,14 +226,41 @@ int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
|
||||
FD_SET(sockfd, &fdset);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout * 1000;
|
||||
lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
|
||||
int res = select(sockfd + 1, nullptr, &fdset, nullptr, timeout<0 ? nullptr : &tv);
|
||||
if (res != 1)
|
||||
{
|
||||
log_e("select: %d",errno);
|
||||
|
||||
int res = lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
|
||||
if (res < 0 && errno != EINPROGRESS) {
|
||||
log_e("connect on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
res = select(sockfd + 1, nullptr, &fdset, nullptr, timeout<0 ? nullptr : &tv);
|
||||
if (res < 0) {
|
||||
log_e("select on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
} else if (res == 0) {
|
||||
log_i("select returned due to timeout %d ms for fd %d", timeout, sockfd);
|
||||
close(sockfd);
|
||||
return 0;
|
||||
} else {
|
||||
int sockerr;
|
||||
socklen_t len = (socklen_t)sizeof(int);
|
||||
res = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &sockerr, &len);
|
||||
|
||||
if (res < 0) {
|
||||
log_e("getsockopt on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sockerr != 0) {
|
||||
log_e("socket error on fd %d, errno: %d, \"%s\"", sockfd, sockerr, strerror(sockerr));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL, 0 ) & (~O_NONBLOCK) );
|
||||
clientSocketHandle.reset(new WiFiClientSocketHandle(sockfd));
|
||||
_rxBuffer.reset(new WiFiClientRxBuffer(sockfd));
|
||||
|
@ -333,7 +333,9 @@ const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAV
|
||||
#endif
|
||||
esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event)
|
||||
{
|
||||
if(event->event_id < 26) log_d("Event: %d - %s", event->event_id, system_event_names[event->event_id]);
|
||||
if(event->event_id < 26) {
|
||||
log_d("Event: %d - %s", event->event_id, system_event_names[event->event_id]);
|
||||
}
|
||||
if(event->event_id == SYSTEM_EVENT_SCAN_DONE) {
|
||||
WiFiScanClass::_scanDone();
|
||||
|
||||
@ -654,3 +656,45 @@ int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult)
|
||||
return (uint32_t)aResult != 0;
|
||||
}
|
||||
|
||||
IPAddress WiFiGenericClass::calculateNetworkID(IPAddress ip, IPAddress subnet) {
|
||||
IPAddress networkID;
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
networkID[i] = subnet[i] & ip[i];
|
||||
|
||||
return networkID;
|
||||
}
|
||||
|
||||
IPAddress WiFiGenericClass::calculateBroadcast(IPAddress ip, IPAddress subnet) {
|
||||
IPAddress broadcastIp;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
broadcastIp[i] = ~subnet[i] | ip[i];
|
||||
|
||||
return broadcastIp;
|
||||
}
|
||||
|
||||
uint8_t WiFiGenericClass::calculateSubnetCIDR(IPAddress subnetMask) {
|
||||
uint8_t CIDR = 0;
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
if (subnetMask[i] == 0x80) // 128
|
||||
CIDR += 1;
|
||||
else if (subnetMask[i] == 0xC0) // 192
|
||||
CIDR += 2;
|
||||
else if (subnetMask[i] == 0xE0) // 224
|
||||
CIDR += 3;
|
||||
else if (subnetMask[i] == 0xF0) // 242
|
||||
CIDR += 4;
|
||||
else if (subnetMask[i] == 0xF8) // 248
|
||||
CIDR += 5;
|
||||
else if (subnetMask[i] == 0xFC) // 252
|
||||
CIDR += 6;
|
||||
else if (subnetMask[i] == 0xFE) // 254
|
||||
CIDR += 7;
|
||||
else if (subnetMask[i] == 0xFF) // 255
|
||||
CIDR += 8;
|
||||
}
|
||||
|
||||
return CIDR;
|
||||
}
|
||||
|
@ -108,6 +108,10 @@ class WiFiGenericClass
|
||||
public:
|
||||
static int hostByName(const char *aHostname, IPAddress &aResult);
|
||||
|
||||
static IPAddress calculateNetworkID(IPAddress ip, IPAddress subnet);
|
||||
static IPAddress calculateBroadcast(IPAddress ip, IPAddress subnet);
|
||||
static uint8_t calculateSubnetCIDR(IPAddress subnetMask);
|
||||
|
||||
protected:
|
||||
friend class WiFiSTAClass;
|
||||
friend class WiFiScanClass;
|
||||
|
@ -34,22 +34,64 @@ WiFiMulti::WiFiMulti()
|
||||
|
||||
WiFiMulti::~WiFiMulti()
|
||||
{
|
||||
APlistClean();
|
||||
for(uint32_t i = 0; i < APlist.size(); i++) {
|
||||
WifiAPlist_t entry = APlist[i];
|
||||
if(entry.ssid) {
|
||||
free(entry.ssid);
|
||||
}
|
||||
if(entry.passphrase) {
|
||||
free(entry.passphrase);
|
||||
}
|
||||
}
|
||||
APlist.clear();
|
||||
}
|
||||
|
||||
bool WiFiMulti::addAP(const char* ssid, const char *passphrase)
|
||||
{
|
||||
return APlistAdd(ssid, passphrase);
|
||||
WifiAPlist_t newAP;
|
||||
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID too long or missing!
|
||||
log_e("[WIFI][APlistAdd] no ssid or ssid too long");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(passphrase && strlen(passphrase) > 63) {
|
||||
// fail passphrase too long!
|
||||
log_e("[WIFI][APlistAdd] passphrase too long");
|
||||
return false;
|
||||
}
|
||||
|
||||
newAP.ssid = strdup(ssid);
|
||||
|
||||
if(!newAP.ssid) {
|
||||
log_e("[WIFI][APlistAdd] fail newAP.ssid == 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(passphrase && *passphrase != 0x00) {
|
||||
newAP.passphrase = strdup(passphrase);
|
||||
if(!newAP.passphrase) {
|
||||
log_e("[WIFI][APlistAdd] fail newAP.passphrase == 0");
|
||||
free(newAP.ssid);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
newAP.passphrase = NULL;
|
||||
}
|
||||
|
||||
APlist.push_back(newAP);
|
||||
log_i("[WIFI][APlistAdd] add SSID: %s", newAP.ssid);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
||||
{
|
||||
|
||||
int8_t scanResult;
|
||||
uint8_t status = WiFi.status();
|
||||
if(status == WL_CONNECTED) {
|
||||
for(uint32_t x = 0; x < APlist.size(); x++) {
|
||||
if(WiFi.SSID()==APlist[x].ssid){
|
||||
if(WiFi.SSID()==APlist[x].ssid) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -128,17 +170,17 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
||||
}
|
||||
|
||||
switch(status) {
|
||||
case 3:
|
||||
case WL_CONNECTED:
|
||||
log_i("[WIFI] Connecting done.");
|
||||
log_d("[WIFI] SSID: %s", WiFi.SSID().c_str());
|
||||
log_d("[WIFI] IP: %s", WiFi.localIP().toString().c_str());
|
||||
log_d("[WIFI] MAC: %s", WiFi.BSSIDstr().c_str());
|
||||
log_d("[WIFI] Channel: %d", WiFi.channel());
|
||||
break;
|
||||
case 1:
|
||||
case WL_NO_SSID_AVAIL:
|
||||
log_e("[WIFI] Connecting Failed AP not found.");
|
||||
break;
|
||||
case 4:
|
||||
case WL_CONNECT_FAILED:
|
||||
log_e("[WIFI] Connecting Failed.");
|
||||
break;
|
||||
default:
|
||||
@ -160,60 +202,3 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// ##################################################################################
|
||||
|
||||
bool WiFiMulti::APlistAdd(const char* ssid, const char *passphrase)
|
||||
{
|
||||
|
||||
WifiAPlist_t newAP;
|
||||
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID to long or missing!
|
||||
log_e("[WIFI][APlistAdd] no ssid or ssid to long");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(passphrase && strlen(passphrase) > 63) {
|
||||
// fail passphrase to long!
|
||||
log_e("[WIFI][APlistAdd] passphrase to long");
|
||||
return false;
|
||||
}
|
||||
|
||||
newAP.ssid = strdup(ssid);
|
||||
|
||||
if(!newAP.ssid) {
|
||||
log_e("[WIFI][APlistAdd] fail newAP.ssid == 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(passphrase && *passphrase != 0x00) {
|
||||
newAP.passphrase = strdup(passphrase);
|
||||
if(!newAP.passphrase) {
|
||||
log_e("[WIFI][APlistAdd] fail newAP.passphrase == 0");
|
||||
free(newAP.ssid);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
newAP.passphrase = NULL;
|
||||
}
|
||||
|
||||
APlist.push_back(newAP);
|
||||
log_i("[WIFI][APlistAdd] add SSID: %s", newAP.ssid);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WiFiMulti::APlistClean(void)
|
||||
{
|
||||
for(uint32_t i = 0; i < APlist.size(); i++) {
|
||||
WifiAPlist_t entry = APlist[i];
|
||||
if(entry.ssid) {
|
||||
free(entry.ssid);
|
||||
}
|
||||
if(entry.passphrase) {
|
||||
free(entry.passphrase);
|
||||
}
|
||||
}
|
||||
APlist.clear();
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,6 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<WifiAPlist_t> APlist;
|
||||
bool APlistAdd(const char* ssid, const char *passphrase = NULL);
|
||||
void APlistClean(void);
|
||||
|
||||
};
|
||||
|
||||
#endif /* WIFICLIENTMULTI_H_ */
|
||||
|
@ -162,6 +162,8 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
|
||||
esp_wifi_set_config(WIFI_IF_STA, &conf);
|
||||
} else if(status() == WL_CONNECTED){
|
||||
return WL_CONNECTED;
|
||||
} else {
|
||||
esp_wifi_set_config(WIFI_IF_STA, &conf);
|
||||
}
|
||||
|
||||
if(!_useStaticIp) {
|
||||
@ -198,6 +200,12 @@ wl_status_t WiFiSTAClass::begin()
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
wifi_config_t current_conf;
|
||||
if(esp_wifi_get_config(WIFI_IF_STA, ¤t_conf) != ESP_OK || esp_wifi_set_config(WIFI_IF_STA, ¤t_conf) != ESP_OK) {
|
||||
log_e("config failed");
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
if(!_useStaticIp) {
|
||||
if(tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA) == ESP_ERR_TCPIP_ADAPTER_DHCPC_START_FAILED){
|
||||
log_e("dhcp client start failed!");
|
||||
@ -484,6 +492,48 @@ IPAddress WiFiSTAClass::dnsIP(uint8_t dns_no)
|
||||
return IPAddress(dns_ip.u_addr.ip4.addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the broadcast ip address.
|
||||
* @return IPAddress broadcastIP
|
||||
*/
|
||||
IPAddress WiFiSTAClass::broadcastIP()
|
||||
{
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return IPAddress();
|
||||
}
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip);
|
||||
return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the network id.
|
||||
* @return IPAddress networkID
|
||||
*/
|
||||
IPAddress WiFiSTAClass::networkID()
|
||||
{
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return IPAddress();
|
||||
}
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip);
|
||||
return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subnet CIDR.
|
||||
* @return uint8_t subnetCIDR
|
||||
*/
|
||||
uint8_t WiFiSTAClass::subnetCIDR()
|
||||
{
|
||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return (uint8_t)0;
|
||||
}
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip);
|
||||
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current SSID associated with the network
|
||||
* @return SSID
|
||||
|
@ -65,6 +65,10 @@ public:
|
||||
IPAddress gatewayIP();
|
||||
IPAddress dnsIP(uint8_t dns_no = 0);
|
||||
|
||||
IPAddress broadcastIP();
|
||||
IPAddress networkID();
|
||||
uint8_t subnetCIDR();
|
||||
|
||||
bool enableIpV6();
|
||||
IPv6Address localIPv6();
|
||||
|
||||
|
@ -22,7 +22,7 @@ compiler.warning_flags.all=-Wall -Werror=all -Wextra
|
||||
|
||||
compiler.path={runtime.tools.xtensa-esp32-elf-gcc.path}/bin/
|
||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/asio" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/esp_event" "-I{compiler.sdk.path}/include/esp_http_client" "-I{compiler.sdk.path}/include/esp_http_server" "-I{compiler.sdk.path}/include/esp_https_ota" "-I{compiler.sdk.path}/include/esp_ringbuf" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freemodbus" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/idf_test" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/libsodium" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/lwip" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/micro-ecc" "-I{compiler.sdk.path}/include/mqtt" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/protobuf-c" "-I{compiler.sdk.path}/include/protocomm" "-I{compiler.sdk.path}/include/pthread" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/smartconfig_ack" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcp_transport" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/wifi_provisioning" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/esp32-camera" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/fb_gfx"
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/asio" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/esp_event" "-I{compiler.sdk.path}/include/esp_http_client" "-I{compiler.sdk.path}/include/esp_http_server" "-I{compiler.sdk.path}/include/esp_https_ota" "-I{compiler.sdk.path}/include/esp_ringbuf" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freemodbus" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/idf_test" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/libsodium" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/lwip" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/micro-ecc" "-I{compiler.sdk.path}/include/mqtt" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/protobuf-c" "-I{compiler.sdk.path}/include/protocomm" "-I{compiler.sdk.path}/include/pthread" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/smartconfig_ack" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcp_transport" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/wifi_provisioning" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/esp32-camera" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/fb_gfx"
|
||||
|
||||
compiler.c.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.flags=-std=gnu99 -Os -g3 -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
|
||||
|
@ -1,54 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
#- set -e
|
||||
|
||||
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
echo "No sketch builds & tests required for tagged TravisCI builds, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "travis_fold:start:sketch_test_env_prepare"
|
||||
pip install pyserial
|
||||
wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
|
||||
tar xf arduino.tar.xz
|
||||
mv arduino-nightly $HOME/arduino_ide
|
||||
mkdir -p $HOME/Arduino/libraries
|
||||
cd $HOME/arduino_ide/hardware
|
||||
mkdir espressif
|
||||
cd espressif
|
||||
ln -s $TRAVIS_BUILD_DIR esp32
|
||||
cd esp32
|
||||
git submodule update --init --recursive
|
||||
cd tools
|
||||
python get.py
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
export PATH="$HOME/arduino_ide:$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin:$PATH"
|
||||
source tools/common.sh
|
||||
echo -e "travis_fold:end:sketch_test_env_prepare"
|
||||
|
||||
echo -e "travis_fold:start:sketch_test"
|
||||
build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
|
||||
# CMake Test
|
||||
echo -e "travis_fold:start:check_cmakelists"
|
||||
tools/check_cmakelists.sh
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
echo -e "travis_fold:end:sketch_test"
|
||||
echo -e "travis_fold:end:check_cmakelists"
|
||||
|
||||
# ArduinoIDE Test
|
||||
echo -e "travis_fold:start:prep_arduino_ide"
|
||||
tools/prep-arduino-ide.sh
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
echo -e "travis_fold:end:prep_arduino_ide"
|
||||
|
||||
echo -e "travis_fold:start:test_arduino_ide"
|
||||
tools/test-arduino-ide.sh
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
echo -e "travis_fold:end:test_arduino_ide"
|
||||
|
||||
echo -e "travis_fold:start:size_report"
|
||||
cat size.log
|
||||
echo -e "travis_fold:end:size_report"
|
||||
|
||||
echo -e "travis_fold:start:platformio_test_env_prepare"
|
||||
pip install -U https://github.com/platformio/platformio/archive/develop.zip && \
|
||||
platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage && \
|
||||
sed -i 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' ~/.platformio/platforms/espressif32/platform.json && \
|
||||
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif32
|
||||
# PlatformIO Test
|
||||
echo -e "travis_fold:start:prep_platformio"
|
||||
tools/prep-platformio.sh
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
echo -e "travis_fold:end:platformio_test_env_prepare"
|
||||
echo -e "travis_fold:end:prep_platformio"
|
||||
|
||||
echo -e "travis_fold:start:platformio_test"
|
||||
platformio ci --board esp32dev libraries/WiFi/examples/WiFiClient && \
|
||||
platformio ci --board esp32dev libraries/WiFiClientSecure/examples/WiFiClientSecure && \
|
||||
platformio ci --board esp32dev libraries/BluetoothSerial/examples/SerialToSerialBT && \
|
||||
platformio ci --board esp32dev libraries/BLE/examples/BLE_server && \
|
||||
platformio ci --board esp32dev libraries/AzureIoT/examples/GetStarted && \
|
||||
platformio ci --board esp32dev libraries/ESP32/examples/Camera/CameraWebServer --project-option="board_build.partitions = huge_app.csv"
|
||||
echo -e "travis_fold:start:test_platformio"
|
||||
tools/test-platformio.sh
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
echo -e "travis_fold:end:platformio_test"
|
||||
echo -e "travis_fold:end:test_platformio"
|
||||
|
@ -3,7 +3,7 @@
|
||||
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
# zip the package if tagged build
|
||||
tools/build-release.sh -a$ESP32_GITHUB_TOKEN
|
||||
else
|
||||
#else
|
||||
# run cmake and sketch tests
|
||||
tools/check_cmakelists.sh && tools/build-tests.sh
|
||||
#tools/build-tests.sh
|
||||
fi
|
||||
|
@ -10,8 +10,10 @@ set -e
|
||||
|
||||
cd "`dirname $0`/.." # cd to arduino-esp32 root
|
||||
|
||||
# pull all submodules
|
||||
git submodule update --init --recursive
|
||||
|
||||
# find all source files in repo
|
||||
#REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name 'main.cpp' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`
|
||||
REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`
|
||||
|
||||
# find all source files named in CMakeLists.txt COMPONENT_SRCS
|
||||
|
@ -1,72 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function print_size_info()
|
||||
{
|
||||
elf_file=$1
|
||||
|
||||
if [ -z "$elf_file" ]; then
|
||||
printf "sketch iram0.text flash.text flash.rodata dram0.data dram0.bss dram flash\n"
|
||||
return 0
|
||||
fi
|
||||
|
||||
elf_name=$(basename $elf_file)
|
||||
sketch_name="${elf_name%.*}"
|
||||
# echo $sketch_name
|
||||
declare -A segments
|
||||
while read -a tokens; do
|
||||
seg=${tokens[0]}
|
||||
seg=${seg//./}
|
||||
size=${tokens[1]}
|
||||
addr=${tokens[2]}
|
||||
if [ "$addr" -eq "$addr" -a "$addr" -ne "0" ] 2>/dev/null; then
|
||||
segments[$seg]=$size
|
||||
fi
|
||||
done < <(xtensa-esp32-elf-size --format=sysv $elf_file)
|
||||
|
||||
total_ram=$((${segments[dram0data]} + ${segments[dram0bss]}))
|
||||
total_flash=$((${segments[iram0text]} + ${segments[flashtext]} + ${segments[dram0data]} + ${segments[flashrodata]}))
|
||||
printf "%-28s %-8d %-8d %-8d %-8d %-8d %-8d %-8d\n" $sketch_name ${segments[iram0text]} ${segments[flashtext]} ${segments[flashrodata]} ${segments[dram0data]} ${segments[dram0bss]} $total_ram $total_flash
|
||||
return 0
|
||||
}
|
||||
|
||||
function build_sketches()
|
||||
{
|
||||
#set +e
|
||||
local arduino=$1
|
||||
local srcpath=$2
|
||||
local build_arg=$3
|
||||
local build_dir=build.tmp
|
||||
mkdir -p $build_dir
|
||||
local build_cmd="python tools/build.py -b esp32 -v -k -p $PWD/$build_dir $build_arg "
|
||||
local sketches=$(find $srcpath -name *.ino)
|
||||
print_size_info >size.log
|
||||
export ARDUINO_IDE_PATH=$arduino
|
||||
for sketch in $sketches; do
|
||||
rm -rf $build_dir/*
|
||||
local sketchdir=$(dirname $sketch)
|
||||
local sketchdirname=$(basename $sketchdir)
|
||||
local sketchname=$(basename $sketch)
|
||||
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
|
||||
echo "Skipping $sketch, beacause it is not the main sketch file";
|
||||
continue
|
||||
fi;
|
||||
if [[ -f "$sketchdir/.test.skip" ]]; then
|
||||
echo -e "\n ------------ Skipping $sketch ------------ \n";
|
||||
continue
|
||||
fi
|
||||
echo -e "\n ------------ Building $sketch ------------ \n";
|
||||
# $arduino --verify $sketch;
|
||||
#echo "$build_cmd $sketch"
|
||||
time ($build_cmd $sketch >build.log)
|
||||
local result=$?
|
||||
if [ $result -ne 0 ]; then
|
||||
echo "Build failed ($1)"
|
||||
echo "Build log:"
|
||||
cat build.log
|
||||
return $result
|
||||
fi
|
||||
rm build.log
|
||||
print_size_info $build_dir/*.elf >>size.log
|
||||
done
|
||||
#set -e
|
||||
}
|
@ -236,7 +236,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
|
||||
def parser(unparsed_args):
|
||||
parser = optparse.OptionParser(
|
||||
usage = "%prog [options]",
|
||||
description = "Transmit image over the air to the esp8266 module with OTA support."
|
||||
description = "Transmit image over the air to the esp32 module with OTA support."
|
||||
)
|
||||
|
||||
# destination ip and port
|
||||
@ -244,7 +244,7 @@ def parser(unparsed_args):
|
||||
group.add_option("-i", "--ip",
|
||||
dest = "esp_ip",
|
||||
action = "store",
|
||||
help = "ESP8266 IP Address.",
|
||||
help = "ESP32 IP Address.",
|
||||
default = False
|
||||
)
|
||||
group.add_option("-I", "--host_ip",
|
||||
@ -256,8 +256,8 @@ def parser(unparsed_args):
|
||||
group.add_option("-p", "--port",
|
||||
dest = "esp_port",
|
||||
type = "int",
|
||||
help = "ESP8266 ota Port. Default 8266",
|
||||
default = 8266
|
||||
help = "ESP32 ota Port. Default 3232",
|
||||
default = 3232
|
||||
)
|
||||
group.add_option("-P", "--host_port",
|
||||
dest = "host_port",
|
||||
@ -310,7 +310,7 @@ def parser(unparsed_args):
|
||||
group.add_option("-t", "--timeout",
|
||||
dest = "timeout",
|
||||
type = "int",
|
||||
help = "Timeout to wait for the ESP8266 to accept invitation",
|
||||
help = "Timeout to wait for the ESP32 to accept invitation",
|
||||
default = 10
|
||||
)
|
||||
parser.add_option_group(group)
|
||||
|
@ -152,6 +152,7 @@ env.Append(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wifi_provisioning"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "xtensa-debug-module"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-face"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32-camera"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-face"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fb_gfx"),
|
||||
|
14
tools/prep-arduino-ide.sh
Executable file
14
tools/prep-arduino-ide.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
pip install pyserial
|
||||
wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
|
||||
tar xf arduino.tar.xz
|
||||
mv arduino-nightly $HOME/arduino_ide
|
||||
mkdir -p $HOME/Arduino/libraries
|
||||
|
||||
cd $HOME/arduino_ide/hardware
|
||||
mkdir espressif
|
||||
cd espressif
|
||||
ln -s $TRAVIS_BUILD_DIR esp32
|
||||
cd esp32/tools
|
||||
python get.py
|
6
tools/prep-platformio.sh
Executable file
6
tools/prep-platformio.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
pip install -U https://github.com/platformio/platformio/archive/develop.zip && \
|
||||
python -m platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage && \
|
||||
sed -i 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' ~/.platformio/platforms/espressif32/platform.json && \
|
||||
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif32
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -91,3 +91,16 @@ bool bootloader_common_label_search(const char *list, char *label);
|
||||
* - ESP_FAIL: An allocation error occurred.
|
||||
*/
|
||||
esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t size, int type, uint8_t *out_sha_256);
|
||||
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
void bootloader_common_vddsdio_configure();
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
*
|
||||
* CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
|
||||
* cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1
|
||||
*/
|
||||
void bootloader_common_set_flash_cs_timing();
|
||||
|
@ -25,7 +25,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x5A5AA5A5
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20190506
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
@ -100,6 +100,9 @@ the adv packet will be discarded until the memory is restored. */
|
||||
#define BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_LIMIT 7 //Maximum ACL connection limitation
|
||||
#define BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_LIMIT 3 //Maximum SCO/eSCO connection limitation
|
||||
|
||||
#define BTDM_CONTROLLER_SCO_DATA_PATH_HCI 0 // SCO data is routed to HCI
|
||||
#define BTDM_CONTROLLER_SCO_DATA_PATH_PCM 1 // SCO data path is PCM
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
|
||||
@ -114,6 +117,7 @@ the adv packet will be discarded until the memory is restored. */
|
||||
.mode = BTDM_CONTROLLER_MODE_EFF, \
|
||||
.ble_max_conn = CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF, \
|
||||
.bt_max_acl_conn = CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF, \
|
||||
.bt_sco_datapath = CONFIG_BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_EFF, \
|
||||
.bt_max_sync_conn = CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF, \
|
||||
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
|
||||
};
|
||||
@ -144,6 +148,7 @@ typedef struct {
|
||||
uint8_t mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
|
||||
uint8_t ble_max_conn; /*!< BLE maximum connection numbers */
|
||||
uint8_t bt_max_acl_conn; /*!< BR/EDR maximum ACL connection numbers */
|
||||
uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module */
|
||||
/*
|
||||
* Following parameters can not be configured runtime when call esp_bt_controller_init()
|
||||
* It will be overwrite with a constant value which in menuconfig or from a macro.
|
||||
|
@ -40,6 +40,7 @@
|
||||
#define CONFIG_SPIFFS_CACHE_WR 1
|
||||
#define CONFIG_SPIRAM_CACHE_WORKAROUND 1
|
||||
#define CONFIG_BROWNOUT_DET_LVL_SEL_0 1
|
||||
#define CONFIG_D0WD_PSRAM_CS_IO 16
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1
|
||||
#define CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE 1
|
||||
#define CONFIG_BTDM_CONTROLLER_MODEM_SLEEP 1
|
||||
@ -57,13 +58,15 @@
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_MBEDTLS_ECDH_C 1
|
||||
#define CONFIG_SPIRAM_USE_CAPS_ALLOC 1
|
||||
#define CONFIG_FRMN1_QUANT 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1
|
||||
#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 8
|
||||
#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10
|
||||
#define CONFIG_MBEDTLS_SSL_ALPN 1
|
||||
#define CONFIG_MBEDTLS_PEM_WRITE_C 1
|
||||
#define CONFIG_BT_SPP_ENABLED 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0xdb5c
|
||||
#define CONFIG_CXX_EXCEPTIONS 1
|
||||
#define CONFIG_D2WD_PSRAM_CLK_IO 9
|
||||
#define CONFIG_FATFS_FS_LOCK 0
|
||||
#define CONFIG_IP_LOST_TIMER_INTERVAL 120
|
||||
#define CONFIG_SPIFFS_META_LENGTH 4
|
||||
@ -85,6 +88,7 @@
|
||||
#define CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF 3
|
||||
#define CONFIG_TCPIP_TASK_AFFINITY_CPU0 1
|
||||
#define CONFIG_FATFS_CODEPAGE 850
|
||||
#define CONFIG_SPIRAM_SPIWP_SD3_PIN 7
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 512
|
||||
#define CONFIG_LWIP_MAX_UDP_PCBS 16
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
@ -119,6 +123,7 @@
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_SPIRAM_BANKSWITCH_ENABLE 1
|
||||
#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1
|
||||
#define CONFIG_HTTPD_PURGE_BUF_LEN 32
|
||||
#define CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR 1
|
||||
#define CONFIG_MB_SERIAL_TASK_STACK_SIZE 2048
|
||||
#define CONFIG_MBEDTLS_PSK_MODES 1
|
||||
@ -129,6 +134,7 @@
|
||||
#define CONFIG_BLUEDROID_PINNED_TO_CORE_0 1
|
||||
#define CONFIG_FATFS_CODEPAGE_850 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MTMN_LITE_QUANT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_SPIFFS_PAGE_CHECK 1
|
||||
#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1
|
||||
@ -152,7 +158,7 @@
|
||||
#define CONFIG_GATTS_SEND_SERVICE_CHANGE_MODE 0
|
||||
#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1
|
||||
#define CONFIG_FATFS_TIMEOUT_MS 10000
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 10
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32
|
||||
#define CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS 1
|
||||
#define CONFIG_MBEDTLS_CCM_C 1
|
||||
#define CONFIG_SPI_MASTER_ISR_IN_IRAM 1
|
||||
@ -192,6 +198,7 @@
|
||||
#define CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT 20
|
||||
#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_XTENSA_IMPL 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BA_WIN 16
|
||||
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
|
||||
#define CONFIG_SPIFFS_USE_MTIME 1
|
||||
@ -212,6 +219,7 @@
|
||||
#define CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V 1
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000
|
||||
#define CONFIG_BROWNOUT_DET_LVL 0
|
||||
#define CONFIG_BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_PCM 1
|
||||
#define CONFIG_MBEDTLS_PEM_PARSE_C 1
|
||||
#define CONFIG_SPIFFS_GC_MAX_RUNS 10
|
||||
#define CONFIG_ARDUINO_RUN_CORE1 1
|
||||
@ -234,6 +242,7 @@
|
||||
#define CONFIG_ESP32_XTAL_FREQ 0
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 0
|
||||
#define CONFIG_D2WD_PSRAM_CS_IO 10
|
||||
#define CONFIG_MBEDTLS_TLS_ENABLED 1
|
||||
#define CONFIG_LWIP_MAX_RAW_PCBS 16
|
||||
#define CONFIG_SMP_ENABLE 1
|
||||
@ -273,7 +282,9 @@
|
||||
#define CONFIG_PPP_PAP_SUPPORT 1
|
||||
#define CONFIG_MBEDTLS_TLS_CLIENT 1
|
||||
#define CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI 1
|
||||
#define CONFIG_BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_EFF 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_D0WD_PSRAM_CLK_IO 17
|
||||
#define CONFIG_SW_COEXIST_PREFERENCE_BALANCE 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
|
@ -1,20 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef float fptp_t;
|
||||
typedef uint8_t uc_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DL_C_IMPL = 0,
|
||||
DL_XTENSA_IMPL = 1
|
||||
} dl_conv_mode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
INPUT_UINT8 = 0,
|
||||
INPUT_FLOAT = 1,
|
||||
} dl_op_type;
|
||||
DL_SUCCESS = 0,
|
||||
DL_FAIL = 1,
|
||||
} dl_error_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -53,9 +52,7 @@ typedef struct
|
||||
int stride_x;
|
||||
int stride_y;
|
||||
dl_padding_type padding;
|
||||
dl_conv_mode mode;
|
||||
dl_op_type type;
|
||||
} dl_matrix3d_conv_config_t;
|
||||
} dl_matrix3d_mobilenet_config_t;
|
||||
|
||||
/*
|
||||
* @brief Allocate a 3D matrix with float items, the access sequence is NHWC
|
||||
@ -93,7 +90,6 @@ void dl_matrix3d_free(dl_matrix3d_t *m);
|
||||
*/
|
||||
void dl_matrix3du_free(dl_matrix3du_t *m);
|
||||
|
||||
|
||||
/*
|
||||
* @brief Dot product with a vector and matrix
|
||||
*
|
||||
@ -101,24 +97,7 @@ void dl_matrix3du_free(dl_matrix3du_t *m);
|
||||
* @param in input vector
|
||||
* @param f filter matrix
|
||||
*/
|
||||
void dl_matrix3d_dot_product(dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f);
|
||||
|
||||
/**
|
||||
* @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d
|
||||
*
|
||||
* @param in Floating point input matrix3d
|
||||
* @param clip If value is higher than this, it will be clipped to this value
|
||||
*/
|
||||
void dl_matrix3d_relu(dl_matrix3d_t *m, fptp_t clip);
|
||||
|
||||
/**
|
||||
* @brief Do a leaky relu (Rectifier Linear Unit) operation, update the input matrix3d
|
||||
*
|
||||
* @param in Floating point input matrix3d
|
||||
* @param clip If value is higher than this, it will be clipped to this value
|
||||
* @param alpha If value is less than zero, it will be updated by multiplying this factor
|
||||
*/
|
||||
void dl_matrix3d_leaky_relu(dl_matrix3d_t *m, fptp_t clip, fptp_t alpha);
|
||||
void dl_matrix3dff_dot_product(dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f);
|
||||
|
||||
/**
|
||||
* @brief Do a softmax operation on a matrix3d
|
||||
@ -127,18 +106,6 @@ void dl_matrix3d_leaky_relu(dl_matrix3d_t *m, fptp_t clip, fptp_t alpha);
|
||||
*/
|
||||
void dl_matrix3d_softmax(dl_matrix3d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Do a general fully connected layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d, size is (1, w, 1, 1)
|
||||
* @param filter Weights of the neurons, size is (1, w, h, 1)
|
||||
* @param bias Bias for the fc layer, size is (1, 1, 1, h)
|
||||
* @return The result of fc layer, size is (1, 1, 1, h)
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_fc(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias);
|
||||
|
||||
/**
|
||||
* @brief Copy a range of float items from an existing matrix to a preallocated matrix
|
||||
*
|
||||
@ -173,9 +140,6 @@ void dl_matrix3du_slice_copy(dl_matrix3du_t *dst,
|
||||
int w,
|
||||
int h);
|
||||
|
||||
|
||||
void dl_matrix3d_conv_1x1 (dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f);
|
||||
|
||||
/**
|
||||
* @brief Do a general CNN layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
@ -197,11 +161,6 @@ dl_matrix3d_t *dl_matrix3d_conv(dl_matrix3d_t *in,
|
||||
int padding,
|
||||
int mode);
|
||||
|
||||
void dl_matrix3d_conv_3x3_normal (dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *f,
|
||||
int step_x,
|
||||
int step_y);
|
||||
/**
|
||||
* @brief Do a general CNN layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
@ -215,57 +174,6 @@ void dl_matrix3d_conv_3x3_normal (dl_matrix3d_t *out,
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3du_conv(dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding,
|
||||
int mode);
|
||||
|
||||
/**
|
||||
* @brief Do a depthwise CNN layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d
|
||||
* @param filter Weights of the neurons
|
||||
* @param stride_x The step length of the convolution window in x(width) direction
|
||||
* @param stride_y The step length of the convolution window in y(height) direction
|
||||
* @param padding One of VALID or SAME
|
||||
* @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of depthwise CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_depthwise_conv(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding,
|
||||
int mode);
|
||||
|
||||
void dl_matrix3d_depthwise_conv_3x3_normal(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *f,
|
||||
int step_x,
|
||||
int step_y);
|
||||
/**
|
||||
* @brief Do a mobilenet block forward, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d
|
||||
* @param filter Weights of the neurons
|
||||
* @param stride_x The step length of the convolution window in x(width) direction
|
||||
* @param stride_y The step length of the convolution window in y(height) direction
|
||||
* @param padding One of VALID or SAME
|
||||
* @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of depthwise CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_mobilenet(void *in,
|
||||
dl_matrix3d_t *dilate,
|
||||
dl_matrix3d_t *depthwise,
|
||||
dl_matrix3d_t *compress,
|
||||
dl_matrix3d_t *bias,
|
||||
dl_matrix3d_t *prelu,
|
||||
dl_matrix3d_conv_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Do a global average pooling layer pass, dimension is (number, width, height, channel)
|
||||
@ -297,13 +205,6 @@ void dl_matrix3d_batch_normalize(dl_matrix3d_t *m,
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_add(dl_matrix3d_t *in_1, dl_matrix3d_t *in_2);
|
||||
|
||||
/**
|
||||
* @brief Do a standard relu operation, update the input matrix3d
|
||||
*
|
||||
* @param m Floating point input matrix3d
|
||||
*/
|
||||
void dl_matrix3d_relu_std(dl_matrix3d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Concatenate the channels of two matrix3ds into a new matrix3d
|
||||
*
|
||||
@ -372,7 +273,7 @@ dl_matrix3d_t *dl_matrix3d_concat_8(dl_matrix3d_t *in_1,
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of a mobilefacenet block
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_mobilefaceblock(void *in,
|
||||
dl_matrix3d_t *dl_matrix3d_mobilefaceblock(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *pw,
|
||||
dl_matrix3d_t *pw_bn_scale,
|
||||
dl_matrix3d_t *pw_bn_offset,
|
||||
@ -410,7 +311,7 @@ dl_matrix3d_t *dl_matrix3d_mobilefaceblock(void *in,
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of a mobilefacenet block
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3d_mobilefaceblock_split(void *in,
|
||||
dl_matrix3d_t *dl_matrix3d_mobilefaceblock_split(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *pw_1,
|
||||
dl_matrix3d_t *pw_2,
|
||||
dl_matrix3d_t *pw_bn_scale,
|
||||
@ -427,23 +328,200 @@ dl_matrix3d_t *dl_matrix3d_mobilefaceblock_split(void *in,
|
||||
int padding,
|
||||
int mode,
|
||||
int shortcut);
|
||||
/**
|
||||
* @brief Print the matrix3d items
|
||||
*
|
||||
* @param m dl_matrix3d_t to be printed
|
||||
* @param message name of matrix
|
||||
*/
|
||||
void dl_matrix3d_print(dl_matrix3d_t *m, char *message);
|
||||
|
||||
/**
|
||||
* @brief Print the matrix3du items
|
||||
*
|
||||
* @param m dl_matrix3du_t to be printed
|
||||
* @param message name of matrix
|
||||
*/
|
||||
void dl_matrix3du_print(dl_matrix3du_t *m, char *message);
|
||||
|
||||
|
||||
void dl_matrix3d_init_bias (dl_matrix3d_t *out, dl_matrix3d_t *bias);
|
||||
void dl_matrix3d_init_bias(dl_matrix3d_t *out, dl_matrix3d_t *bias);
|
||||
|
||||
void dl_matrix3d_multiply(dl_matrix3d_t *out, dl_matrix3d_t *in1, dl_matrix3d_t *in2);
|
||||
|
||||
//
|
||||
// Activation
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Do a standard relu operation, update the input matrix3d
|
||||
*
|
||||
* @param m Floating point input matrix3d
|
||||
*/
|
||||
void dl_matrix3d_relu(dl_matrix3d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d
|
||||
*
|
||||
* @param in Floating point input matrix3d
|
||||
* @param clip If value is higher than this, it will be clipped to this value
|
||||
*/
|
||||
void dl_matrix3d_relu_clip(dl_matrix3d_t *m, fptp_t clip);
|
||||
|
||||
/**
|
||||
* @brief Do a Prelu (Rectifier Linear Unit) operation, update the input matrix3d
|
||||
*
|
||||
* @param in Floating point input matrix3d
|
||||
* @param alpha If value is less than zero, it will be updated by multiplying this factor
|
||||
*/
|
||||
void dl_matrix3d_p_relu(dl_matrix3d_t *in, dl_matrix3d_t *alpha);
|
||||
|
||||
/**
|
||||
* @brief Do a leaky relu (Rectifier Linear Unit) operation, update the input matrix3d
|
||||
*
|
||||
* @param in Floating point input matrix3d
|
||||
* @param alpha If value is less than zero, it will be updated by multiplying this factor
|
||||
*/
|
||||
void dl_matrix3d_leaky_relu(dl_matrix3d_t *m, fptp_t alpha);
|
||||
|
||||
//
|
||||
// Conv 1x1
|
||||
//
|
||||
void dl_matrix3dff_conv_1x1(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter);
|
||||
|
||||
void dl_matrix3dff_conv_1x1_with_bias(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias);
|
||||
|
||||
void dl_matrix3duf_conv_1x1(dl_matrix3d_t *out,
|
||||
dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *filter);
|
||||
|
||||
void dl_matrix3duf_conv_1x1_with_bias(dl_matrix3d_t *out,
|
||||
dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias);
|
||||
|
||||
//
|
||||
// Conv 3x3
|
||||
//
|
||||
void dl_matrix3dff_conv_3x3_op(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *f,
|
||||
int step_x,
|
||||
int step_y);
|
||||
|
||||
dl_matrix3d_t *dl_matrix3dff_conv_3x3(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding);
|
||||
|
||||
//
|
||||
// Conv Common
|
||||
//
|
||||
|
||||
dl_matrix3d_t *dl_matrix3duf_conv_common(dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding);
|
||||
|
||||
//
|
||||
// Depthwise 3x3
|
||||
//
|
||||
|
||||
dl_matrix3d_t *dl_matrix3dff_depthwise_conv_3x3(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding);
|
||||
|
||||
dl_matrix3d_t *dl_matrix3duf_depthwise_conv_3x3(dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding);
|
||||
|
||||
void dl_matrix3dff_depthwise_conv_3x3_op(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *f,
|
||||
int step_x,
|
||||
int step_y);
|
||||
|
||||
//
|
||||
// Depthwise Common
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Do a depthwise CNN layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d
|
||||
* @param filter Weights of the neurons
|
||||
* @param stride_x The step length of the convolution window in x(width) direction
|
||||
* @param stride_y The step length of the convolution window in y(height) direction
|
||||
* @param padding One of VALID or SAME
|
||||
* @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of depthwise CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3dff_depthwise_conv_common(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding);
|
||||
|
||||
//
|
||||
// FC
|
||||
//
|
||||
/**
|
||||
* @brief Do a general fully connected layer pass, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d, size is (1, w, 1, 1)
|
||||
* @param filter Weights of the neurons, size is (1, w, h, 1)
|
||||
* @param bias Bias for the fc layer, size is (1, 1, 1, h)
|
||||
* @return The result of fc layer, size is (1, 1, 1, h)
|
||||
*/
|
||||
void dl_matrix3dff_fc(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter);
|
||||
|
||||
void dl_matrix3dff_fc_with_bias(dl_matrix3d_t *out,
|
||||
dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *filter,
|
||||
dl_matrix3d_t *bias);
|
||||
|
||||
//
|
||||
// Mobilenet
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Do a mobilenet block forward, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3d
|
||||
* @param filter Weights of the neurons
|
||||
* @param stride_x The step length of the convolution window in x(width) direction
|
||||
* @param stride_y The step length of the convolution window in y(height) direction
|
||||
* @param padding One of VALID or SAME
|
||||
* @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of depthwise CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3dff_mobilenet(dl_matrix3d_t *in,
|
||||
dl_matrix3d_t *dilate_filter,
|
||||
dl_matrix3d_t *dilate_prelu,
|
||||
dl_matrix3d_t *depthwise_filter,
|
||||
dl_matrix3d_t *depthwise_prelu,
|
||||
dl_matrix3d_t *compress_filter,
|
||||
dl_matrix3d_t *bias,
|
||||
dl_matrix3d_mobilenet_config_t config);
|
||||
|
||||
/**
|
||||
* @brief Do a mobilenet block forward, dimension is (number, width, height, channel)
|
||||
*
|
||||
* @param in Input matrix3du
|
||||
* @param filter Weights of the neurons
|
||||
* @param stride_x The step length of the convolution window in x(width) direction
|
||||
* @param stride_y The step length of the convolution window in y(height) direction
|
||||
* @param padding One of VALID or SAME
|
||||
* @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect
|
||||
* If ESP_PLATFORM is not defined, this value is not used. Default is 0
|
||||
* @return The result of depthwise CNN layer
|
||||
*/
|
||||
dl_matrix3d_t *dl_matrix3duf_mobilenet(dl_matrix3du_t *in,
|
||||
dl_matrix3d_t *dilate_filter,
|
||||
dl_matrix3d_t *dilate_prelu,
|
||||
dl_matrix3d_t *depthwise_filter,
|
||||
dl_matrix3d_t *depthwise_prelu,
|
||||
dl_matrix3d_t *compress_filter,
|
||||
dl_matrix3d_t *bias,
|
||||
dl_matrix3d_mobilenet_config_t config);
|
||||
|
@ -20,12 +20,38 @@ typedef struct
|
||||
/******* fix end *******/
|
||||
} dl_matrix3dq_t;
|
||||
|
||||
#ifndef DL_QTP_SHIFT
|
||||
#define DL_QTP_SHIFT 15
|
||||
#define DL_QTP_RANGE ((1<<DL_QTP_SHIFT)-1)
|
||||
//#define DL_ITMQ(m, x, y) m->itemq[(y)+(x)*m->stride]
|
||||
#define DL_ITMQ(m, x, y) m->itemq[(y) + (x)*m->stride]
|
||||
#define DL_QTP_RANGE ((1 << DL_QTP_SHIFT) - 1)
|
||||
#define DL_QTP_MAX 32767
|
||||
#define DL_QTP_MIN -32768
|
||||
|
||||
#define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null
|
||||
|
||||
#define DL_SHIFT_AUTO 32
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DL_C_IMPL = 0,
|
||||
DL_XTENSA_IMPL = 1
|
||||
} dl_conv_mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int stride_x;
|
||||
int stride_y;
|
||||
dl_padding_type padding;
|
||||
dl_conv_mode mode;
|
||||
int dilate_exponent;
|
||||
int depthwise_exponent;
|
||||
int compress_exponent;
|
||||
} dl_matrix3dq_mobilenet_config_t;
|
||||
|
||||
//
|
||||
// Utility
|
||||
//
|
||||
|
||||
/*
|
||||
* @brief Allocate a 3D matrix
|
||||
@ -49,9 +75,6 @@ void dl_matrix3dq_free(dl_matrix3dq_t *m);
|
||||
* @param m Matrix to zero
|
||||
*/
|
||||
|
||||
dl_matrix3d_t *dl_matrix3d_from_matrixq(dl_matrix3dq_t *m);
|
||||
dl_matrix3dq_t *dl_matrixq_from_matrix3d_qmf(dl_matrix3d_t *m,int exponent);
|
||||
dl_matrix3dq_t *dl_matrixq_from_matrix3d(dl_matrix3d_t *m);
|
||||
/**
|
||||
* @brief Copy a range of items from an existing matrix to a preallocated matrix
|
||||
*
|
||||
@ -62,8 +85,143 @@ void dl_matrix3dq_free(dl_matrix3dq_t *m);
|
||||
* @param h Height of the resulting matrix
|
||||
* @return The resulting slice matrix
|
||||
*/
|
||||
void dl_matrix3dq_slice_copy (dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, int y, int w, int h);
|
||||
void dl_matrix3dq_slice_copy(dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, int y, int w, int h);
|
||||
|
||||
dl_matrix3d_t *dl_matrix3d_from_matrixq(dl_matrix3dq_t *m);
|
||||
|
||||
dl_matrix3dq_t *dl_matrixq_from_matrix3d_qmf(dl_matrix3d_t *m, int exponent);
|
||||
|
||||
dl_matrix3dq_t *dl_matrixq_from_matrix3d(dl_matrix3d_t *m);
|
||||
|
||||
qtp_t dl_matrix3dq_quant_range_exceeded_checking(int64_t value, char *location);
|
||||
|
||||
void dl_matrix3dq_shift_exponent(dl_matrix3dq_t *out, dl_matrix3dq_t *in, int exponent);
|
||||
|
||||
void dl_matrix3dq_batch_normalize(dl_matrix3dq_t *m, dl_matrix3dq_t *scale, dl_matrix3dq_t *offset);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_add(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent);
|
||||
|
||||
//
|
||||
// Activation
|
||||
//
|
||||
void dl_matrix3dq_relu(dl_matrix3dq_t *in);
|
||||
|
||||
void dl_matrix3dq_relu_clip(dl_matrix3dq_t *in, fptp_t clip);
|
||||
|
||||
void dl_matrix3dq_leaky_relu(dl_matrix3dq_t *in, fptp_t alpha, fptp_t clip);
|
||||
|
||||
void dl_matrix3dq_p_relu(dl_matrix3dq_t *in, dl_matrix3dq_t *alpha);
|
||||
|
||||
//
|
||||
// Concat
|
||||
//
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat(dl_matrix3dq_t *in_1,
|
||||
dl_matrix3dq_t *in_2);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat_4(dl_matrix3dq_t *in_1,
|
||||
dl_matrix3dq_t *in_2,
|
||||
dl_matrix3dq_t *in_3,
|
||||
dl_matrix3dq_t *in_4);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat_8(dl_matrix3dq_t *in_1,
|
||||
dl_matrix3dq_t *in_2,
|
||||
dl_matrix3dq_t *in_3,
|
||||
dl_matrix3dq_t *in_4,
|
||||
dl_matrix3dq_t *in_5,
|
||||
dl_matrix3dq_t *in_6,
|
||||
dl_matrix3dq_t *in_7,
|
||||
dl_matrix3dq_t *in_8);
|
||||
|
||||
//
|
||||
// Conv 1x1
|
||||
//
|
||||
void dl_matrix3dqq_conv_1x1(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3dqq_conv_1x1_with_relu(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3dqq_conv_1x1_with_bias(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_conv_mode mode,
|
||||
char *name);
|
||||
|
||||
void dl_matrix3dqq_conv_1x1_with_prelu(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *prelu,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3dqq_conv_1x1_with_bias_relu(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3duq_conv_1x1(dl_matrix3dq_t *out,
|
||||
dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3duq_conv_1x1_with_bias(dl_matrix3dq_t *out,
|
||||
dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_conv_mode mode);
|
||||
|
||||
//
|
||||
// Conv 3x3
|
||||
//
|
||||
void dl_matrix3dqq_conv_3x3_op(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
int stride_x,
|
||||
int stride_y);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_conv_3x3(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
dl_matrix3dq_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
int relu);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
char *name);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias_prelu(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_matrix3dq_t *prelu,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
char *name);
|
||||
|
||||
//
|
||||
// Conv common
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Do a general CNN layer pass, dimension is (number, width, height, channel)
|
||||
@ -78,67 +236,213 @@ void dl_matrix3dq_slice_copy (dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, i
|
||||
* If ESP_PLATFORM is not defined, this value is not used.
|
||||
* @return The result of CNN layer.
|
||||
*/
|
||||
dl_matrix3dq_t *dl_matrix3dq_fc (dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, int exponent,int mode);
|
||||
dl_matrix3dq_t *dl_matrix3dqq_conv_common(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
dl_conv_mode mode);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_conv (dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias,
|
||||
int stride_x, int stride_y, int padding, int exponent, int mode);
|
||||
dl_matrix3dq_t *dl_matrix3dq_conv_normal (dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias,
|
||||
int stride_x, int stride_y, int padding, int exponent, int mode);
|
||||
dl_matrix3dq_t *dl_matrix3duq_conv_common(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3dq_conv_1x1 (dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *f, dl_conv_mode mode);
|
||||
//
|
||||
// Depthwise 3x3
|
||||
//
|
||||
dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_3x3(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
|
||||
void dl_matrix3dq_conv_3x3_normal (dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
|
||||
#if CONFIG_DEVELOPING_CODE
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_2(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_3(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
#endif
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
dl_matrix3dq_t *bias,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
int relu);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_prelu(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *prelu,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3s1_with_bias(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
int relu);
|
||||
|
||||
//
|
||||
// Depthwise Common
|
||||
//
|
||||
#if CONFIG_DEVELOPING_CODE
|
||||
dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_common(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
dl_conv_mode mode);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_common(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
int exponent,
|
||||
dl_conv_mode mode);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Dot Product
|
||||
//
|
||||
|
||||
void dl_matrix3dqq_dot_product(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
int step_x,
|
||||
int step_y);
|
||||
dl_matrix3dq_t *dl_matrix3dq_conv_3x3_with_bn (dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
dl_matrix3dq_t *scale,
|
||||
dl_matrix3dq_t *offset,
|
||||
int step_x,
|
||||
int step_y,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_conv_mode mode);
|
||||
|
||||
//
|
||||
// FC
|
||||
//
|
||||
|
||||
void dl_matrix3dqq_fc(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_conv_mode mode);
|
||||
|
||||
void dl_matrix3dqq_fc_with_bias(dl_matrix3dq_t *out,
|
||||
dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *filter,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_conv_mode mode,
|
||||
char *name);
|
||||
|
||||
//
|
||||
// Mobilefaceblock
|
||||
//
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_split(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *pw_1,
|
||||
dl_matrix3dq_t *pw_2,
|
||||
dl_matrix3dq_t *pw_bias,
|
||||
dl_matrix3dq_t *dw,
|
||||
dl_matrix3dq_t *dw_bias,
|
||||
dl_matrix3dq_t *pw_linear_1,
|
||||
dl_matrix3dq_t *pw_linear_2,
|
||||
dl_matrix3dq_t *pw_linear_bias,
|
||||
int pw_exponent,
|
||||
int dw_exponent,
|
||||
int pw_linear_exponent,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
dl_conv_mode mode,
|
||||
int shortcut);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *pw,
|
||||
dl_matrix3dq_t *pw_bias,
|
||||
dl_matrix3dq_t *dw,
|
||||
dl_matrix3dq_t *dw_bias,
|
||||
dl_matrix3dq_t *pw_linear,
|
||||
dl_matrix3dq_t *pw_linear_bias,
|
||||
int pw_exponent,
|
||||
int dw_exponent,
|
||||
int pw_linear_exponent,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
dl_padding_type padding,
|
||||
dl_conv_mode mode,
|
||||
int shortcut);
|
||||
|
||||
//
|
||||
// Mobilenet
|
||||
//
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dqq_mobilenet(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *dilate,
|
||||
dl_matrix3dq_t *dilate_prelu,
|
||||
dl_matrix3dq_t *depthwise,
|
||||
dl_matrix3dq_t *depth_prelu,
|
||||
dl_matrix3dq_t *compress,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_matrix3dq_mobilenet_config_t config,
|
||||
char *name);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3duq_mobilenet(dl_matrix3du_t *in,
|
||||
dl_matrix3dq_t *dilate,
|
||||
dl_matrix3dq_t *dilate_prelu,
|
||||
dl_matrix3dq_t *depthwise,
|
||||
dl_matrix3dq_t *depth_prelu,
|
||||
dl_matrix3dq_t *compress,
|
||||
dl_matrix3dq_t *bias,
|
||||
dl_matrix3dq_mobilenet_config_t config,
|
||||
char *name);
|
||||
|
||||
//
|
||||
// Padding
|
||||
//
|
||||
|
||||
dl_error_type dl_matrix3dqq_padding(dl_matrix3dq_t **padded_in,
|
||||
dl_matrix3dq_t **out,
|
||||
dl_matrix3dq_t *in,
|
||||
int out_c,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding,
|
||||
int exponent,
|
||||
int relu);
|
||||
/**
|
||||
* @brief Print the matrix3d items
|
||||
*
|
||||
* @param m dl_matrix3d_t to be printed
|
||||
* @param message name of matrix
|
||||
*/
|
||||
void dl_matrix3dq_print (dl_matrix3dq_t *m, char *message);
|
||||
int exponent);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_depthwise_conv (dl_matrix3dq_t *in, dl_matrix3dq_t *filter,
|
||||
int stride_x, int stride_y, int padding, int exponent, int mode);
|
||||
dl_matrix3dq_t *dl_matrix3dq_depthwise_conv_3x3_with_bn(dl_matrix3dq_t *in,
|
||||
dl_matrix3dq_t *f,
|
||||
dl_matrix3dq_t *scale,
|
||||
dl_matrix3dq_t *offset,
|
||||
int step_x,
|
||||
int step_y,
|
||||
dl_error_type dl_matrix3duq_padding(dl_matrix3du_t **padded_in,
|
||||
dl_matrix3dq_t **out,
|
||||
dl_matrix3du_t *in,
|
||||
int out_c,
|
||||
int stride_x,
|
||||
int stride_y,
|
||||
int padding,
|
||||
int exponent,
|
||||
int relu);
|
||||
int exponent);
|
||||
|
||||
void dl_matrix3dq_relu (dl_matrix3dq_t *m, fptp_t clip);
|
||||
//
|
||||
// Pooling
|
||||
//
|
||||
|
||||
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_global_pool (dl_matrix3dq_t *in);
|
||||
void dl_matrix3dq_batch_normalize (dl_matrix3dq_t *m, dl_matrix3dq_t *scale, dl_matrix3dq_t *offset);
|
||||
dl_matrix3dq_t *dl_matrix3dq_add (dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent);
|
||||
void dl_matrix3dq_relu_std (dl_matrix3dq_t *m);
|
||||
dl_matrix3dq_t *dl_matrix3dq_mobilefaceblock (void *in, dl_matrix3dq_t *pw, dl_matrix3dq_t *pw_bn_scale,dl_matrix3dq_t *pw_bn_offset,
|
||||
dl_matrix3dq_t *dw, dl_matrix3dq_t *dw_bn_scale,dl_matrix3dq_t *dw_bn_offset,
|
||||
dl_matrix3dq_t *pw_linear, dl_matrix3dq_t *pw_linear_bn_scale,dl_matrix3dq_t *pw_linear_bn_offset,
|
||||
int pw_exponent,int dw_exponent,int pw_linear_exponent,int stride_x, int stride_y, int padding, int mode, int shortcut);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2);
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat_4(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, dl_matrix3dq_t *in_3, dl_matrix3dq_t *in_4);
|
||||
dl_matrix3dq_t *dl_matrix3dq_concat_8(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, dl_matrix3dq_t *in_3, dl_matrix3dq_t *in_4, dl_matrix3dq_t *in_5, dl_matrix3dq_t *in_6, dl_matrix3dq_t *in_7, dl_matrix3dq_t *in_8);
|
||||
|
||||
dl_matrix3dq_t *dl_matrix3dq_mobilefaceblock_split (void *in, dl_matrix3dq_t *pw_1, dl_matrix3dq_t *pw_2, dl_matrix3dq_t *pw_bn_scale,dl_matrix3dq_t *pw_bn_offset,
|
||||
dl_matrix3dq_t *dw, dl_matrix3dq_t *dw_bn_scale,dl_matrix3dq_t *dw_bn_offset,
|
||||
dl_matrix3dq_t *pw_linear_1, dl_matrix3dq_t *pw_linear_2, dl_matrix3dq_t *pw_linear_bn_scale,dl_matrix3dq_t *pw_linear_bn_offset,
|
||||
int pw_exponent,int dw_exponent,int pw_linear_exponent,int stride_x, int stride_y, int padding, int mode, int shortcut);
|
||||
dl_matrix3dq_t *dl_matrix3dq_global_pool(dl_matrix3dq_t *in);
|
||||
|
@ -40,13 +40,27 @@ extern "C"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float min_face; /// the minimum size of face can be detected
|
||||
float pyramid; /// the pyramid scale
|
||||
int pyramid_times; /// the pyramid resizing times
|
||||
threshold_config_t p_threshold; /// score, nms and candidate threshold of pnet
|
||||
threshold_config_t r_threshold; /// score, nms and candidate threshold of rnet
|
||||
threshold_config_t o_threshold; /// score, nms and candidate threshold of onet
|
||||
mtmn_resize_type type; /// image resize type. 'pyramid' will lose efficacy, when 'type'==FAST.
|
||||
float score; /// score threshold for filter candidates by score
|
||||
float nms; /// nms threshold for nms process
|
||||
int candidate_number; /// candidate number limitation for each net
|
||||
} threshold_config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int w; /// net width
|
||||
int h; /// net height
|
||||
threshold_config_t threshold; /// threshold of net
|
||||
} net_config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float min_face; /// The minimum size of a detectable face
|
||||
float pyramid; /// The scale of the gradient scaling for the input images
|
||||
int pyramid_times; /// The pyramid resizing times
|
||||
threshold_config_t p_threshold; /// The thresholds for P-Net. For details, see the definition of threshold_config_t
|
||||
threshold_config_t r_threshold; /// The thresholds for R-Net. For details, see the definition of threshold_config_t
|
||||
threshold_config_t o_threshold; /// The thresholds for O-Net. For details, see the definition of threshold_config_t
|
||||
mtmn_resize_type type; /// The image resize type. 'pyramid' will lose efficacy, when 'type'==FAST.
|
||||
} mtmn_config_t;
|
||||
|
||||
static inline mtmn_config_t mtmn_init_config()
|
||||
|
@ -89,6 +89,12 @@ extern "C"
|
||||
dl_matrix3du_t *src,
|
||||
dl_matrix3du_t *dest);
|
||||
|
||||
/**
|
||||
* @brief Run the face recognition model to get the face feature
|
||||
*
|
||||
* @param aligned_face A 56x56x3 image, the variable need to do align_face first
|
||||
* @return face_id A 512 vector, size (1, 1, 1, 512)
|
||||
*/
|
||||
dl_matrix3d_t *get_face_id(dl_matrix3du_t *aligned_face);
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,10 @@ extern "C"
|
||||
*/
|
||||
dl_matrix3dq_t *frmn_q(dl_matrix3dq_t *in, dl_conv_mode mode);
|
||||
|
||||
dl_matrix3dq_t *frmn2_q(dl_matrix3dq_t *in, dl_conv_mode mode);
|
||||
dl_matrix3dq_t *frmn2p_q(dl_matrix3dq_t *in, dl_conv_mode mode);
|
||||
dl_matrix3dq_t *frmn2c_q(dl_matrix3dq_t *in, dl_conv_mode mode);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -28,20 +28,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "dl_lib_matrix3d.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float score; /// score threshold for filter candidates by score
|
||||
float nms; /// nms threshold for nms process
|
||||
int candidate_number; /// candidate number limitation for each net
|
||||
} threshold_config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int w; /// net width
|
||||
int h; /// net height
|
||||
threshold_config_t threshold; /// threshold of net
|
||||
} net_config_t;
|
||||
#include "dl_lib_matrix3dq.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -51,30 +38,89 @@ extern "C"
|
||||
} mtmn_net_t;
|
||||
|
||||
/**
|
||||
* @brief Forward the pnet process, coarse detection
|
||||
* @brief Free a mtmn_net_t
|
||||
*
|
||||
* @param p A mtmn_net_t pointer
|
||||
*/
|
||||
void mtmn_net_t_free(mtmn_net_t *p);
|
||||
|
||||
/**
|
||||
* @brief Forward the pnet process, coarse detection. Calculate in float.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format, size is 320x240
|
||||
* @return Scores for every pixel, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *pnet(dl_matrix3du_t *in);
|
||||
mtmn_net_t *pnet_lite_f(dl_matrix3du_t *in);
|
||||
|
||||
/**
|
||||
* @brief Forward the rnet process, fine determine the boxes from pnet
|
||||
* @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in float.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *rnet_with_score_verify(dl_matrix3du_t *in, float threshold);
|
||||
mtmn_net_t *rnet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold);
|
||||
|
||||
/**
|
||||
* @brief Forward the onet process, fine determine the boxes from rnet
|
||||
* @brief Forward the onet process, fine determine the boxes from rnet. Calculate in float.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, box offset, and landmark with respect.
|
||||
*/
|
||||
mtmn_net_t *onet_with_score_verify(dl_matrix3du_t *in, float threshold);
|
||||
mtmn_net_t *onet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold);
|
||||
|
||||
/**
|
||||
* @brief Forward the pnet process, coarse detection. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format, size is 320x240
|
||||
* @return Scores for every pixel, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *pnet_lite_q(dl_matrix3du_t *in, dl_conv_mode mode);
|
||||
|
||||
/**
|
||||
* @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *rnet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode);
|
||||
|
||||
/**
|
||||
* @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, box offset, and landmark with respect.
|
||||
*/
|
||||
mtmn_net_t *onet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode);
|
||||
|
||||
/**
|
||||
* @brief Forward the pnet process, coarse detection. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format, size is 320x240
|
||||
* @return Scores for every pixel, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *pnet_heavy_q(dl_matrix3du_t *in, dl_conv_mode mode);
|
||||
|
||||
/**
|
||||
* @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, and box offset with respect.
|
||||
*/
|
||||
mtmn_net_t *rnet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode);
|
||||
|
||||
/**
|
||||
* @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization.
|
||||
*
|
||||
* @param in Image matrix, rgb888 format
|
||||
* @param threshold Score threshold to detect human face
|
||||
* @return Scores for every box, box offset, and landmark with respect.
|
||||
*/
|
||||
mtmn_net_t *onet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ typedef enum {
|
||||
SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */
|
||||
SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */
|
||||
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
|
||||
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
||||
|
@ -1479,6 +1479,13 @@ esp_err_t esp_mesh_switch_channel(const uint8_t *new_bssid, int csa_newchan, int
|
||||
*/
|
||||
esp_err_t esp_mesh_get_router_bssid(uint8_t *router_bssid);
|
||||
|
||||
/**
|
||||
* @brief Get the TSF time
|
||||
*
|
||||
* @return the TSF time
|
||||
*/
|
||||
int64_t esp_mesh_get_tsf_time(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
24
tools/sdk/include/esp32/esp_private/esp_wifi_private.h
Normal file
24
tools/sdk/include/esp32/esp_private/esp_wifi_private.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2015-2019 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.
|
||||
|
||||
#ifndef _ESP_WIFI_PRIVATE_H
|
||||
#define _ESP_WIFI_PRIVATE_H
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "rom/queue.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
#include "esp_wifi_os_adapter.h"
|
||||
|
||||
#endif /* _ESP_WIFI_PRIVATE_H */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user