Skip to content

Commit

Permalink
Merge pull request #129 from taks/fix-128
Browse files Browse the repository at this point in the history
Reflect new build args propagation in `build.rs`
  • Loading branch information
taks authored Jun 27, 2024
2 parents 50d683b + d1b0dcd commit 073d9f4
Show file tree
Hide file tree
Showing 39 changed files with 80 additions and 74 deletions.
11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ opt-level = "z"
[features]
default = ["std"]

std = ["esp-idf-svc/std", "esp-idf-hal/std", "once_cell/std", "bstr/std"]
no_std = ["once_cell/critical-section", "esp-idf-hal/critical-section", "bstr/alloc"]
std = ["esp-idf-svc/std", "once_cell/std", "bstr/std"]
no_std = ["once_cell/critical-section", "esp-idf-svc/critical-section", "bstr/alloc"]
debug = []

[dependencies]
log = { version = "0.4", default-features = false }
esp-idf-sys = { version = "0.35", default-features = false }
esp-idf-hal = { version = "0.44", default-features = false, features = ["embassy-sync"] }
esp-idf-svc = { version = "0.49", default-features = false, features = ["alloc"] }
embedded-svc = { version = "0.28", default-features = false }
esp-idf-svc = { version = "0.49", default-features = false, features = ["alloc", "embassy-sync"] }

