All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed
@ 2022-09-01 11:07 Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 2/6] adapter: Implement PowerState property Bastien Nocera
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

Instead of only replying to D-Bus requests with an error saying the
adapter is blocked, keep track of the rfkill being enabled or disabled
so we know the rfkill state of the adapter at all times.
---
 src/adapter.c | 25 +++++++++++++--
 src/adapter.h |  1 +
 src/btd.h     |  1 +
 src/rfkill.c  | 89 ++++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 91 insertions(+), 25 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 51b099dae..7c11a688d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -250,6 +250,7 @@ struct btd_adapter {
 	uint32_t dev_class;		/* controller class of device */
 	char *name;			/* controller device name */
 	char *short_name;		/* controller short name */
+	bool blocked;			/* whether rfkill is enabled */
 	uint32_t supported_settings;	/* controller supported settings */
 	uint32_t pending_settings;	/* pending controller settings */
 	uint32_t current_settings;	/* current controller settings */
@@ -654,6 +655,8 @@ static void set_mode_complete(uint8_t status, uint16_t length,
 	if (status != MGMT_STATUS_SUCCESS) {
 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
 						mgmt_errstr(status), status);
+		if (status == MGMT_STATUS_RFKILLED)
+			adapter->blocked = true;
 		adapter->pending_settings &= ~data->setting;
 		return;
 	}
@@ -2947,10 +2950,12 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
 						mgmt_errstr(status), status);
 
-		if (status == MGMT_STATUS_RFKILLED)
+		if (status == MGMT_STATUS_RFKILLED) {
 			dbus_err = ERROR_INTERFACE ".Blocked";
-		else
+			adapter->blocked = true;
+		} else {
 			dbus_err = ERROR_INTERFACE ".Failed";
+		}
 
 		g_dbus_pending_property_error(data->id, dbus_err,
 							mgmt_errstr(status));
@@ -6681,6 +6686,7 @@ static void load_config(struct btd_adapter *adapter)
 static struct btd_adapter *btd_adapter_new(uint16_t index)
 {
 	struct btd_adapter *adapter;
+	int blocked;
 
 	adapter = g_try_new0(struct btd_adapter, 1);
 	if (!adapter)
@@ -6689,6 +6695,9 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
 	adapter->dev_id = index;
 	adapter->mgmt = mgmt_ref(mgmt_primary);
 	adapter->pincode_requested = false;
+	blocked = rfkill_get_blocked(index);
+	if (blocked > 0)
+		adapter->blocked = true;
 
 	/*
 	 * Setup default configuration values. These are either adapter
@@ -6714,6 +6723,8 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
 	DBG("Modalias: %s", adapter->modalias);
 	DBG("Discoverable timeout: %u seconds", adapter->discoverable_timeout);
 	DBG("Pairable timeout: %u seconds", adapter->pairable_timeout);
+	if (blocked > 0)
+		DBG("Blocked: yes");
 
 	adapter->auths = g_queue_new();
 	adapter->exps = queue_new();
@@ -7581,6 +7592,9 @@ int btd_cancel_authorization(guint id)
 
 int btd_adapter_restore_powered(struct btd_adapter *adapter)
 {
+	if (adapter->blocked)
+		adapter->blocked = false;
+
 	if (btd_adapter_get_powered(adapter))
 		return 0;
 
@@ -7589,6 +7603,13 @@ int btd_adapter_restore_powered(struct btd_adapter *adapter)
 	return 0;
 }
 
+int btd_adapter_set_blocked(struct btd_adapter *adapter)
+{
+	if (!adapter->blocked)
+		adapter->blocked = true;
+	return 0;
+}
+
 void btd_adapter_register_pin_cb(struct btd_adapter *adapter,
 							btd_adapter_pin_cb_t cb)
 {
diff --git a/src/adapter.h b/src/adapter.h
index f38f473b7..78eb069ae 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -144,6 +144,7 @@ guint btd_request_authorization_cable_configured(const bdaddr_t *src, const bdad
 int btd_cancel_authorization(guint id);
 
 int btd_adapter_restore_powered(struct btd_adapter *adapter);
+int btd_adapter_set_blocked(struct btd_adapter *adapter);
 
 typedef ssize_t (*btd_adapter_pin_cb_t) (struct btd_adapter *adapter,
 			struct btd_device *dev, char *out, bool *display,
diff --git a/src/btd.h b/src/btd.h
index c02b2691e..63be6d8d4 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -144,6 +144,7 @@ void plugin_cleanup(void);
 
 void rfkill_init(void);
 void rfkill_exit(void);
+int rfkill_get_blocked(uint16_t index);
 
 GKeyFile *btd_get_main_conf(void);
 bool btd_kernel_experimental_enabled(const char *uuid);
diff --git a/src/rfkill.c b/src/rfkill.c
index 2099c5ac5..a0a50d9e4 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -55,12 +55,71 @@ struct rfkill_event {
 };
 #define RFKILL_EVENT_SIZE_V1    8
 
+static int get_adapter_id_for_rfkill(int rfkill_id)
+{
+	char sysname[PATH_MAX];
+	int namefd;
+
+	snprintf(sysname, sizeof(sysname) - 1,
+			"/sys/class/rfkill/rfkill%u/name", rfkill_id);
+
+	namefd = open(sysname, O_RDONLY);
+	if (namefd < 0)
+		return -1;
+
+	memset(sysname, 0, sizeof(sysname));
+
+	if (read(namefd, sysname, sizeof(sysname) - 1) < 4) {
+		close(namefd);
+		return -1;
+	}
+
+	close(namefd);
+
+	if (g_str_has_prefix(sysname, "hci") == FALSE)
+		return -1;
+
+	return atoi(sysname + 3);
+}
+
+int rfkill_get_blocked(uint16_t index)
+{
+	int fd;
+	int blocked = -1;
+
+	fd = open("/dev/rfkill", O_RDWR);
+	if (fd < 0) {
+		DBG("Failed to open RFKILL control device");
+		return -1;
+	}
+
+	while (1) {
+		struct rfkill_event event = { 0 };
+		int id;
+		ssize_t len;
+
+		len = read(fd, &event, sizeof(event));
+		if (len < RFKILL_EVENT_SIZE_V1)
+			break;
+
+		id = get_adapter_id_for_rfkill(event.idx);
+
+		if (index == id) {
+			blocked = event.soft || event.hard;
+			break;
+		}
+	}
+	close(fd);
+
+	return blocked;
+}
+
 static gboolean rfkill_event(GIOChannel *chan,
 				GIOCondition cond, gpointer data)
 {
 	struct rfkill_event event = { 0 };
 	struct btd_adapter *adapter;
-	char sysname[PATH_MAX];
+	bool blocked = false;
 	ssize_t len;
 	int fd, id;
 
@@ -84,7 +143,7 @@ static gboolean rfkill_event(GIOChannel *chan,
 						event.soft, event.hard);
 
 	if (event.soft || event.hard)
-		return TRUE;
+		blocked = true;
 
 	if (event.op != RFKILL_OP_CHANGE)
 		return TRUE;
@@ -93,26 +152,7 @@ static gboolean rfkill_event(GIOChannel *chan,
 					event.type != RFKILL_TYPE_ALL)
 		return TRUE;
 
-	snprintf(sysname, sizeof(sysname) - 1,
-			"/sys/class/rfkill/rfkill%u/name", event.idx);
-
-	fd = open(sysname, O_RDONLY);
-	if (fd < 0)
-		return TRUE;
-
-	memset(sysname, 0, sizeof(sysname));
-
-	if (read(fd, sysname, sizeof(sysname) - 1) < 4) {
-		close(fd);
-		return TRUE;
-	}
-
-	close(fd);
-
-	if (g_str_has_prefix(sysname, "hci") == FALSE)
-		return TRUE;
-
-	id = atoi(sysname + 3);
+	id = get_adapter_id_for_rfkill(event.idx);
 	if (id < 0)
 		return TRUE;
 
@@ -122,7 +162,10 @@ static gboolean rfkill_event(GIOChannel *chan,
 
 	DBG("RFKILL unblock for hci%d", id);
 
-	btd_adapter_restore_powered(adapter);
+	if (blocked)
+		btd_adapter_set_blocked(adapter);
+	else
+		btd_adapter_restore_powered(adapter);
 
 	return TRUE;
 }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH BlueZ v7 2/6] adapter: Implement PowerState property
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
@ 2022-09-01 11:07 ` Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 3/6] client: Print the " Bastien Nocera
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

This property should allow any program to show whether an adapter is in
the process of being turned on.

As turning on an adapter isn't instantaneous, it's important that the UI
reflects the transitional state of the adapter's power, and doesn't
assume the device is already turned on but not yet working, or still off
despite having requested for it to be turned on, in both cases making
the UI feel unresponsive.

This can also not be implemented in front-ends directly as, then,
the status of an adapter wouldn't be reflected correctly in the Settings
window if it's turned on in the system menu. Implementing it in the
front-ends would also preclude from having feedback about the state of
the adapter when bluetoothd is the one powering up the adapter after the
rfkill was unblocked.

See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121
and the original https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773
---
 src/adapter.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 128 insertions(+), 11 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 7c11a688d..59afbcb6d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -239,6 +239,14 @@ struct btd_adapter_pin_cb_iter {
 	/* When the iterator reaches the end, it is NULL and attempt is 0 */
 };
 
+enum {
+	ADAPTER_POWER_STATE_OFF,
+	ADAPTER_POWER_STATE_ON,
+	ADAPTER_POWER_STATE_ON_DISABLING,
+	ADAPTER_POWER_STATE_OFF_ENABLING,
+	ADAPTER_POWER_STATE_OFF_BLOCKED,
+};
+
 struct btd_adapter {
 	int ref_count;
 
@@ -250,9 +258,9 @@ struct btd_adapter {
 	uint32_t dev_class;		/* controller class of device */
 	char *name;			/* controller device name */
 	char *short_name;		/* controller short name */
-	bool blocked;			/* whether rfkill is enabled */
 	uint32_t supported_settings;	/* controller supported settings */
 	uint32_t pending_settings;	/* pending controller settings */
+	uint32_t power_state;		/* the power state */
 	uint32_t current_settings;	/* current controller settings */
 
 	char *path;			/* adapter object path */
@@ -326,6 +334,24 @@ struct btd_adapter {
 	struct queue *exps;
 };
 
+static char *adapter_power_state_str(uint32_t power_state)
+{
+	switch (power_state) {
+	case ADAPTER_POWER_STATE_OFF:
+		return "off";
+	case ADAPTER_POWER_STATE_ON:
+		return "on";
+	case ADAPTER_POWER_STATE_ON_DISABLING:
+		return "on-disabling";
+	case ADAPTER_POWER_STATE_OFF_ENABLING:
+		return "off-enabling";
+	case ADAPTER_POWER_STATE_OFF_BLOCKED:
+		return "off-blocked";
+	}
+	DBG("Invalid power state %d", power_state);
+	return "";
+}
+
 typedef enum {
 	ADAPTER_AUTHORIZE_DISCONNECTED = 0,
 	ADAPTER_AUTHORIZE_CHECK_CONNECTED
@@ -619,6 +645,29 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings)
 	}
 }
 
