OSDN Git Service

Bluetooth 5 feature check implementation (1/3)
authorJakub Pawlowski <jpawlowski@google.com>
Fri, 10 Mar 2017 02:11:43 +0000 (18:11 -0800)
committerJakub Pawlowski <jpawlowski@google.com>
Fri, 10 Mar 2017 02:18:59 +0000 (18:18 -0800)
Wire the new feature check API to actual values received from the
controller.

Test: manual
Bug: 30622771
Change-Id: I2eefb7d5bb00d89ac7ea803191ba05f830080ade

btif/src/btif_dm.cc
device/include/controller.h
device/src/controller.cc
stack/include/hcidefs.h

index 5f29a49..47c6e4f 100644 (file)
@@ -59,6 +59,7 @@
 #include "btif_util.h"
 #include "btif_util.h"
 #include "btu.h"
+#include "device/include/controller.h"
 #include "device/include/interop.h"
 #include "include/stack_config.h"
 #include "osi/include/allocator.h"
@@ -1887,6 +1888,16 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
       local_le_features.debug_logging_supported =
           cmn_vsc_cb.debug_logging_supported > 0;
 
+      const controller_t* controller = controller_get_interface();
+
+      local_le_features.le_2m_phy_supported = controller->supports_ble_2m_phy();
+      local_le_features.le_coded_phy_supported =
+          controller->supports_ble_coded_phy();
+      local_le_features.le_extended_advertising_supported =
+          controller->supports_ble_extended_advertising();
+      local_le_features.le_periodic_advertising_supported =
+          controller->supports_ble_periodic_advertising();
+
       memcpy(prop.val, &local_le_features, prop.len);
       HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, BT_STATUS_SUCCESS, 1,
                 &prop);
index 228beb9..cfe7c80 100644 (file)
@@ -54,6 +54,8 @@ typedef struct controller_t {
   bool (*supports_ble_packet_extension)(void);
   bool (*supports_ble_connection_parameters_request)(void);
   bool (*supports_ble_privacy)(void);
+  bool (*supports_ble_2m_phy)(void);
+  bool (*supports_ble_coded_phy)(void);
   bool (*supports_ble_extended_advertising)(void);
   bool (*supports_ble_periodic_advertising)(void);
 
index d0014d2..9a74687 100644 (file)
@@ -377,6 +377,18 @@ static bool supports_ble_connection_parameters_request(void) {
   return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array);
 }
 
+static bool supports_ble_2m_phy(void) {
+  CHECK(readable);
+  CHECK(ble_supported);
+  return HCI_LE_2M_PHY_SUPPORTED(features_ble.as_array);
+}
+
+static bool supports_ble_coded_phy(void) {
+  CHECK(readable);
+  CHECK(ble_supported);
+  return HCI_LE_CODED_PHY_SUPPORTED(features_ble.as_array);
+}
+
 static bool supports_ble_extended_advertising(void) {
   CHECK(readable);
   CHECK(ble_supported);
@@ -486,6 +498,8 @@ static const controller_t interface = {
     supports_ble_packet_extension,
     supports_ble_connection_parameters_request,
     supports_ble_privacy,
+    supports_ble_2m_phy,
+    supports_ble_coded_phy,
     supports_ble_extended_advertising,
     supports_ble_periodic_advertising,
 
index e6c86ea..e958cc7 100644 (file)
@@ -3186,6 +3186,9 @@ typedef struct {
   ((x)[HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF] & \
    HCI_SUPP_COMMANDS_RLE_RC_CONN_PARAM_UPD_NEG_RPY_MASK)
 
+#define HCI_LE_2M_PHY_SUPPORTED(x) (((x)[1] & 0x01))     // BIT 8 SET
+#define HCI_LE_CODED_PHY_SUPPORTED(x) (((x)[1] & 0x08))  // BIT 11 SET
+
 /* LE Advertising Extension related Procedurs */
 #define HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(x) \
   (((x)[1] & 0x10))  // BIT 12 SET