client: Add command wake
Luiz Augusto von Dentz
maintainerPATCH 1/2 client: Add command wake
From: Luiz Augusto von Dentz <[email protected]>
This adds command wake which can be used to set WakeAllowed property:
[bluetoothctl]> wake XX:XX:XX:XX:XX:XX off [bluetoothctl]> Changing wake off succeeded [bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: no [bluetoothctl]> wake XX:XX:XX:XX:XX:XX on [bluetoothctl]> Changing wake on succeeded [bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: yes [bluetoothctl]> wake XX:XX:XX:XX:XX:XX
--- client/main.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
client/main.c +38 -0
@@ -2050,6 +2050,42 @@ static void cmd_disconn(int argc, char *argv[]) proxy_address(proxy)); } +static void cmd_wake (int argc,char *argv[]) +{ +GDBusProxy *proxy; +dbus_bool_t value; +char *str; + + proxy =find_device (argc, argv); +if (!proxy) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +if (argc <=2 ) { +print_property (proxy,"WakeAllowed" ); +return ; + } + +if (!strcasecmp (argv[2 ],"on" )) { + value = TRUE; + }else if (!strcasecmp (argv[2 ],"off" )) { + value = FALSE; + }else { +bt_shell_printf ("Invalid value %s\n" , argv[2 ]); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + + str =g_strdup_printf ("wake %s" , value == TRUE ?"on" :"off" ); + +if (g_dbus_proxy_set_property_basic (proxy,"WakeAllowed" , +DBUS_TYPE_BOOLEAN , &value, + generic_callback, str, g_free)) +return ; + +g_free (str); + +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} +static void cmd_list_attributes (int argc,char *argv[]) {GDBusProxy *proxy;
@@ -3130,6 +3166,8 @@ static const struct bt_shell_menu main_menu = { dev_generator }, {"disconnect" ,"[dev]" , cmd_disconn,"Disconnect device" , dev_generator }, + { "wake", "[dev] [on/off]", cmd_wake, "Get/Set wake support", + dev_generator }, { } }, };
Signature · 1 line
2.47.1
Luiz Augusto von Dentz
maintainerPATCH 2/2 device: Fix not being able to set WakeAllowed
From: Luiz Augusto von Dentz <[email protected]>
Setting WakeAllowed was not working as intended since device_set_wake_override was changing the current_flags which btd_device_flags_changed checks to determine if flags has been changed to only then call device_set_wake_allowed_complete.
--- src/device.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
src/device.c +26 -11
@@ -1515,13 +1515,21 @@ void device_set_wake_support(struct btd_device *device, bool wake_support) device->wake_support = wake_support; -/* If wake configuration has not been made yet, set the initial -* configuration. +if (device->wake_support) + device->supported_flags |=DEVICE_FLAG_REMOTE_WAKEUP ; +else + device->supported_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP ; + +/* If there is not override set, set the default the same as +* support value. */ -if (device->wake_override ==WAKE_FLAG_DEFAULT ) { +if (device->wake_override ==WAKE_FLAG_DEFAULT )device_set_wake_override (device, wake_support); -device_set_wake_allowed (device, wake_support,-1U ); - } + +/* Set wake_allowed according to the override value. */ +device_set_wake_allowed (device, + device->wake_override ==WAKE_FLAG_ENABLED , +-1U ); }static bool device_get_wake_allowed (struct btd_device *device)
@@ -1531,13 +1539,10 @@ static bool device_get_wake_allowed(struct btd_device *device)void device_set_wake_override (struct btd_device *device,bool wake_override) { -if (wake_override) { +if (wake_override) device->wake_override =WAKE_FLAG_ENABLED ; - device->current_flags |=DEVICE_FLAG_REMOTE_WAKEUP ; - }else { +else device->wake_override =WAKE_FLAG_DISABLED ; - device->current_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP ; - } }static void device_set_wake_allowed_complete (struct btd_device *device)
@@ -1563,6 +1568,12 @@ static void set_wake_allowed_complete(uint8_t status, uint16_t length,if (status !=MGMT_STATUS_SUCCESS ) {error ("Set device flags return status: %s" ,mgmt_errstr (status)); +if (dev->wake_id !=-1U ) { +g_dbus_pending_property_error (dev->wake_id, +ERROR_INTERFACE ".Failed" , +mgmt_errstr (status)); + dev->wake_id =-1U ; + }return ; }
@@ -1583,8 +1594,11 @@ void device_set_wake_allowed(struct btd_device *device, bool wake_allowed,* progress. Only update wake allowed if pending value doesn't match the * new value. */ -if (wake_allowed == device->pending_wake_allowed) +if (device->wake_id !=-1U && id !=-1U ) { +g_dbus_pending_property_error (id,ERROR_INTERFACE ".Busy" , +"Property change in progress" );return ; + } device->wake_id = id; device->pending_wake_allowed = wake_allowed;
@@ -4358,6 +4372,7 @@ static struct btd_device *device_new(struct btd_adapter *adapter, device->tx_power =127 ; device->volume =-1 ; + device->wake_id =-1U ; device->db =gatt_db_new ();if (!device->db) {
Signature · 1 line
2.47.1
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=918786
---Test result---
Test Summary:
CheckPatch PENDING 0.22 seconds GitLint PENDING 0.19 seconds BuildEll PASS 20.44 seconds BluezMake PASS 1576.00 seconds MakeCheck PASS 12.89 seconds MakeDistcheck PASS 158.77 seconds CheckValgrind PASS 214.09 seconds CheckSmatch PASS 273.04 seconds bluezmakeextell PASS 99.11 seconds IncrementalBuild PENDING 0.29 seconds ScanBuild PASS 845.50 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 12 lines · On Tue, 17 Dec 2024 13:13:33 -0500 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
This adds command wake which can be used to set WakeAllowed property:
[bluetoothctl]> wake XX:XX:XX:XX:XX:XX off [bluetoothctl]> Changing wake off succeeded [bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: no [bluetoothctl]> wake XX:XX:XX:XX:XX:XX on [bluetoothctl]> Changing wake on succeeded [bluetoothctl]> [CHG] Device XX:XX:XX:XX:XX:XX WakeAllowed: yes [bluetoothctl]> wake XX:XX:XX:XX:XX:XX
Quoted 1 line
[...]
Here is the summary with links:
- [BlueZ,v1,1/2] client: Add command wake
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c0fb6c067e48 - [BlueZ,v1,2/2] device: Fix not being able to set WakeAllowed https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=dfb1ffdc95a0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html