Rust bindings for the Apache NimBLE project
Ensure you have the proper compiler for the platform you're targeting. For example, if you are using an nRF chip, this means you will need
arm-none-eabi-gcc
/arm-none-eabi-cc
, provided by the Arm GNU Toolchain.
This will allow cc
to compile NimBLE's code (more info below).
This repository provides the port layer implementations and high level bindings that allow you to use the NimBLE stack in a Rust embedded project.
This crate provides the raw bindings generated by bindgen
from NimBLE's header files. Additionally, it contains implementations for NimBLE's port layer types and
functions, and support for different radio drivers through their respective Peripheral Access Crate.
Note that you need to change the BINDGEN_EXTRA_CLANG_ARGS
environment variable to contain an argument that points
to the correct sysroot for your platform:
# .cargo/config.toml
[env]
BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=/usr/arm-none-eabi"
This crate provides the high-level bindings intended for your use. Only controller bindings are available, for now.
At build time, cbindgen
is used to generate the C types for the port layer
implemented in apache-nimble-sys
. Then, cc
is used to compile the NimBLE code
itself, which gets linked into your final binary. Depending on the feature flags you choose, certain parts of
NimBLE's code will be compiled. You can enable/disable the following feature flags:
controller
- (TODO)
host
- High-level bindings for NimBLE's host subsystem (
mynewt-nimble/nimble/host
)
- High-level bindings for NimBLE's host subsystem (
Internally, NimBLE code will use a critical section implementation that disables all interrupts (implemented as part of the port layer).
Code that uses the critical-section
crate will use a separate implementation that disables all interrupts, except
those that are needed by the NimBLE controller (typically RADIO, RNG, and RTC0). Make sure to enable the
critical-section
flag on the apache-nimble
crate, and remember not to disable NimBLE interrupts in application code, as it
may interfere with NimBLE's processing.
NimBLE provides a porting layer that allows developers to provide support for different operating systems. This repository contains port layer implementations intended to be used with common Rust embedded environments.
To select a specific port layer, enable one of the following feature flags on the apache-nimble
crate:
port-layer-embassy
- Implemented with
embassy-time-driver
, andembassy-sync
primitives. Intended to be used with theembassy-executor
.
- Implemented with
The apache-nimble-sys
crate provides support for a radio driver by implementing port layer functions that set up their respective interrupt handlers.
The apache-nimble
crate provides support by compiling the necessary C driver code (mynewt-nimble/nimble/drivers
) at build time, based on the chosen chip below.
To select a radio driver to use, enable one of the following feature flags on the apache-nimble
crate:
nrf52840
This repository contains code for nrfx
,
and CMSIS_5
, which are available under their
own respective licenses.
The apache-nimble
and apache-nimble-sys
crates are available under the Apache 2.0 license.