Verification logs based on BT 5.0 controller ============================================== [S20] phy 45:18:F8:CF:23:7E Selected phys: LE1MTX Selected phys: LE1MRX [S20] phy 45:18:F8:CF:23:7E LE2MTX LE2MRX [S20] Changing PHY succeeded Device 45:18:F8:CF:23:7E Phy: LE2MTX Device 45:18:F8:CF:23:7E Phy: LE2MRX Reviewed-by: Anupam Roy <anupam.r@xxxxxxxxxxx> --- client/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/client/main.c b/client/main.c index ab925769b..e7146ab6f 100644 --- a/client/main.c +++ b/client/main.c @@ -1705,6 +1705,7 @@ static void cmd_info(int argc, char *argv[]) print_property(proxy, "TxPower"); print_property(proxy, "AdvertisingFlags"); print_property(proxy, "AdvertisingData"); + print_property(proxy, "Phy"); battery_proxy = find_battery_by_path(battery_proxies, g_dbus_proxy_get_path(proxy)); @@ -2071,6 +2072,47 @@ static void cmd_phy_configuration(int argc, char *argv[]) g_strfreev(phys); } +static void get_phy(GDBusProxy *proxy) +{ + print_property_with_label(proxy, "Phy", + "Selected phys"); +} + +static void cmd_phy(int argc, char *argv[]) +{ + GDBusProxy *proxy; + 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])) { + bt_shell_printf("Device address not given as input\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + proxy = find_proxy_by_address(default_ctrl->devices, argv[1]); + if (!proxy) { + bt_shell_printf("Device %s not available\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (argc == 2) + return get_phy(proxy); + + phys = g_strdupv(&argv[2]); + phys_len = g_strv_length(phys); + + g_dbus_proxy_set_property_array(proxy, + "Phy", DBUS_TYPE_STRING, phys, + phys_len, generic_callback, "PHY", + NULL); + + g_strfreev(phys); +} + + static void cmd_list_attributes(int argc, char *argv[]) { GDBusProxy *proxy; @@ -3072,6 +3114,9 @@ static const struct bt_shell_menu main_menu = { "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT] " "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]", cmd_phy_configuration, "Get/Set PHY Configuration" }, + { "phy", "<dev> [LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] " + "[LECODEDTX] [LECODEDRX] [LECODEDS2] [LECODEDS8]", + cmd_phy, "Get/Set LE PHY preferences for a connected device" }, { } }, }; -- 2.17.1