-
Notifications
You must be signed in to change notification settings - Fork 52
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
How can I get my custom service object registered on the system bus? #53
Comments
I wonder if you are connecting to the right connection. The bus you've shown that has the exported objects has name |
I'm not sure if it's related but I'm trying to implement a Bluetooth GATT server using Bluez over DBus and after exporting the interface I still receive |
Maybe it's related to this #17? |
@EricBorland Any news about this problem? I'm also trying to get a BLE Gatt server over DBus, but got the same error when trying to RegisterApplication. My interface looks good, but got the error too. Here it is:
|
Hey, it's been a while but I ended up getting it working. I don't remember what exactly I was doing wrong or what I did to fix it, but the final code looked like something similar to this: import dbus, { Message, Variant } from 'dbus-next';
const {
ACCESS_READ,
INTERFACES,
Interface,
method,
property,
} = dbus.interface;
export default class GattApplication extends Interface {
@property({ signature: 's', access: ACCESS_READ })
path = '/';
services = [];
constructor(bus, services) {
super(INTERFACES.GATT_APPLICATION);
// Properties definition
this._bus = bus;
// Exporting interface to bus
this._bus.exportInterface(this.path, this);
// Initializing services
this.addServices(services);
// Exporting GetManagedObjects to ObjectManager
this._bus.addMethod('GetManagedObjects', INTERFACES.OBJECT_MANAGER, this.path, 'a{oa{sa{sv}}}', this.GetManagedObjects.bind(this));
}
addService(service) {
this.services.push(service);
this._bus.exportInterface(service.getPath(), service);
}
addServices(services) {
services.forEach(service => this.addService(service));
}
GetManagedObjects() {
const response = {};
this.services.forEach(service => {
response[service.getPath()] = service.getProperties();
service.getCharacteristics().forEach(characteristic => {
response[characteristic.getPath()] = characteristic.getProperties();
characteristic.getDescriptors().forEach(descriptor => {
response[descriptor.getPath()] = descriptor.getProperties();
});
});
});
return response;
}
} And used like this: const { agentManager, gattManager, advertisingManager } = await this.bus.initManagers(['agent', 'gatt', 'advertising']);
const app = new Gatt.Application(this.bus, services);
await gattManager.RegisterApplication(app.path, {});
console.log('Application successfully registered in GATT'); Where Cheers |
Thanks a lot @EricBorland, it helped me a lot.
With that GattApplication, I can Now I have to create services. Any advice on that part? I have found some example in the Python example. I'll try to convert that Python code into JS. |
Ok, so that was definitely the lack of service. I created a dummy service emulating a battery service (uuid 180f) containing a characteristic emulating battery level (uuid 2a19). All based on the format of the application above. I then added an advertisement service which is sent through DBus to the Bluez LEAdvertisingManager. And voilà, my device is now discoverable. Again, thanks a lot for your help 👍 |
I'm looking for the way to register my custom service on D-Bus with dbus-next API. But I'm not getting it working.
What I did is:
Interface
dbus.systemBus().export('/service/path', aboveObject)
for each dbus-next Interface object to be exportedThen when I got a
ProxyObject
of the service path, I couldn't find anything ininterfaces
property of theProxyObject
. What am I missing?With node-dbus, it has
dbus.registerService()
to register a Service Object (not Interface). I'd say the Service Object registration function is required to register a set of D-Bus interfaces but I don't have any idea of the equivalent function in dbus-next.The text was updated successfully, but these errors were encountered: