2021-07-22 06:00:59

by Ayush Garg

[permalink] [raw]
Subject: [PATCH BlueZ 6/7] client: Add support for get/set PHY configuration in bluetoothctl

Verification logs based on BT 5.0 controller
==============================================
[bluetooth] default-phy LE1MTX LE2MTX LE1MRX LE2MRX LECODEDTX LECODEDRX
[bluetooth]
Changing PHY Configuration succeeded
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LE1MTX
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LE1MRX
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LE2MTX
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LE2MRX
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LECODEDTX
Controller D6:C9:16:E8:6A:D9 PhyConfiguration: LECODEDRX

Verification logs based on BT 4.0 controller
=============================================
[bluetooth]# default-phy
Supported phys: BR1M1SLOT
Supported phys: BR1M3SLOT
Supported phys: BR1M5SLOT
Supported phys: EDR2M1SLOT
Supported phys: EDR2M3SLOT
Supported phys: EDR2M5SLOT
Supported phys: EDR3M1SLOT
Supported phys: EDR3M3SLOT
Supported phys: EDR3M5SLOT
Supported phys: LE1MTX
Supported phys: LE1MRX
Selected phys: BR1M1SLOT
Selected phys: LE1MTX
Selected phys: LE1MRX
[bluetooth]# default-phy BR1M1SLOT LE1MTX LE1MRX BR1M3SLOT
Changing PHY Configuration succeeded
[CHG] Controller 00:1A:7D:DA:71:14 PhyConfiguration: BR1M1SLOT
[CHG] Controller 00:1A:7D:DA:71:14 PhyConfiguration: BR1M3SLOT
[CHG] Controller 00:1A:7D:DA:71:14 PhyConfiguration: LE1MTX
[CHG] Controller 00:1A:7D:DA:71:14 PhyConfiguration: LE1MRX

Reviewed-by: Anupam Roy <[email protected]>
---
client/main.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)

diff --git a/client/main.c b/client/main.c
index c1a62edb7..ab925769b 100644
--- a/client/main.c
+++ b/client/main.c
@@ -934,6 +934,8 @@ static void cmd_show(int argc, char *argv[])
print_property(adapter->proxy, "Modalias");
print_property(adapter->proxy, "Discovering");
print_property(adapter->proxy, "Roles");
+ print_property(adapter->proxy, "SupportedPhyConfiguration");
+ print_property(adapter->proxy, "PhyConfiguration");

if (adapter->ad_proxy) {
bt_shell_printf("Advertising Features:\n");
@@ -2038,6 +2040,37 @@ static void cmd_disconn(int argc, char *argv[])
proxy_address(proxy));
}

+static void get_phy_configuration(void)
+{
+ print_property_with_label(default_ctrl->proxy,
+ "SupportedPhyConfiguration", "Supported phys");
+
+ print_property_with_label(default_ctrl->proxy, "PhyConfiguration",
+ "Selected phys");
+}
+
+static void cmd_phy_configuration(int argc, char *argv[])
+{
+ char **phys = NULL;
+ size_t phys_len = 0;
+
+ if (check_default_ctrl() == FALSE)
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+ if (argc < 2 || !strlen(argv[1]))
+ return get_phy_configuration();
+
+ phys = g_strdupv(&argv[1]);
+ phys_len = g_strv_length(phys);
+
+ g_dbus_proxy_set_property_array(default_ctrl->proxy,
+ "PhyConfiguration", DBUS_TYPE_STRING, phys,
+ phys_len, generic_callback, "PHY Configuration",
+ NULL);
+
+ g_strfreev(phys);
+}
+
static void cmd_list_attributes(int argc, char *argv[])
{
GDBusProxy *proxy;
@@ -3033,6 +3066,12 @@ static const struct bt_shell_menu main_menu = {
dev_generator },
{ "disconnect", "[dev]", cmd_disconn, "Disconnect device",
dev_generator },
+ { "default-phy", "[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
+ "[LECODEDTX] [LECODEDRX] "
+ "[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT] "
+ "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT] "
+ "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
+ cmd_phy_configuration, "Get/Set PHY Configuration" },
{ } },
};

--
2.17.1