brei: pass the proto object through to send_message

Makes for easier debugging since we can print names instead of just
ids/opcodes.
This commit is contained in:
Peter Hutterer 2023-02-03 21:30:41 +10:00
parent 2a8661f7ad
commit 01a2ff2d72
5 changed files with 22 additions and 10 deletions

View file

@ -39,7 +39,7 @@ struct {{target.name}};
* message sending functions (requests for libei, events for libeis).
*/
extern int {{target.name}}_send_message(
{{target.as_arg}}, uint32_t object_id, uint32_t opcode,
{{target.as_arg}}, const struct brei_object *obj, uint32_t opcode,
const char *signature, size_t nargs, ...
);
@ -80,7 +80,7 @@ int
return -ENOTSUP;
return {{target.name}}_send_message(
ctx, obj->id, {{outgoing.fqdn.upper()}}, "{{outgoing.signature}}",
ctx, obj, {{outgoing.fqdn.upper()}}, "{{outgoing.signature}}",
{{outgoing.arguments|length}}{%- for arg in outgoing.arguments %}, {{arg.name}}{% endfor -%}
);
}

View file

@ -108,7 +108,7 @@ void
ei_unregister_object(struct ei *ei, struct brei_object *object);
int
ei_send_message(struct ei *ei, uint32_t object_id,
ei_send_message(struct ei *ei, const struct brei_object *object,
uint32_t opcode, const char *signature, size_t nargs, ...);
void

View file

@ -1441,16 +1441,22 @@ connection_dispatch(struct source *source, void *userdata)
}
int
ei_send_message(struct ei *ei, uint32_t object_id,
ei_send_message(struct ei *ei, const struct brei_object *object,
uint32_t opcode, const char *signature, size_t nargs, ...)
{
int fd = source_get_fd(ei->source);
log_debug(ei, "sending: %#x:%u signature '%s'", object_id, opcode, signature);
log_debug(ei, "sending: object %#x (%s@v%u:%s(%u)) signature '%s'",
object->id,
object->interface->name,
object->interface->version,
object->interface->requests[opcode].name,
opcode,
signature);
va_list args;
va_start(args, nargs);
int rc = brei_send_message(fd, object_id, opcode, signature, nargs, args);
int rc = brei_send_message(fd, object->id, opcode, signature, nargs, args);
va_end(args);
return rc < 0 ? rc : 0;
}

View file

@ -158,17 +158,23 @@ eis_client_find_device(struct eis_client *client, uint32_t deviceid)
}
int
eis_client_send_message(struct eis_client *client, uint32_t object_id,
eis_client_send_message(struct eis_client *client, const struct brei_object *object,
uint32_t opcode, const char *signature, size_t nargs, ...)
{
struct eis *eis = eis_client_get_context(client);
int fd = source_get_fd(client->source);
log_debug(eis, "sending: %#x:%u signature '%s'", object_id, opcode, signature);
log_debug(eis, "sending: object %#x (%s@v%u:%s(%u)) signature '%s'",
object->id,
object->interface->name,
object->interface->version,
object->interface->events[opcode].name,
opcode,
signature);
va_list args;
va_start(args, nargs);
int rc = brei_send_message(fd, object_id, opcode, signature, nargs, args);
int rc = brei_send_message(fd, object->id, opcode, signature, nargs, args);
va_end(args);
return rc < 0 ? rc : 0;
}

View file

@ -97,7 +97,7 @@ eis_client_setup_done(struct eis_client *client, const char *name, bool is_sende
const struct eis_client_interface_versions *versions);
int
eis_client_send_message(struct eis_client *client, uint32_t object_id,
eis_client_send_message(struct eis_client *client, const struct brei_object *obj,
uint32_t opcode, const char *signature, size_t nargs, ...);
void