Skip to content

Commit

Permalink
Merge pull request #71 from quartiq/rs/issue-69/keepalive-interval
Browse files Browse the repository at this point in the history
Patching keepalive interval support
  • Loading branch information
ryan-summers authored Dec 7, 2021
2 parents 8c2d9d5 + f4dc972 commit d770e61
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ This document describes the changes to Minimq between releases.
# [Unreleased]

## Added
## Removed
## Changed
## Fixed

# Version [0.5.1]
Version 0.5.1 was published on 2021-12-07

## Fixed
* Fixed an issue where the keepalive interval could not be set properly. See
[#69](https://github.com/quartiq/minimq/issues/69).
* Fixed an issue where the keepalive interval was not set properly. See
[#70](https://github.com/quartiq/minimq/issues/70).

# Version [0.5.0]
Version 0.5.0 was published on 2021-12-06
Expand Down Expand Up @@ -59,7 +67,8 @@ Version 0.1.0 was published on 2020-08-27

* Initial library release and publish to crates.io

[Unreleased]: https://github.com/quartiq/minimq/compare/0.5.0...HEAD
[Unreleased]: https://github.com/quartiq/minimq/compare/0.5.1...HEAD
[0.5.0]: https://github.com/quartiq/minimq/releases/tag/0.5.1
[0.5.0]: https://github.com/quartiq/minimq/releases/tag/0.5.0
[0.4.0]: https://github.com/quartiq/minimq/releases/tag/0.4.0
[0.3.0]: https://github.com/quartiq/minimq/releases/tag/0.3.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "minimq"
version = "0.5.0"
version = "0.5.1"
authors = ["Ryan Summers <[email protected]>", "Max Rottenkolber <[email protected]>"]
edition = "2018"

Expand Down
4 changes: 3 additions & 1 deletion src/mqtt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ where
&mut self,
interval_seconds: u16,
) -> Result<(), Error<TcpStack::Error>> {
if self.connection_state.state() != &States::Active {
if (self.connection_state.state() == &States::Active)
|| (self.connection_state.state() == &States::Establishing)
{
return Err(Error::NotReady);
}

Expand Down
2 changes: 1 addition & 1 deletion src/session_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<Clock: embedded_time::Clock, const MSG_SIZE: usize, const MSG_COUNT: usize>
/// # Note
/// If no keep-alive interval is specified, zero is returned.
pub fn keepalive_interval(&self) -> u16 {
(self.keep_alive_interval.unwrap_or(0.milliseconds()).0 * 1000) as u16
(self.keep_alive_interval.unwrap_or(0.milliseconds()).0 / 1000) as u16
}

/// Update the keep-alive interval.
Expand Down
3 changes: 3 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ fn main() -> std::io::Result<()> {
let mut mqtt =
Minimq::<_, _, 256, 16>::new(localhost, "", stack, StandardClock::default()).unwrap();

// Use a keepalive interval for the client.
mqtt.client.set_keepalive_interval(60).unwrap();

let mut published = false;
let mut subscribed = false;
let mut responses = 0;
Expand Down

0 comments on commit d770e61

Please sign in to comment.