[systemd-devel] Callback isn't called when using sd_bus_add_match
Ben-melech, Shiran
shiran.ben-melech at intel.com
Wed May 4 12:56:42 UTC 2016
Hi,
I'm currently developing a little library using sd-bus to work with bluez.
I'm trying to catch signals sent over the bus using sd_bus_add_match (see code below)
But the callback does not seem to be triggered.
I'm opening the bus using:
/* Connect to the system bus */
r = sd_bus_open_system(&new_context->bus);
if(r < 0) {
syslog(LOG_ERR, "Failed to connect to system bus: %s\n", strerror(-r));
}
Could anyone please help?
static int test_callback(sd_bus_message *message, void *userdata, sd_bus_error *error)
{
printf("callback called\n");
return EXIT_SUCCESS;
}
int
lb_register_for_device_data(lb_context *lb_ctx, sd_bus_message_handler_t callback, void *userdata)
{
if (DEBUG > 0) printf("Method Called: %s\n", __FUNCTION__);
int r;
r = sd_bus_add_match(lb_ctx->bus, NULL, "type=signal", test_callback, userdata);
if (r < 0) {
syslog(LOG_ERR, "Failed on sd_bus_add_object\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
I've tried various option in the "type" parameter but none succeeded.
Regards,
Shiran
---------------------------------------------------------------------
Intel Electronics Ltd.
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the systemd-devel
mailing list