Skip to content

Commit 342e640

Browse files
committed
add h2zero NimBLE example
1 parent df8ab31 commit 342e640

File tree

11 files changed

+255
-0
lines changed

11 files changed

+255
-0
lines changed

.github/workflows/examples.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- "examples/arduino-rmt-blink"
1919
- "examples/arduino-usb-keyboard"
2020
- "examples/arduino-wifiscan"
21+
- "examples/espidf-arduino-h2zero-BLE_scan"
2122
- "examples/espidf-arduino-blink"
2223
- "examples/espidf-arduino-littlefs"
2324
- "examples/espidf-blink"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.pio
2+
.vscode
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.16.0)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
add_compile_definitions(ARDUINO_ARCH_ESP32=1)
4+
project(Arduino_IDF_BLE_scan)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Arduino_IDF_BLE_scan example using 3rd party NimBLE stack
2+
3+
BLE scan example, using the great h2zero NimBLE implementation. The needed NimBLE lib is loaded via the IDF component manager -> `idf_component.yml`.
4+
Mandantory not to forget to switch Arduino included BLE libs.
5+
Done in `sdkconfig.defaults`
6+
7+
Thx @h2zero for the great BLE library.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in a an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env]
12+
platform = espressif32
13+
framework = arduino, espidf
14+
monitor_speed = 115200
15+
board_build.embed_txtfiles =
16+
managed_components/espressif__esp_insights/server_certs/https_server.crt
17+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
18+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
19+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
20+
21+
[env:esp32]
22+
board = esp32dev
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# CONFIG_AUTOSTART_ARDUINO is not set
2+
# CONFIG_WS2812_LED_ENABLE is not set
3+
CONFIG_FREERTOS_HZ=1000
4+
CONFIG_MBEDTLS_PSK_MODES=y
5+
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
6+
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
7+
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
8+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
9+
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
10+
11+
# Override some defaults so BT stack is enabled
12+
# in this example
13+
#
14+
# BT config
15+
#
16+
CONFIG_BT_ENABLED=y
17+
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
18+
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
19+
CONFIG_BTDM_CTRL_MODE_BTDM=n
20+
CONFIG_BT_BLUEDROID_ENABLED=n
21+
CONFIG_BT_NIMBLE_ENABLED=y
22+
23+
#
24+
# Arduino Configuration
25+
#
26+
#
27+
# Disable all Arduino included BLE libraries
28+
#
29+
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
30+
# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set
31+
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
32+
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
33+
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
34+
# end of Arduino Configuration
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file was automatically generated for projects
2+
# without default 'CMakeLists.txt' file.
3+
4+
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
5+
6+
idf_component_register(SRCS ${app_sources})
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
dependencies:
2+
# Required IDF version
3+
idf: ">=4.4"
4+
5+
esp-nimble-cpp:
6+
git: https://github.com/h2zero/esp-nimble-cpp.git
7+
8+
9+
# # Defining a dependency from the registry:
10+
# # https://components.espressif.com/component/example/cmp
11+
# example/cmp: "^3.3.3" # Automatically update minor releases
12+
#
13+
# # Other ways to define dependencies
14+
#
15+
# # For components maintained by Espressif only name can be used.
16+
# # Same as `espressif/cmp`
17+
# component: "~1.0.0" # Automatically update bugfix releases
18+
#
19+
# # Or in a longer form with extra parameters
20+
# component2:
21+
# version: ">=2.0.0"
22+
#
23+
# # For transient dependencies `public` flag can be set.
24+
# # `public` flag doesn't have an effect for the `main` component.
25+
# # All dependencies of `main` are public by default.
26+
# public: true
27+
#
28+
# # For components hosted on non-default registry:
29+
# service_url: "https://componentregistry.company.com"
30+
#
31+
# # For components in git repository:
32+
# test_component:
33+
# path: test_component
34+
# git: ssh://[email protected]/user/components.git
35+
#
36+
# # For test projects during component development
37+
# # components can be used from a local directory
38+
# # with relative or absolute path
39+
# some_local_component:
40+
# path: ../../projects/component

0 commit comments

Comments
 (0)