bitflags = { version = "2.4.1" }
bstr = { version = "1.8.0", default-features = false }
Expand All @@ -43,7 +40,7 @@ uuid = { version = "1", default-features = false, features = ["macro-diagnostics

[dev-dependencies]
anyhow = "1"
esp-idf-sys = { version = "0.35", default-features = false, features = ["binstart", "alloc_handler"] }
esp-idf-svc = "0.49"

[build-dependencies]
anyhow = "1"
Expand Down
6 changes: 2 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
fn main() -> anyhow::Result<()> {
embuild::build::CfgArgs::output_propagated("ESP_IDF")?;
embuild::build::LinkArgs::output_propagated("ESP_IDF")
fn main() {
embuild::espidf::sysenv::output();
}
6 changes: 3 additions & 3 deletions examples/ble5_multi_advertiser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use esp_idf_sys::{BLE_HCI_LE_PHY_1M, BLE_HCI_LE_PHY_CODED};
use esp_idf_svc::sys::{BLE_HCI_LE_PHY_1M, BLE_HCI_LE_PHY_CODED};

use esp32_nimble::{
utilities::BleUuid, BLEAddress, BLEAddressType, BLEDevice, BLEExtAdvertisement, NimbleProperties,
Expand All @@ -7,7 +7,7 @@ use esp32_nimble::{
const SERVICE_UUID: BleUuid = BleUuid::Uuid16(0xABCD);

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let ble_device = BLEDevice::take();
Expand Down Expand Up @@ -56,6 +56,6 @@ fn main() -> anyhow::Result<()> {
}

loop {
esp_idf_hal::delay::FreeRtos::delay_ms(5000);
esp_idf_svc::hal::delay::FreeRtos::delay_ms(5000);
}
}
11 changes: 6 additions & 5 deletions examples/ble_client.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use bstr::ByteSlice;
use esp32_nimble::{uuid128, BLEClient, BLEDevice};
use esp_idf_hal::prelude::Peripherals;
use esp_idf_hal::task::block_on;
use esp_idf_hal::timer::{TimerConfig, TimerDriver};
use esp_idf_sys as _;
use esp_idf_svc::hal::{
prelude::Peripherals,
task::block_on,
timer::{TimerConfig, TimerDriver},
};

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let peripherals = Peripherals::take()?;
Expand Down
7 changes: 3 additions & 4 deletions examples/ble_keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use esp32_nimble::{
enums::*, hid::*, utilities::mutex::Mutex, BLEAdvertisementData, BLECharacteristic, BLEDevice,
BLEHIDDevice, BLEServer,
};
use esp_idf_sys as _;
use std::sync::Arc;

const KEYBOARD_ID: u8 = 0x01;
Expand Down Expand Up @@ -298,12 +297,12 @@ impl Keyboard {

fn send_report(&self, keys: &KeyReport) {
self.input_keyboard.lock().set_from(keys).notify();
esp_idf_hal::delay::Ets::delay_ms(7);
esp_idf_svc::hal::delay::Ets::delay_ms(7);
}
}

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let mut keyboard = Keyboard::new()?;
Expand All @@ -313,6 +312,6 @@ fn main() -> anyhow::Result<()> {
::log::info!("Sending 'Hello world'...");
keyboard.write("Hello world\n");
}
esp_idf_hal::delay::FreeRtos::delay_ms(5000);
esp_idf_svc::hal::delay::FreeRtos::delay_ms(5000);
}
}
8 changes: 2 additions & 6 deletions examples/ble_scan.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use esp32_nimble::BLEDevice;
use esp_idf_hal::task::block_on;
use esp_idf_sys as _;
use esp_idf_svc::hal::task::block_on;
use log::*;

fn main() -> anyhow::Result<()> {
// Temporary. Will disappear once ESP-IDF 4.4 is released, but for now it is necessary to call this function once,
// or else some patches to the runtime implemented by esp-idf-sys might not link properly.
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();

// Bind the log crate to the ESP Logging facilities
esp_idf_svc::log::EspLogger::initialize_default();
log::set_max_level(log::LevelFilter::Debug);

Expand Down
5 changes: 2 additions & 3 deletions examples/ble_secure_client.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use esp32_nimble::{enums::*, utilities::BleUuid, BLEClient, BLEDevice};
use esp_idf_hal::task::block_on;
use esp_idf_sys as _;
use esp_idf_svc::hal::task::block_on;
use log::*;

const SERVICE_UUID: BleUuid = BleUuid::Uuid16(0xABCD);

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

block_on(async {
Expand Down
7 changes: 3 additions & 4 deletions examples/ble_secure_server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use esp32_nimble::{
enums::*, utilities::BleUuid, BLEAdvertisementData, BLEDevice, NimbleProperties,
};
use esp_idf_sys as _;

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let device = BLEDevice::take();
Expand All @@ -21,7 +20,7 @@ fn main() -> anyhow::Result<()> {
server.on_connect(|server, desc| {
::log::info!("Client connected: {:?}", desc);

if server.connected_count() < (esp_idf_sys::CONFIG_BT_NIMBLE_MAX_CONNECTIONS as _) {
if server.connected_count() < (esp_idf_svc::sys::CONFIG_BT_NIMBLE_MAX_CONNECTIONS as _) {
::log::info!("Multi-connect support: start advertising");
ble_advertising.lock().start().unwrap();
}
Expand Down Expand Up @@ -66,6 +65,6 @@ fn main() -> anyhow::Result<()> {
::log::info!("bonded_addresses: {:?}", device.bonded_addresses());

loop {
esp_idf_hal::delay::FreeRtos::delay_ms(1000);
esp_idf_svc::hal::delay::FreeRtos::delay_ms(1000);
}
}
7 changes: 3 additions & 4 deletions examples/ble_server.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use esp32_nimble::{uuid128, BLEAdvertisementData, BLEDevice, NimbleProperties};
use esp_idf_sys as _;
use std::format;

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let ble_device = BLEDevice::take();
Expand All @@ -17,7 +16,7 @@ fn main() -> anyhow::Result<()> {
.update_conn_params(desc.conn_handle(), 24, 48, 0, 60)
.unwrap();

if server.connected_count() < (esp_idf_sys::CONFIG_BT_NIMBLE_MAX_CONNECTIONS as _) {
if server.connected_count() < (esp_idf_svc::sys::CONFIG_BT_NIMBLE_MAX_CONNECTIONS as _) {
::log::info!("Multi-connect support: start advertising");
ble_advertising.lock().start().unwrap();
}
Expand Down Expand Up @@ -74,7 +73,7 @@ fn main() -> anyhow::Result<()> {

let mut counter = 0;
loop {
esp_idf_hal::delay::FreeRtos::delay_ms(1000);
esp_idf_svc::hal::delay::FreeRtos::delay_ms(1000);
notifying_characteristic
.lock()
.set_value(format!("Counter: {counter}").as_bytes())
Expand Down
10 changes: 3 additions & 7 deletions examples/ble_start_stop.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use esp32_nimble::{uuid128, BLEAdvertisementData, BLEDevice, NimbleProperties};
use esp_idf_hal::peripherals::Peripherals;
use esp_idf_hal::uart::*;
use esp_idf_hal::units::Hertz;
use esp_idf_hal::{delay::*, gpio};
use esp_idf_sys as _;
use esp_idf_svc::hal::{delay::*, gpio, peripherals::Peripherals, uart::*, units::Hertz};

fn main() -> anyhow::Result<()> {
esp_idf_sys::link_patches();
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();

let peripherals = Peripherals::take()?;
Expand Down Expand Up @@ -80,7 +76,7 @@ fn main() -> anyhow::Result<()> {
let mut buf = [0_u8; 10];
let mut initialized = true;
loop {
esp_idf_hal::delay::FreeRtos::delay_ms(1000);
esp_idf_svc::hal::delay::FreeRtos::delay_ms(1000);
let len = uart.read(&mut buf, NON_BLOCK)?;
if (buf[..len]).contains(&b's') {
if initialized {
Expand Down
10 changes: 5 additions & 5 deletions src/ble_address.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use esp_idf_sys::*;
use esp_idf_svc::sys::*;
use num_enum::TryFromPrimitive;

/// Bluetooth Device address type
Expand All @@ -14,13 +14,13 @@ pub enum BLEAddressType {
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct BLEAddress {
pub(crate) value: esp_idf_sys::ble_addr_t,
pub(crate) value: ble_addr_t,
}

impl BLEAddress {
pub fn new(val: [u8; 6], addr_type: BLEAddressType) -> Self {
let mut ret = Self {
value: esp_idf_sys::ble_addr_t {
value: ble_addr_t {
val,
type_: addr_type as _,
},
Expand Down Expand Up @@ -61,8 +61,8 @@ impl BLEAddress {
}
}

impl From<esp_idf_sys::ble_addr_t> for BLEAddress {
fn from(value: esp_idf_sys::ble_addr_t) -> Self {
impl From<ble_addr_t> for BLEAddress {
fn from(value: ble_addr_t) -> Self {
Self { value }
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ble_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use core::{
ffi::c_void,
sync::atomic::{AtomicBool, Ordering},
};
use esp_idf_svc::sys as esp_idf_sys;
use esp_idf_sys::{esp, esp_nofail, EspError};
use once_cell::sync::Lazy;

Expand Down
1 change: 1 addition & 0 deletions src/ble_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::num::NonZeroI32;
use esp_idf_svc::sys as esp_idf_sys;

#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct BLEError(NonZeroI32);
Expand Down
1 change: 1 addition & 0 deletions src/ble_security.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::enums;
use esp_idf_svc::sys as esp_idf_sys;

pub struct BLESecurity {
passkey: u32,
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_advertised_device.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::boxed::Box;
use alloc::vec::Vec;
use bstr::{BStr, BString};
use esp_idf_svc::sys as esp_idf_sys;

use crate::enums::{AdvFlag, AdvType};
use crate::utilities::BleUuid;
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_attribute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::BLEClient;
use esp_idf_svc::sys as esp_idf_sys;

pub(crate) trait BLEAttribute {
fn get_client(&self) -> Option<BLEClient>;
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
};
use alloc::{boxed::Box, string::ToString, vec::Vec};
use core::{cell::UnsafeCell, ffi::c_void};
use esp_idf_svc::sys as esp_idf_sys;
use esp_idf_sys::*;

#[allow(clippy::type_complexity)]
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_reader.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use alloc::vec::Vec;
use core::ffi::c_void;
use esp_idf_svc::sys as esp_idf_sys;

use crate::{ble, utilities::voidp_to_ref, BLEError, Signal};

Expand Down
1 change: 1 addition & 0 deletions src/client/ble_remote_characteristic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{BLEAttribute, BLEClient};
use alloc::{boxed::Box, vec::Vec};
use bitflags::bitflags;
use core::ffi::c_void;
use esp_idf_svc::sys as esp_idf_sys;

bitflags! {
#[repr(transparent)]
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_remote_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
utilities::{BleUuid, WeakUnsafeCell},
BLEError,
};
use esp_idf_svc::sys as esp_idf_sys;

#[derive(Clone)]
pub struct BLERemoteDescriptor {
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_remote_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
};
use alloc::vec::Vec;
use core::ffi::c_void;
use esp_idf_svc::sys as esp_idf_sys;

pub struct BLERemoteServiceState {
client: WeakUnsafeCell<BLEClientState>,
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{ble, enums::*, utilities::voidp_to_ref, BLEAdvertisedDevice, BLEErro
use alloc::sync::Arc;
use alloc::{boxed::Box, vec::Vec};
use core::ffi::c_void;
use esp_idf_svc::sys as esp_idf_sys;

pub struct BLEScan {
#[allow(clippy::type_complexity)]
Expand Down
1 change: 1 addition & 0 deletions src/client/ble_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
utilities::{as_void_ptr, voidp_to_ref},
BLEError, Signal,
};
use esp_idf_svc::sys as esp_idf_sys;

pub struct BLEWriter {
conn_handle: u16,
Expand Down
Loading

0 comments on commit 073d9f4

Please sign in to comment.