Skip to content

Commit

Permalink
removing match rules
Browse files Browse the repository at this point in the history
  • Loading branch information
William C Bonner committed Nov 22, 2024
1 parent b6d8fc9 commit 6332db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (POLICY CMP0115)
endif()

project (VictronBTLELogger
VERSION 3.20241119.0
VERSION 3.20241121.0
DESCRIPTION "Log Victron Direct Bluetooth LE messages and graph battery states"
HOMEPAGE_URL https://github.com/wcbonner/VictronBTLELogger
)
Expand Down
12 changes: 11 additions & 1 deletion victronbtlelogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2630,7 +2630,7 @@ int main(int argc, char** argv)
dbus_bus_add_match(dbus_conn, MatchRule.c_str(), &dbus_error); // https://dbus.freedesktop.org/doc/api/html/group__DBusBus.html#ga4eb6401ba014da3dbe3dc4e2a8e5b3ef
if (dbus_error_is_set(&dbus_error))
{
std::cout << "Error adding a match rule on the D-Bus system bus: " << dbus_error.message << std::endl;
std::cerr << "Error adding a match rule on the D-Bus system bus: " << dbus_error.message << std::endl;
dbus_error_free(&dbus_error);
}
}
Expand Down Expand Up @@ -2690,6 +2690,16 @@ int main(int argc, char** argv)
#else
} while (bRun && difftime(TimeNow, TimeStart) < (60 * 30)); // Maintain DBus connection for no more than 30 minutes
#endif // DEBUG
for (auto& MatchRule : MatchRules)
{
dbus_error_init(&dbus_error); // https://dbus.freedesktop.org/doc/api/html/group__DBusErrors.html#ga8937f0b7cdf8554fa6305158ce453fbe
dbus_bus_remove_match(dbus_conn, MatchRule.c_str(), &dbus_error); // https://dbus.freedesktop.org/doc/api/html/group__DBusBus.html#ga4eb6401ba014da3dbe3dc4e2a8e5b3ef
if (dbus_error_is_set(&dbus_error))
{
std::cerr << "Error removing a match rule on the D-Bus system bus: " << dbus_error.message << std::endl;
dbus_error_free(&dbus_error);
}
}
bluez_discovery(dbus_conn, BlueZAdapter.c_str(), false);
bluez_dbus_RemoveKnownDevices(dbus_conn, BlueZAdapter.c_str(), VictronEncryptionKeys);
//bluez_filter_le(dbus_conn, BlueZAdapter.c_str(), false, false); // remove discovery filter
Expand Down

0 comments on commit 6332db7

Please sign in to comment.