From a6c241d520105355247e4ffe23df6d40e3503fb2 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Thu, 6 Jun 2024 13:38:50 -0400 Subject: [PATCH] port: support ESP32 v3.x --- .github/workflows/build.yml | 13 ++++--------- README.md | 2 -- examples/BlePingServer/.ci.json | 4 ++-- mk/ci-list.sh | 5 ++--- src/port/random.cpp | 2 +- src/transport/ble-server-transport.hpp | 6 +++--- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 227a883..f58dfe9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,20 +15,15 @@ jobs: fqbn: esp8266:esp8266:nodemcuv2 - chip: ESP32 core-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json - core-version: '@2.0.17' - fqbn: esp32:esp32:esp32wrover - build-args: --build-property=build.partitions=default_ffat + fqbn: esp32:esp32:esp32wrover:PartitionScheme=noota_ffat arduino-libs: NimBLE-Arduino - chip: ESP32S2 core-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json core-version: '@2.0.17' - fqbn: esp32:esp32:adafruit_magtag29_esp32s2 - build-args: --build-property=build.partitions=default_ffat + fqbn: esp32:esp32:adafruit_magtag29_esp32s2:PartitionScheme=noota_ffat - chip: ESP32C3 core-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json - core-version: '@2.0.17' - fqbn: esp32:esp32:esp32c3 - build-args: --build-property=build.partitions=default_ffat + fqbn: esp32:esp32:esp32c3:PartitionScheme=noota_ffat arduino-libs: NimBLE-Arduino - chip: nRF52 fqbn: adafruit:nrf52:feather52832 @@ -73,7 +68,7 @@ jobs: NDNPH_VERSION: develop - name: Compile examples run: | - mk/ci-list.sh ${{ matrix.chip }} ${{ matrix.fqbn }} "${{ matrix.build-args }}" | bash + mk/ci-list.sh ${{ matrix.chip }} ${{ matrix.fqbn }} | bash publish: needs: [build] runs-on: ubuntu-22.04 diff --git a/README.md b/README.md index bec91e3..81762e4 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ **esp8266ndn** library enables [Named Data Networking](https://named-data.net/) application development in Arduino environment. It supports [ESP8266](https://github.com/esp8266/Arduino), [ESP32, ESP32-S2, ESP32-C3](https://github.com/espressif/arduino-esp32), and [Adafruit nRF52](https://github.com/adafruit/Adafruit_nRF52_Arduino) microcontrollers. -Note: currently NDNph and esp8266ndn are compatible with ESP32 Arduino core v2.x; it is incompatible with ESP32 Arduino core v3.x at the moment. - * [Doxygen documentation](https://esp8266ndn.ndn.today/) * [#esp8266ndn on Twitter](https://twitter.com/hashtag/esp8266ndn) for announcements * [GitHub Issues](https://github.com/yoursunny/esp8266ndn) for bug reports and best-effort support diff --git a/examples/BlePingServer/.ci.json b/examples/BlePingServer/.ci.json index e66a0aa..a67b786 100644 --- a/examples/BlePingServer/.ci.json +++ b/examples/BlePingServer/.ci.json @@ -2,11 +2,11 @@ "ESP8266": [], "ESP32": [ "", - "--build-property=compiler.cpp.extra_flags=-DDEMO_BLEPINGSERVER_DISABLE_NIMBLE=1" + "--build-property=build.defines=-DDEMO_BLEPINGSERVER_DISABLE_NIMBLE=1" ], "ESP32S2": [], "ESP32C3": [ "", - "--build-property=compiler.cpp.extra_flags=-DDEMO_BLEPINGSERVER_DISABLE_NIMBLE=1" + "--build-property=build.defines=-DDEMO_BLEPINGSERVER_DISABLE_NIMBLE=1" ] } diff --git a/mk/ci-list.sh b/mk/ci-list.sh index 17315f2..3ca37a0 100755 --- a/mk/ci-list.sh +++ b/mk/ci-list.sh @@ -3,7 +3,6 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")"/.. CHIP=$1 FQBN=$2 -BUILDARGS="$3" echo 'set -euo pipefail' for E in $(find ./examples -name '*.ino' -printf '%h\n'); do @@ -11,14 +10,14 @@ for E in $(find ./examples -name '*.ino' -printf '%h\n'); do cat $E/.ci.json else echo '{}' - fi | jq -r --arg chip $CHIP --arg fqbn $FQBN --arg sketch $E --arg buildArgs "$BUILDARGS" ' + fi | jq -r --arg chip $CHIP --arg fqbn $FQBN --arg sketch $E ' .[$chip] // [""] | .[] | [ "printf \"\\n----\\033[1;35m Build " + ($sketch | sub(".*/"; "")) + " in " + $fqbn + (if .!="" then " with " + . else "" end) + " \\033[0m----\\n\"", - "arduino-cli compile -b " + $fqbn + " --warnings more " + $sketch + " " + $buildArgs + " " + . + "arduino-cli compile -b " + $fqbn + " --warnings more " + $sketch + " " + . ] | .[] ' done diff --git a/src/port/random.cpp b/src/port/random.cpp index 4cb37e8..972ac0d 100644 --- a/src/port/random.cpp +++ b/src/port/random.cpp @@ -3,7 +3,7 @@ #if defined(ARDUINO_ARCH_ESP8266) #include #elif defined(ARDUINO_ARCH_ESP32) -#include +#include #elif defined(ARDUINO_ARCH_NRF52) #include #include diff --git a/src/transport/ble-server-transport.hpp b/src/transport/ble-server-transport.hpp index b1bd12b..425efd9 100644 --- a/src/transport/ble-server-transport.hpp +++ b/src/transport/ble-server-transport.hpp @@ -69,7 +69,7 @@ class BleServerTransport : public BleServerTransportBase { /** @brief Retrieve BLE address and address type. */ String getAddr() const { - return String(::BLEDevice::getAddress().toString().data()) + " (addr-type=public)"; + return String(::BLEDevice::getAddress().toString().c_str()) + " (addr-type=public)"; } private: @@ -102,8 +102,8 @@ class BleServerTransport : public BleServerTransportBase { if (chr != m_transport.m_cs) { return; } - std::string value = chr->getValue(); - m_transport.handleReceive(reinterpret_cast(value.data()), value.size(), 0); + auto value = chr->getValue(); + m_transport.handleReceive(reinterpret_cast(value.c_str()), value.length(), 0); } private: