Skip to content

Commit

Permalink
Slight changes to make it compile on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
aklajnert committed Sep 29, 2020
1 parent b3779b6 commit bca76d7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ extern crate failure_derive;
use btleplug::api::{BDAddr, Central, Characteristic, ParseBDAddrError, Peripheral, UUID};
#[cfg(target_os = "linux")]
use btleplug::bluez::{
adapter::ConnectedAdapter, manager::Manager, peripheral::Peripheral as PeripheralStruct,
adapter::ConnectedAdapter as Adapter, manager::Manager,
peripheral::Peripheral as PeripheralStruct,
};
#[cfg(target_os = "macos")]
use btleplug::corebluetooth::{
Expand All @@ -27,7 +28,7 @@ fn get_central(manager: &Manager) -> Adapter {
}

#[cfg(target_os = "linux")]
fn get_central(manager: &Manager) -> ConnectedAdapter {
fn get_central(manager: &Manager) -> Adapter {
let adapters = manager.adapters().unwrap();
let adapter = adapters.into_iter().next().unwrap();
adapter.connect().unwrap()
Expand Down Expand Up @@ -232,6 +233,7 @@ impl Idasen {
}

/// Return the desk height in tenth millimeters (1m = 10000)
#[cfg(any(target_os = "windows", target_os = "macos"))]
pub fn position(&self) -> Result<i16, Error> {
let response = self.desk.read_by_type(
&self.position_characteristic,
Expand All @@ -242,4 +244,13 @@ impl Idasen {
Err(_) => Err(Error::CannotReadPosition),
}
}

#[cfg(target_os = "linux")]
pub fn position(&self) -> Result<i16, Error> {
let response = self.desk.read_by_type(
&self.position_characteristic,
self.position_characteristic.uuid,
);
Ok(bytes_to_tenth_millimeters(&response))
}
}

0 comments on commit bca76d7

Please sign in to comment.