Skip to content

Commit

Permalink
Subscribe before reading position (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklajnert authored Feb 24, 2021
1 parent 4f84943 commit 262a2b9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ pub enum Error {
#[fail(display = "Desired position has to be between MIN_HEIGHT and MAX_HEIGHT.")]
PositionNotInRange,

#[fail(display = "Cannot subscribe to read position.")]
CannotSubscribePosition,

#[fail(display = "Cannot read position.")]
CannotReadPosition,

Expand Down Expand Up @@ -176,6 +179,9 @@ impl<T: Device> Idasen<T> {
return Err(Error::CharacteristicsNotFound("Position".to_string()));
}
let position_characteristic = position_characteristic.unwrap().clone();
if desk.subscribe(&position_characteristic).is_err() {
return Err(Error::CannotSubscribePosition)
};

Ok(Self {
desk,
Expand Down

0 comments on commit 262a2b9

Please sign in to comment.