Skip to content

Commit

Permalink
Update changelog; simplify BtCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Sep 19, 2023
1 parent 5407d1b commit baec47e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.47.0] - 2023-09-02
## [0.47.0] - 2023-09-19
* MSRV raised to 1.71
* New `experimental` module - `bt` - providing Bluetooth support based on the ESP-IDF Bluedroid implementation
* Only classic BT supported for now (on the ESP32) with the following profiles: A2DP sink, AVRC controller, HFP client, GAP
* BLE support in the works, but not buildable yet
* TLS over TCP/IP support in the `tls` module via `EspTls` and `AsyncEspTls`
* TLS over TCP/IP support in the `tls` module via `EspTls` and (for async mode) `AsyncEspTls`
* PSK support for `mqtt`
* Dependencies `esp-idf-sys` and `esp-idf-hal` are now re-exported as `esp_idf_svc::sys` and `esp_idf_svc::hal`
* Upgraded to `embedded-svc` 0.26
Expand Down
6 changes: 3 additions & 3 deletions src/bt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl From<esp_bt_uuid_t> for BtUuid {
#[allow(clippy::type_complexity)]
pub(crate) struct BtCallback<A, R> {
initialized: AtomicBool,
callback: UnsafeCell<Option<alloc::boxed::Box<alloc::boxed::Box<dyn Fn(A) -> R>>>>,
callback: UnsafeCell<Option<alloc::boxed::Box<dyn Fn(A) -> R>>>,
default_result: R,
}

Expand All @@ -165,7 +165,7 @@ where

let b: alloc::boxed::Box<dyn Fn(A) -> R + 'd> = alloc::boxed::Box::new(callback);
let b: alloc::boxed::Box<dyn Fn(A) -> R + 'static> = unsafe { core::mem::transmute(b) };
*unsafe { self.callback.get().as_mut() }.unwrap() = Some(alloc::boxed::Box::new(b));
*unsafe { self.callback.get().as_mut() }.unwrap() = Some(b);

Ok(())
}
Expand All @@ -181,7 +181,7 @@ where
}

pub unsafe fn call(&self, arg: A) -> R {
if let Some(callback) = unsafe { self.callback.get().as_ref() }.unwrap().as_ref() {
if let Some(callback) = unsafe { self.callback.get().as_ref() }.unwrap() {
(callback)(arg)
} else {
self.default_result.clone()
Expand Down

0 comments on commit baec47e

Please sign in to comment.