Skip to content

Commit

Permalink
Merge pull request #133 from taks/fix-guru-meditation-error
Browse files Browse the repository at this point in the history
Fix Guru Meditation Error
  • Loading branch information
taks authored Jul 19, 2024
2 parents 1becf0d + d7a5bae commit 080cf47
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/client/ble_client.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::{
ble,
ble_device::OWN_ADDR_TYPE,
ble_error::return_code_to_string,
utilities::{as_void_ptr, voidp_to_ref, ArcUnsafeCell, BleUuid},
BLEAddress, BLEConnDesc, BLEDevice, BLEError, BLERemoteService, Signal,
};
use alloc::{boxed::Box, string::ToString, vec::Vec};
use core::{cell::UnsafeCell, ffi::c_void};
use alloc::{boxed::Box, vec::Vec};
use core::{cell::UnsafeCell, ffi::c_void, ptr};
use esp_idf_svc::sys as esp_idf_sys;
use esp_idf_sys::*;

Expand Down Expand Up @@ -284,9 +283,8 @@ impl BLEClient {
client.state.conn_handle = esp_idf_sys::BLE_HS_CONN_HANDLE_NONE as _;

::log::info!(
"Disconnected: {}",
return_code_to_string(disconnect.reason as _)
.map_or_else(|| disconnect.reason.to_string(), |x| x.to_string())
"Disconnected: {:?}",
BLEError::convert(disconnect.reason as _)
);

if let Some(callback) = &client.state.on_disconnect {
Expand Down Expand Up @@ -440,3 +438,13 @@ impl BLEClient {
ret as _
}
}

impl Drop for BLEClient {
fn drop(&mut self) {
if self.connected() {
unsafe {
esp_idf_sys::ble_gap_set_event_cb(self.conn_handle(), None, ptr::null_mut());
}
}
}
}

0 comments on commit 080cf47

Please sign in to comment.