summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnupam Roy <anupam.r@samsung.com>2018-08-06 22:46:01 +0530
committerPyun DoHyun <dh79.pyun@samsung.com>2018-08-07 00:27:55 +0000
commit29f4d6ea68467b59235e7b59dfe39d552a5a8f56 (patch)
tree2a4d763c4e3dcb8da86a434fc742096a8a8d68a7
parent8627e52a262af7963a6ab2ca72c38417475020c5 (diff)
downloadbluez-29f4d6ea68467b59235e7b59dfe39d552a5a8f56.tar.gz
bluez-29f4d6ea68467b59235e7b59dfe39d552a5a8f56.tar.bz2
bluez-29f4d6ea68467b59235e7b59dfe39d552a5a8f56.zip
Implement 'Get Phy Configuration' MGMT command
This patch implements MGMT_OP_GET_PHY_CONFIGURATION operation if MGMT interface supports PHY Configuration setting. It introduces two new adapter properties (l2 2m phy and le coded phy). These properties are filled upon getting response from kernel about supported phys's. which are then exported to user by 'SupportedLEFeatures' adapter property. This mgmt command supports reading above parameters in bit fields, based on LE PHY (1M, 2M & CODED) and also BREDR packet types as following- - BR 1M (1 SLOT, 3 SLOT, 5 SLOT) - EDR 2M (1 SLOT, 3 SLOT, 5 SLOT) - EDR 3M (1 SLOT, 3 SLOT, 5 SLOT) - 1M TX, 1M RX - 2M TX, 2M RX - CODED TX, CODED RX Verification logs based on BT 5.0 controller - bluetoothd[637]: src/adapter.c:get_phy_configuration_resp() Supported phys: [0x7e00] bluetoothd[637]: src/adapter.c:get_phy_configuration_resp() Configurable phys: [0x7800] bluetoothd[637]: src/adapter.c:get_phy_configuration_resp() Selected phys: [0x600] bluetoothd[637]: src/adapter.c:get_phy_configuration_resp() Adapter supports LE 2M PHY bluetoothd[637]: src/adapter.c:get_phy_configuration_resp() Adapter supports LE CODED PHY Change-Id: I9ec3565b5d1b9a0de3daea666d34754958bb1550 Signed-off-by: Anupam Roy <anupam.r@samsung.com>
-rw-r--r--src/adapter.c102
1 files changed, 100 insertions, 2 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 4ff27115..dfff35e1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -343,6 +343,11 @@ struct btd_adapter {
#endif
#endif
bool is_default; /* true if adapter is default one */
+
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ bool le_2m_phy_supported;
+ bool le_coded_phy_supported;
+#endif
};
typedef enum {
@@ -6696,9 +6701,10 @@ static gboolean property_get_supported_le_features(
const char *str, *val;
int value;
DBusMessageIter entry;
+ struct btd_adapter *adapter = user_data;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &entry);
+ DBUS_TYPE_STRING_AS_STRING, &entry);
value = adapter_le_get_max_adv_instance();
if (value > 0) {
@@ -6740,6 +6746,36 @@ static gboolean property_get_supported_le_features(
g_free((void *)val);
}
+ if (adapter->supported_settings & MGMT_SETTING_PHY_CONFIGURATION) {
+ /* 2M PHY Support */
+ str = g_strdup("2m_phy");
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);
+
+ if (adapter->le_2m_phy_supported)
+ val = g_strdup("true");
+ else
+ val = g_strdup("false");
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &val);
+
+ g_free((void *)str);
+ g_free((void *)val);
+
+ /* CODED PHY Support */
+ str = g_strdup("coded_phy");
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);
+
+ if (adapter->le_coded_phy_supported)
+ val = g_strdup("true");
+ else
+ val = g_strdup("false");
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &val);
+
+ g_free((void *)str);
+ g_free((void *)val);
+ }
+
dbus_message_iter_close_container(iter, &entry);
return TRUE;
@@ -8771,8 +8807,62 @@ void adapter_auto_connect_remove(struct btd_adapter *adapter,
adapter->connect_list = g_slist_remove(adapter->connect_list, device);
}
+#if defined (TIZEN_FEATURE_BLUEZ_MODIFY)
+static void get_phy_configuration_resp(uint8_t status, uint16_t len, const void *param,
+ void *user_data)
+{
+ uint32_t supported_phys;
+ uint32_t configurable_phys;
+ uint32_t selected_phys;
+
+ const struct mgmt_rp_get_phy_confguration *rp = param;
+ struct btd_adapter *adapter = user_data;
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Get PHY Configuration failed with status 0x%02x (%s)",
+ status, mgmt_errstr(status));
+ return;
+ }
+
+ if (len < sizeof(*rp)) {
+ error("Too small get-phy reply (%u bytes)", len);
+ return;
+ }
+
+ supported_phys = get_le32(&rp->supported_phys);
+ configurable_phys = get_le32(&rp-> configurable_phys);
+ selected_phys = get_le16(&rp->selected_phys);
+
+ DBG("Supported phys: [0x%x]", supported_phys);
+ DBG("Configurable phys: [0x%x]", configurable_phys);
+ DBG("Selected phys: [0x%x]", selected_phys);
+
+ if (adapter->supported_settings & MGMT_SETTING_LE) {
+ if ((supported_phys & MGMT_PHY_LE_2M_TX) &&
+ (supported_phys & MGMT_PHY_LE_2M_RX)) {
+ DBG("Adapter supports LE 2M PHY");
+ adapter->le_2m_phy_supported = TRUE;
+ } else
+ DBG("Adapter does not support LE 2M PHY");
+
+ if ((supported_phys & MGMT_PHY_LE_CODED_TX) &&
+ (supported_phys & MGMT_PHY_LE_CODED_RX)) {
+ adapter->le_coded_phy_supported = TRUE;
+ DBG("Adapter supports LE CODED PHY");
+ } else
+ DBG("Adapter does not support LE CODED PHY");
+ }
+
+ /* Emit Property Changed Signal */
+ g_dbus_emit_property_changed(dbus_conn, adapter->path,
+ ADAPTER_INTERFACE, "SupportedLEFeatures");
+
+}
+#endif
+
static void adapter_start(struct btd_adapter *adapter)
{
+
#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(__SPRD_PATCH__)
if (adapter_le_read_ble_feature_info())
g_dbus_emit_property_changed(dbus_conn, adapter->path,
@@ -13743,7 +13833,6 @@ static void read_info_complete(uint8_t status, uint16_t length,
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
adapter_check_version(adapter, rp->version);
#endif
-
clear_uuids(adapter);
clear_devices(adapter);
@@ -13765,6 +13854,15 @@ static void read_info_complete(uint8_t status, uint16_t length,
missing_settings = adapter->current_settings ^
adapter->supported_settings;
+/* If adapter supports PHY CONFIGURATION SETTING, then read PHY configuration and save them */
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ if (adapter->supported_settings & MGMT_SETTING_PHY_CONFIGURATION) {
+ if (mgmt_send(adapter->mgmt, MGMT_OP_GET_PHY_CONFIGURATION, adapter->dev_id, 0, NULL,
+ get_phy_configuration_resp, adapter, NULL) == 0)
+ error("Unable to send %s cmd",
+ mgmt_opstr(MGMT_OP_GET_PHY_CONFIGURATION));
+ }
+#endif
switch (main_opts.mode) {
case BT_MODE_DUAL:
if (missing_settings & MGMT_SETTING_SSP) {