Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run example #6

Open
HHX94666 opened this issue Sep 7, 2022 · 2 comments
Open

Failed to run example #6

HHX94666 opened this issue Sep 7, 2022 · 2 comments

Comments

@HHX94666
Copy link

HHX94666 commented Sep 7, 2022

bluez-dbus-cpp/build$ ./bin/example

Found adapter '/org/bluez/hci0'
Name: XXX
Address: C8:E2:65:07:72:8F type: public
Powered: 1
Discoverable: 1
Pairable: 1

LEAdvertisingManager1
ActiveInstances:
SupportedInstances:
SupportedIncludes: "tx-power","appearance","local-name",
Loading complete.
commands:
q quit
$> DirectedValue()
Error registering application org.bluez.Error.Failed with message Failed to create entry in database
Advertisement registered.

@HHX94666
Copy link
Author

HHX94666 commented Sep 7, 2022

Why are there only ReadOnlyCharacteristic and no ReadWriteCharacteristic in the library?

@brouhaha
Copy link

I'm not expert at this, but...

The example works for me. The "Failed to create entry in database" is a BlueZ error. The only condition I know of that causes that error is if you try to register a UUID for a service that is already in use or reserved. Did you modify the example Did you run more than one instance of it concurrently?

The ReadOnlyCharacteristic is a convenience wrapper to make a read-only characteristic, and is quite useful for e.g. the characteristics in the Device Information Service.

For a read-write characteristic, you have to create a sublass of GenericCharacteristic, and implement WriteValue(). In the example, in SerialCharacteristic.h, a read/write characteristic class is derived from GenericCharacteristic:

class SerialCharacteristic :
    public GattCharacteristicBuilder<GenericCharacteristic>

and then in example.cpp it is instantiated:

SerialCharacteristic::create( srv2, connection, "de0a7b0c-358f-4cef-b778-8fe9abf09d53" )
        .finalize();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants