Skip to content

Commit 9afabc8

Browse files
authored
Merge pull request #3 from ESPresense/codex/update-example-to-show-new-functionality
Add workflow to build PlatformIO examples
2 parents 7c7068d + 0a1e1be commit 9afabc8

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build Arduino examples
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/**'
7+
- 'examples/**'
8+
- 'library.properties'
9+
- '.github/workflows/platformio-examples.yml'
10+
pull_request:
11+
paths:
12+
- 'src/**'
13+
- 'examples/**'
14+
- 'library.properties'
15+
- '.github/workflows/platformio-examples.yml'
16+
workflow_dispatch:
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.11'
30+
31+
- name: Cache PlatformIO
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.platformio
35+
key: platformio-${{ runner.os }}-${{ hashFiles('library.properties') }}
36+
restore-keys: |
37+
platformio-${{ runner.os }}-
38+
39+
- name: Install PlatformIO Core
40+
run: pip install --upgrade platformio
41+
42+
- name: Build examples
43+
shell: bash
44+
run: |
45+
set -euo pipefail
46+
shopt -s nullglob
47+
sketches=(examples/*/*.ino)
48+
49+
if [ ${#sketches[@]} -eq 0 ]; then
50+
echo "No examples found"
51+
exit 1
52+
fi
53+
54+
for sketch in "${sketches[@]}"; do
55+
sketch_dir=$(dirname "$sketch")
56+
sketch_name=$(basename "$sketch_dir")
57+
echo "::group::Building ${sketch_name}"
58+
pio ci \
59+
--board esp32dev \
60+
--lib="." \
61+
"$sketch"
62+
echo "::endgroup::"
63+
done

examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* This example will scan forever while consuming as few resources as possible
33
* and report all advertisments on the serial monitor.
44
*
5+
* The scan callback prints the primary advertising channel for each
6+
* advertisement when available, demonstrating the use of
7+
* NimBLEAdvertisedDevice::getChannel().
8+
*
59
* Created: on January 31 2021
610
* Author: H2zero
711
*
@@ -13,7 +17,14 @@ NimBLEScan* pBLEScan;
1317

1418
class MyAdvertisedDeviceCallbacks: public NimBLEAdvertisedDeviceCallbacks {
1519
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
16-
Serial.printf("Advertised Device: %s \n", advertisedDevice->toString().c_str());
20+
uint8_t channel = advertisedDevice->getChannel();
21+
if (channel != 0xFF) {
22+
Serial.printf("Advertised Device on channel %u: %s \n",
23+
channel, advertisedDevice->toString().c_str());
24+
} else {
25+
Serial.printf("Advertised Device on unknown channel: %s \n",
26+
advertisedDevice->toString().c_str());
27+
}
1728
}
1829
};
1930

0 commit comments

Comments
 (0)