diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e68626bc9d3..63d88b10f38 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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? diff --git a/.github/stale.yml b/.github/stale.yml index 3ffbe87f2b2..e969fcba5b1 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -33,17 +33,17 @@ 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 + [STALE_SET] 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. +unmarkComment: > + [STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. # Comment to post when closing a stale Issue or Pull Request. closeComment: > - This stale issue has been automatically closed. Thank you for your contributions. + [STALE_DEL] 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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..baa6a22041c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,376 @@ +name: ESP32 Arduino CI + +on: + push: + branches: + - master + - release/* + 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/ci/check-cmakelists.sh + + - name: Install Arduino IDE + env: + #ESP32_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: Install Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/prep-arduino-ide.sh + - name: Test Arduino IDE + env: + TRAVIS_BUILD_DIR: ${{ github.workspace }} + run: ./tools/ci/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: 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/ci/prep-platformio.sh + - name: Test PlatformIO + run: ./tools/ci/test-platformio.sh diff --git a/.travis.yml b/.travis.yml index 9225828b15e..906beec981d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ sudo: false language: python -python: - - "2.7" os: - linux @@ -10,22 +8,55 @@ os: git: depth: false -env: - global: - - secure: "l/4Dt+KQ/mACtGAHDUsPr66fUte840PZoQ4xpPikqWZI0uARu4l+Ym7+sHinnT6fBqrj8AJeBYGz4nFa8NK4LutZn9mSD40w+sxl0wSV4oHV8rzKe3Cd8+sMG3+o33yWoikMNjSvqa73Q0rm+SgrlInNdZbuAyixL+a2alaWSnGPm4F2xwUGj+S33TOy5P/Xp77CYtCV5S8vzyk/eEdNhoF0GYePJVdfuzCOUjXMyT5OWxORkzzQ7Hnn/Ka/RDfV8Si4HgujLQBrK5q6iPnNBFqBSqilYBepSMn4opnOBpIm0SCgePz7XQEFC83buA7GUcnCnfg38bf+dCwHaODf1d1PmqVRYt2QmfinexXtM4afAtL0iBUDtvrfnXHzwW9w82VeZhpbJSVh9DUQvB0IlsZeCz9J9PUBAi3N+SMX+9l+BomYwRUlPuKY+Ef2JKk9q6mxtUkky5R0daAlVxEhpVdQks1rT+T+NMoDMemxQ3SKEiqAHh6EgHecruszffmZ71uLX9MpERpew0qN+UFiafws+jkTjx+3yF9yut0Hf9sMbeAYzzkGzRqJTUEBJ6B29Cql8M0yRXCNN/8wuuTHhG8esstozga4ZQoIVrq7mEAgup376PTcNfr1+imbbWVQ7lJdYIuDe6OS5V3OX6np11vgK/DbhfyzvQv9Z1zAGnM=" - - REMOTE_URL=https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG - -script: - - bash $TRAVIS_BUILD_DIR/tools/build.sh +before_install: + - git submodule update --init --recursive + +stages: + - build + - deploy + +jobs: + include: + + - name: "Build Arduino 0" + if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) + stage: build + script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 0 4 -deploy: - provider: script - skip_cleanup: true - script: bash $TRAVIS_BUILD_DIR/tools/deploy.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease + - name: "Build Arduino 1" + if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) + stage: build + script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 1 4 - on: - tags: true + - name: "Build Arduino 2" + if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) + stage: build + script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 2 4 + - name: "Build Arduino 3" + if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) + stage: build + script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 3 4 + + - name: "Build PlatformIO" + if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) + stage: build + script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 4 4 + + - name: "Package & Deploy" + if: tag IS present + stage: deploy + env: + - secure: "l/4Dt+KQ/mACtGAHDUsPr66fUte840PZoQ4xpPikqWZI0uARu4l+Ym7+sHinnT6fBqrj8AJeBYGz4nFa8NK4LutZn9mSD40w+sxl0wSV4oHV8rzKe3Cd8+sMG3+o33yWoikMNjSvqa73Q0rm+SgrlInNdZbuAyixL+a2alaWSnGPm4F2xwUGj+S33TOy5P/Xp77CYtCV5S8vzyk/eEdNhoF0GYePJVdfuzCOUjXMyT5OWxORkzzQ7Hnn/Ka/RDfV8Si4HgujLQBrK5q6iPnNBFqBSqilYBepSMn4opnOBpIm0SCgePz7XQEFC83buA7GUcnCnfg38bf+dCwHaODf1d1PmqVRYt2QmfinexXtM4afAtL0iBUDtvrfnXHzwW9w82VeZhpbJSVh9DUQvB0IlsZeCz9J9PUBAi3N+SMX+9l+BomYwRUlPuKY+Ef2JKk9q6mxtUkky5R0daAlVxEhpVdQks1rT+T+NMoDMemxQ3SKEiqAHh6EgHecruszffmZ71uLX9MpERpew0qN+UFiafws+jkTjx+3yF9yut0Hf9sMbeAYzzkGzRqJTUEBJ6B29Cql8M0yRXCNN/8wuuTHhG8esstozga4ZQoIVrq7mEAgup376PTcNfr1+imbbWVQ7lJdYIuDe6OS5V3OX6np11vgK/DbhfyzvQv9Z1zAGnM=" + - REMOTE_URL=https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG + script: bash $TRAVIS_BUILD_DIR/tools/ci/build-release.sh -a$ESP32_GITHUB_TOKEN + before_deploy: git submodule update --init + deploy: + - provider: script + skip_cleanup: true + script: bash $TRAVIS_BUILD_DIR/tools/ci/deploy-release.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease + on: + tags: true notifications: email: diff --git a/boards.txt b/boards.txt index 0f2b1cdc988..1bd216ec70f 100644 --- a/boards.txt +++ b/boards.txt @@ -46,6 +46,7 @@ esp32.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FA 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.default_8MB.upload.maximum_size=3342336 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) @@ -68,6 +69,10 @@ esp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs esp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 esp32.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) esp32.menu.PartitionScheme.fatflash.build.partitions=ffat +esp32.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +esp32.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) +esp32.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +esp32.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 esp32.menu.CPUFreq.240=240MHz (WiFi/BT) esp32.menu.CPUFreq.240.build.f_cpu=240000000L @@ -114,7 +119,6 @@ esp32.menu.FlashSize.2M.build.flash_size=2MB esp32.menu.FlashSize.2M.build.partitions=minimal esp32.menu.FlashSize.16M=16MB (128Mb) esp32.menu.FlashSize.16M.build.flash_size=16MB -esp32.menu.FlashSize.16M.build.partitions=ffat esp32.menu.UploadSpeed.921600=921600 esp32.menu.UploadSpeed.921600.upload.speed=921600 @@ -364,7 +368,7 @@ magicbit.serial.disableRTS=true magicbit.build.mcu=esp32 magicbit.build.core=esp32 -magicbit.build.variant=esp32 +magicbit.build.variant=magicbit magicbit.build.board=ESP32_DEV magicbit.build.f_cpu=240000000L @@ -1187,7 +1191,7 @@ pocket_32.menu.UploadSpeed.512000.upload.speed=512000 ############################################################## -WeMosBat.name="WeMos" WiFi&Bluetooth Battery +WeMosBat.name=WeMos WiFi&Bluetooth Battery WeMosBat.upload.tool=esptool_py WeMosBat.upload.maximum_size=1310720 @@ -2329,6 +2333,7 @@ m5stack-fire.menu.PSRAM.disabled.build.defines= m5stack-fire.menu.PartitionScheme.default=Default (2 x 6.5 MB app, 3.6 MB SPIFFS) m5stack-fire.menu.PartitionScheme.default.build.partitions=default_16MB +m5stack-fire.menu.PartitionScheme.default.upload.maximum_size=6553600 m5stack-fire.menu.PartitionScheme.large_spiffs=Large SPIFFS (7 MB) m5stack-fire.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB m5stack-fire.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824 @@ -2758,6 +2763,7 @@ heltec_wifi_lora_32_V2.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix- heltec_wifi_lora_32_V2.menu.PartitionScheme.default=default_8MB heltec_wifi_lora_32_V2.menu.PartitionScheme.default.build.partitions=default_8MB +heltec_wifi_lora_32_V2.menu.PartitionScheme.default.upload.maximum_size=3342336 heltec_wifi_lora_32_V2.menu.PartitionScheme.minimal=Minimal (2MB FLASH) heltec_wifi_lora_32_V2.menu.PartitionScheme.minimal.build.partitions=minimal heltec_wifi_lora_32_V2.menu.PartitionScheme.no_ota=No OTA (Large APP) @@ -2875,6 +2881,7 @@ heltec_wireless_stick.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-e heltec_wireless_stick.menu.PartitionScheme.default=default_8MB heltec_wireless_stick.menu.PartitionScheme.default.build.partitions=default_8MB +heltec_wireless_stick.menu.PartitionScheme.default.upload.maximum_size=3342336 heltec_wireless_stick.menu.PartitionScheme.minimal=Minimal (2MB FLASH) heltec_wireless_stick.menu.PartitionScheme.minimal.build.partitions=minimal heltec_wireless_stick.menu.PartitionScheme.no_ota=No OTA (Large APP) @@ -3955,6 +3962,7 @@ ttgo-t-watch.menu.PSRAM.disabled.build.defines= ttgo-t-watch.menu.PartitionScheme.default=Default (2 x 6.5 MB app, 3.6 MB SPIFFS) ttgo-t-watch.menu.PartitionScheme.default.build.partitions=default_16MB +ttgo-t-watch.menu.PartitionScheme.default.upload.maximum_size=6553600 ttgo-t-watch.menu.PartitionScheme.large_spiffs=Large SPIFFS (7 MB) ttgo-t-watch.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB ttgo-t-watch.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824 diff --git a/cores/esp32/Client.h b/cores/esp32/Client.h index e6d9c66f1d6..962cacc51da 100644 --- a/cores/esp32/Client.h +++ b/cores/esp32/Client.h @@ -28,8 +28,6 @@ class Client: public Stream public: virtual int connect(IPAddress ip, uint16_t port) =0; virtual int connect(const char *host, uint16_t port) =0; - virtual int connect(IPAddress ip, uint16_t port, int timeout) =0; - virtual int connect(const char *host, uint16_t port, int timeout) =0; virtual size_t write(uint8_t) =0; virtual size_t write(const uint8_t *buf, size_t size) =0; virtual int available() = 0; diff --git a/cores/esp32/Esp.cpp b/cores/esp32/Esp.cpp index 8df9514ee66..54451127ef3 100644 --- a/cores/esp32/Esp.cpp +++ b/cores/esp32/Esp.cpp @@ -92,13 +92,6 @@ void EspClass::deepSleep(uint32_t time_us) esp_deep_sleep(time_us); } -uint32_t EspClass::getCycleCount() -{ - uint32_t ccount; - __asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount)); - return ccount; -} - void EspClass::restart(void) { esp_restart(); diff --git a/cores/esp32/Esp.h b/cores/esp32/Esp.h index f8e7b9cfe70..2580eecf65b 100644 --- a/cores/esp32/Esp.h +++ b/cores/esp32/Esp.h @@ -75,8 +75,8 @@ class EspClass uint32_t getMaxAllocPsram(); uint8_t getChipRevision(); - uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; } - uint32_t getCycleCount(); + uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); } + inline uint32_t getCycleCount() __attribute__((always_inline)); const char * getSdkVersion(); void deepSleep(uint32_t time_us); @@ -101,6 +101,13 @@ class EspClass }; +uint32_t IRAM_ATTR EspClass::getCycleCount() +{ + uint32_t ccount; + __asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount)); + return ccount; +} + extern EspClass ESP; #endif //ESP_H diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 495e8687379..545c9b05562 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -55,6 +55,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in _uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, 256, invert); if(!baud) { + uartStartDetectBaudrate(_uart); time_t startMillis = millis(); unsigned long detectedBaudRate = 0; while(millis() - startMillis < timeout_ms && !(detectedBaudRate = uartDetectBaudrate(_uart))) { diff --git a/cores/esp32/Print.cpp b/cores/esp32/Print.cpp index 8c295347f2a..60964703306 100644 --- a/cores/esp32/Print.cpp +++ b/cores/esp32/Print.cpp @@ -52,19 +52,24 @@ 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); + int len = vsnprintf(temp, sizeof(loc_buf), format, copy); va_end(copy); + if(len < 0) { + va_end(arg); + return 0; + }; if(len >= sizeof(loc_buf)){ - temp = new char[len+1]; + temp = (char*) malloc(len+1); if(temp == NULL) { + va_end(arg); return 0; } + len = vsnprintf(temp, len+1, format, arg); } - len = vsnprintf(temp, len+1, format, arg); - write((uint8_t*)temp, len); va_end(arg); - if(len >= sizeof(loc_buf)){ - delete[] temp; + len = write((uint8_t*)temp, len); + if(temp != loc_buf){ + free(temp); } return len; } @@ -154,8 +159,10 @@ size_t Print::print(struct tm * timeinfo, const char * format) } char buf[64]; size_t written = strftime(buf, 64, f, timeinfo); - print(buf); - return written; + if(written == 0){ + return written; + } + return print(buf); } size_t Print::println(void) diff --git a/cores/esp32/WString.cpp b/cores/esp32/WString.cpp index 69444696aa4..aee4b1c94bd 100644 --- a/cores/esp32/WString.cpp +++ b/cores/esp32/WString.cpp @@ -31,7 +31,7 @@ String::String(const char *cstr) { init(); - if(cstr) + if (cstr) copy(cstr, strlen(cstr)); } @@ -136,7 +136,7 @@ inline void String::init(void) { } void String::invalidate(void) { - if(!sso() && wbuffer()) + if(!isSSO() && wbuffer()) free(wbuffer()); init(); } @@ -154,17 +154,21 @@ unsigned char String::reserve(unsigned int size) { unsigned char String::changeBuffer(unsigned int maxStrLen) { // Can we use SSO here to avoid allocation? - if (maxStrLen < sizeof(sso_buf)) { - if (sso() || !buffer()) { + if (maxStrLen < sizeof(sso.buff) - 1) { + if (isSSO() || !buffer()) { // Already using SSO, nothing to do + uint16_t oldLen = len(); setSSO(true); + setLen(oldLen); return 1; - } else { // if bufptr && !sso() - // Using bufptr, need to shrink into sso_buff - char temp[sizeof(sso_buf)]; + } else { // if bufptr && !isSSO() + // Using bufptr, need to shrink into sso.buff + char temp[sizeof(sso.buff)]; memcpy(temp, buffer(), maxStrLen); free(wbuffer()); + uint16_t oldLen = len(); setSSO(true); + setLen(oldLen); memcpy(wbuffer(), temp, maxStrLen); return 1; } @@ -176,12 +180,12 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) { return false; } uint16_t oldLen = len(); - char *newbuffer = (char *) realloc(sso() ? nullptr : wbuffer(), newSize); - if(newbuffer) { + char *newbuffer = (char *) realloc(isSSO() ? nullptr : wbuffer(), newSize); + if (newbuffer) { size_t oldSize = capacity() + 1; // include NULL. - if (sso()) { + if (isSSO()) { // Copy the SSO buffer into allocated space - memcpy(newbuffer, sso_buf, sizeof(sso_buf)); + memmove(newbuffer, sso.buff, sizeof(sso.buff)); } if (newSize > oldSize) { @@ -206,7 +210,7 @@ String & String::copy(const char *cstr, unsigned int length) { return *this; } setLen(length); - strcpy(wbuffer(), cstr); + memmove(wbuffer(), cstr, length + 1); return *this; } @@ -216,7 +220,7 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length) { return *this; } setLen(length); - strcpy_P(wbuffer(), (PGM_P)pstr); + memcpy_P(wbuffer(), (PGM_P)pstr, length + 1); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here return *this; } @@ -224,20 +228,20 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length) { void String::move(String &rhs) { if(buffer()) { if(capacity() >= rhs.len()) { - strcpy(wbuffer(), rhs.buffer()); + memmove(wbuffer(), rhs.buffer(), rhs.length() + 1); setLen(rhs.len()); rhs.invalidate(); return; } else { - if (!sso()) { + if (!isSSO()) { free(wbuffer()); setBuffer(nullptr); } } } - if (rhs.sso()) { + if (rhs.isSSO()) { setSSO(true); - memmove(sso_buf, rhs.sso_buf, sizeof(sso_buf)); + memmove(sso.buff, rhs.sso.buff, sizeof(sso.buff)); } else { setSSO(false); setBuffer(rhs.wbuffer()); @@ -309,7 +313,7 @@ unsigned char String::concat(const String &s) { return 1; if (!reserve(newlen)) return 0; - memcpy(wbuffer() + len(), buffer(), len()); + memmove(wbuffer() + len(), buffer(), len()); setLen(newlen); wbuffer()[len()] = 0; return 1; @@ -326,7 +330,12 @@ unsigned char String::concat(const char *cstr, unsigned int length) { return 1; if(!reserve(newlen)) return 0; - strcpy(wbuffer() + len(), cstr); + if (cstr >= wbuffer() && cstr < wbuffer() + len()) + // compatible with SSO in ram #6155 (case "x += x.c_str()") + memmove(wbuffer() + len(), cstr, length + 1); + else + // compatible with source in flash #6367 + memcpy_P(wbuffer() + len(), cstr, length + 1); setLen(newlen); return 1; } @@ -392,7 +401,7 @@ unsigned char String::concat(const __FlashStringHelper * str) { if (length == 0) return 1; unsigned int newlen = len() + length; if (!reserve(newlen)) return 0; - strcpy_P(wbuffer() + len(), (PGM_P)str); + memcpy_P(wbuffer() + len(), (PGM_P)str, length + 1); setLen(newlen); return 1; } diff --git a/cores/esp32/WString.h b/cores/esp32/WString.h index 11b12aa08a5..38bd116f4ae 100644 --- a/cores/esp32/WString.h +++ b/cores/esp32/WString.h @@ -27,6 +27,7 @@ #include #include #include +#include // An inherited class for holding the result of a concatenation. These // result objects are assumed to be writable by subsequent concatenations. @@ -82,6 +83,12 @@ class String { return 0; } } + inline void clear(void) { + setLen(0); + } + inline bool isEmpty(void) const { + return length() == 0; + } // creates a copy of the assigned value. if the value is null or // invalid, or if the memory allocation fails, the string will be @@ -98,7 +105,7 @@ class String { // returns true on success, false on failure (in which case, the string // is left unchanged). if the argument is null or invalid, the - // concatenation is considered unsucessful. + // concatenation is considered unsuccessful. unsigned char concat(const String &str); unsigned char concat(const char *cstr); unsigned char concat(char c); @@ -199,7 +206,7 @@ class String { unsigned char startsWith(const String &prefix, unsigned int offset) const; unsigned char endsWith(const String &suffix) const; - // character acccess + // character access char charAt(unsigned int index) const; void setCharAt(unsigned int index, char c); char operator [](unsigned int index) const; @@ -250,27 +257,29 @@ class String { uint16_t cap; uint16_t len; }; - - // SSO is handled by checking the last byte of sso_buff. - // When not in SSO mode, that byte is set to 0xff, while when in SSO mode it is always 0x00 (so it can serve as the string terminator as well as a flag) - // This allows strings up up to 12 (11 + \0 termination) without any extra space. - enum { SSOSIZE = sizeof(struct _ptr) + 4 }; // Characters to allocate space for SSO, must be 12 or more - enum { CAPACITY_MAX = 65535 }; // If size of capacity changed, be sure to update this enum + // This allows strings up up to 11 (10 + \0 termination) without any extra space. + enum { SSOSIZE = sizeof(struct _ptr) + 4 - 1 }; // Characters to allocate space for SSO, must be 12 or more + struct _sso { + char buff[SSOSIZE]; + unsigned char len : 7; // Ensure only one byte is allocated by GCC for the bitfields + unsigned char isSSO : 1; + } __attribute__((packed)); // Ensure that GCC doesn't expand the flag byte to a 32-bit word for alignment issues + enum { CAPACITY_MAX = 65535 }; // If typeof(cap) changed from uint16_t, be sure to update this enum to the max value storable in the type union { struct _ptr ptr; - char sso_buf[SSOSIZE]; + struct _sso sso; }; // Accessor functions - inline bool sso() const { return sso_buf[SSOSIZE - 1] == 0; } - inline unsigned int len() const { return sso() ? strlen(sso_buf) : ptr.len; } - inline unsigned int capacity() const { return sso() ? SSOSIZE - 1 : ptr.cap; } - inline void setSSO(bool sso) { sso_buf[SSOSIZE - 1] = sso ? 0x00 : 0xff; } - inline void setLen(int len) { if (!sso()) ptr.len = len; } - inline void setCapacity(int cap) { if (!sso()) ptr.cap = cap; } - inline void setBuffer(char *buff) { if (!sso()) ptr.buff = buff; } + inline bool isSSO() const { return sso.isSSO; } + inline unsigned int len() const { return isSSO() ? sso.len : ptr.len; } + inline unsigned int capacity() const { return isSSO() ? (unsigned int)SSOSIZE - 1 : ptr.cap; } // Size of max string not including terminal NUL + inline void setSSO(bool set) { sso.isSSO = set; } + inline void setLen(int len) { if (isSSO()) sso.len = len; else ptr.len = len; } + inline void setCapacity(int cap) { if (!isSSO()) ptr.cap = cap; } + inline void setBuffer(char *buff) { if (!isSSO()) ptr.buff = buff; } // Buffer accessor functions - inline const char *buffer() const { return (const char *)(sso() ? sso_buf : ptr.buff); } - inline char *wbuffer() const { return sso() ? const_cast(sso_buf) : ptr.buff; } // Writable version of buffer + inline const char *buffer() const { return (const char *)(isSSO() ? sso.buff : ptr.buff); } + inline char *wbuffer() const { return isSSO() ? const_cast(sso.buff) : ptr.buff; } // Writable version of buffer protected: void init(void); diff --git a/cores/esp32/esp32-hal-cpu.c b/cores/esp32/esp32-hal-cpu.c index c9b8f4c6644..1e30bcf71b1 100644 --- a/cores/esp32/esp32-hal-cpu.c +++ b/cores/esp32/esp32-hal-cpu.c @@ -23,6 +23,7 @@ #include "soc/rtc_cntl_reg.h" #include "rom/rtc.h" #include "soc/apb_ctrl_reg.h" +#include "soc/efuse_reg.h" #include "esp32-hal.h" #include "esp32-hal-cpu.h" @@ -150,6 +151,15 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){ } return false; } + //check if cpu supports the frequency + if(cpu_freq_mhz == 240){ + //Check if ESP32 is rated for a CPU frequency of 160MHz only + if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) && + REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_LOW)) { + log_e("Can not switch to 240 MHz! Chip CPU frequency rated for 160MHz."); + cpu_freq_mhz = 160; + } + } //Get current CPU clock configuration rtc_clk_cpu_freq_get_config(&cconf); //return if frequency has not changed diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index d80271a2c11..2dee63dc325 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -343,6 +343,8 @@ void uartFlush(uart_t* uart) READ_PERI_REG(UART_FIFO_REG(uart->num)); } + xQueueReset(uart->queue); + UART_MUTEX_UNLOCK(); } @@ -399,7 +401,12 @@ uint32_t uartGetBaudRate(uart_t* uart) if(uart == NULL) { return 0; } + uint32_t clk_div = (uart->dev->clk_div.div_int << 4) | (uart->dev->clk_div.div_frag & 0x0F); + if(!clk_div) { + return 0; + } + return ((getApbFrequency()<<4)/clk_div); } @@ -520,6 +527,14 @@ unsigned long uartBaudrateDetect(uart_t *uart, bool flg) * detected calling uartBadrateDetect(). The raw baudrate is computed using the UART_CLK_FREQ. The raw baudrate is * rounded to the closed real baudrate. */ +void uartStartDetectBaudrate(uart_t *uart) { + if(!uart) return; + + uart->dev->auto_baud.glitch_filt = 0x08; + uart->dev->auto_baud.en = 0; + uart->dev->auto_baud.en = 1; +} + unsigned long uartDetectBaudrate(uart_t *uart) { diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 9874866bcf7..821ca9c6ce0 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -72,6 +72,7 @@ size_t uartResizeRxBuffer(uart_t* uart, size_t new_size); void uartSetDebug(uart_t* uart); int uartGetDebug(); +void uartStartDetectBaudrate(uart_t *uart); unsigned long uartDetectBaudrate(uart_t *uart); bool uartRxActive(uart_t* uart); diff --git a/docs/platformio.md b/docs/platformio.md index fac446539e5..33f4b22cba3 100644 --- a/docs/platformio.md +++ b/docs/platformio.md @@ -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) diff --git a/libraries/ArduinoOTA/src/ArduinoOTA.cpp b/libraries/ArduinoOTA/src/ArduinoOTA.cpp index 5df367d5873..884c9d341c1 100644 --- a/libraries/ArduinoOTA/src/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/src/ArduinoOTA.cpp @@ -127,9 +127,7 @@ void ArduinoOTAClass::begin() { } _initialized = true; _state = OTA_IDLE; -#ifdef OTA_DEBUG - OTA_DEBUG.printf("OTA server at: %s.local:%u\n", _hostname.c_str(), _port); -#endif + log_i("OTA server at: %s.local:%u", _hostname.c_str(), _port); } int ArduinoOTAClass::parseInt(){ @@ -173,6 +171,7 @@ void ArduinoOTAClass::_onRx(){ _md5 = readStringUntil('\n'); _md5.trim(); if(_md5.length() != 32){ + log_e("bad md5 length"); return; } @@ -198,6 +197,7 @@ void ArduinoOTAClass::_onRx(){ } else if (_state == OTA_WAITAUTH) { int cmd = parseInt(); if (cmd != U_AUTH) { + log_e("%d was expected. got %d instead", U_AUTH, cmd); _state = OTA_IDLE; return; } @@ -205,6 +205,7 @@ void ArduinoOTAClass::_onRx(){ String cnonce = readStringUntil(' '); String response = readStringUntil('\n'); if (cnonce.length() != 32 || response.length() != 32) { + log_e("auth param fail"); _state = OTA_IDLE; return; } @@ -225,6 +226,7 @@ void ArduinoOTAClass::_onRx(){ } else { _udp_ota.beginPacket(_udp_ota.remoteIP(), _udp_ota.remotePort()); _udp_ota.print("Authentication Failed"); + log_w("Authentication Failed"); _udp_ota.endPacket(); if (_error_callback) _error_callback(OTA_AUTH_ERROR); _state = OTA_IDLE; @@ -234,9 +236,9 @@ void ArduinoOTAClass::_onRx(){ void ArduinoOTAClass::_runUpdate() { if (!Update.begin(_size, _cmd)) { -#ifdef OTA_DEBUG - Update.printError(OTA_DEBUG); -#endif + + log_e("Begin ERROR: %s", Update.errorString()); + if (_error_callback) { _error_callback(OTA_BEGIN_ERROR); } @@ -272,21 +274,15 @@ void ArduinoOTAClass::_runUpdate() { } if (!waited){ if(written && tried++ < 3){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Try[%u]: %u\n", tried, written); -#endif + log_i("Try[%u]: %u", tried, written); if(!client.printf("%u", written)){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("failed to respond\n"); -#endif + log_e("failed to respond"); _state = OTA_IDLE; break; } continue; } -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Receive Failed\n"); -#endif + log_e("Receive Failed"); if (_error_callback) { _error_callback(OTA_RECEIVE_ERROR); } @@ -295,9 +291,7 @@ void ArduinoOTAClass::_runUpdate() { return; } if(!available){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("No Data: %u\n", waited); -#endif + log_e("No Data: %u", waited); _state = OTA_IDLE; break; } @@ -317,18 +311,14 @@ void ArduinoOTAClass::_runUpdate() { log_w("didn't write enough! %u != %u", written, r); } if(!client.printf("%u", written)){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("failed to respond\n"); -#endif + log_w("failed to respond"); } total += written; if(_progress_callback) { _progress_callback(total, _size); } } else { -#ifdef OTA_DEBUG - Update.printError(OTA_DEBUG); -#endif + log_e("Write ERROR: %s", Update.errorString()); } } @@ -351,10 +341,7 @@ void ArduinoOTAClass::_runUpdate() { Update.printError(client); client.stop(); delay(10); -#ifdef OTA_DEBUG - OTA_DEBUG.print("Update ERROR: "); - Update.printError(OTA_DEBUG); -#endif + log_e("Update ERROR: %s", Update.errorString()); _state = OTA_IDLE; } } @@ -366,9 +353,7 @@ void ArduinoOTAClass::end() { MDNS.end(); } _state = OTA_IDLE; -#ifdef OTA_DEBUG - OTA_DEBUG.println("OTA server stopped."); -#endif + log_i("OTA server stopped."); } void ArduinoOTAClass::handle() { @@ -395,4 +380,4 @@ void ArduinoOTAClass::setTimeout(int timeoutInMillis) { #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA) ArduinoOTAClass ArduinoOTA; -#endif \ No newline at end of file +#endif diff --git a/libraries/BLE/src/BLEAdvertising.cpp b/libraries/BLE/src/BLEAdvertising.cpp index 48bb9bbccef..ec73400c6d8 100644 --- a/libraries/BLE/src/BLEAdvertising.cpp +++ b/libraries/BLE/src/BLEAdvertising.cpp @@ -505,7 +505,7 @@ void BLEAdvertising::handleGAPEvent( } case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: { log_i("STOP advertising"); - start(); + //start(); break; } default: diff --git a/libraries/BLE/src/BLECharacteristic.cpp b/libraries/BLE/src/BLECharacteristic.cpp index 45d3c8e1b33..11636921b77 100644 --- a/libraries/BLE/src/BLECharacteristic.cpp +++ b/libraries/BLE/src/BLECharacteristic.cpp @@ -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. - } + 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,9 +377,9 @@ void BLECharacteristic::handleGATTServerEvent( } } else { // read.is_long == false - 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. - } + // 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(); @@ -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); - m_pCallbacks = pCallbacks; + if (pCallbacks != nullptr){ + m_pCallbacks = pCallbacks; + } else { + m_pCallbacks = &defaultCallback; + } log_v("<< setCallbacks"); } // setCallbacks @@ -754,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 */ diff --git a/libraries/BLE/src/BLECharacteristic.h b/libraries/BLE/src/BLECharacteristic.h index dd65cc4b8c4..adec9587ee0 100644 --- a/libraries/BLE/src/BLECharacteristic.h +++ b/libraries/BLE/src/BLECharacteristic.h @@ -90,6 +90,8 @@ class BLECharacteristic { 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; @@ -130,9 +132,22 @@ class BLECharacteristic { */ 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_ */ diff --git a/libraries/BLE/src/BLERemoteService.cpp b/libraries/BLE/src/BLERemoteService.cpp index 5c65f9552a7..754e8ac22d5 100644 --- a/libraries/BLE/src/BLERemoteService.cpp +++ b/libraries/BLE/src/BLERemoteService.cpp @@ -14,6 +14,8 @@ #include #include "esp32-hal-log.h" +#pragma GCC diagnostic warning "-Wunused-but-set-parameter" + BLERemoteService::BLERemoteService( esp_gatt_id_t srvcId, BLEClient* pClient, @@ -164,7 +166,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(), @@ -228,7 +230,6 @@ std::map* BLERemoteService::getCharacteri * @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID */ void BLERemoteService::getCharacteristics(std::map* pCharacteristicMap) { -#pragma GCC diagnostic ignored "-Wunused-but-set-parameter" pCharacteristicMap = &m_characteristicMapByHandle; } // Get the characteristics map. diff --git a/libraries/BLE/src/FreeRTOS.cpp b/libraries/BLE/src/FreeRTOS.cpp index 071853cfcfc..895ba267f81 100644 --- a/libraries/BLE/src/FreeRTOS.cpp +++ b/libraries/BLE/src/FreeRTOS.cpp @@ -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? diff --git a/libraries/BLE/src/FreeRTOS.h b/libraries/BLE/src/FreeRTOS.h index b861c8757c8..4d089c81db6 100644 --- a/libraries/BLE/src/FreeRTOS.h +++ b/libraries/BLE/src/FreeRTOS.h @@ -40,6 +40,8 @@ class FreeRTOS { bool take(uint32_t timeoutMs, std::string owner = ""); std::string toString(); uint32_t wait(std::string owner = ""); + bool timedWait(std::string owner = "", uint32_t timeoutMs = portMAX_DELAY); + uint32_t value(){ return m_value; }; private: SemaphoreHandle_t m_semaphore; diff --git a/libraries/EEPROM/src/EEPROM.cpp b/libraries/EEPROM/src/EEPROM.cpp index 1bec6127d2c..7f4ab090f1f 100644 --- a/libraries/EEPROM/src/EEPROM.cpp +++ b/libraries/EEPROM/src/EEPROM.cpp @@ -29,7 +29,7 @@ #include EEPROMClass::EEPROMClass(void) - : _handle(NULL) + : _handle(0) , _data(0) , _size(0) , _dirty(false) @@ -40,7 +40,7 @@ EEPROMClass::EEPROMClass(void) EEPROMClass::EEPROMClass(uint32_t sector) // Only for compatiility, no sectors in nvs! - : _handle(NULL) + : _handle(0) , _data(0) , _size(0) , _dirty(false) @@ -50,7 +50,7 @@ EEPROMClass::EEPROMClass(uint32_t sector) } EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size) - : _handle(NULL) + : _handle(0) , _data(0) , _size(0) , _dirty(false) @@ -60,7 +60,7 @@ EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size) } EEPROMClass::~EEPROMClass() { - // end(); + end(); } bool EEPROMClass::begin(size_t size) { @@ -152,6 +152,9 @@ void EEPROMClass::end() { } _data = 0; _size = 0; + + nvs_close(_handle); + _handle = 0; } uint8_t EEPROMClass::read(int address) { diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp index df8eef0640f..07d29ee7175 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp +++ b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp @@ -229,6 +229,7 @@ static esp_err_t capture_handler(httpd_req_t *req){ httpd_resp_set_type(req, "image/jpeg"); httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg"); + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); size_t out_len, out_width, out_height; uint8_t * out_buf; @@ -282,6 +283,7 @@ static esp_err_t capture_handler(httpd_req_t *req){ face_id = run_face_recognition(image_matrix, net_boxes); } draw_face_boxes(image_matrix, net_boxes, face_id); + free(net_boxes->score); free(net_boxes->box); free(net_boxes->landmark); free(net_boxes); @@ -325,6 +327,8 @@ static esp_err_t stream_handler(httpd_req_t *req){ return res; } + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + while(true){ detected = false; face_id = 0; @@ -378,6 +382,7 @@ static esp_err_t stream_handler(httpd_req_t *req){ } fr_recognize = esp_timer_get_time(); draw_face_boxes(image_matrix, net_boxes, face_id); + free(net_boxes->score); free(net_boxes->box); free(net_boxes->landmark); free(net_boxes); @@ -624,15 +629,18 @@ void startCameraServer(){ ra_filter_init(&ra_filter, 20); + mtmn_config.type = FAST; mtmn_config.min_face = 80; - mtmn_config.pyramid = 0.7; + mtmn_config.pyramid = 0.707; + mtmn_config.pyramid_times = 4; mtmn_config.p_threshold.score = 0.6; mtmn_config.p_threshold.nms = 0.7; + mtmn_config.p_threshold.candidate_number = 20; mtmn_config.r_threshold.score = 0.7; mtmn_config.r_threshold.nms = 0.7; - mtmn_config.r_threshold.candidate_number = 4; + mtmn_config.r_threshold.candidate_number = 10; mtmn_config.o_threshold.score = 0.7; - mtmn_config.o_threshold.nms = 0.4; + mtmn_config.o_threshold.nms = 0.7; mtmn_config.o_threshold.candidate_number = 1; face_id_init(&id_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES); diff --git a/libraries/ESP32/examples/DeepSleep/TimerWakeUp/TimerWakeUp.ino b/libraries/ESP32/examples/DeepSleep/TimerWakeUp/TimerWakeUp.ino index e8f280f3824..ec43cf72ea7 100644 --- a/libraries/ESP32/examples/DeepSleep/TimerWakeUp/TimerWakeUp.ino +++ b/libraries/ESP32/examples/DeepSleep/TimerWakeUp/TimerWakeUp.ino @@ -19,7 +19,7 @@ Author: Pranav Cherukupalli */ -#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; diff --git a/libraries/FFat/examples/FFat_time/FFat_time.ino b/libraries/FFat/examples/FFat_time/FFat_time.ino new file mode 100644 index 00000000000..1e3794514c5 --- /dev/null +++ b/libraries/FFat/examples/FFat_time/FFat_time.ino @@ -0,0 +1,177 @@ +#include "FS.h" +#include "FFat.h" +#include +#include + +const char* ssid = "your-ssid"; +const char* password = "your-password"; + +long timezone = 1; +byte daysavetime = 1; + +void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ + Serial.printf("Listing directory: %s\n", dirname); + + File root = fs.open(dirname); + if(!root){ + Serial.println("Failed to open directory"); + return; + } + if(!root.isDirectory()){ + Serial.println("Not a directory"); + return; + } + + File file = root.openNextFile(); + while(file){ + if(file.isDirectory()){ + Serial.print(" DIR : "); + Serial.print (file.name()); + time_t t= file.getLastWrite(); + struct tm * tmstruct = localtime(&t); + Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec); + if(levels){ + listDir(fs, file.name(), levels -1); + } + } else { + Serial.print(" FILE: "); + Serial.print(file.name()); + Serial.print(" SIZE: "); + Serial.print(file.size()); + time_t t= file.getLastWrite(); + struct tm * tmstruct = localtime(&t); + Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec); + } + file = root.openNextFile(); + } +} + +void createDir(fs::FS &fs, const char * path){ + Serial.printf("Creating Dir: %s\n", path); + if(fs.mkdir(path)){ + Serial.println("Dir created"); + } else { + Serial.println("mkdir failed"); + } +} + +void removeDir(fs::FS &fs, const char * path){ + Serial.printf("Removing Dir: %s\n", path); + if(fs.rmdir(path)){ + Serial.println("Dir removed"); + } else { + Serial.println("rmdir failed"); + } +} + +void readFile(fs::FS &fs, const char * path){ + Serial.printf("Reading file: %s\n", path); + + File file = fs.open(path); + if(!file){ + Serial.println("Failed to open file for reading"); + return; + } + + Serial.print("Read from file: "); + while(file.available()){ + Serial.write(file.read()); + } + file.close(); +} + +void writeFile(fs::FS &fs, const char * path, const char * message){ + Serial.printf("Writing file: %s\n", path); + + File file = fs.open(path, FILE_WRITE); + if(!file){ + Serial.println("Failed to open file for writing"); + return; + } + if(file.print(message)){ + Serial.println("File written"); + } else { + Serial.println("Write failed"); + } + file.close(); +} + +void appendFile(fs::FS &fs, const char * path, const char * message){ + Serial.printf("Appending to file: %s\n", path); + + File file = fs.open(path, FILE_APPEND); + if(!file){ + Serial.println("Failed to open file for appending"); + return; + } + if(file.print(message)){ + Serial.println("Message appended"); + } else { + Serial.println("Append failed"); + } + file.close(); +} + +void renameFile(fs::FS &fs, const char * path1, const char * path2){ + Serial.printf("Renaming file %s to %s\n", path1, path2); + if (fs.rename(path1, path2)) { + Serial.println("File renamed"); + } else { + Serial.println("Rename failed"); + } +} + +void deleteFile(fs::FS &fs, const char * path){ + Serial.printf("Deleting file: %s\n", path); + if(fs.remove(path)){ + Serial.println("File deleted"); + } else { + Serial.println("Delete failed"); + } +} + +void setup(){ + Serial.begin(115200); + // We start by connecting to a WiFi network + Serial.println(); + Serial.println(); + Serial.print("Connecting to "); + Serial.println(ssid); + + WiFi.begin(ssid, password); + + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + Serial.println("Contacting Time Server"); + configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); + struct tm tmstruct ; + delay(2000); + tmstruct.tm_year = 0; + getLocalTime(&tmstruct, 5000); + Serial.printf("\nNow is : %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct.tm_year)+1900,( tmstruct.tm_mon)+1, tmstruct.tm_mday,tmstruct.tm_hour , tmstruct.tm_min, tmstruct.tm_sec); + Serial.println(""); + + if(!FFat.begin(true)){ + Serial.println("FFat Mount Failed"); + return; + } + + listDir(FFat, "/", 0); + removeDir(FFat, "/mydir"); + createDir(FFat, "/mydir"); + deleteFile(FFat, "/hello.txt"); + writeFile(FFat, "/hello.txt", "Hello "); + appendFile(FFat, "/hello.txt", "World!\n"); + listDir(FFat, "/", 0); +} + +void loop(){ + +} + + diff --git a/libraries/FFat/src/FFat.cpp b/libraries/FFat/src/FFat.cpp index 3dbda110131..2c53f3a338a 100644 --- a/libraries/FFat/src/FFat.cpp +++ b/libraries/FFat/src/FFat.cpp @@ -76,6 +76,7 @@ void F_Fat::end() bool F_Fat::format(bool full_wipe, char* partitionLabel) { esp_err_t result; + bool res = true; if(_wl_handle){ log_w("Already Mounted!"); return false; @@ -83,7 +84,10 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel) wl_handle_t temp_handle; // Attempt to mount to see if there is already data const esp_partition_t *ffat_partition = check_ffat_partition(partitionLabel); - if (!ffat_partition) return false; + if (!ffat_partition){ + log_w("No partition!"); + return false; + } result = wl_mount(ffat_partition, &temp_handle); if (result == ESP_OK) { @@ -91,6 +95,9 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel) uint32_t wipe_size = full_wipe ? wl_size(temp_handle) : 16384; wl_erase_range(temp_handle, 0, wipe_size); wl_unmount(temp_handle); + } else { + res = false; + log_w("wl_mount failed!"); } // Now do a mount with format_if_fail (which it will) esp_vfs_fat_mount_config_t conf = { @@ -99,7 +106,11 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel) }; result = esp_vfs_fat_spiflash_mount("/format_ffat", partitionLabel, &conf, &temp_handle); esp_vfs_fat_spiflash_unmount("/format_ffat", temp_handle); - return result; + if (result != ESP_OK){ + res = false; + log_w("esp_vfs_fat_spiflash_mount failed!"); + } + return res; } size_t F_Fat::totalBytes() diff --git a/libraries/HTTPClient/library.properties b/libraries/HTTPClient/library.properties index 0369caa74ca..153a2e2575d 100644 --- a/libraries/HTTPClient/library.properties +++ b/libraries/HTTPClient/library.properties @@ -2,8 +2,8 @@ name=HTTPClient version=1.2 author=Markus Sattler maintainer=Markus Sattler -sentence=http Client for ESP32 +sentence=HTTP Client for ESP32 paragraph= category=Communication -url=https://github.com/Links2004/Arduino/tree/libraries/ESP8266HTTPClient +url=https://github.com/espressif/arduino-esp32/tree/master/libraries/HTTPClient architectures=esp32 diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index ab632342d81..f4b0ae54654 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -1,3 +1,4 @@ +#include /** * 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(); - _client = nullptr; + 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()) { - log_d("already connected, try reuse!"); + 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,11 +1103,12 @@ int HTTPClient::handleHeaderResponse() return HTTPC_ERROR_NOT_CONNECTED; } - _canReuse = !_useHTTP10; + clear(); + + _canReuse = _reuse; String transferEncoding; - _returnCode = -1; - _size = -1; + _transferEncoding = HTTPC_TE_IDENTITY; unsigned long lastDataTime = millis(); @@ -1099,8 +1123,10 @@ 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(); - _canReuse = (_returnCode != '0'); } else if(headerLine.indexOf(':')) { String headerName = headerLine.substring(0, headerLine.indexOf(':')); String headerValue = headerLine.substring(headerLine.indexOf(':') + 1); @@ -1110,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")) { diff --git a/libraries/HTTPClient/src/HTTPClient.h b/libraries/HTTPClient/src/HTTPClient.h index 45f6e3f4311..e089bb54973 100644 --- a/libraries/HTTPClient/src/HTTPClient.h +++ b/libraries/HTTPClient/src/HTTPClient.h @@ -197,7 +197,7 @@ class HTTPClient }; bool beginInternal(String url, const char* expectedProtocol); - void disconnect(); + void disconnect(bool preserveClient = false); void clear(); int returnError(int error); bool connect(void); diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index 7891c4164b1..7f2977572ec 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -204,7 +204,7 @@ void SPIClass::transferBits(uint32_t data, uint32_t * out, uint8_t bits) * @param data uint8_t * * @param size uint32_t */ -void SPIClass::writeBytes(uint8_t * data, uint32_t size) +void SPIClass::writeBytes(const uint8_t * data, uint32_t size) { if(_inTransaction){ return spiWriteNL(_spi, data, size); diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 6007cce8f2d..e34833bd435 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -76,7 +76,7 @@ class SPIClass void write(uint8_t data); void write16(uint16_t data); void write32(uint32_t data); - void writeBytes(uint8_t * data, uint32_t size); + void writeBytes(const uint8_t * data, uint32_t size); void writePixels(const void * data, uint32_t size);//ili9341 compatible void writePattern(uint8_t * data, uint8_t size, uint32_t repeat); diff --git a/libraries/Ticker/src/Ticker.cpp b/libraries/Ticker/src/Ticker.cpp index ce5cf69332c..1deeb7fb69f 100644 --- a/libraries/Ticker/src/Ticker.cpp +++ b/libraries/Ticker/src/Ticker.cpp @@ -43,9 +43,9 @@ void Ticker::_attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t } esp_timer_create(&_timerConfig, &_timer); if (repeat) { - esp_timer_start_periodic(_timer, milliseconds * 1000); + esp_timer_start_periodic(_timer, milliseconds * 1000ULL); } else { - esp_timer_start_once(_timer, milliseconds * 1000); + esp_timer_start_once(_timer, milliseconds * 1000ULL); } } diff --git a/libraries/Update/src/Update.h b/libraries/Update/src/Update.h index 43b3a887a64..9a46a784870 100644 --- a/libraries/Update/src/Update.h +++ b/libraries/Update/src/Update.h @@ -80,6 +80,8 @@ class UpdateClass { */ void printError(Stream &out); + const char * errorString(); + /* sets the expected MD5 for the firmware (hexString) */ diff --git a/libraries/Update/src/Updater.cpp b/libraries/Update/src/Updater.cpp index 2c73e686ffd..cfa28827e96 100644 --- a/libraries/Update/src/Updater.cpp +++ b/libraries/Update/src/Updater.cpp @@ -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; } @@ -366,4 +363,8 @@ void UpdateClass::printError(Stream &out){ out.println(_err2str(_error)); } +const char * UpdateClass::errorString(){ + return _err2str(_error); +} + UpdateClass Update; diff --git a/libraries/WiFi/src/ETH.cpp b/libraries/WiFi/src/ETH.cpp index b9caddb1130..2ffea758ded 100644 --- a/libraries/WiFi/src/ETH.cpp +++ b/libraries/WiFi/src/ETH.cpp @@ -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; diff --git a/libraries/WiFi/src/ETH.h b/libraries/WiFi/src/ETH.h index 8dcd85b9cbd..f5441a9d0ed 100644 --- a/libraries/WiFi/src/ETH.h +++ b/libraries/WiFi/src/ETH.h @@ -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(); diff --git a/libraries/WiFi/src/WiFiAP.cpp b/libraries/WiFi/src/WiFiAP.cpp index 8b7bbf15701..1f8af5852ee 100644 --- a/libraries/WiFi/src/WiFiAP.cpp +++ b/libraries/WiFi/src/WiFiAP.cpp @@ -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. diff --git a/libraries/WiFi/src/WiFiAP.h b/libraries/WiFi/src/WiFiAP.h index 12792741af4..f1533cc3611 100644 --- a/libraries/WiFi/src/WiFiAP.h +++ b/libraries/WiFi/src/WiFiAP.h @@ -45,6 +45,10 @@ class WiFiAPClass IPAddress softAPIP(); + IPAddress softAPBroadcastIP(); + IPAddress softAPNetworkID(); + uint8_t softAPSubnetCIDR(); + bool softAPenableIpV6(); IPv6Address softAPIPv6(); diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h index 09841f1a106..4915cfd5203 100644 --- a/libraries/WiFi/src/WiFiClient.h +++ b/libraries/WiFi/src/WiFiClient.h @@ -28,7 +28,15 @@ class WiFiClientSocketHandle; class WiFiClientRxBuffer; -class WiFiClient : public Client +class ESPLwIPClient : public Client +{ +public: + virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0; + virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0; + virtual int setTimeout(uint32_t seconds) = 0; +}; + +class WiFiClient : public ESPLwIPClient { protected: std::shared_ptr clientSocketHandle; diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 3fc99c97159..c972fe6708b 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -367,7 +367,7 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event) (reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL)) && WiFi.getAutoReconnect()) { - WiFi.disconnect(true); + WiFi.disconnect(); WiFi.begin(); } } else if(event->event_id == SYSTEM_EVENT_STA_GOT_IP) { @@ -656,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; +} diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index de79ca16a5f..ad0cd260767 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -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; diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index a9f6d649e7a..db5e019af31 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -492,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 diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index b383a7b1be1..d9140101593 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -64,6 +64,10 @@ class WiFiSTAClass IPAddress subnetMask(); IPAddress gatewayIP(); IPAddress dnsIP(uint8_t dns_no = 0); + + IPAddress broadcastIP(); + IPAddress networkID(); + uint8_t subnetCIDR(); bool enableIpV6(); IPv6Address localIPv6(); diff --git a/libraries/WiFi/src/WiFiScan.cpp b/libraries/WiFi/src/WiFiScan.cpp index 726bb455551..cabedbb8661 100644 --- a/libraries/WiFi/src/WiFiScan.cpp +++ b/libraries/WiFi/src/WiFiScan.cpp @@ -22,6 +22,7 @@ */ + #include "WiFi.h" #include "WiFiGeneric.h" #include "WiFiScan.h" @@ -42,7 +43,8 @@ extern "C" { } bool WiFiScanClass::_scanAsync = false; - +uint32_t WiFiScanClass::_scanStarted = 0; +uint32_t WiFiScanClass::_scanTimeout = 10000; uint16_t WiFiScanClass::_scanCount = 0; void* WiFiScanClass::_scanResult = 0; @@ -58,6 +60,7 @@ int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, return WIFI_SCAN_RUNNING; } + WiFiScanClass::_scanTimeout = max_ms_per_chan * 20; WiFiScanClass::_scanAsync = async; WiFi.enableSTA(true); @@ -78,6 +81,11 @@ int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, config.scan_time.active.max = max_ms_per_chan; } if(esp_wifi_scan_start(&config, false) == ESP_OK) { + _scanStarted = millis(); + if (!_scanStarted) { //Prevent 0 from millis overflow + ++_scanStarted; + } + WiFiGenericClass::clearStatusBits(WIFI_SCAN_DONE_BIT); WiFiGenericClass::setStatusBits(WIFI_SCANNING_BIT); @@ -107,6 +115,7 @@ void WiFiScanClass::_scanDone() WiFiScanClass::_scanCount = 0; } } + WiFiScanClass::_scanStarted=0; //Reset after a scan is completed for normal behavior WiFiGenericClass::setStatusBits(WIFI_SCAN_DONE_BIT); WiFiGenericClass::clearStatusBits(WIFI_SCANNING_BIT); } @@ -132,6 +141,11 @@ void * WiFiScanClass::_getScanInfoByIndex(int i) */ int16_t WiFiScanClass::scanComplete() { + if (WiFiScanClass::_scanStarted && (millis()-WiFiScanClass::_scanStarted) > WiFiScanClass::_scanTimeout) { //Check is scan was started and if the delay expired, return WIFI_SCAN_FAILED in this case + WiFiGenericClass::clearStatusBits(WIFI_SCANNING_BIT); + return WIFI_SCAN_FAILED; + } + if(WiFiGenericClass::getStatusBits() & WIFI_SCAN_DONE_BIT) { return WiFiScanClass::_scanCount; } diff --git a/libraries/WiFi/src/WiFiScan.h b/libraries/WiFi/src/WiFiScan.h index 8ec9bb083f8..41ab00802e3 100644 --- a/libraries/WiFi/src/WiFiScan.h +++ b/libraries/WiFi/src/WiFiScan.h @@ -50,8 +50,11 @@ class WiFiScanClass protected: static bool _scanAsync; - + + static uint32_t _scanStarted; + static uint32_t _scanTimeout; static uint16_t _scanCount; + static void* _scanResult; static void * _getScanInfoByIndex(int i); diff --git a/libraries/WiFiClientSecure/src/WiFiClientSecure.h b/libraries/WiFiClientSecure/src/WiFiClientSecure.h index 1e8382957c2..cd4f20e0f1c 100644 --- a/libraries/WiFiClientSecure/src/WiFiClientSecure.h +++ b/libraries/WiFiClientSecure/src/WiFiClientSecure.h @@ -72,6 +72,8 @@ class WiFiClientSecure : public WiFiClient bool verify(const char* fingerprint, const char* domain_name); void setHandshakeTimeout(unsigned long handshake_timeout); + int setTimeout(uint32_t seconds){ return 0; } + operator bool() { return connected(); diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index ce48ebebd21..ce8b31c727c 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -22,7 +22,7 @@ const char *pers = "esp32-tls"; -static int handle_error(int err) +static int _handle_error(int err, const char * file, int line) { if(err == -30848){ return err; @@ -30,12 +30,15 @@ static int handle_error(int err) #ifdef MBEDTLS_ERROR_C char error_buf[100]; mbedtls_strerror(err, error_buf, 100); - log_e("%s", error_buf); + log_e("[%s():%d]: (%d) %s", file, line, err, error_buf); +#else + log_e("[%s():%d]: code %d", file, line, err); #endif - log_e("MbedTLS message code: %d", err); return err; } +#define handle_error(e) _handle_error(e, __FUNCTION__, __LINE__) + void ssl_init(sslclient_context *ssl_client) { diff --git a/package/merge_packages.py b/package/merge_packages.py old mode 100644 new mode 100755 index c05787c8d8f..53fbbd9b0a9 --- a/package/merge_packages.py +++ b/package/merge_packages.py @@ -36,7 +36,11 @@ def pkgVersionNormalized(versionString): verParts = re.split('\.|-rc', verStr, flags=re.IGNORECASE) if len(verParts) == 3: - verStr = str(versionString) + '-rc' + str(sys.maxint) + if (sys.version_info > (3, 0)): # Python 3 + verStr = str(versionString) + '-rc' + str(sys.maxsize) + else: # Python 2 + verStr = str(versionString) + '-rc' + str(sys.maxint) + elif len(verParts) != 4: print("pkgVersionNormalized WARNING: unexpected version format: {0})".format(verStr), file=sys.stderr) diff --git a/tools/build-tests.sh b/tools/build-tests.sh deleted file mode 100755 index 3abed4ec142..00000000000 --- a/tools/build-tests.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/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" -if [ $? -ne 0 ]; then exit 1; fi -echo -e "travis_fold:end:sketch_test" - -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 -if [ $? -ne 0 ]; then exit 1; fi -echo -e "travis_fold:end:platformio_test_env_prepare" - -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" -if [ $? -ne 0 ]; then exit 1; fi -echo -e "travis_fold:end:platformio_test" diff --git a/tools/build.py b/tools/build.py deleted file mode 100755 index 28bb453ae62..00000000000 --- a/tools/build.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# build.py — build a sketch using arduino-builder -# -# Wrapper script around arduino-builder which accepts some ESP8266-specific -# options and translates them into FQBN -# -# Copyright © 2016 Ivan Grokhotkov -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# - - -from __future__ import print_function -import sys -import os -import argparse -import subprocess -import tempfile -import shutil - -def compile(tmp_dir, sketch, tools_dir, hardware_dir, ide_path, f, args): - cmd = ide_path + '/arduino-builder ' - cmd += '-compile -logger=human ' - cmd += '-build-path "' + tmp_dir + '" ' - cmd += '-tools "' + ide_path + '/tools-builder" ' - if args.library_path: - for lib_dir in args.library_path: - cmd += '-libraries "' + lib_dir + '" ' - cmd += '-hardware "' + ide_path + '/hardware" ' - if args.hardware_dir: - for hw_dir in args.hardware_dir: - cmd += '-hardware "' + hw_dir + '" ' - else: - cmd += '-hardware "' + hardware_dir + '" ' - # Debug=Serial,DebugLevel=Core____ - cmd += '-fqbn=espressif:esp32:{board_name}:' \ - 'FlashFreq={flash_freq},' \ - 'PartitionScheme=huge_app,' \ - 'UploadSpeed=921600'.format(**vars(args)) - cmd += ' ' - cmd += '-ide-version=10607 ' - cmd += '-warnings={warnings} '.format(**vars(args)) - if args.verbose: - cmd += '-verbose ' - cmd += sketch - - if args.verbose: - print('Building: ' + cmd, file=f) - - cmds = cmd.split(' ') - p = subprocess.Popen(cmds, stdout=f, stderr=subprocess.STDOUT) - p.wait() - return p.returncode - -def parse_args(): - parser = argparse.ArgumentParser(description='Sketch build helper') - parser.add_argument('-v', '--verbose', help='Enable verbose output', - action='store_true') - parser.add_argument('-i', '--ide_path', help='Arduino IDE path') - parser.add_argument('-p', '--build_path', help='Build directory') - parser.add_argument('-l', '--library_path', help='Additional library path', - action='append') - parser.add_argument('-d', '--hardware_dir', help='Additional hardware path', - action='append') - parser.add_argument('-b', '--board_name', help='Board name', default='esp32') - parser.add_argument('-w', '--warnings', help='Compilation warnings level', - default='none', choices=['none', 'all', 'more']) - parser.add_argument('-o', '--output_binary', help='File name for output binary') - parser.add_argument('-k', '--keep', action='store_true', - help='Don\'t delete temporary build directory') - parser.add_argument('--flash_freq', help='Flash frequency', default=40, - type=int, choices=[40, 80]) - parser.add_argument('sketch_path', help='Sketch file path') - return parser.parse_args() - -def main(): - args = parse_args() - - ide_path = args.ide_path - if not ide_path: - ide_path = os.environ.get('ARDUINO_IDE_PATH') - if not ide_path: - print("Please specify Arduino IDE path via --ide_path option" - "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr) - return 2 - - sketch_path = args.sketch_path - tmp_dir = args.build_path - created_tmp_dir = False - if not tmp_dir: - tmp_dir = tempfile.mkdtemp() - created_tmp_dir = True - - tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' - # this is not the correct hardware folder to add. - hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' - - output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' - if args.verbose: - print("Sketch: ", sketch_path) - print("Build dir: ", tmp_dir) - print("Output: ", output_name) - - if args.verbose: - f = sys.stdout - else: - f = open(tmp_dir + '/build.log', 'w') - - res = compile(tmp_dir, sketch_path, tools_dir, hardware_dir, ide_path, f, args) - if res != 0: - return res - - if args.output_binary is not None: - shutil.copy(output_name, args.output_binary) - - if created_tmp_dir and not args.keep: - shutil.rmtree(tmp_dir, ignore_errors=True) - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools/build.sh b/tools/build.sh deleted file mode 100755 index 96bced008e1..00000000000 --- a/tools/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -if [ ! -z "$TRAVIS_TAG" ]; then - # zip the package if tagged build - tools/build-release.sh -a$ESP32_GITHUB_TOKEN -else - # run cmake and sketch tests - tools/check_cmakelists.sh && tools/build-tests.sh -fi diff --git a/tools/build-release.sh b/tools/ci/build-release.sh similarity index 99% rename from tools/build-release.sh rename to tools/ci/build-release.sh index 3de516603b2..6d95fba13ae 100755 --- a/tools/build-release.sh +++ b/tools/ci/build-release.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [ -z "$TRAVIS_TAG" ]; then + echo "Skipping Packaging: Regular build" + exit 0 +fi + ############################################################ # $1 - download link # $2 - JSON output file diff --git a/tools/ci/build-tests.sh b/tools/ci/build-tests.sh new file mode 100755 index 00000000000..6ec5e2feac8 --- /dev/null +++ b/tools/ci/build-tests.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +if [ ! -z "$TRAVIS_TAG" ]; then + echo "Skipping Test: Tagged build" + exit 0 +fi + +CHUNK_INDEX=$1 +CHUNKS_CNT=$2 +BUILD_PIO=0 +if [ "$#" -lt 2 ]; then + echo "Building all sketches" + CHUNK_INDEX=0 + CHUNKS_CNT=1 + BUILD_PIO=1 +fi +if [ "$CHUNKS_CNT" -le 0 ]; then + CHUNK_INDEX=0 + CHUNKS_CNT=1 + BUILD_PIO=1 +fi +if [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ]; then + CHUNK_INDEX=$CHUNKS_CNT +fi +if [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then + BUILD_PIO=1 +fi + +# CMake Test +if [ "$CHUNK_INDEX" -eq 0 ]; then + echo -e "travis_fold:start:check_cmakelists" + tools/ci/check-cmakelists.sh + if [ $? -ne 0 ]; then exit 1; fi + echo -e "travis_fold:end:check_cmakelists" +fi + +if [ "$BUILD_PIO" -eq 0 ]; then + # ArduinoIDE Test + echo -e "travis_fold:start:prep_arduino_ide" + tools/ci/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/ci/test-arduino-ide.sh $CHUNK_INDEX $CHUNKS_CNT + 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" +else + # PlatformIO Test + echo -e "travis_fold:start:prep_platformio" + cd tools && python get.py && cd .. + tools/ci/prep-platformio.sh + if [ $? -ne 0 ]; then exit 1; fi + echo -e "travis_fold:end:prep_platformio" + + echo -e "travis_fold:start:test_platformio" + tools/ci/test-platformio.sh + if [ $? -ne 0 ]; then exit 1; fi + echo -e "travis_fold:end:test_platformio" +fi \ No newline at end of file diff --git a/tools/check_cmakelists.sh b/tools/ci/check-cmakelists.sh similarity index 87% rename from tools/check_cmakelists.sh rename to tools/ci/check-cmakelists.sh index d23c85a8d0d..4d11359cf80 100755 --- a/tools/check_cmakelists.sh +++ b/tools/ci/check-cmakelists.sh @@ -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 diff --git a/tools/deploy.sh b/tools/ci/deploy-release.sh similarity index 100% rename from tools/deploy.sh rename to tools/ci/deploy-release.sh diff --git a/tools/ci/prep-arduino-ide.sh b/tools/ci/prep-arduino-ide.sh new file mode 100755 index 00000000000..90c8d397386 --- /dev/null +++ b/tools/ci/prep-arduino-ide.sh @@ -0,0 +1,13 @@ +#!/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 +mkdir -p $HOME/Arduino/hardware/espressif +cd $HOME/Arduino/hardware/espressif + +ln -s $TRAVIS_BUILD_DIR esp32 +cd esp32/tools +python get.py diff --git a/tools/ci/prep-platformio.sh b/tools/ci/prep-platformio.sh new file mode 100755 index 00000000000..dbcb444d25e --- /dev/null +++ b/tools/ci/prep-platformio.sh @@ -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 diff --git a/tools/ci/test-arduino-ide.sh b/tools/ci/test-arduino-ide.sh new file mode 100755 index 00000000000..f902ce27214 --- /dev/null +++ b/tools/ci/test-arduino-ide.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +CHUNK_INDEX=$1 +CHUNKS_CNT=$2 +if [ "$#" -lt 2 ]; then + echo "Building all sketches" + CHUNK_INDEX=0 + CHUNKS_CNT=1 +fi +if [ "$CHUNKS_CNT" -le 0 ]; then + echo "Chunks count must be positive number" + exit 1 +fi +if [ "$CHUNK_INDEX" -ge "$CHUNKS_CNT" ]; then + echo "Chunk index must be less than chunks count" + exit 1 +fi + +export ARDUINO_BOARD_FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none" + +export ARDUINO_IDE_PATH=$HOME/arduino_ide +export ARDUINO_USR_PATH=$HOME/Arduino + +export EXAMPLES_PATH=$TRAVIS_BUILD_DIR/libraries +export EXAMPLES_BUILD_DIR=$HOME/build.tmp +export EXAMPLES_CACHE_DIR=$HOME/cache.tmp +export EXAMPLES_BUILD_CMD="$ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=\"10810\" -hardware \"$ARDUINO_IDE_PATH/hardware\" -hardware \"$ARDUINO_USR_PATH/hardware\" -tools \"$ARDUINO_IDE_PATH/tools-builder\" -built-in-libraries \"$ARDUINO_IDE_PATH/libraries\" -libraries \"$ARDUINO_USR_PATH/libraries\" -fqbn=$ARDUINO_BOARD_FQBN -warnings=\"all\" -build-cache \"$EXAMPLES_CACHE_DIR\" -build-path \"$EXAMPLES_BUILD_DIR\" -verbose" +export EXAMPLES_SIZE_BIN=$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-size + +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 < <($EXAMPLES_SIZE_BIN --format=sysv $elf_file) + + total_ram=$((${segments[dram0data]} + ${segments[dram0bss]})) + total_flash=$((${segments[iram0text]} + ${segments[flashtext]} + ${segments[dram0data]} + ${segments[flashrodata]})) + printf "%-32s %-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_sketch() +{ + local sketch=$1 + echo -e "\n------------ Building $sketch ------------\n"; + rm -rf $EXAMPLES_BUILD_DIR/* + time ($EXAMPLES_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 + return 0 +} + +function count_sketches() +{ + local sketches=$(find $EXAMPLES_PATH -name *.ino) + local sketchnum=0 + rm -rf sketches.txt + for sketch in $sketches; do + local sketchdir=$(dirname $sketch) + local sketchdirname=$(basename $sketchdir) + local sketchname=$(basename $sketch) + if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then + continue + fi; + if [[ -f "$sketchdir/.test.skip" ]]; then + continue + fi + echo $sketch >> sketches.txt + sketchnum=$(($sketchnum + 1)) + done + return $sketchnum +} + +function build_sketches() +{ + mkdir -p $EXAMPLES_BUILD_DIR + mkdir -p $EXAMPLES_CACHE_DIR + mkdir -p $ARDUINO_USR_PATH/libraries + mkdir -p $ARDUINO_USR_PATH/hardware + + local chunk_idex=$1 + local chunks_num=$2 + count_sketches + local sketchcount=$? + local sketches=$(cat sketches.txt) + + local chunk_size=$(( $sketchcount / $chunks_num )) + local all_chunks=$(( $chunks_num * $chunk_size )) + if [ "$all_chunks" -lt "$sketchcount" ]; then + chunk_size=$(( $chunk_size + 1 )) + fi + + local start_index=$(( $chunk_idex * $chunk_size )) + if [ "$sketchcount" -le "$start_index" ]; then + echo "Skipping job" + return 0 + fi + + local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) + if [ "$end_index" -gt "$sketchcount" ]; then + end_index=$sketchcount + fi + + local start_num=$(( $start_index + 1 )) + #echo -e "Sketches: \n$sketches\n" + echo "Found $sketchcount Sketches"; + echo "Chunk Count : $chunks_num" + echo "Chunk Size : $chunk_size" + echo "Start Sketch: $start_num" + echo "End Sketch : $end_index" + + local sketchnum=0 + print_size_info >size.log + for sketch in $sketches; do + 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 "Skipping $sketch marked"; + continue + fi + sketchnum=$(($sketchnum + 1)) + if [ "$sketchnum" -le "$start_index" ]; then + #echo "Skipping $sketch index low" + continue + fi + if [ "$sketchnum" -gt "$end_index" ]; then + #echo "Skipping $sketch index high" + continue + fi + build_sketch $sketch + local result=$? + if [ $result -ne 0 ]; then + return $result + fi + print_size_info $EXAMPLES_BUILD_DIR/*.elf >>size.log + done + return 0 +} + +build_sketches $CHUNK_INDEX $CHUNKS_CNT + +if [ $? -ne 0 ]; then exit 1; fi diff --git a/tools/ci/test-platformio.sh b/tools/ci/test-platformio.sh new file mode 100755 index 00000000000..f699595b1c4 --- /dev/null +++ b/tools/ci/test-platformio.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +python -m platformio ci --board esp32dev libraries/WiFi/examples/WiFiClient && \ +python -m platformio ci --board esp32dev libraries/WiFiClientSecure/examples/WiFiClientSecure && \ +python -m platformio ci --board esp32dev libraries/BluetoothSerial/examples/SerialToSerialBT && \ +python -m platformio ci --board esp32dev libraries/BLE/examples/BLE_server && \ +python -m platformio ci --board esp32dev libraries/AzureIoT/examples/GetStarted && \ +python -m platformio ci --board esp32dev libraries/ESP32/examples/Camera/CameraWebServer --project-option="board_build.partitions = huge_app.csv" +if [ $? -ne 0 ]; then exit 1; fi diff --git a/tools/common.sh b/tools/common.sh deleted file mode 100755 index 0cb50a10465..00000000000 --- a/tools/common.sh +++ /dev/null @@ -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 -} diff --git a/tools/partitions/app3M_fat9M_16MB.csv b/tools/partitions/app3M_fat9M_16MB.csv new file mode 100644 index 00000000000..0f67e69fbfe --- /dev/null +++ b/tools/partitions/app3M_fat9M_16MB.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x300000, +app1, app, ota_1, 0x310000,0x300000, +ffat, data, fat, 0x610000,0x9F0000, +# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage diff --git a/tools/partitions/default_ffat.csv b/tools/partitions/default_ffat.csv index b5bca09dc3f..d921c9fe3d9 100644 --- a/tools/partitions/default_ffat.csv +++ b/tools/partitions/default_ffat.csv @@ -3,4 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x140000, app1, app, ota_1, 0x150000,0x140000, -ffat, data, fat, 0x291000,0x170000, +ffat, data, fat, 0x290000,0x170000, diff --git a/tools/partitions/ffat.csv b/tools/partitions/ffat.csv index ed8720bf80b..b98bf0c3034 100644 --- a/tools/partitions/ffat.csv +++ b/tools/partitions/ffat.csv @@ -3,5 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x200000, app1, app, ota_1, 0x210000,0x200000, -ffat, data, fat, 0x410000,0xBEF000, +ffat, data, fat, 0x410000,0xBF0000, # to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage diff --git a/tools/sdk/bin/bootloader_dio_40m.bin b/tools/sdk/bin/bootloader_dio_40m.bin index 39c00ad7172..70d4510a14d 100644 Binary files a/tools/sdk/bin/bootloader_dio_40m.bin and b/tools/sdk/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dio_80m.bin b/tools/sdk/bin/bootloader_dio_80m.bin index cbcc3f6416e..4b77aab0622 100644 Binary files a/tools/sdk/bin/bootloader_dio_80m.bin and b/tools/sdk/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_40m.bin b/tools/sdk/bin/bootloader_dout_40m.bin index da1a2b77b38..464a0b1ab5a 100644 Binary files a/tools/sdk/bin/bootloader_dout_40m.bin and b/tools/sdk/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_80m.bin b/tools/sdk/bin/bootloader_dout_80m.bin index 92ed2ca382e..b66faeee2b3 100644 Binary files a/tools/sdk/bin/bootloader_dout_80m.bin and b/tools/sdk/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_40m.bin b/tools/sdk/bin/bootloader_qio_40m.bin index 40f63f98038..70d4510a14d 100644 Binary files a/tools/sdk/bin/bootloader_qio_40m.bin and b/tools/sdk/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_80m.bin b/tools/sdk/bin/bootloader_qio_80m.bin index dee2fcf0187..627d104cc2c 100644 Binary files a/tools/sdk/bin/bootloader_qio_80m.bin and b/tools/sdk/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_40m.bin b/tools/sdk/bin/bootloader_qout_40m.bin index da6a167e9db..898b8e0c9d4 100644 Binary files a/tools/sdk/bin/bootloader_qout_40m.bin and b/tools/sdk/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_80m.bin b/tools/sdk/bin/bootloader_qout_80m.bin index 390ce20db39..a514b2ed660 100644 Binary files a/tools/sdk/bin/bootloader_qout_80m.bin and b/tools/sdk/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/include/bootloader_support/bootloader_common.h b/tools/sdk/include/bootloader_support/bootloader_common.h index f184ef5ce5c..194d2769cbd 100644 --- a/tools/sdk/include/bootloader_support/bootloader_common.h +++ b/tools/sdk/include/bootloader_support/bootloader_common.h @@ -96,3 +96,11 @@ esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t s * @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(); diff --git a/tools/sdk/include/config/sdkconfig.h b/tools/sdk/include/config/sdkconfig.h index ebfe44efd18..6d6152bce40 100644 --- a/tools/sdk/include/config/sdkconfig.h +++ b/tools/sdk/include/config/sdkconfig.h @@ -60,7 +60,7 @@ #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 10 +#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 16 #define CONFIG_MBEDTLS_SSL_ALPN 1 #define CONFIG_MBEDTLS_PEM_WRITE_C 1 #define CONFIG_BT_SPP_ENABLED 1 @@ -130,6 +130,7 @@ #define CONFIG_GATTS_SEND_SERVICE_CHANGE_AUTO 1 #define CONFIG_LWIP_DHCPS_LEASE_UNIT 60 #define CONFIG_SPIFFS_USE_MAGIC 1 +#define CONFIG_OV7725_SUPPORT 1 #define CONFIG_TCPIP_TASK_STACK_SIZE 2560 #define CONFIG_BLUEDROID_PINNED_TO_CORE_0 1 #define CONFIG_FATFS_CODEPAGE_850 1 @@ -291,7 +292,6 @@ #define CONFIG_ESP32_DEBUG_STUBS_ENABLE 1 #define CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30 #define CONFIG_TCPIP_LWIP 1 -#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST 1 #define CONFIG_REDUCE_PHY_TX_POWER 1 #define CONFIG_BOOTLOADER_WDT_TIME_MS 9000 #define CONFIG_FREERTOS_CORETIMER_0 1 diff --git a/tools/sdk/include/esp32/esp_event_legacy.h b/tools/sdk/include/esp32/esp_event_legacy.h index 3bb2a77b9ff..a2518841819 100644 --- a/tools/sdk/include/esp32/esp_event_legacy.h +++ b/tools/sdk/include/esp32/esp_event_legacy.h @@ -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 */ diff --git a/tools/sdk/include/esp32/esp_private/esp_wifi_private.h b/tools/sdk/include/esp32/esp_private/esp_wifi_private.h new file mode 100644 index 00000000000..fcdebb6ba59 --- /dev/null +++ b/tools/sdk/include/esp32/esp_private/esp_wifi_private.h @@ -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 */ diff --git a/tools/sdk/include/esp32/esp_private/esp_wifi_types_private.h b/tools/sdk/include/esp32/esp_private/esp_wifi_types_private.h new file mode 100644 index 00000000000..dd56e0fdecf --- /dev/null +++ b/tools/sdk/include/esp32/esp_private/esp_wifi_types_private.h @@ -0,0 +1,21 @@ +// 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_TYPES_PRIVATE_H +#define _ESP_WIFI_TYPES_PRIVATE_H + +#include "rom/queue.h" +#include "esp_interface.h" + +#endif diff --git a/tools/sdk/include/esp32/esp_wifi.h b/tools/sdk/include/esp32/esp_wifi.h index e67f4606bd5..57014b8d9a2 100644 --- a/tools/sdk/include/esp32/esp_wifi.h +++ b/tools/sdk/include/esp32/esp_wifi.h @@ -59,15 +59,10 @@ #include #include -#include "freertos/FreeRTOS.h" -#include "freertos/queue.h" -#include "rom/queue.h" -#include "sdkconfig.h" #include "esp_err.h" #include "esp_wifi_types.h" -#include "esp_wifi_crypto_types.h" #include "esp_event.h" -#include "esp_wifi_os_adapter.h" +#include "esp_private/esp_wifi_private.h" #ifdef __cplusplus extern "C" { @@ -89,6 +84,10 @@ extern "C" { #define ESP_ERR_WIFI_WOULD_BLOCK (ESP_ERR_WIFI_BASE + 14) /*!< The caller would block */ #define ESP_ERR_WIFI_NOT_CONNECT (ESP_ERR_WIFI_BASE + 15) /*!< Station still in disconnect status */ +#define ESP_ERR_WIFI_POST (ESP_ERR_WIFI_BASE + 18) /*!< Failed to post the event to WiFi task */ +#define ESP_ERR_WIFI_INIT_STATE (ESP_ERR_WIFI_BASE + 19) /*!< Invalod WiFi state when init/deinit is called */ +#define ESP_ERR_WIFI_STOP_STATE (ESP_ERR_WIFI_BASE + 20) /*!< Returned when WiFi is stopping */ + /** * @brief WiFi stack configuration parameters passed to esp_wifi_init call. */ @@ -581,7 +580,7 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); * and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14} * then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected * from the AP the country info is set back back to the country info of the station automatically, - * {.cc="USA", .schan=1, .nchan=11} in the example. + * {.cc="US", .schan=1, .nchan=11} in the example. * @attention 3. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, always use the configured country info. * @attention 4. When the country info is changed because of configuration or because the station connects to a different * external AP, the country IE in probe response/beacon of the soft-AP is changed also. @@ -840,6 +839,16 @@ esp_err_t esp_wifi_set_auto_connect(bool en) __attribute__ ((deprecated)); */ esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated)); +/** + * @brief Function signature for received Vendor-Specific Information Element callback. + * @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback. + * @param type Information element type, based on frame type received. + * @param sa Source 802.11 address. + * @param vnd_ie Pointer to the vendor specific element data received. + * @param rssi Received signal strength indication. + */ +typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi); + /** * @brief Set 802.11 Vendor-Specific Information Element * @@ -858,16 +867,6 @@ esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated)); */ esp_err_t esp_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie); -/** - * @brief Function signature for received Vendor-Specific Information Element callback. - * @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback. - * @param type Information element type, based on frame type received. - * @param sa Source 802.11 address. - * @param vnd_ie Pointer to the vendor specific element data received. - * @param rssi Received signal strength indication. - */ -typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi); - /** * @brief Register Vendor-Specific Information Element monitoring callback. * @@ -881,60 +880,22 @@ typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); /** - * @brief Set maximum WiFi transmiting power - * - * @attention WiFi transmiting power is divided to six levels in phy init data. - * Level0 represents highest transmiting power and level5 represents lowest - * transmiting power. Packets of different rates are transmitted in - * different powers according to the configuration in phy init data. - * This API only sets maximum WiFi transmiting power. If this API is called, - * the transmiting power of every packet will be less than or equal to the - * value set by this API. If this API is not called, the value of maximum - * transmitting power set in phy_init_data.bin or menuconfig (depend on - * whether to use phy init data in partition or not) will be used. Default - * value is level0. Values passed in power are mapped to transmit power - * levels as follows: - * - [78, 127]: level0 - * - [76, 77]: level1 - * - [74, 75]: level2 - * - [68, 73]: level3 - * - [60, 67]: level4 - * - [52, 59]: level5 - * - [44, 51]: level5 - 2dBm - * - [34, 43]: level5 - 4.5dBm - * - [28, 33]: level5 - 6dBm - * - [20, 27]: level5 - 8dBm - * - [8, 19]: level5 - 11dBm - * - [-128, 7]: level5 - 14dBm - * - * @param power Maximum WiFi transmiting power. + * @brief Set maximum WiFi transmitting power + * + * @param power Maximum WiFi transmitting power, unit is 0.25dBm, range is [40, 82] corresponding to 10dBm - 20.5dBm here. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start + * - ESP_ERR_WIFI_NOT_ARG: invalid argument */ esp_err_t esp_wifi_set_max_tx_power(int8_t power); /** * @brief Get maximum WiFi transmiting power * - * @attention This API gets maximum WiFi transmiting power. Values got - * from power are mapped to transmit power levels as follows: - * - 78: 19.5dBm - * - 76: 19dBm - * - 74: 18.5dBm - * - 68: 17dBm - * - 60: 15dBm - * - 52: 13dBm - * - 44: 11dBm - * - 34: 8.5dBm - * - 28: 7dBm - * - 20: 5dBm - * - 8: 2dBm - * - -4: -1dBm - * - * @param power Maximum WiFi transmiting power. + * @param power Maximum WiFi transmitting power, unit is 0.25dBm. * * @return * - ESP_OK: succeed @@ -1102,19 +1063,6 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config); */ esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config); -/** - * @brief A general API to set/get WiFi internal configuration, it's for debug only - * - * @param cmd : ioctl command type - * @param cfg : configuration for the command - * - * @return - * - ESP_OK: succeed - * - others: failed - */ -esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg); - - #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/esp32/esp_wifi_internal.h b/tools/sdk/include/esp32/esp_wifi_internal.h index 252f5a27c33..d41b099db60 100644 --- a/tools/sdk/include/esp32/esp_wifi_internal.h +++ b/tools/sdk/include/esp32/esp_wifi_internal.h @@ -170,15 +170,26 @@ esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5); esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5); /** - * @brief Check the git commit id of WiFi library + * @brief Check the MD5 values of the esp_wifi_types.h in IDF and WiFi library * - * @attention 1. It is used for internal CI WiFi library check + * @attention 1. It is used for internal CI version check + * + * @return + * - ESP_OK : succeed + * - ESP_WIFI_INVALID_ARG : MD5 check fail + */ +esp_err_t esp_wifi_internal_wifi_type_md5_check(const char *md5); + +/** + * @brief Check the MD5 values of the esp_wifi.h in IDF and WiFi library + * + * @attention 1. It is used for internal CI version check * * @return * - ESP_OK : succeed - * - ESP_FAIL : fail + * - ESP_WIFI_INVALID_ARG : MD5 check fail */ -esp_err_t esp_wifi_internal_git_commit_id_check(void); +esp_err_t esp_wifi_internal_esp_wifi_md5_check(const char *md5); /** * @brief Allocate a chunk of memory for WiFi driver @@ -233,6 +244,18 @@ typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta ); */ esp_err_t esp_wifi_internal_update_mac_time( uint32_t time_delta ); +/** + * @brief A general API to set/get WiFi internal configuration, it's for debug only + * + * @param cmd : ioctl command type + * @param cfg : configuration for the command + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/esp32/esp_wifi_types.h b/tools/sdk/include/esp32/esp_wifi_types.h index cfe45ac6c7c..3f6eccde0be 100644 --- a/tools/sdk/include/esp32/esp_wifi_types.h +++ b/tools/sdk/include/esp32/esp_wifi_types.h @@ -18,9 +18,8 @@ #include #include -#include "rom/queue.h" #include "esp_err.h" -#include "esp_interface.h" +#include "esp_private/esp_wifi_types_private.h" #ifdef __cplusplus extern "C" { @@ -49,7 +48,7 @@ typedef struct { char cc[3]; /**< country code string */ uint8_t schan; /**< start channel */ uint8_t nchan; /**< total channel number */ - int8_t max_tx_power; /**< maximum tx power */ + int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ wifi_country_policy_t policy; /**< country policy */ } wifi_country_t; diff --git a/tools/sdk/include/esp32/hwcrypto/aes.h b/tools/sdk/include/esp32/hwcrypto/aes.h index 1dd5291f07c..5a3fd24fe03 100644 --- a/tools/sdk/include/esp32/hwcrypto/aes.h +++ b/tools/sdk/include/esp32/hwcrypto/aes.h @@ -41,17 +41,13 @@ extern "C" { /** * \brief AES context structure * - * \note buf is able to hold 32 extra bytes, which can be used: - * - for alignment purposes if VIA padlock is used, and/or - * - to simplify key expansion in the 256-bit case by - * generating an extra round key */ typedef struct { uint8_t key_bytes; + volatile uint8_t key_in_hardware; /* This variable is used for fault injection checks, so marked volatile to avoid optimisation */ uint8_t key[32]; } esp_aes_context; - /** * \brief The AES XTS context-type definition. */ diff --git a/tools/sdk/include/lwip/lwip/mem.h b/tools/sdk/include/lwip/lwip/mem.h index 73540f7e284..ff208d25c32 100644 --- a/tools/sdk/include/lwip/lwip/mem.h +++ b/tools/sdk/include/lwip/lwip/mem.h @@ -55,22 +55,6 @@ typedef size_t mem_size_t; typedef u16_t mem_size_t; #define MEM_SIZE_F U16_F -#if ESP_LWIP -/** - * lwip_malloc: if CONFIG_ALLOC_MEMORY_IN_SPIRAM_FIRST is enabled, Try to - * allocate memory for lwip in SPIRAM firstly. If failed, try to allocate - * internal memory then. - */ -#if CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST -#ifndef mem_malloc -#define mem_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#endif -#ifndef mem_calloc -#define mem_calloc(n, size) heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#endif -#endif -#endif - #else /* MEM_SIZE would have to be aligned, but using 64000 here instead of diff --git a/tools/sdk/include/mqtt/mqtt_client.h b/tools/sdk/include/mqtt/mqtt_client.h old mode 100755 new mode 100644 index 56d6aeabbd8..cb061328406 --- a/tools/sdk/include/mqtt/mqtt_client.h +++ b/tools/sdk/include/mqtt/mqtt_client.h @@ -18,7 +18,7 @@ extern "C" { #endif -typedef struct esp_mqtt_client* esp_mqtt_client_handle_t; +typedef struct esp_mqtt_client *esp_mqtt_client_handle_t; /** * @brief MQTT event types. @@ -44,6 +44,10 @@ typedef enum { - data_len length of the data for this event - current_data_offset offset of the current data for this event - total_data_len total length of the data received + Note: Multiple MQTT_EVENT_DATA could be fired for one message, if it is + longer than internal buffer. In that case only first event contains topic + pointer and length, other contain data only with current data length + and current data offset updating. */ MQTT_EVENT_BEFORE_CONNECT, /*!< The event occurs before connecting */ } esp_mqtt_event_id_t; @@ -73,7 +77,7 @@ typedef struct { int session_present; /*!< MQTT session_present flag for connection event */ } esp_mqtt_event_t; -typedef esp_mqtt_event_t* esp_mqtt_event_handle_t; +typedef esp_mqtt_event_t *esp_mqtt_event_handle_t; typedef esp_err_t (* mqtt_event_callback_t)(esp_mqtt_event_handle_t event); @@ -107,14 +111,130 @@ typedef struct { int refresh_connection_after_ms; /*!< Refresh connection after this value (in milliseconds) */ } esp_mqtt_client_config_t; +/** + * @brief Creates mqtt client handle based on the configuration + * + * @param config mqtt configuration structure + * + * @return mqtt_client_handle if successfully created, NULL on error + */ esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *config); + +/** + * @brief Sets mqtt connection URI. This API is usually used to overrides the URI + * configured in esp_mqtt_client_init + * + * @param client mqtt client hanlde + * @param uri + * + * @return ESP_FAIL if URI parse error, ESP_OK on success + */ esp_err_t esp_mqtt_client_set_uri(esp_mqtt_client_handle_t client, const char *uri); + +/** + * @brief Starts mqtt client with already created client handle + * + * @param client mqtt client handle + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on wrong initialization + * ESP_FAIL on other error + */ esp_err_t esp_mqtt_client_start(esp_mqtt_client_handle_t client); + +/** + * @brief This api is typically used to force reconnection upon a specific event + * + * @param client mqtt client handle + * + * @return ESP_OK on success + * ESP_FAIL if client is in invalid state + */ +esp_err_t esp_mqtt_client_reconnect(esp_mqtt_client_handle_t client); + +/** + * @brief Stops mqtt client tasks + * + * @param client mqtt client handle + * + * @return ESP_OK on success + * ESP_FAIL if client is in invalid state + */ esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client); -esp_err_t esp_mqtt_client_subscribe(esp_mqtt_client_handle_t client, const char *topic, int qos); -esp_err_t esp_mqtt_client_unsubscribe(esp_mqtt_client_handle_t client, const char *topic); + +/** + * @brief Subscribe the client to defined topic with defined qos + * + * Notes: + * - Client must be connected to send subscribe message + * - This API is could be executed from a user task or + * from a mqtt event callback i.e. internal mqtt task + * (API is protected by internal mutex, so it might block + * if a longer data receive operation is in progress. + * + * @param client mqtt client handle + * @param topic + * @param qos + * + * @return message_id of the subscribe message on success + * -1 on failure + */ +int esp_mqtt_client_subscribe(esp_mqtt_client_handle_t client, const char *topic, int qos); + +/** + * @brief Unsubscribe the client from defined topic + * + * Notes: + * - Client must be connected to send unsubscribe message + * - It is thread safe, please refer to `esp_mqtt_client_subscribe` for details + * + * @param client mqtt client handle + * @param topic + * + * @return message_id of the subscribe message on success + * -1 on failure + */ +int esp_mqtt_client_unsubscribe(esp_mqtt_client_handle_t client, const char *topic); + +/** + * @brief Client to send a publish message to the broker + * + * Notes: + * - Client doesn't have to be connected to send publish message + * (although it would drop all qos=0 messages, qos>1 messages would be enqueued) + * - It is thread safe, please refer to `esp_mqtt_client_subscribe` for details + * + * @param client mqtt client handle + * @param topic topic string + * @param data payload string (set to NULL, sending empty payload message) + * @param len data length, if set to 0, length is calculated from payload string + * @param qos qos of publish message + * @param retain ratain flag + * + * @return message_id of the subscribe message on success + * 0 if cannot publish + */ int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic, const char *data, int len, int qos, int retain); + +/** + * @brief Destroys the client handle + * + * @param client mqtt client handle + * + * @return ESP_OK + */ esp_err_t esp_mqtt_client_destroy(esp_mqtt_client_handle_t client); + +/** + * @brief Set configuration structure, typically used when updating the config (i.e. on "before_connect" event + * + * @param client mqtt client handle + * + * @param config mqtt configuration structure + * + * @return ESP_ERR_NO_MEM if failed to allocate + * ESP_OK on success + */ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_client_config_t *config); #ifdef __cplusplus diff --git a/tools/sdk/include/mqtt/mqtt_config.h b/tools/sdk/include/mqtt/mqtt_config.h index c0b4ab7545c..033fc0a732a 100644 --- a/tools/sdk/include/mqtt/mqtt_config.h +++ b/tools/sdk/include/mqtt/mqtt_config.h @@ -10,6 +10,7 @@ #define MQTT_PROTOCOL_311 CONFIG_MQTT_PROTOCOL_311 #define MQTT_RECONNECT_TIMEOUT_MS (10*1000) +#define MQTT_POLL_READ_TIMEOUT_MS (1000) #if CONFIG_MQTT_BUFFER_SIZE #define MQTT_BUFFER_SIZE_BYTE CONFIG_MQTT_BUFFER_SIZE @@ -61,14 +62,18 @@ #define MQTT_CORE_SELECTION_ENABLED CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED +#ifdef CONFIG_MQTT_DISABLE_API_LOCKS +#define MQTT_DISABLE_API_LOCKS CONFIG_MQTT_DISABLE_API_LOCKS +#endif + #ifdef CONFIG_MQTT_USE_CORE_0 - #define MQTT_TASK_CORE 0 +#define MQTT_TASK_CORE 0 #else - #ifdef CONFIG_MQTT_USE_CORE_1 - #define MQTT_TASK_CORE 1 - #else - #define MQTT_TASK_CORE 0 - #endif +#ifdef CONFIG_MQTT_USE_CORE_1 +#define MQTT_TASK_CORE 1 +#else +#define MQTT_TASK_CORE 0 +#endif #endif diff --git a/tools/sdk/include/vfs/esp_vfs.h b/tools/sdk/include/vfs/esp_vfs.h index 57a0320f187..7033b267655 100644 --- a/tools/sdk/include/vfs/esp_vfs.h +++ b/tools/sdk/include/vfs/esp_vfs.h @@ -221,6 +221,8 @@ typedef struct /** stop_socket_select which can be called from ISR; set only for the socket driver */ void (*stop_socket_select_isr)(BaseType_t *woken); /** end_select is called to stop the I/O multiplexing and deinitialize the environment created by start_select for the given VFS */ + void* (*get_socket_select_semaphore)(); + /** get_socket_select_semaphore returns semaphore allocated in the socket driver; set only for the socket driver */ void (*end_select)(); } esp_vfs_t; diff --git a/tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h b/tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h index 6204f465385..6adf5ec7e35 100644 --- a/tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h +++ b/tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h @@ -98,6 +98,13 @@ struct eap_method { #define BLOB_NAME_LEN 3 #define BLOB_NUM 3 +enum SIG_WPA2 { + SIG_WPA2_START = 0, + SIG_WPA2_RX, + SIG_WPA2_TASK_DEL, + SIG_WPA2_MAX, +}; + /** * struct eap_sm - EAP state machine data */ @@ -114,8 +121,7 @@ struct eap_sm { u8 current_identifier; u8 ownaddr[ETH_ALEN]; #ifdef USE_WPA2_TASK -#define SIG_WPA2_NUM 2 - u8 wpa2_sig_cnt[SIG_WPA2_NUM]; + u8 wpa2_sig_cnt[SIG_WPA2_MAX]; #endif u8 finish_state; diff --git a/tools/sdk/include/wpa_supplicant/wps/wps.h b/tools/sdk/include/wpa_supplicant/wps/wps.h index b731b9b95f2..31092cbb836 100644 --- a/tools/sdk/include/wpa_supplicant/wps/wps.h +++ b/tools/sdk/include/wpa_supplicant/wps/wps.h @@ -1009,9 +1009,9 @@ enum wps_cb_status { typedef void (*wps_st_cb_t)(int status); #ifdef USE_WPS_TASK -#define SIG_WPS_START 0 -#define SIG_WPS_RX 1 -#define SIG_WPS_NUM 2 +#define SIG_WPS_START 2 +#define SIG_WPS_RX 3 +#define SIG_WPS_NUM 9 #endif #define WPS_EAP_EXT_VENDOR_TYPE "WFA-SimpleConfig-Enrollee-1-0" diff --git a/tools/sdk/lib/libapp_trace.a b/tools/sdk/lib/libapp_trace.a index e07a7abe307..fd4556cb532 100644 Binary files a/tools/sdk/lib/libapp_trace.a and b/tools/sdk/lib/libapp_trace.a differ diff --git a/tools/sdk/lib/libapp_update.a b/tools/sdk/lib/libapp_update.a index f48f5ac2405..7feaa11090a 100644 Binary files a/tools/sdk/lib/libapp_update.a and b/tools/sdk/lib/libapp_update.a differ diff --git a/tools/sdk/lib/libasio.a b/tools/sdk/lib/libasio.a index ae598e56dde..bf1dbe4546c 100644 Binary files a/tools/sdk/lib/libasio.a and b/tools/sdk/lib/libasio.a differ diff --git a/tools/sdk/lib/libbootloader_support.a b/tools/sdk/lib/libbootloader_support.a index dbd68eb9198..bb24c7493ff 100644 Binary files a/tools/sdk/lib/libbootloader_support.a and b/tools/sdk/lib/libbootloader_support.a differ diff --git a/tools/sdk/lib/libbt.a b/tools/sdk/lib/libbt.a index 0dcb09c3c3e..06b85b67b4e 100644 Binary files a/tools/sdk/lib/libbt.a and b/tools/sdk/lib/libbt.a differ diff --git a/tools/sdk/lib/libbtdm_app.a b/tools/sdk/lib/libbtdm_app.a old mode 100755 new mode 100644 index 79f1d0d916f..b4d1fcfbe67 Binary files a/tools/sdk/lib/libbtdm_app.a and b/tools/sdk/lib/libbtdm_app.a differ diff --git a/tools/sdk/lib/libcoap.a b/tools/sdk/lib/libcoap.a index 73882410506..9b8b4829abe 100644 Binary files a/tools/sdk/lib/libcoap.a and b/tools/sdk/lib/libcoap.a differ diff --git a/tools/sdk/lib/libcoexist.a b/tools/sdk/lib/libcoexist.a index 1172048ce83..87f22e299ce 100644 Binary files a/tools/sdk/lib/libcoexist.a and b/tools/sdk/lib/libcoexist.a differ diff --git a/tools/sdk/lib/libconsole.a b/tools/sdk/lib/libconsole.a index 4b8df2ac2f8..a0218aafd28 100644 Binary files a/tools/sdk/lib/libconsole.a and b/tools/sdk/lib/libconsole.a differ diff --git a/tools/sdk/lib/libcore.a b/tools/sdk/lib/libcore.a index 10ef3c1da0a..7e5ece4ae0a 100644 Binary files a/tools/sdk/lib/libcore.a and b/tools/sdk/lib/libcore.a differ diff --git a/tools/sdk/lib/libcxx.a b/tools/sdk/lib/libcxx.a index eba60b001f0..0340b578f8c 100644 Binary files a/tools/sdk/lib/libcxx.a and b/tools/sdk/lib/libcxx.a differ diff --git a/tools/sdk/lib/libdriver.a b/tools/sdk/lib/libdriver.a index 0926ec1c11c..a14d3e2cded 100644 Binary files a/tools/sdk/lib/libdriver.a and b/tools/sdk/lib/libdriver.a differ diff --git a/tools/sdk/lib/libesp-tls.a b/tools/sdk/lib/libesp-tls.a index 3cc30c8ddf1..07054b291d9 100644 Binary files a/tools/sdk/lib/libesp-tls.a and b/tools/sdk/lib/libesp-tls.a differ diff --git a/tools/sdk/lib/libesp32-camera.a b/tools/sdk/lib/libesp32-camera.a index e8b2aa76194..cf852898c56 100644 Binary files a/tools/sdk/lib/libesp32-camera.a and b/tools/sdk/lib/libesp32-camera.a differ diff --git a/tools/sdk/lib/libesp32.a b/tools/sdk/lib/libesp32.a index 89b3b6b4fe8..a64f27e428d 100644 Binary files a/tools/sdk/lib/libesp32.a and b/tools/sdk/lib/libesp32.a differ diff --git a/tools/sdk/lib/libesp_adc_cal.a b/tools/sdk/lib/libesp_adc_cal.a index d2a35d56388..49ec7e6760c 100644 Binary files a/tools/sdk/lib/libesp_adc_cal.a and b/tools/sdk/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/lib/libesp_event.a b/tools/sdk/lib/libesp_event.a index f26e8c3e58f..a0997d98466 100644 Binary files a/tools/sdk/lib/libesp_event.a and b/tools/sdk/lib/libesp_event.a differ diff --git a/tools/sdk/lib/libesp_http_client.a b/tools/sdk/lib/libesp_http_client.a index 4e1c644d92a..d34294f8321 100644 Binary files a/tools/sdk/lib/libesp_http_client.a and b/tools/sdk/lib/libesp_http_client.a differ diff --git a/tools/sdk/lib/libesp_http_server.a b/tools/sdk/lib/libesp_http_server.a index 1372ada87f5..de1a4f76eb5 100644 Binary files a/tools/sdk/lib/libesp_http_server.a and b/tools/sdk/lib/libesp_http_server.a differ diff --git a/tools/sdk/lib/libesp_https_ota.a b/tools/sdk/lib/libesp_https_ota.a index dd793f8f337..a3a5b14bb1d 100644 Binary files a/tools/sdk/lib/libesp_https_ota.a and b/tools/sdk/lib/libesp_https_ota.a differ diff --git a/tools/sdk/lib/libesp_ringbuf.a b/tools/sdk/lib/libesp_ringbuf.a index 3bf1508daeb..e9e3179f94f 100644 Binary files a/tools/sdk/lib/libesp_ringbuf.a and b/tools/sdk/lib/libesp_ringbuf.a differ diff --git a/tools/sdk/lib/libespnow.a b/tools/sdk/lib/libespnow.a index 78616d02417..39078d7cb93 100644 Binary files a/tools/sdk/lib/libespnow.a and b/tools/sdk/lib/libespnow.a differ diff --git a/tools/sdk/lib/libethernet.a b/tools/sdk/lib/libethernet.a index 66cb8546356..1739f7d623e 100644 Binary files a/tools/sdk/lib/libethernet.a and b/tools/sdk/lib/libethernet.a differ diff --git a/tools/sdk/lib/libexpat.a b/tools/sdk/lib/libexpat.a index 2d35decc6aa..3bee0694821 100644 Binary files a/tools/sdk/lib/libexpat.a and b/tools/sdk/lib/libexpat.a differ diff --git a/tools/sdk/lib/libface_detection.a b/tools/sdk/lib/libface_detection.a index 6c1383f38ff..3902f3e1ba5 100644 Binary files a/tools/sdk/lib/libface_detection.a and b/tools/sdk/lib/libface_detection.a differ diff --git a/tools/sdk/lib/libface_recognition.a b/tools/sdk/lib/libface_recognition.a index 45b0e04e88a..845d3b311cb 100644 Binary files a/tools/sdk/lib/libface_recognition.a and b/tools/sdk/lib/libface_recognition.a differ diff --git a/tools/sdk/lib/libfatfs.a b/tools/sdk/lib/libfatfs.a index f31a384cc4f..de02e657aee 100644 Binary files a/tools/sdk/lib/libfatfs.a and b/tools/sdk/lib/libfatfs.a differ diff --git a/tools/sdk/lib/libfb_gfx.a b/tools/sdk/lib/libfb_gfx.a index 308e08de9c6..32e1251e7e0 100644 Binary files a/tools/sdk/lib/libfb_gfx.a and b/tools/sdk/lib/libfb_gfx.a differ diff --git a/tools/sdk/lib/libfreemodbus.a b/tools/sdk/lib/libfreemodbus.a index bd59430b6a1..3142ba6b9c1 100644 Binary files a/tools/sdk/lib/libfreemodbus.a and b/tools/sdk/lib/libfreemodbus.a differ diff --git a/tools/sdk/lib/libfreertos.a b/tools/sdk/lib/libfreertos.a index 5c226ad97cf..2ed18663b85 100644 Binary files a/tools/sdk/lib/libfreertos.a and b/tools/sdk/lib/libfreertos.a differ diff --git a/tools/sdk/lib/libheap.a b/tools/sdk/lib/libheap.a index 47ac0caa3eb..d2f9cc96f87 100644 Binary files a/tools/sdk/lib/libheap.a and b/tools/sdk/lib/libheap.a differ diff --git a/tools/sdk/lib/libimage_util.a b/tools/sdk/lib/libimage_util.a index f1908482dd6..e389ce2b848 100644 Binary files a/tools/sdk/lib/libimage_util.a and b/tools/sdk/lib/libimage_util.a differ diff --git a/tools/sdk/lib/libjsmn.a b/tools/sdk/lib/libjsmn.a index 2d9278fe354..0294befe7c4 100644 Binary files a/tools/sdk/lib/libjsmn.a and b/tools/sdk/lib/libjsmn.a differ diff --git a/tools/sdk/lib/libjson.a b/tools/sdk/lib/libjson.a index a2a96ef88e2..9e7b190a7b3 100644 Binary files a/tools/sdk/lib/libjson.a and b/tools/sdk/lib/libjson.a differ diff --git a/tools/sdk/lib/liblibsodium.a b/tools/sdk/lib/liblibsodium.a index 4d2e74dd393..a33df1981ac 100644 Binary files a/tools/sdk/lib/liblibsodium.a and b/tools/sdk/lib/liblibsodium.a differ diff --git a/tools/sdk/lib/liblog.a b/tools/sdk/lib/liblog.a index 1307c1faf7f..c912533ebce 100644 Binary files a/tools/sdk/lib/liblog.a and b/tools/sdk/lib/liblog.a differ diff --git a/tools/sdk/lib/liblwip.a b/tools/sdk/lib/liblwip.a index 5736ad9cbf7..7904c4ace73 100644 Binary files a/tools/sdk/lib/liblwip.a and b/tools/sdk/lib/liblwip.a differ diff --git a/tools/sdk/lib/libmbedtls.a b/tools/sdk/lib/libmbedtls.a index 0c2567e63a2..e85972e9fa7 100644 Binary files a/tools/sdk/lib/libmbedtls.a and b/tools/sdk/lib/libmbedtls.a differ diff --git a/tools/sdk/lib/libmdns.a b/tools/sdk/lib/libmdns.a index 6a8d96d937a..e3e685664b8 100644 Binary files a/tools/sdk/lib/libmdns.a and b/tools/sdk/lib/libmdns.a differ diff --git a/tools/sdk/lib/libmesh.a b/tools/sdk/lib/libmesh.a index 9fd0dbfe61a..326bb0bfcc1 100644 Binary files a/tools/sdk/lib/libmesh.a and b/tools/sdk/lib/libmesh.a differ diff --git a/tools/sdk/lib/libmicro-ecc.a b/tools/sdk/lib/libmicro-ecc.a index 85e25cbf903..66f712b02f8 100644 Binary files a/tools/sdk/lib/libmicro-ecc.a and b/tools/sdk/lib/libmicro-ecc.a differ diff --git a/tools/sdk/lib/libmqtt.a b/tools/sdk/lib/libmqtt.a index e95f9ee2a56..98344cc9007 100644 Binary files a/tools/sdk/lib/libmqtt.a and b/tools/sdk/lib/libmqtt.a differ diff --git a/tools/sdk/lib/libnet80211.a b/tools/sdk/lib/libnet80211.a index cbe2ea2c861..3effa68be48 100644 Binary files a/tools/sdk/lib/libnet80211.a and b/tools/sdk/lib/libnet80211.a differ diff --git a/tools/sdk/lib/libnewlib.a b/tools/sdk/lib/libnewlib.a index 6395599fce9..37136fddc52 100644 Binary files a/tools/sdk/lib/libnewlib.a and b/tools/sdk/lib/libnewlib.a differ diff --git a/tools/sdk/lib/libnghttp.a b/tools/sdk/lib/libnghttp.a index 1b5b84c14e5..8bfd8d1fb87 100644 Binary files a/tools/sdk/lib/libnghttp.a and b/tools/sdk/lib/libnghttp.a differ diff --git a/tools/sdk/lib/libnvs_flash.a b/tools/sdk/lib/libnvs_flash.a index 30ff92a9469..d71b82cba6f 100644 Binary files a/tools/sdk/lib/libnvs_flash.a and b/tools/sdk/lib/libnvs_flash.a differ diff --git a/tools/sdk/lib/libopenssl.a b/tools/sdk/lib/libopenssl.a index 21305331ff2..bf68995d513 100644 Binary files a/tools/sdk/lib/libopenssl.a and b/tools/sdk/lib/libopenssl.a differ diff --git a/tools/sdk/lib/libphy.a b/tools/sdk/lib/libphy.a old mode 100755 new mode 100644 index 8d7464c80ce..83ccef7e85e Binary files a/tools/sdk/lib/libphy.a and b/tools/sdk/lib/libphy.a differ diff --git a/tools/sdk/lib/libpp.a b/tools/sdk/lib/libpp.a index eeffe0a1d1c..6354cba8ebc 100644 Binary files a/tools/sdk/lib/libpp.a and b/tools/sdk/lib/libpp.a differ diff --git a/tools/sdk/lib/libprotobuf-c.a b/tools/sdk/lib/libprotobuf-c.a index f0c0b9b2d27..e0921da39a7 100644 Binary files a/tools/sdk/lib/libprotobuf-c.a and b/tools/sdk/lib/libprotobuf-c.a differ diff --git a/tools/sdk/lib/libprotocomm.a b/tools/sdk/lib/libprotocomm.a index 80705bd1aaa..ed9ef7c9f77 100644 Binary files a/tools/sdk/lib/libprotocomm.a and b/tools/sdk/lib/libprotocomm.a differ diff --git a/tools/sdk/lib/libpthread.a b/tools/sdk/lib/libpthread.a index 687571fece3..624bb355ffd 100644 Binary files a/tools/sdk/lib/libpthread.a and b/tools/sdk/lib/libpthread.a differ diff --git a/tools/sdk/lib/libsdmmc.a b/tools/sdk/lib/libsdmmc.a index ce7aa9ce78c..48f80d84725 100644 Binary files a/tools/sdk/lib/libsdmmc.a and b/tools/sdk/lib/libsdmmc.a differ diff --git a/tools/sdk/lib/libsmartconfig.a b/tools/sdk/lib/libsmartconfig.a index f948e370389..04e2cb834c9 100644 Binary files a/tools/sdk/lib/libsmartconfig.a and b/tools/sdk/lib/libsmartconfig.a differ diff --git a/tools/sdk/lib/libsmartconfig_ack.a b/tools/sdk/lib/libsmartconfig_ack.a index 60e267e89fb..5e736dd9dcd 100644 Binary files a/tools/sdk/lib/libsmartconfig_ack.a and b/tools/sdk/lib/libsmartconfig_ack.a differ diff --git a/tools/sdk/lib/libsoc.a b/tools/sdk/lib/libsoc.a index 47584868b83..d80523ca42c 100644 Binary files a/tools/sdk/lib/libsoc.a and b/tools/sdk/lib/libsoc.a differ diff --git a/tools/sdk/lib/libspi_flash.a b/tools/sdk/lib/libspi_flash.a index 879ce1857f5..e99f638c2c0 100644 Binary files a/tools/sdk/lib/libspi_flash.a and b/tools/sdk/lib/libspi_flash.a differ diff --git a/tools/sdk/lib/libspiffs.a b/tools/sdk/lib/libspiffs.a index ac505b24720..dff38e5e4d5 100644 Binary files a/tools/sdk/lib/libspiffs.a and b/tools/sdk/lib/libspiffs.a differ diff --git a/tools/sdk/lib/libtcp_transport.a b/tools/sdk/lib/libtcp_transport.a index 71ee42b446e..1c5dd3fa9ae 100644 Binary files a/tools/sdk/lib/libtcp_transport.a and b/tools/sdk/lib/libtcp_transport.a differ diff --git a/tools/sdk/lib/libtcpip_adapter.a b/tools/sdk/lib/libtcpip_adapter.a index c8cef277d3d..f4a74b0721d 100644 Binary files a/tools/sdk/lib/libtcpip_adapter.a and b/tools/sdk/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/lib/libulp.a b/tools/sdk/lib/libulp.a index 3f5e7957f38..2c37c7a6c50 100644 Binary files a/tools/sdk/lib/libulp.a and b/tools/sdk/lib/libulp.a differ diff --git a/tools/sdk/lib/libvfs.a b/tools/sdk/lib/libvfs.a index b68422ca5cc..326b2bcfe41 100644 Binary files a/tools/sdk/lib/libvfs.a and b/tools/sdk/lib/libvfs.a differ diff --git a/tools/sdk/lib/libwear_levelling.a b/tools/sdk/lib/libwear_levelling.a index c829c4b443a..9641d5896f4 100644 Binary files a/tools/sdk/lib/libwear_levelling.a and b/tools/sdk/lib/libwear_levelling.a differ diff --git a/tools/sdk/lib/libwifi_provisioning.a b/tools/sdk/lib/libwifi_provisioning.a index 85c4c5efd66..f347dae9f42 100644 Binary files a/tools/sdk/lib/libwifi_provisioning.a and b/tools/sdk/lib/libwifi_provisioning.a differ diff --git a/tools/sdk/lib/libwpa.a b/tools/sdk/lib/libwpa.a index 5660fb9979d..ac1a36fdd4d 100644 Binary files a/tools/sdk/lib/libwpa.a and b/tools/sdk/lib/libwpa.a differ diff --git a/tools/sdk/lib/libwpa2.a b/tools/sdk/lib/libwpa2.a index b2b1cef11de..4ba731fe950 100644 Binary files a/tools/sdk/lib/libwpa2.a and b/tools/sdk/lib/libwpa2.a differ diff --git a/tools/sdk/lib/libwpa_supplicant.a b/tools/sdk/lib/libwpa_supplicant.a index ed86c137cd5..5631572f24c 100644 Binary files a/tools/sdk/lib/libwpa_supplicant.a and b/tools/sdk/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/lib/libwps.a b/tools/sdk/lib/libwps.a index 99ab2928e11..139e9e1b2fe 100644 Binary files a/tools/sdk/lib/libwps.a and b/tools/sdk/lib/libwps.a differ diff --git a/tools/sdk/lib/libxtensa-debug-module.a b/tools/sdk/lib/libxtensa-debug-module.a index bbe91d3feff..34567ef6258 100644 Binary files a/tools/sdk/lib/libxtensa-debug-module.a and b/tools/sdk/lib/libxtensa-debug-module.a differ diff --git a/tools/sdk/sdkconfig b/tools/sdk/sdkconfig index 8eba3aab2d8..97cab6898f5 100644 --- a/tools/sdk/sdkconfig +++ b/tools/sdk/sdkconfig @@ -293,7 +293,7 @@ CONFIG_SPIRAM_SPEED_40M=y CONFIG_SPIRAM_CACHE_WORKAROUND=y CONFIG_SPIRAM_BANKSWITCH_ENABLE=y CONFIG_SPIRAM_BANKSWITCH_RESERVE=8 -CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST=y +CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST= CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY= # @@ -395,7 +395,7 @@ CONFIG_SW_COEXIST_PREFERENCE_WIFI= CONFIG_SW_COEXIST_PREFERENCE_BT= CONFIG_SW_COEXIST_PREFERENCE_BALANCE=y CONFIG_SW_COEXIST_PREFERENCE_VALUE=2 -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER= CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y @@ -430,7 +430,7 @@ CONFIG_PM_ENABLE= # Camera configuration # CONFIG_OV2640_SUPPORT=y -CONFIG_OV7725_SUPPORT= +CONFIG_OV7725_SUPPORT=y CONFIG_OV3660_SUPPORT=y CONFIG_SCCB_HARDWARE_I2C=y CONFIG_CAMERA_CORE0= @@ -630,7 +630,6 @@ CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES= CONFIG_TCP_OVERSIZE_MSS=y CONFIG_TCP_OVERSIZE_QUARTER_MSS= CONFIG_TCP_OVERSIZE_DISABLE= -CONFIG_LWIP_WND_SCALE= # # UDP diff --git a/variants/magicbit/pins_arduino.h b/variants/magicbit/pins_arduino.h index 18fc83db302..4f496860bf2 100644 --- a/variants/magicbit/pins_arduino.h +++ b/variants/magicbit/pins_arduino.h @@ -66,6 +66,6 @@ static const uint8_t MOTOR1A = 32; static const uint8_t MOTOR1B = 33; static const uint8_t MOTOR2A = 16; static const uint8_t MOTOR2B = 17; - +static const uint8_t LED_BUILTIN=16; #endif /* Pins_Arduino_h */