Skip to content

Commit a8e5473

Browse files
committed
Update actions workflow to build BT5 examples, fix example builds.
1 parent c3c24a1 commit a8e5473

File tree

3 files changed

+155
-18
lines changed

3 files changed

+155
-18
lines changed

.github/workflows/build.yml

Lines changed: 138 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
- "examples/NimBLE_Server"
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Set up Python
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: "3.x"
2020
- name: Install platformio
@@ -43,6 +43,48 @@ jobs:
4343
cp ${{ matrix.example }}/* example/src/
4444
platformio run -d example
4545
46+
build_bt5_esp_pio:
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
example:
51+
- "examples/Bluetooth_5/NimBLE_extended_client"
52+
- "examples/Bluetooth_5/NimBLE_extended_server"
53+
variant:
54+
- esp32c3
55+
- esp32s3
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: "3.x"
63+
- name: Install platformio
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install platformio
67+
- name: Build esp PIO
68+
run: |
69+
mkdir -p example/lib
70+
rsync -Rr . example/lib/
71+
mkdir example/src
72+
cat > example/platformio.ini << EOF
73+
[env]
74+
platform = espressif32
75+
framework = arduino
76+
77+
[env:esp32c3]
78+
board = esp32-c3-devkitm-1
79+
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'
80+
81+
[env:esp32s3]
82+
board = esp32-s3-devkitc-1
83+
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'
84+
EOF
85+
cp ${{ matrix.example }}/* example/src/
86+
platformio run -d example
87+
4688
build_arduino-esp32:
4789
strategy:
4890
fail-fast: false
@@ -56,7 +98,7 @@ jobs:
5698
- esp32s3
5799
runs-on: ubuntu-latest
58100
steps:
59-
- uses: actions/checkout@v3
101+
- uses: actions/checkout@v4
60102
- name: Build arduino-esp32
61103
uses: arduino/compile-sketches@v1.1.0
62104
with:
@@ -68,6 +110,33 @@ jobs:
68110
fqbn: "esp32:esp32:${{ matrix.variant }}"
69111
sketch-paths: ${{ matrix.example }}
70112

113+
build_bt5_arduino-esp32:
114+
strategy:
115+
fail-fast: false
116+
matrix:
117+
example:
118+
- "examples/Bluetooth_5/NimBLE_extended_client"
119+
- "examples/Bluetooth_5/NimBLE_extended_server"
120+
variant:
121+
- esp32c3
122+
- esp32s3
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v4
126+
- name: Set config for BT5
127+
run: |
128+
sed -i '0,/#include \"nimconfig_rename.h\"/a #define CONFIG_BT_NIMBLE_EXT_ADV 1' ./src/nimconfig.h
129+
- name: Build BT5 arduino-esp32
130+
uses: arduino/compile-sketches@v1.1.0
131+
with:
132+
cli-version: latest
133+
platforms: |
134+
- name: "esp32:esp32"
135+
source-url: "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
136+
version: latest
137+
fqbn: "esp32:esp32:${{ matrix.variant }}"
138+
sketch-paths: ${{ matrix.example }}
139+
71140
build_n-able-Arduino:
72141
strategy:
73142
fail-fast: false
@@ -82,7 +151,7 @@ jobs:
82151
- Generic_nRF52840
83152
runs-on: ubuntu-latest
84153
steps:
85-
- uses: actions/checkout@v3
154+
- uses: actions/checkout@v4
86155
- name: Build n-able Arduino
87156
uses: arduino/compile-sketches@v1.1.0
88157
with:
@@ -94,6 +163,32 @@ jobs:
94163
fqbn: "h2zero:arm-ble:${{ matrix.variant }}"
95164
sketch-paths: ${{ matrix.example }}
96165

166+
build_bt5_n-able-Arduino:
167+
strategy:
168+
fail-fast: false
169+
matrix:
170+
example:
171+
- "examples/Bluetooth_5/NimBLE_extended_client"
172+
- "examples/Bluetooth_5/NimBLE_extended_server"
173+
variant:
174+
- Generic_nRF52840
175+
runs-on: ubuntu-latest
176+
steps:
177+
- uses: actions/checkout@v4
178+
- name: Set config for BT5
179+
run: |
180+
echo "-DCONFIG_BT_NIMBLE_EXT_ADV=1" > ${{ matrix.example }}/build_opt.h
181+
- name: Build BT5 n-able Arduino
182+
uses: arduino/compile-sketches@v1.1.0
183+
with:
184+
cli-version: latest
185+
platforms: |
186+
- name: "h2zero:arm-ble"
187+
source-url: "https://h2zero.github.io/n-able-Arduino/package_n-able_boards_index.json"
188+
version: latest
189+
fqbn: "h2zero:arm-ble:${{ matrix.variant }}"
190+
sketch-paths: ${{ matrix.example }}
191+
97192
build_n-able-pio:
98193
strategy:
99194
fail-fast: false
@@ -103,9 +198,9 @@ jobs:
103198
- "examples/NimBLE_Server"
104199
runs-on: ubuntu-latest
105200
steps:
106-
- uses: actions/checkout@v3
201+
- uses: actions/checkout@v4
107202
- name: Set up Python
108-
uses: actions/setup-python@v4
203+
uses: actions/setup-python@v5
109204
with:
110205
python-version: "3.x"
111206
- name: Install platformio
@@ -136,10 +231,46 @@ jobs:
136231
EOF
137232
cp ${{ matrix.example }}/* example/src/
138233
platformio run -d example
234+
235+
build_bt5_n-able-pio:
236+
strategy:
237+
fail-fast: false
238+
matrix:
239+
example:
240+
- "examples/Bluetooth_5/NimBLE_extended_client"
241+
- "examples/Bluetooth_5/NimBLE_extended_server"
242+
runs-on: ubuntu-latest
243+
steps:
244+
- uses: actions/checkout@v4
245+
- name: Set up Python
246+
uses: actions/setup-python@v5
247+
with:
248+
python-version: "3.x"
249+
- name: Install platformio
250+
run: |
251+
python -m pip install --upgrade pip
252+
pip install platformio
253+
- name: Build esp PIO
254+
run: |
255+
mkdir -p example/lib
256+
rsync -Rr . example/lib/
257+
mkdir example/src
258+
cat > example/platformio.ini << EOF
259+
[env]
260+
platform = https://github.com/h2zero/platform-n-able.git#1.0.0
261+
framework = arduino
262+
263+
[env:generic_nrf52840]
264+
board = generic_nrf52840
265+
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'
266+
EOF
267+
cp ${{ matrix.example }}/* example/src/
268+
platformio run -d example
269+
139270
build_docs:
140271
runs-on: ubuntu-latest
141272
steps:
142-
- uses: actions/checkout@v3
273+
- uses: actions/checkout@v4
143274
- name: Doxygen Action
144275
uses: mattnotmitt/doxygen-action@v1.9.5
145276
with:

examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
*
99
*/
1010