+static void adapter_set_power_state(struct btd_adapter *adapter, uint32_t value)
+{
+	if (adapter->power_state == value)
+		return;
+
+	DBG("%s", adapter_power_state_str(value));
+	adapter->power_state = value;
+	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+					ADAPTER_INTERFACE, "PowerState");
+}
+
+static void reset_power_state_target(struct btd_adapter *adapter,
+					uint32_t value)
+{
+	if (value &&
+	    adapter->power_state == ADAPTER_POWER_STATE_OFF_ENABLING) {
+		adapter_set_power_state(adapter, ADAPTER_POWER_STATE_ON);
+	} else if (!value &&
+		   adapter->power_state == ADAPTER_POWER_STATE_ON_DISABLING) {
+		adapter_set_power_state(adapter, ADAPTER_POWER_STATE_OFF);
+	}
+}
+
 static void new_settings_callback(uint16_t index, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -636,6 +685,12 @@ static void new_settings_callback(uint16_t index, uint16_t length,
 	if (settings == adapter->current_settings)
 		return;
 
+	if ((adapter->current_settings ^ settings) & MGMT_SETTING_POWERED) {
+		reset_power_state_target(adapter,
+					settings & MGMT_SETTING_POWERED ?
+					0x01 : 0x00);
+	}
+
 	DBG("Settings: 0x%08x", settings);
 
 	settings_changed(adapter, settings);
@@ -644,6 +699,7 @@ static void new_settings_callback(uint16_t index, uint16_t length,
 struct set_mode_data {
 	struct btd_adapter *adapter;
 	uint32_t setting;
+	uint8_t value;
 };
 
 static void set_mode_complete(uint8_t status, uint16_t length,
@@ -656,8 +712,12 @@ static void set_mode_complete(uint8_t status, uint16_t length,
 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
 						mgmt_errstr(status), status);
 		if (status == MGMT_STATUS_RFKILLED)
-			adapter->blocked = true;
+			adapter_set_power_state(adapter,
+					ADAPTER_POWER_STATE_OFF_BLOCKED);
 		adapter->pending_settings &= ~data->setting;
+		if (status != MGMT_STATUS_RFKILLED &&
+		    data->setting & MGMT_SETTING_POWERED)
+			reset_power_state_target(adapter, data->value);
 		return;
 	}
 
@@ -695,6 +755,11 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
 	switch (opcode) {
 	case MGMT_OP_SET_POWERED:
 		setting = MGMT_SETTING_POWERED;
+		if (adapter->power_state != ADAPTER_POWER_STATE_OFF_BLOCKED) {
+			adapter_set_power_state(adapter, mode ?
+					ADAPTER_POWER_STATE_OFF_ENABLING :
+					ADAPTER_POWER_STATE_ON_DISABLING);
+		}
 		break;
 	case MGMT_OP_SET_CONNECTABLE:
 		setting = MGMT_SETTING_CONNECTABLE;
@@ -715,6 +780,7 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
 	data = g_new0(struct set_mode_data, 1);
 	data->adapter = adapter;
 	data->setting = setting;
+	data->value = mode;
 
 	if (mgmt_send(adapter->mgmt, opcode,
 				adapter->dev_id, sizeof(cp), &cp,
@@ -722,8 +788,13 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
 		adapter->pending_settings |= setting;
 		return true;
 	}
-
 	g_free(data);
+	if (setting == MGMT_SETTING_POWERED) {
+		/* cancel the earlier setting */
+		adapter_set_power_state(adapter, mode ?
+					ADAPTER_POWER_STATE_OFF :
+					ADAPTER_POWER_STATE_ON);
+	}
 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
 							adapter->dev_id);
 
@@ -2934,6 +3005,7 @@ struct property_set_data {
 	struct btd_adapter *adapter;
 	uint32_t setting;
 	GDBusPendingPropertySet id;
+	uint8_t value;
 };
 
 static void property_set_mode_complete(uint8_t status, uint16_t length,
@@ -2952,7 +3024,8 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
 
 		if (status == MGMT_STATUS_RFKILLED) {
 			dbus_err = ERROR_INTERFACE ".Blocked";
-			adapter->blocked = true;
+			adapter_set_power_state(adapter,
+					ADAPTER_POWER_STATE_OFF_BLOCKED);
 		} else {
 			dbus_err = ERROR_INTERFACE ".Failed";
 		}
@@ -2961,6 +3034,9 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
 							mgmt_errstr(status));
 
 		adapter->pending_settings &= ~data->setting;
+		if (status != MGMT_STATUS_RFKILLED &&
+		    data->setting & MGMT_SETTING_POWERED)
+			reset_power_state_target(adapter, data->value);
 		return;
 	}
 
@@ -3084,6 +3160,15 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
 	data->adapter = adapter;
 	data->setting = setting;
 	data->id = id;
+	data->setting = setting;
+	data->value = mode;
+
+	if (setting == MGMT_SETTING_POWERED &&
+	    adapter->power_state != ADAPTER_POWER_STATE_OFF_BLOCKED) {
+		adapter_set_power_state(adapter, mode ?
+					ADAPTER_POWER_STATE_OFF_ENABLING :
+					ADAPTER_POWER_STATE_ON_DISABLING);
+	}
 
 	if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param,
 			property_set_mode_complete, data, g_free) > 0) {
@@ -3092,6 +3177,12 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
 	}
 
 	g_free(data);
+	if (setting == MGMT_SETTING_POWERED) {
+		/* cancel the earlier setting */
+		adapter_set_power_state(adapter, mode ?
+					ADAPTER_POWER_STATE_OFF :
+					ADAPTER_POWER_STATE_ON);
+	}
 
 failed:
 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
@@ -3123,6 +3214,18 @@ static void property_set_powered(const GDBusPropertyTable *property,
 	property_set_mode(adapter, MGMT_SETTING_POWERED, iter, id);
 }
 
+static gboolean property_get_power_state(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	const char *str;
+
+	str = adapter_power_state_str(adapter->power_state);
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str);
+
+	return TRUE;
+}
+
 static gboolean property_get_discoverable(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *user_data)
 {
@@ -3761,6 +3864,8 @@ static const GDBusPropertyTable adapter_properties[] = {
 	{ "Alias", "s", property_get_alias, property_set_alias },
 	{ "Class", "u", property_get_class },
 	{ "Powered", "b", property_get_powered, property_set_powered },
+	{ "PowerState", "s", property_get_power_state, NULL, NULL,
+			     G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
 	{ "Discoverable", "b", property_get_discoverable,
 					property_set_discoverable },
 	{ "DiscoverableTimeout", "u", property_get_discoverable_timeout,
@@ -5567,6 +5672,7 @@ static void adapter_start(struct btd_adapter *adapter)
 {
 	g_dbus_emit_property_changed(dbus_conn, adapter->path,
 						ADAPTER_INTERFACE, "Powered");
+	adapter_set_power_state(adapter, ADAPTER_POWER_STATE_ON);
 
 	DBG("adapter %s has been enabled", adapter->path);
 
@@ -6697,7 +6803,7 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
 	adapter->pincode_requested = false;
 	blocked = rfkill_get_blocked(index);
 	if (blocked > 0)
-		adapter->blocked = true;
+		adapter->power_state = ADAPTER_POWER_STATE_OFF_BLOCKED;
 
 	/*
 	 * Setup default configuration values. These are either adapter
@@ -6724,7 +6830,8 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
 	DBG("Discoverable timeout: %u seconds", adapter->discoverable_timeout);
 	DBG("Pairable timeout: %u seconds", adapter->pairable_timeout);
 	if (blocked > 0)
-		DBG("Blocked: yes");
+		DBG("Power state: %s",
+			adapter_power_state_str(adapter->power_state));
 
 	adapter->auths = g_queue_new();
 	adapter->exps = queue_new();
@@ -7316,6 +7423,9 @@ static void adapter_stop(struct btd_adapter *adapter)
 
 	g_dbus_emit_property_changed(dbus_conn, adapter->path,
 						ADAPTER_INTERFACE, "Powered");
+	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+						ADAPTER_INTERFACE,
+						"PowerState");
 
 	DBG("adapter %s has been disabled", adapter->path);
 }
@@ -7592,10 +7702,18 @@ int btd_cancel_authorization(guint id)
 
 int btd_adapter_restore_powered(struct btd_adapter *adapter)
 {
-	if (adapter->blocked)
-		adapter->blocked = false;
+	bool powered;
 
-	if (btd_adapter_get_powered(adapter))
+	powered = btd_adapter_get_powered(adapter);
+	if (adapter->power_state == ADAPTER_POWER_STATE_OFF_BLOCKED &&
+	    rfkill_get_blocked(adapter->dev_id) == 0) {
+		adapter_set_power_state(adapter,
+					powered ?
+					ADAPTER_POWER_STATE_ON :
+					ADAPTER_POWER_STATE_OFF);
+	}
+
+	if (powered)
 		return 0;
 
 	set_mode(adapter, MGMT_OP_SET_POWERED, 0x01);
@@ -7605,8 +7723,7 @@ int btd_adapter_restore_powered(struct btd_adapter *adapter)
 
 int btd_adapter_set_blocked(struct btd_adapter *adapter)
 {
-	if (!adapter->blocked)
-		adapter->blocked = true;
+	adapter_set_power_state(adapter, ADAPTER_POWER_STATE_OFF_BLOCKED);
 	return 0;
 }
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH BlueZ v7 3/6] client: Print the PowerState property
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 2/6] adapter: Implement PowerState property Bastien Nocera
@ 2022-09-01 11:07 ` Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 4/6] adapter-api: Add PowerState property documentation Bastien Nocera
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

---
 client/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/client/main.c b/client/main.c
index 6773d5262..2816e880f 100644
--- a/client/main.c
+++ b/client/main.c
@@ -981,6 +981,7 @@ static void cmd_show(int argc, char *argv[])
 	print_property(adapter->proxy, "Alias");
 	print_property(adapter->proxy, "Class");
 	print_property(adapter->proxy, "Powered");
+	print_property(adapter->proxy, "PowerState");
 	print_property(adapter->proxy, "Discoverable");
 	print_property(adapter->proxy, "DiscoverableTimeout");
 	print_property(adapter->proxy, "Pairable");
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH BlueZ v7 4/6] adapter-api: Add PowerState property documentation
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 2/6] adapter: Implement PowerState property Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 3/6] client: Print the " Bastien Nocera
@ 2022-09-01 11:07 ` Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 5/6] adapter: Fix typo in function name Bastien Nocera
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

---
 doc/adapter-api.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 48466ab75..9b2721c1b 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -269,6 +269,21 @@ Properties	string Address [readonly]
 			restart or unplugging of the adapter it will reset
 			back to false.
 
+		string PowerState [readonly, experimental]
+
+			The power state of an adapter.
+
+			The power state will show whether the adapter is
+			turning off, or turning on, as well as being on
+			or off.
+
+			Possible values:
+				"on" - powered on
+				"off" - powered off
+				"off-enabling" - transitioning from "off" to "on"
+				"on-disabling" - transitioning from "on" to "off"
+				"off-blocked" - blocked by rfkill
+
 		boolean Discoverable [readwrite]
 
 			Switch an adapter to discoverable or non-discoverable
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH BlueZ v7 5/6] adapter: Fix typo in function name
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
                   ` (2 preceding siblings ...)
  2022-09-01 11:07 ` [PATCH BlueZ v7 4/6] adapter-api: Add PowerState property documentation Bastien Nocera
@ 2022-09-01 11:07 ` Bastien Nocera
  2022-09-01 11:07 ` [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState Bastien Nocera
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

---
 src/adapter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 59afbcb6d..8fb2acdc8 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3511,7 +3511,7 @@ static gboolean property_get_experimental(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
-static gboolean property_experimental_exits(const GDBusPropertyTable *property,
+static gboolean property_experimental_exists(const GDBusPropertyTable *property,
 								void *data)
 {
 	struct btd_adapter *adapter = data;
@@ -3879,7 +3879,7 @@ static const GDBusPropertyTable adapter_properties[] = {
 					property_exists_modalias },
 	{ "Roles", "as", property_get_roles },
 	{ "ExperimentalFeatures", "as", property_get_experimental, NULL,
-					property_experimental_exits },
+					property_experimental_exists },
 	{ }
 };
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
                   ` (3 preceding siblings ...)
  2022-09-01 11:07 ` [PATCH BlueZ v7 5/6] adapter: Fix typo in function name Bastien Nocera
@ 2022-09-01 11:07 ` Bastien Nocera
  2022-11-13 15:54   ` Jonas Dreßler
  2022-09-01 12:18 ` [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is rfkill'ed bluez.test.bot
  2022-09-01 18:50 ` [PATCH BlueZ v7 1/6] " patchwork-bot+bluetooth
  6 siblings, 1 reply; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 11:07 UTC (permalink / raw)
  To: linux-bluetooth

Now that the feature has been tested, that the API is deemed adequate
and the reliability sufficient.
---
 src/adapter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 8fb2acdc8..841096d7f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3864,8 +3864,7 @@ static const GDBusPropertyTable adapter_properties[] = {
 	{ "Alias", "s", property_get_alias, property_set_alias },
 	{ "Class", "u", property_get_class },
 	{ "Powered", "b", property_get_powered, property_set_powered },
-	{ "PowerState", "s", property_get_power_state, NULL, NULL,
-			     G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+	{ "PowerState", "s", property_get_power_state },
 	{ "Discoverable", "b", property_get_discoverable,
 					property_set_discoverable },
 	{ "DiscoverableTimeout", "u", property_get_discoverable_timeout,
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* RE: [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is rfkill'ed
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
                   ` (4 preceding siblings ...)
  2022-09-01 11:07 ` [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState Bastien Nocera
@ 2022-09-01 12:18 ` bluez.test.bot
  2022-09-01 18:50 ` [PATCH BlueZ v7 1/6] " patchwork-bot+bluetooth
  6 siblings, 0 replies; 12+ messages in thread
From: bluez.test.bot @ 2022-09-01 12:18 UTC (permalink / raw)
  To: linux-bluetooth, hadess

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=673192

---Test result---

Test Summary:
CheckPatch                    PASS      9.13 seconds
GitLint                       PASS      6.18 seconds
Prep - Setup ELL              PASS      31.76 seconds
Build - Prep                  PASS      0.90 seconds
Build - Configure             PASS      10.19 seconds
Build - Make                  PASS      939.89 seconds
Make Check                    PASS      12.96 seconds
Make Check w/Valgrind         PASS      340.88 seconds
Make Distcheck                PASS      284.03 seconds
Build w/ext ELL - Configure   PASS      10.35 seconds
Build w/ext ELL - Make        PASS      97.92 seconds
Incremental Build w/ patches  PASS      700.61 seconds
Scan Build                    PASS      756.40 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed
  2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
                   ` (5 preceding siblings ...)
  2022-09-01 12:18 ` [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is rfkill'ed bluez.test.bot
@ 2022-09-01 18:50 ` patchwork-bot+bluetooth
  2022-09-01 20:10   ` Bastien Nocera
  6 siblings, 1 reply; 12+ messages in thread
From: patchwork-bot+bluetooth @ 2022-09-01 18:50 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu,  1 Sep 2022 13:07:14 +0200 you wrote:
> Instead of only replying to D-Bus requests with an error saying the
> adapter is blocked, keep track of the rfkill being enabled or disabled
> so we know the rfkill state of the adapter at all times.
> ---
>  src/adapter.c | 25 +++++++++++++--
>  src/adapter.h |  1 +
>  src/btd.h     |  1 +
>  src/rfkill.c  | 89 ++++++++++++++++++++++++++++++++++++++-------------
>  4 files changed, 91 insertions(+), 25 deletions(-)

Here is the summary with links:
  - [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is rfkill'ed
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=abf5ba6b80ad
  - [BlueZ,v7,2/6] adapter: Implement PowerState property
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=58021a665b7f
  - [BlueZ,v7,3/6] client: Print the PowerState property
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=48992da64f52
  - [BlueZ,v7,4/6] adapter-api: Add PowerState property documentation
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6e49216ad47d
  - [BlueZ,v7,5/6] adapter: Fix typo in function name
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=61f4f2895882
  - [BlueZ,v7,6/6] adapter: Remove experimental flag for PowerState
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed
  2022-09-01 18:50 ` [PATCH BlueZ v7 1/6] " patchwork-bot+bluetooth
@ 2022-09-01 20:10   ` Bastien Nocera
  0 siblings, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-09-01 20:10 UTC (permalink / raw)
  To: patchwork-bot+bluetooth; +Cc: linux-bluetooth

On Thu, 2022-09-01 at 18:50 +0000, patchwork-bot+bluetooth@kernel.org
wrote:
> Hello:
> 
> This series was applied to bluetooth/bluez.git (master)
> by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
> 
> On Thu,  1 Sep 2022 13:07:14 +0200 you wrote:
> > Instead of only replying to D-Bus requests with an error saying the
> > adapter is blocked, keep track of the rfkill being enabled or
> > disabled
> > so we know the rfkill state of the adapter at all times.
> > ---
> >  src/adapter.c | 25 +++++++++++++--
> >  src/adapter.h |  1 +
> >  src/btd.h     |  1 +
> >  src/rfkill.c  | 89 ++++++++++++++++++++++++++++++++++++++---------
> > ----
> >  4 files changed, 91 insertions(+), 25 deletions(-)
> 
> Here is the summary with links:
>   - [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is
> rfkill'ed
>    
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=abf5ba6b80ad
>   - [BlueZ,v7,2/6] adapter: Implement PowerState property
>    
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=58021a665b7f
>   - [BlueZ,v7,3/6] client: Print the PowerState property
>    
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=48992da64f52
>   - [BlueZ,v7,4/6] adapter-api: Add PowerState property documentation
>    
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6e49216ad47d
>   - [BlueZ,v7,5/6] adapter: Fix typo in function name
>    
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=61f4f2895882
>   - [BlueZ,v7,6/6] adapter: Remove experimental flag for PowerState
>     (no matching commit)
> 
> You are awesome, thank you!

Sweet, thanks!

The links are missing "commit/" in the URL though, so should be:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=abf5ba6b80ad
not:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=abf5ba6b80ad

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState
  2022-09-01 11:07 ` [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState Bastien Nocera
@ 2022-11-13 15:54   ` Jonas Dreßler
  2022-11-14 23:35     ` Luiz Augusto von Dentz
  2022-11-17 14:18     ` Bastien Nocera
  0 siblings, 2 replies; 12+ messages in thread
From: Jonas Dreßler @ 2022-11-13 15:54 UTC (permalink / raw)
  To: Bastien Nocera, linux-bluetooth, luiz.von.dentz

Hi everyone,

Can we please apply this one, too? The property being experimental means distros
need to downstream patch BlueZ for the feature to work, I'm not sure all packagers
are aware of that.

FWIW, I can confirm the feature in gnome-shell works after removing the flag!

Cheers,
Jonas

On 9/1/22 13:07, Bastien Nocera wrote:
> Now that the feature has been tested, that the API is deemed adequate
> and the reliability sufficient.
> ---
>   src/adapter.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/adapter.c b/src/adapter.c
> index 8fb2acdc8..841096d7f 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3864,8 +3864,7 @@ static const GDBusPropertyTable adapter_properties[] = {
>   	{ "Alias", "s", property_get_alias, property_set_alias },
>   	{ "Class", "u", property_get_class },
>   	{ "Powered", "b", property_get_powered, property_set_powered },
> -	{ "PowerState", "s", property_get_power_state, NULL, NULL,
> -			     G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
> +	{ "PowerState", "s", property_get_power_state },
>   	{ "Discoverable", "b", property_get_discoverable,
>   					property_set_discoverable },
>   	{ "DiscoverableTimeout", "u", property_get_discoverable_timeout,


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState
  2022-11-13 15:54   ` Jonas Dreßler
@ 2022-11-14 23:35     ` Luiz Augusto von Dentz
  2022-11-17 14:18     ` Bastien Nocera
  1 sibling, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2022-11-14 23:35 UTC (permalink / raw)
  To: Jonas Dreßler; +Cc: Bastien Nocera, linux-bluetooth, luiz.von.dentz

Hi Jonas,

On Sun, Nov 13, 2022 at 8:03 AM Jonas Dreßler <jonas@dressler.it> wrote:
>
> Hi everyone,
>
> Can we please apply this one, too? The property being experimental means distros
> need to downstream patch BlueZ for the feature to work, I'm not sure all packagers
> are aware of that.

Well experimental can be enabled by passing -E to bluetoothd, so it
can be enabled at runtime, that said we might switch it to stable on
the next release.

> FWIW, I can confirm the feature in gnome-shell works after removing the flag!
>
> Cheers,
> Jonas
>
> On 9/1/22 13:07, Bastien Nocera wrote:
> > Now that the feature has been tested, that the API is deemed adequate
> > and the reliability sufficient.
> > ---
> >   src/adapter.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 8fb2acdc8..841096d7f 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -3864,8 +3864,7 @@ static const GDBusPropertyTable adapter_properties[] = {
> >       { "Alias", "s", property_get_alias, property_set_alias },
> >       { "Class", "u", property_get_class },
> >       { "Powered", "b", property_get_powered, property_set_powered },
> > -     { "PowerState", "s", property_get_power_state, NULL, NULL,
> > -                          G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
> > +     { "PowerState", "s", property_get_power_state },
> >       { "Discoverable", "b", property_get_discoverable,
> >                                       property_set_discoverable },
> >       { "DiscoverableTimeout", "u", property_get_discoverable_timeout,
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState
  2022-11-13 15:54   ` Jonas Dreßler
  2022-11-14 23:35     ` Luiz Augusto von Dentz
@ 2022-11-17 14:18     ` Bastien Nocera
  1 sibling, 0 replies; 12+ messages in thread
From: Bastien Nocera @ 2022-11-17 14:18 UTC (permalink / raw)
  To: Jonas Dreßler, linux-bluetooth, luiz.von.dentz

On Sun, 2022-11-13 at 16:54 +0100, Jonas Dreßler wrote:
> Hi everyone,
> 
> Can we please apply this one, too? The property being experimental
> means distros
> need to downstream patch BlueZ for the feature to work, I'm not sure
> all packagers
> are aware of that.

I enabled it without the experimental flag in Fedora, because I wrote
it, and I know I'll be responsible for it should there be any bugs.

I really don't want to be on the spot for fixing a problem upstream, or
in another distribution if another distribution enables the feature
without testing it, or responsible for fixing their libraries should we
decide that the API isn't good enough.

> FWIW, I can confirm the feature in gnome-shell works after removing
> the flag!

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-11-17 14:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 11:07 [PATCH BlueZ v7 1/6] adapter: Keep track of whether the adapter is rfkill'ed Bastien Nocera
2022-09-01 11:07 ` [PATCH BlueZ v7 2/6] adapter: Implement PowerState property Bastien Nocera
2022-09-01 11:07 ` [PATCH BlueZ v7 3/6] client: Print the " Bastien Nocera
2022-09-01 11:07 ` [PATCH BlueZ v7 4/6] adapter-api: Add PowerState property documentation Bastien Nocera
2022-09-01 11:07 ` [PATCH BlueZ v7 5/6] adapter: Fix typo in function name Bastien Nocera
2022-09-01 11:07 ` [PATCH BlueZ v7 6/6] adapter: Remove experimental flag for PowerState Bastien Nocera
2022-11-13 15:54   ` Jonas Dreßler
2022-11-14 23:35     ` Luiz Augusto von Dentz
2022-11-17 14:18     ` Bastien Nocera
2022-09-01 12:18 ` [BlueZ,v7,1/6] adapter: Keep track of whether the adapter is rfkill'ed bluez.test.bot
2022-09-01 18:50 ` [PATCH BlueZ v7 1/6] " patchwork-bot+bluetooth
2022-09-01 20:10   ` Bastien Nocera

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.