From 0a1e1be2541654bfd9662bfce082824e87791679 Mon Sep 17 00:00:00 2001 From: Darrell Date: Mon, 10 Nov 2025 05:46:31 -0500 Subject: [PATCH] Add PlatformIO example build workflow --- .github/workflows/platformio-examples.yml | 63 +++++++++++++++++++ .../NimBLE_Scan_Continuous.ino | 13 +++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/platformio-examples.yml diff --git a/.github/workflows/platformio-examples.yml b/.github/workflows/platformio-examples.yml new file mode 100644 index 000000000..a2fbe0a3a --- /dev/null +++ b/.github/workflows/platformio-examples.yml @@ -0,0 +1,63 @@ +name: Build Arduino examples + +on: + push: + paths: + - 'src/**' + - 'examples/**' + - 'library.properties' + - '.github/workflows/platformio-examples.yml' + pull_request: + paths: + - 'src/**' + - 'examples/**' + - 'library.properties' + - '.github/workflows/platformio-examples.yml' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Cache PlatformIO + uses: actions/cache@v4 + with: + path: ~/.platformio + key: platformio-${{ runner.os }}-${{ hashFiles('library.properties') }} + restore-keys: | + platformio-${{ runner.os }}- + + - name: Install PlatformIO Core + run: pip install --upgrade platformio + + - name: Build examples + shell: bash + run: | + set -euo pipefail + shopt -s nullglob + sketches=(examples/*/*.ino) + + if [ ${#sketches[@]} -eq 0 ]; then + echo "No examples found" + exit 1 + fi + + for sketch in "${sketches[@]}"; do + sketch_dir=$(dirname "$sketch") + sketch_name=$(basename "$sketch_dir") + echo "::group::Building ${sketch_name}" + pio ci \ + --board esp32dev \ + --lib="." \ + "$sketch" + echo "::endgroup::" + done diff --git a/examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino b/examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino index b8d24d264..6660b28c7 100644 --- a/examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino +++ b/examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino @@ -2,6 +2,10 @@ * This example will scan forever while consuming as few resources as possible * and report all advertisments on the serial monitor. * + * The scan callback prints the primary advertising channel for each + * advertisement when available, demonstrating the use of + * NimBLEAdvertisedDevice::getChannel(). + * * Created: on January 31 2021 * Author: H2zero * @@ -13,7 +17,14 @@ NimBLEScan* pBLEScan; class MyAdvertisedDeviceCallbacks: public NimBLEAdvertisedDeviceCallbacks { void onResult(NimBLEAdvertisedDevice* advertisedDevice) { - Serial.printf("Advertised Device: %s \n", advertisedDevice->toString().c_str()); + uint8_t channel = advertisedDevice->getChannel(); + if (channel != 0xFF) { + Serial.printf("Advertised Device on channel %u: %s \n", + channel, advertisedDevice->toString().c_str()); + } else { + Serial.printf("Advertised Device on unknown channel: %s \n", + advertisedDevice->toString().c_str()); + } } };