11-
/****************************************************
12-
* For use with ESP32C3, ESP32S3, ESP32H2 ONLY! *
13-
/**************************************************/
14-
1511
#include <NimBLEDevice.h>
1612
#if !CONFIG_BT_NIMBLE_EXT_ADV
1713
# error Must enable extended advertising, see nimconfig.h file.

examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
*
1313
*/
1414

15-
/****************************************************
16-
* For use with ESP32C3, ESP32S3, ESP32H2 ONLY! *
17-
/**************************************************/
18-
1915
#include "NimBLEDevice.h"
2016
#if !CONFIG_BT_NIMBLE_EXT_ADV
2117
# error Must enable extended advertising, see nimconfig.h file.
2218
#endif
2319

20+
#ifdef ESP_PLATFORM
2421
#include "esp_sleep.h"
22+
#endif
2523

2624
#define SERVICE_UUID "ABCD"
2725
#define CHARACTERISTIC_UUID "1234"
@@ -48,8 +46,12 @@ class ServerCallbacks: public NimBLEServerCallbacks {
4846
};
4947

5048
void onDisconnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo, int reason) {
51-
Serial.printf("Client disconnected - sleeping for %u seconds\n", sleepSeconds);
49+
Serial.printf("Client disconnected - sleeping for %" PRIu32 "seconds\n", sleepSeconds);
50+
#ifdef ESP_PLATFORM
5251
esp_deep_sleep_start();
52+
#else
53+
systemRestart(); // nRF platforms restart then sleep via delay in setup.
54+
#endif
5355
};
5456
};
5557

@@ -63,18 +65,24 @@ class advertisingCallbacks: public NimBLEExtAdvertisingCallbacks {
6365
printf("Client connecting\n");
6466
return;
6567
case BLE_HS_ETIMEOUT:
66-
printf("Time expired - sleeping for %u seconds\n", sleepSeconds);
68+
printf("Time expired - sleeping for %" PRIu32 "seconds\n", sleepSeconds);
6769
break;
6870
default:
6971
break;
7072
}
71-
73+
#ifdef ESP_PLATFORM
7274
esp_deep_sleep_start();
75+
#else
76+
systemRestart(); // nRF platforms restart then sleep via delay in setup.
77+
#endif
7378
}
7479
};
7580

7681
void setup () {
7782
Serial.begin(115200);
83+
#ifndef ESP_PLATFORM
84+
delay(sleepSeconds * 1000); // system ON sleep mode for nRF platforms to simulate the esp deep sleep with timer wakeup
85+
#endif
7886

7987
NimBLEDevice::init("Extended advertiser");
8088

@@ -143,7 +151,9 @@ void setup () {
143151
Serial.printf("Failed to register advertisment data\n");
144152
}
145153

154+
#ifdef ESP_PLATFORM
146155
esp_sleep_enable_timer_wakeup(sleepSeconds * 1000000);
156+
#endif
147157
}
148158

149159
void loop () {

0 commit comments

Comments
 (0)