Skip to content

changed NimBLE example #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 61 commits into
base: develop_33
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5711fca
Update README.md
Jason2866 Mar 9, 2025
6fa2efb
Update IDF 5.4.0.250303
Jason2866 Mar 9, 2025
aa5a97e
Added missing UM boards and fixed TinyS3 product URL. (#122)
UnexpectedMaker Mar 10, 2025
e247f2e
boards update taken from https://github.com/sivar2311/platformio_boards
Jason2866 Mar 19, 2025
832a195
pioarduino core 6.1.18
Jason2866 Mar 19, 2025
cac1250
Update IDF 5.4.0.250314
Jason2866 Mar 19, 2025
60b2963
Create esp32-s3-devkitc-1-n32r8v.json
Jason2866 Mar 20, 2025
b2c4121
Board Arduino Nano: standard no remapping
Jason2866 Mar 21, 2025
0a48460
Update arduino_nano_esp32.json
Jason2866 Mar 21, 2025
3d5ca25
add arduino_nano_esp32 board to Arduino Blink example
Jason2866 Mar 21, 2025
2fa97a5
remove already defined
Jason2866 Mar 21, 2025
9c5cf8b
no Arduino Nora Nano support
Jason2866 Mar 24, 2025
10aa217
arduino_nano_esp32.json: flash recovery image
Jason2866 Mar 24, 2025
fafc700
Update esptoolpy v4.8.9
Jason2866 Apr 1, 2025
6899b83
Create Bug_report.md
Jason2866 Apr 2, 2025
63fc1b3
Create config.yml
Jason2866 Apr 2, 2025
8eec5f0
add PR template
Jason2866 Apr 2, 2025
a7fab12
Update esp32-s3-devkitc1-n16r16.json (#136)
ikorman Apr 2, 2025
714989f
Ignore not used libs in example "Tasmota"
Jason2866 Apr 2, 2025
441f2b9
Disable BLE (sdkconfig) in CI Tasmota example
Jason2866 Apr 3, 2025
80cbeca
set lib_archive=False as default to make weak defines in Arduino Core…
Jason2866 Apr 7, 2025
a13d5f5
revert c
Jason2866 Apr 7, 2025
9c7f8b8
Set lib_archive to False as default
Jason2866 Apr 7, 2025
4eee52d
Update main.py
Jason2866 Apr 7, 2025
eb12567
Update IDF 5.4.1.250407
Jason2866 Apr 13, 2025
ba2dae6
Update platform.json
Jason2866 Apr 13, 2025
fa7beed
add esp-rom-elfs
Jason2866 Apr 13, 2025
6e848c3
Use actual develop 5.4. libs
Jason2866 Apr 13, 2025
f0bb1b8
Update pip dependencies
Jason2866 Apr 13, 2025
9530453
Update espidf.py
Jason2866 Apr 14, 2025
88fbdaf
Update IDF v5.4.1.250411
Jason2866 Apr 14, 2025
3a85a8b
remove old (not anymore working) way of setting start address of firm…
Jason2866 Apr 16, 2025
729d601
Update README.md
Jason2866 Apr 16, 2025
7da09cf
Update README.md to fix typos (#139)
lboue Apr 16, 2025
d47f924
remove generated old sdkconfig leftover
Jason2866 Apr 19, 2025
b07c738
Fix Arduino as an component of IDF compile for the C2
Jason2866 Apr 20, 2025
43ef94a
change example `custom_component_add`
Jason2866 Apr 23, 2025
d81abd0
Use Arduino libs idf-release_v5.4-3ad36321
Jason2866 Apr 23, 2025
b4d0e71
Esp32ExceptionDecoder: decode stack overflow backtraces
Jason2866 Apr 25, 2025
044dd0e
Fix Matter Arduino as an component of IDF example
Jason2866 Apr 25, 2025
2bdbd35
Update README.md
Jason2866 Apr 26, 2025
f8ec6d4
Add tl-install to install tools not in pio registry. Using for instal…
Jason2866 Apr 28, 2025
88a9675
Fix matter arduino as an component of IDF example (#150)
Jason2866 Apr 28, 2025
3532226
Update examples.yml
Jason2866 Apr 28, 2025
3389fe5
Update CMakeLists.txt
Jason2866 Apr 28, 2025
c962973
silence warning 'missing-field-initializers' in matter example
Jason2866 Apr 28, 2025
3f2bba1
Refactor toolchain install
Jason2866 Apr 30, 2025
faee6ac
New gdb v16.2 (#156)
Jason2866 Apr 30, 2025
a3d12dd
use sdkconfig setting `MMU_PAGE_SIZE`
Jason2866 May 1, 2025
bb6350e
fix pvs studio install for windows
Jason2866 May 1, 2025
63072e0
refactor check tools install
Jason2866 May 1, 2025
15cd60d
more examples to test check tools install
Jason2866 May 1, 2025
30dd6d8
Update platformio.ini
Jason2866 May 1, 2025
60ef22a
Update c2 compile skeleton
Jason2866 May 1, 2025
d501a0a
Update platformio.ini
Jason2866 May 1, 2025
f4def7f
Remove all dependencies to Platformio registry (#160)
Jason2866 May 2, 2025
7a33014
check for requirements match of already installed tools (#165)
Jason2866 May 4, 2025
829c345
fix crash when reinstalling
Jason2866 May 4, 2025
2c337e4
fix uploadfs
Jason2866 May 5, 2025
5ce80da
change NimBLE example
Jason2866 May 8, 2025
90f9cb6
Merge branch 'develop_33' into merge
Jason2866 May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- "examples/arduino-wifiscan"
- "examples/arduino-zigbee-light"
- "examples/arduino-zigbee-switch"
- "examples/arduino-NimBLE-ext_client"
- "examples/arduino-matter-light"
- "examples/tasmota"
- "examples/espidf-arduino-h2zero-BLE_scan"
- "examples/espidf-arduino-matter-light"
- "examples/arduino-matter-light"
- "examples/espidf-arduino-blink"
- "examples/espidf-arduino-littlefs"
- "examples/espidf-blink"
Expand Down
5 changes: 5 additions & 0 deletions examples/arduino-NimBLE-ext_client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NimBLE_extended_client example using h2zero Arduino NimBLE stack

BLE 5 client example, using the great [h2zero NimBLE](https://github.com/h2zero/NimBLE-Arduino) implementation.

Thx @h2zero for the great BLE library.
53 changes: 53 additions & 0 deletions examples/arduino-NimBLE-ext_client/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
platform = espressif32
framework = arduino
monitor_speed = 115200
build_flags =
'-DCONFIG_BT_NIMBLE_EXT_ADV=1'
lib_deps =
https://github.com/h2zero/NimBLE-Arduino
lib_ignore =
BLE
BluetoothSerial
SimpleBLE
WiFiProv
custom_component_remove =
espressif/esp_hosted
espressif/esp_wifi_remote
espressif/esp-dsp
espressif/network_provisioning
espressif/esp_rainmaker
espressif/rmaker_common
espressif/esp_insights
espressif/esp_diag_data_store
espressif/esp_diagnostics
espressif/libsodium
espressif/esp-modbus
espressif/esp-cbor
espressif/esp-sr
espressif/esp32-camera

[env:esp32s3]
board = esp32-s3-devkitc-1

[env:esp32c2]
board = esp32-c2-devkitm-1

[env:esp32c3]
board = esp32-c3-devkitm-1

[env:esp32c6]
board = esp32-c6-devkitm-1

[env:esp32h2]
board = esp32-h2-devkitm-1
150 changes: 150 additions & 0 deletions examples/arduino-NimBLE-ext_client/src/NimBLE_extended_client.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

/** NimBLE Extended Client Demo:
*
* Demonstrates the Bluetooth 5.x client capabilities.
*
* Created: on April 2 2022
* Author: H2zero
*
*/

#include <Arduino.h>
#include <NimBLEDevice.h>
#if !CONFIG_BT_NIMBLE_EXT_ADV
# error Must enable extended advertising, see nimconfig.h file.
#endif

#define SERVICE_UUID "ABCD"
#define CHARACTERISTIC_UUID "1234"

static const NimBLEAdvertisedDevice* advDevice;
static bool doConnect = false;
static uint32_t scanTime = 10 * 1000; // In milliseconds, 0 = scan forever

/** Define the PHY's to use when connecting to peer devices, can be 1, 2, or all 3 (default).*/
static uint8_t connectPhys = BLE_GAP_LE_PHY_CODED_MASK | BLE_GAP_LE_PHY_1M_MASK /*| BLE_GAP_LE_PHY_2M_MASK */;

/** Define a class to handle the callbacks for client connection events */
class ClientCallbacks : public NimBLEClientCallbacks {
void onConnect(NimBLEClient* pClient) override { Serial.printf("Connected\n"); };

void onDisconnect(NimBLEClient* pClient, int reason) override {
Serial.printf("%s Disconnected, reason = %d - Starting scan\n", pClient->getPeerAddress().toString().c_str(), reason);
NimBLEDevice::getScan()->start(scanTime);
}
} clientCallbacks;

/** Define a class to handle the callbacks when advertisements are received */
class scanCallbacks : public NimBLEScanCallbacks {
void onResult(const NimBLEAdvertisedDevice* advertisedDevice) override {
Serial.printf("Advertised Device found: %s\n", advertisedDevice->toString().c_str());
if (advertisedDevice->isAdvertisingService(NimBLEUUID("ABCD"))) {
Serial.printf("Found Our Service\n");
doConnect = true;
/** Save the device reference in a global for the client to use*/
advDevice = advertisedDevice;
/** stop scan before connecting */
NimBLEDevice::getScan()->stop();
}
}

/** Callback to process the results of the completed scan or restart it */
void onScanEnd(const NimBLEScanResults& results, int rc) override { Serial.printf("Scan Ended\n"); }
} scanCallbacks;

/** Handles the provisioning of clients and connects / interfaces with the server */
bool connectToServer() {
NimBLEClient* pClient = nullptr;

pClient = NimBLEDevice::createClient();
pClient->setClientCallbacks(&clientCallbacks, false);

/**
* Set the PHY's to use for this connection. This is a bitmask that represents the PHY's:
* * 0x01 BLE_GAP_LE_PHY_1M_MASK
* * 0x02 BLE_GAP_LE_PHY_2M_MASK
* * 0x04 BLE_GAP_LE_PHY_CODED_MASK
* Combine these with OR ("|"), eg BLE_GAP_LE_PHY_1M_MASK | BLE_GAP_LE_PHY_2M_MASK | BLE_GAP_LE_PHY_CODED_MASK;
*/
pClient->setConnectPhy(connectPhys);

/** Set how long we are willing to wait for the connection to complete (milliseconds), default is 30000. */
pClient->setConnectTimeout(10 * 1000);

if (!pClient->connect(advDevice)) {
/** Created a client but failed to connect, don't need to keep it as it has no data */
NimBLEDevice::deleteClient(pClient);
Serial.printf("Failed to connect, deleted client\n");
return false;
}

Serial.printf("Connected to: %s RSSI: %d\n", pClient->getPeerAddress().toString().c_str(), pClient->getRssi());

/** Now we can read/write/subscribe the characteristics of the services we are interested in */
NimBLERemoteService* pSvc = nullptr;
NimBLERemoteCharacteristic* pChr = nullptr;

pSvc = pClient->getService(SERVICE_UUID);
if (pSvc) {
pChr = pSvc->getCharacteristic(CHARACTERISTIC_UUID);
if (pChr) {
if (pChr->canRead()) {
std::string value = pChr->readValue();
Serial.printf("Characteristic value: %s\n", value.c_str());
}
}

} else {
Serial.printf("ABCD service not found.\n");
}

NimBLEDevice::deleteClient(pClient);
Serial.printf("Done with this device!\n");
return true;
}

void setup() {
Serial.begin(115200);
Serial.printf("Starting NimBLE Client\n");

/** Initialize NimBLE and set the device name */
NimBLEDevice::init("NimBLE Extended Client");

/** Create aNimBLE Scan instance and set the callbacks for scan events */
NimBLEScan* pScan = NimBLEDevice::getScan();
pScan->setScanCallbacks(&scanCallbacks);

/** Set scan interval (how often) and window (how long) in milliseconds */
pScan->setInterval(97);
pScan->setWindow(67);

/**
* Active scan will gather scan response data from advertisers
* but will use more energy from both devices
*/
pScan->setActiveScan(true);

/**
* Start scanning for advertisers for the scan time specified (in milliseconds) 0 = forever
* Optional callback for when scanning stops.
*/
pScan->start(scanTime);

Serial.printf("Scanning for peripherals\n");
}

void loop() {
/** Loop here until we find a device we want to connect to */
if (doConnect) {
if (connectToServer()) {
Serial.printf("Success!, scanning for more!\n");
} else {
Serial.printf("Failed to connect, starting scan\n");
}

doConnect = false;
NimBLEDevice::getScan()->start(scanTime);
}

delay(10);
}
3 changes: 2 additions & 1 deletion examples/arduino-blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ custom_component_remove = espressif/esp_hosted
espressif/esp_diagnostics
espressif/esp_rainmaker
espressif/rmaker_common
custom_component_add = espressif/cmake_utilities @ 0.*
custom_component_add =
espressif/cmake_utilities @ 0.*

[env:esp32-s3-arduino_nano_esp32]
platform = espressif32
Expand Down
2 changes: 0 additions & 2 deletions examples/espidf-arduino-h2zero-BLE_scan/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions examples/espidf-arduino-h2zero-BLE_scan/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions examples/espidf-arduino-h2zero-BLE_scan/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions examples/espidf-arduino-h2zero-BLE_scan/platformio.ini

This file was deleted.

34 changes: 0 additions & 34 deletions examples/espidf-arduino-h2zero-BLE_scan/sdkconfig.defaults

This file was deleted.

6 changes: 0 additions & 6 deletions examples/espidf-arduino-h2zero-BLE_scan/src/CMakeLists.txt

This file was deleted.

41 changes: 0 additions & 41 deletions examples/espidf-arduino-h2zero-BLE_scan/src/idf_component.yml

This file was deleted.

Loading
Loading