| 958 | } |
| 959 | |
| 960 | fn is_connected(&mut self, peripheral_uuid: Uuid, fut: CoreBluetoothReplyStateShared) { |
| 961 | if let Some(p) = self.peripherals.get_mut(&peripheral_uuid) { |
| 962 | let state = unsafe { p.peripheral.state() }; |
| 963 | trace!("Connected state {:?} ", state); |
| 964 | fut.lock() |
| 965 | .unwrap() |
| 966 | .set_reply(CoreBluetoothReply::State(state)); |
| 967 | } else { |
| 968 | // Peripheral was removed after disconnect — report as disconnected |
| 969 | // rather than hanging the future forever. |
| 970 | fut.lock() |
| 971 | .unwrap() |
| 972 | .set_reply(CoreBluetoothReply::State(CBPeripheralState::Disconnected)); |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | fn write_value( |
| 977 | &mut self, |