struct desc {
struct chrc *chrc;
char *path;
+ uint16_t handle;
char *uuid;
char **flags;
int value_len;
struct chrc {
struct service *service;
char *path;
+ uint16_t handle;
char *uuid;
char **flags;
bool notifying;
struct service {
DBusConnection *conn;
char *path;
+ uint16_t handle;
char *uuid;
bool primary;
GList *chrcs;
text = bt_uuidstr_to_str(service->uuid);
if (!text)
- bt_shell_printf("%s%s%s%s Service\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%s%s Service (Handle 0x%04x)\n\t%s\n\t"
+ "%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
service->primary ? "Primary" :
"Secondary",
- service->path, service->uuid);
+ service->handle, service->path,
+ service->uuid);
else
- bt_shell_printf("%s%s%s%s Service\n\t%s\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%s%s Service (Handle 0x%04x)\n\t%s\n\t%s"
+ "\n\t%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
service->primary ? "Primary" :
"Secondary",
- service->path, service->uuid, text);
+ service->handle, service->path,
+ service->uuid, text);
}
static void print_inc_service(struct service *service, const char *description)
text = bt_uuidstr_to_str(service->uuid);
if (!text)
- bt_shell_printf("%s%s%s%s Included Service\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%s%s Included Service (Handle 0x%04x)\n\t"
+ "%s\n\t%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
service->primary ? "Primary" :
"Secondary",
- service->path, service->uuid);
+ service->handle, service->path,
+ service->uuid);
else
- bt_shell_printf("%s%s%s%s Included Service\n\t%s\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%s%s Included Service (Handle 0x%04x)\n\t"
+ "%s\n\t%s\n\t%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
service->primary ? "Primary" :
"Secondary",
- service->path, service->uuid, text);
+ service->handle, service->path,
+ service->uuid, text);
}
static void print_service_proxy(GDBusProxy *proxy, const char *description)
text = bt_uuidstr_to_str(chrc->uuid);
if (!text)
- bt_shell_printf("%s%s%sCharacteristic\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%sCharacteristic (Handle 0x%04x)\n\t%s\n\t"
+ "%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
- chrc->path, chrc->uuid);
+ chrc->handle, chrc->path, chrc->uuid);
else
- bt_shell_printf("%s%s%sCharacteristic\n\t%s\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%sCharacteristic (Handle 0x%04x)\n\t%s\n\t"
+ "%s\n\t%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
- chrc->path, chrc->uuid, text);
+ chrc->handle, chrc->path, chrc->uuid,
+ text);
}
static void print_characteristic(GDBusProxy *proxy, const char *description)
text = bt_uuidstr_to_str(desc->uuid);
if (!text)
- bt_shell_printf("%s%s%sDescriptor\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%sDescriptor (Handle 0x%04x)\n\t%s\n\t"
+ "%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
- desc->path, desc->uuid);
+ desc->handle, desc->path, desc->uuid);
else
- bt_shell_printf("%s%s%sDescriptor\n\t%s\n\t%s\n\t%s\n",
+ bt_shell_printf("%s%s%sDescriptor (Handle 0x%04x)\n\t%s\n\t"
+ "%s\n\t%s\n",
description ? "[" : "",
description ? : "",
description ? "] " : "",
- desc->path, desc->uuid, text);
+ desc->handle, desc->path, desc->uuid,
+ text);
}
static void print_descriptor(GDBusProxy *proxy, const char *description)
g_free(service);
}
+static gboolean service_get_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct service *service = data;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16,
+ &service->handle);
+
+ return TRUE;
+}
+
+static void service_set_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *value, GDBusPendingPropertySet id,
+ void *data)
+{
+ struct service *service = data;
+
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) {
+ g_dbus_pending_property_error(id, "org.bluez.InvalidArguments",
+ "Invalid arguments in method call");
+ return;
+ }
+
+ dbus_message_iter_get_basic(value, &service->handle);
+
+ print_service(service, COLORED_CHG);
+
+ g_dbus_pending_property_success(id);
+}
+
static gboolean service_get_uuid(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
static const GDBusPropertyTable service_properties[] = {
+ { "Handle", "q", service_get_handle, service_set_handle },
{ "UUID", "s", service_get_uuid },
{ "Primary", "b", service_get_primary },
{ "Includes", "ao", service_get_includes,
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+static gboolean chrc_get_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct chrc *chrc = data;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &chrc->handle);
+
+ return TRUE;
+}
+
+static void chrc_set_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *value, GDBusPendingPropertySet id,
+ void *data)
+{
+ struct chrc *chrc = data;
+
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) {
+ g_dbus_pending_property_error(id, "org.bluez.InvalidArguments",
+ "Invalid arguments in method call");
+ return;
+ }
+
+ dbus_message_iter_get_basic(value, &chrc->handle);
+
+ print_chrc(chrc, COLORED_CHG);
+
+ g_dbus_pending_property_success(id);
+}
+
static gboolean chrc_get_uuid(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
}
static const GDBusPropertyTable chrc_properties[] = {
+ { "Handle", "s", chrc_get_handle, chrc_set_handle, NULL },
{ "UUID", "s", chrc_get_uuid, NULL, NULL },
{ "Service", "o", chrc_get_service, NULL, NULL },
{ "Value", "ay", chrc_get_value, NULL, NULL },
{ }
};
+static gboolean desc_get_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct desc *desc = data;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &desc->handle);
+
+ return TRUE;
+}
+
+static void desc_set_handle(const GDBusPropertyTable *property,
+ DBusMessageIter *value, GDBusPendingPropertySet id,
+ void *data)
+{
+ struct desc *desc = data;
+
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT16) {
+ g_dbus_pending_property_error(id, "org.bluez.InvalidArguments",
+ "Invalid arguments in method call");
+ return;
+ }
+
+ dbus_message_iter_get_basic(value, &desc->handle);
+
+ print_desc(desc, COLORED_CHG);
+
+ g_dbus_pending_property_success(id);
+}
+
static gboolean desc_get_uuid(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
}
static const GDBusPropertyTable desc_properties[] = {
+ { "Handle", "q", desc_get_handle, desc_set_handle, NULL },
{ "UUID", "s", desc_get_uuid, NULL, NULL },
{ "Characteristic", "o", desc_get_chrc, NULL, NULL },
{ "Value", "ay", desc_get_value, NULL, NULL },