mirror of
https://github.com/OpenBluetoothToolbox/SimpleBLE
synced 2025-05-08 21:47:10 +08:00
Exposed trusted property
This commit is contained in:
parent
fd3504f7eb
commit
8eef23d8ff
@ -34,6 +34,8 @@ class Device : public SimpleDBus::Proxy {
|
||||
|
||||
bool paired(bool refresh = true);
|
||||
bool bonded(bool refresh = true);
|
||||
bool trusted();
|
||||
void trusted(bool trusted);
|
||||
bool connected(bool refresh = true);
|
||||
bool services_resolved(bool refresh = true);
|
||||
|
||||
|
@ -33,6 +33,8 @@ class Device1 : public SimpleDBus::Interface {
|
||||
std::map<std::string, ByteArray> ServiceData(bool refresh = true);
|
||||
bool Paired(bool refresh = true);
|
||||
bool Bonded(bool refresh = true);
|
||||
bool Trusted();
|
||||
void Trusted(bool trusted);
|
||||
bool Connected(bool refresh = true);
|
||||
bool ServicesResolved(bool refresh = true);
|
||||
|
||||
|
@ -92,6 +92,10 @@ bool Device::paired(bool refresh) { return device1()->Paired(refresh); }
|
||||
|
||||
bool Device::bonded(bool refresh) { return device1()->Bonded(refresh); }
|
||||
|
||||
bool Device::trusted() { return device1()->Trusted(); }
|
||||
|
||||
void Device::trusted(bool trusted) { device1()->Trusted(trusted); }
|
||||
|
||||
bool Device::connected(bool refresh) { return device1()->Connected(refresh); }
|
||||
|
||||
bool Device::services_resolved(bool refresh) { return device1()->ServicesResolved(refresh); }
|
||||
|
@ -6,7 +6,6 @@ Agent1::Agent1(std::shared_ptr<SimpleDBus::Connection> conn, SimpleDBus::Proxy*
|
||||
: SimpleDBus::Interface(conn, proxy, "org.bluez.Agent1") {}
|
||||
|
||||
void Agent1::message_handle(SimpleDBus::Message& msg) {
|
||||
std::cout << "Agent1::message_handle()\n" << msg.to_string() << std::endl;
|
||||
|
||||
if (msg.get_type() == SimpleDBus::Message::Type::METHOD_CALL) {
|
||||
// To minimize the amount of repeated code, create a method return object that will be
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "simplebluez/interfaces/Device1.h"
|
||||
#include "simpledbus/interfaces/Properties.h"
|
||||
#include "simpledbus/advanced/Proxy.h"
|
||||
|
||||
using namespace SimpleBluez;
|
||||
|
||||
@ -111,6 +113,26 @@ bool Device1::Bonded(bool refresh) {
|
||||
return _properties["Bonded"].get_boolean();
|
||||
}
|
||||
|
||||
bool Device1::Trusted() {
|
||||
std::scoped_lock lock(_property_update_mutex);
|
||||
return _properties["Trusted"].get_boolean();
|
||||
}
|
||||
|
||||
void Device1::Trusted(bool trusted) {
|
||||
SimpleDBus::Holder value_array = SimpleDBus::Holder::create_boolean(trusted);
|
||||
|
||||
{
|
||||
std::scoped_lock lock(_property_update_mutex);
|
||||
_properties["Trusted"] = value_array;
|
||||
}
|
||||
|
||||
std::map<std::string, SimpleDBus::Holder> changed_properties;
|
||||
changed_properties["Trusted"] = value_array;
|
||||
|
||||
std::shared_ptr<SimpleDBus::Properties> properties = std::dynamic_pointer_cast<SimpleDBus::Properties>(_proxy->interface_get("org.freedesktop.DBus.Properties"));
|
||||
properties->PropertiesChanged("org.bluez.Device1", changed_properties);
|
||||
}
|
||||
|
||||
bool Device1::Connected(bool refresh) {
|
||||
if (refresh) {
|
||||
property_refresh("Connected");
|
||||
|
Loading…
x
Reference in New Issue
Block a user