Skip to content

Commit 9678ea6

Browse files
authored
Merge branch 'embassy-rs:master' into macros-feature
2 parents 30d017f + 93ad991 commit 9678ea6

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

nrf-softdevice-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ syn = { version = "1.0.39", features = ["full", "extra-traits"] }
1414
quote = "1.0.7"
1515
darling = "0.13.4"
1616
proc-macro2 = "1.0.18"
17-
Inflector = "0.11.4"
17+
Inflector = { version = "0.11.4", default-features = false }
1818
uuid = "1.2.2"
1919

2020
[lib]

nrf-softdevice/src/ble/central.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ where
183183
// has been dropped and the scanning has been stopped.
184184
static mut BUF: [u8; BUF_LEN] = [0u8; BUF_LEN];
185185
static mut BUF_DATA: raw::ble_data_t = raw::ble_data_t {
186-
p_data: unsafe { BUF.as_mut_ptr() },
186+
p_data: unsafe { (&mut *(&raw mut BUF)).as_mut_ptr() },
187187
len: BUF_LEN as u16,
188188
};
189189

nrf-softdevice/src/ble/connection.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ impl ConnectionState {
301301
}
302302

303303
let ret = unsafe { raw::sd_ble_gap_disconnect(conn_handle, reason.into()) };
304+
// This case can occur in normal operation if e.g. the connection was
305+
// already being disconnected when disconnect() is called, so
306+
// return as error instead of a panic.
307+
if ret == raw::NRF_ERROR_INVALID_STATE {
308+
return Err(DisconnectedError);
309+
}
304310
unwrap!(RawError::convert(ret), "sd_ble_gap_disconnect");
305311

306312
self.disconnecting = true;
@@ -825,7 +831,7 @@ pub(crate) fn with_state<T>(index: u8, f: impl FnOnce(&mut ConnectionState) -> T
825831

826832
fn allocate_index<T>(f: impl FnOnce(u8, &mut ConnectionState) -> T) -> Result<T, OutOfConnsError> {
827833
unsafe {
828-
for (i, s) in STATES.iter().enumerate() {
834+
for (i, s) in (&*(&raw const STATES)).iter().enumerate() {
829835
let state = &mut *s.get();
830836
if state.refcount == 0 && !state.conn_handle.is_connected() {
831837
return Ok(f(i as u8, state));

nrf-softdevice/src/softdevice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl Softdevice {
287287
};
288288

289289
unsafe {
290-
let p = SOFTDEVICE.as_mut_ptr();
290+
let p = (&mut *(&raw mut SOFTDEVICE)).as_mut_ptr();
291291
p.write(sd);
292292
&mut *p
293293
}
@@ -298,7 +298,7 @@ impl Softdevice {
298298
/// (a call to [`enable`] has returned without error) and no `&mut` references
299299
/// to the softdevice are active
300300
pub unsafe fn steal() -> &'static Softdevice {
301-
&*SOFTDEVICE.as_ptr()
301+
&*(&*(&raw const SOFTDEVICE)).as_ptr()
302302
}
303303

304304
/// Runs the softdevice event handling loop.

0 commit comments

Comments
 (0)