From befcf7d59d6c030c05eef381893b511705defa78 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 7 Dec 2021 12:08:35 +0100 Subject: [PATCH 1/2] Patching keepalive interval support --- CHANGELOG.md | 13 ++++++++++--- Cargo.toml | 2 +- src/mqtt_client.rs | 4 +++- tests/integration_test.rs | 3 +++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f512c54..71e53d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ 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). # Version [0.5.0] Version 0.5.0 was published on 2021-12-06 @@ -59,7 +65,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 diff --git a/Cargo.toml b/Cargo.toml index 8bbd0a5..41976b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minimq" -version = "0.5.0" +version = "0.5.1" authors = ["Ryan Summers ", "Max Rottenkolber "] edition = "2018" diff --git a/src/mqtt_client.rs b/src/mqtt_client.rs index a5f652e..81fbd28 100644 --- a/src/mqtt_client.rs +++ b/src/mqtt_client.rs @@ -175,7 +175,9 @@ where &mut self, interval_seconds: u16, ) -> Result<(), 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); } diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 606224b..56af1fa 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -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; From f4dc972152a60910bb3bbcbc062f4aa98304f973 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 7 Dec 2021 12:20:45 +0100 Subject: [PATCH 2/2] Fixing keepalive storage --- CHANGELOG.md | 2 ++ src/session_state.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e53d6..7567efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ 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 diff --git a/src/session_state.rs b/src/session_state.rs index 92ee76c..0582353 100644 --- a/src/session_state.rs +++ b/src/session_state.rs @@ -60,7 +60,7 @@ impl /// # 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.