From 67302ba45473e4cdf906756ff5af468506cc40f6 Mon Sep 17 00:00:00 2001 From: Matthew Pfeiffer Date: Thu, 6 Aug 2020 19:28:56 -0400 Subject: [PATCH 1/2] Fix BlueZ advertisement registration Previously, BlueZ tries to call the ObjectManager interface on the advertisement object, fails, and fails the RegisterAdvertisement call. Could have sworn I saw this work before, but it could have been influenced by other configuration. --- src/peripheral/bluez/advertisement.rs | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/peripheral/bluez/advertisement.rs b/src/peripheral/bluez/advertisement.rs index 1f751db..583a144 100644 --- a/src/peripheral/bluez/advertisement.rs +++ b/src/peripheral/bluez/advertisement.rs @@ -66,13 +66,29 @@ impl Advertisement { .unwrap_or_else(Vec::new)) }); }); - tree.insert(object_path.clone(), &[iface_token], ()); + let ifaces = [iface_token, tree.object_manager()]; + tree.insert(object_path.clone(), &ifaces, ()); + + let tree = Arc::new(Mutex::new(tree)); + + { + let tree = tree.clone(); + let mut match_rule = MatchRule::new_method_call(); + match_rule.path = Some(object_path.clone()); + connection.default.start_receive( + match_rule, + Box::new(move |msg, conn| { + tree.lock().unwrap().handle_message(msg, conn).unwrap(); + true + }), + ); + } Advertisement { connection, adapter, object_path, - tree: Arc::new(Mutex::new(tree)), + tree, is_advertising, name, uuids, @@ -90,18 +106,6 @@ impl Advertisement { pub async fn register(self: &Self) -> Result<(), Error> { // Register with DBus let proxy = self.connection.get_bluez_proxy(&self.adapter); - - let mut match_rule = MatchRule::new(); - match_rule.path = Some(self.object_path.clone()); - let tree = self.tree.clone(); - self.connection.default.start_receive( - match_rule, - Box::new(move |msg, conn| { - tree.lock().unwrap().handle_message(msg, conn).unwrap(); - true - }), - ); - proxy .method_call( LE_ADVERTISING_MANAGER_IFACE, From 15f424334279c1590c54fd0bbbadc62d221d7acc Mon Sep 17 00:00:00 2001 From: Matthew Pfeiffer Date: Fri, 7 Aug 2020 17:51:53 -0400 Subject: [PATCH 2/2] Use stable rust in CI There've been lots of rustfmt install errors on travis lately. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b73d9d..051594d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ branches: only: - master language: rust -rust: - - nightly cache: cargo: true matrix: