#include "bt-hal-log.h"
#include "bt-hal-msg.h"
#include "bt-hal-utils.h"
+#include "bt-hal-adapter-le.h"
#include <bt-hal-adapter-dbus-handler.h>
#include <bt-hal-dbus-common-utils.h>
return BT_STATUS_SUCCESS;
}
-static void ___bt_fill_le_supported_features(const char *item,
- const char *value, uint8_t *le_features)
-{
- DBG("+");
-
- if (g_strcmp0(item, "adv_inst_max") == 0)
- le_features[1] = atoi(value);
- else if (g_strcmp0(item, "rpa_offloading") == 0)
- le_features[2] = atoi(value);
- else if (g_strcmp0(item, "max_filter") == 0)
- le_features[4] = atoi(value);
- else
- DBG("No registered item");
-
- /*
- * TODO: Need to check these usages for Bluez Case. In Bluedroid case,
- * these are used, so just setting all to 0
- */
- le_features[3] = 0; /* Adapter MAX IRK List Size */
- /* lo byte */
- le_features[5] = 0; /* Adapter Scan result storage size */
- /* hi byte */
- le_features[6] = 0;
- le_features[7] = 0; /* Adapter Activity energy info supported */
-
- DBG("-");
-}
-
static gboolean __bt_adapter_all_properties_cb(gpointer user_data)
{
GVariant *result = user_data;
char *name = NULL;
char *val = NULL;
GVariantIter *iter = NULL;
- uint8_t le_features[8];
+ bt_local_le_features_t le_features;
gboolean le_features_present = FALSE;
+ memset(&le_features, 0x00, sizeof(le_features));
+
g_variant_get(value, "as", &iter);
if (iter) {
while (g_variant_iter_loop(iter, "s", &name)) {
DBG("name = %s", name);
g_variant_iter_loop(iter, "s", &val);
DBG("Value = %s", val);
- ___bt_fill_le_supported_features(name, val, le_features);
+ _bt_hal_update_le_feature_support(name, val, &le_features);
le_features_present = TRUE;
}
g_variant_iter_free(iter);
if (le_features_present) {
size += __bt_insert_hal_properties(buf + size,
- HAL_PROP_ADAPTER_LOCAL_LE_FEAT, sizeof(le_features), le_features);
+ HAL_PROP_ADAPTER_LOCAL_LE_FEAT, sizeof(le_features), &le_features);
ev->num_props++;
} else {
DBG("le supported features values are NOT provided by Stack");
int adv_inst_max;
int rpa_offloading;
int max_filter;
+ int le_2m_phy;
+ int le_coded_phy;
} bt_adapter_le_feature_info_t;
typedef struct {
{
__bt_hal_free_le_adv_slot();
}
-gboolean _bt_hal_update_le_feature_support(const char *item, const char *value)
+
+gboolean _bt_hal_update_le_feature_support(const char *item, const char *value,
+ bt_local_le_features_t *le_features)
{
if (item == NULL || value == NULL)
return FALSE;
INFO("Advertising instance max : %d", le_feature_info.adv_inst_max);
le_adv_slot = g_malloc0(sizeof(bt_adapter_le_adv_slot_t) * le_feature_info.adv_inst_max);
}
+ /* Fill LE feature bytes */
+ le_features->max_adv_instance = atoi(value);
+
} else if (g_strcmp0(item, "rpa_offloading") == 0) {
le_feature_info.rpa_offloading = atoi(value);
INFO("RPA offloading : %d", le_feature_info.rpa_offloading);
+
+ /* Fill LE feature bytes */
+ le_features->rpa_offload_supported = atoi(value);
+
} else if (g_strcmp0(item, "max_filter") == 0) {
le_feature_info.max_filter = atoi(value);
INFO("BLE Scan max filter : %d", le_feature_info.max_filter);
+
+ /* Fill LE feature bytes */
+ le_features->max_adv_filter_supported = atoi(value);
+
+ } else if (g_strcmp0(item, "2m_phy") == 0) {
+ if (g_strcmp0(value, "true") == 0) {
+ le_feature_info.le_2m_phy = TRUE;
+ /* Fill LE feature bytes */
+ le_features->le_2m_phy_supported = 0x1;
+ } else {
+ le_feature_info.le_2m_phy = FALSE;
+ /* Fill LE feature bytes */
+ le_features->le_2m_phy_supported = 0x0;
+ }
+ INFO("2M PHY Supported [%s]", le_feature_info.le_2m_phy ? "TRUE" : "FALSE");
+ } else if (g_strcmp0(item, "coded_phy") == 0) {
+ if (g_strcmp0(value, "true") == 0) {
+ le_feature_info.le_coded_phy = TRUE;
+ /* Fill LE feature bytes */
+ le_features->le_coded_phy_supported = 0x1;
+ } else {
+ le_feature_info.le_coded_phy = FALSE;
+ /* Fill LE feature bytes */
+ le_features->le_coded_phy_supported = 0x0;
+ }
+ INFO("CODED PHY Supported [%s]", le_feature_info.le_coded_phy ? "TRUE" : "FALSE");
} else {
DBG("No registered item");
return FALSE;
void _bt_hal_unregister_gatt_le_dbus_handler_cb();
-gboolean _bt_hal_update_le_feature_support(const char *item, const char *value);
+gboolean _bt_hal_update_le_feature_support(const char *item, const char *value,
+ bt_local_le_features_t *le_features);
int _bt_hal_get_available_adv_slot_id(bt_uuid_t *uuid);
char *val = NULL;
GVariantIter *iter = NULL;
g_variant_get(value, "as", &iter);
+ bt_local_le_features_t le_features;
+ gboolean le_features_present = FALSE;
if (iter == NULL)
continue;
+ memset(&le_features, 0x00, sizeof(le_features));
+
while (g_variant_iter_next(iter, "&s", &name) &&
- g_variant_iter_next(iter, "&s", &val)) {
+ g_variant_iter_next(iter, "&s", &val)) {
DBG("name = %s, Value = %s", name, val);
- if (FALSE == _bt_hal_update_le_feature_support(name, val))
+ if (FALSE == _bt_hal_update_le_feature_support(name, val, &le_features))
ERR("Failed to update LE feature (name = %s, value = %s)", name, val);
+ else
+ le_features_present = TRUE;
}
g_variant_iter_free(iter);
+ if (le_features_present) {
+ size += __bt_insert_hal_properties(buf + size,
+ HAL_PROP_ADAPTER_LOCAL_LE_FEAT, sizeof(le_features), &le_features);
+ ev->num_props++;
+ } else {
+ DBG("le supported features values are NOT provided by Stack");
+ }
} else if (!g_strcmp0(key, "IpspInitStateChanged")) {
g_variant_get(value, "b" , &ipsp_initialized);
DBG("##IPSP Initialized = %d", ipsp_initialized);
str += ret;
buf_len -= ret;
- scan_num = (f->scan_result_storage_size_hibyte << 8) +
- f->scan_result_storage_size_lobyte;
+ scan_num = f->scan_result_storage_size;
ret = snprintf(str, buf_len, "Num of offloaded scan results: %u,\n", scan_num);
if (0 > ret) {
str += ret;
buf_len -= ret;
+ ret = snprintf(str, buf_len, "LE 2M PHY Support: %s\n",
+ f->le_2m_phy_supported ? "TRUE" : "FALSE");
+ if (0 > ret) {
+ ERR("snprintf failed with %d", ret);
+ return;
+ }
+ str += ret;
+ buf_len -= ret;
+
+ ret = snprintf(str, buf_len, "LE CODED PHY Support: %s\n",
+ f->le_coded_phy_supported ? "TRUE" : "FALSE");
+ if (0 > ret) {
+ ERR("snprintf failed with %d", ret);
+ return;
+ }
+ str += ret;
+ buf_len -= ret;
+
ret = snprintf(str, buf_len, "}");
if (0 > ret) {
ERR("snprintf failed with %d", ret);
str += sprintf(str, "Num of offloaded scan filters: %u,\n",
f->max_adv_filter_supported);
- scan_num = (f->scan_result_storage_size_hibyte << 8) +
- f->scan_result_storage_size_lobyte;
+ scan_num = f->scan_result_storage_size;
str += sprintf(str, "Num of offloaded scan results: %u,\n", scan_num);
str += sprintf(str, "Activity & energy report support: %s\n",
f->activity_energy_info_supported ? "TRUE" : "FALSE");
+ str += sprintf(str, "LE 2M PHY support: %s\n",
+ f->le_2m_phy_supported ? "TRUE" : "FALSE");
+
+ str += sprintf(str, "LE Coded PHY support: %s\n",
+ f->le_coded_phy_supported ? "TRUE" : "FALSE");
+
sprintf(str, "}");
}
int manufacturer;
} bt_remote_version_t;
+
+typedef struct {
+ uint16_t version_supported;
+ uint8_t local_privacy_enabled;
+ uint8_t max_adv_instance;
+ uint8_t rpa_offload_supported;
+ uint8_t max_irk_list_size;
+ uint8_t max_adv_filter_supported;
+ uint8_t activity_energy_info_supported;
+ uint16_t scan_result_storage_size;
+ uint16_t total_trackable_advertisers;
+ bool extended_scan_support;
+ bool debug_logging_supported;
+ bool le_2m_phy_supported;
+ bool le_coded_phy_supported;
+ bool le_extended_advertising_supported;
+ bool le_periodic_advertising_supported;
+ uint16_t le_maximum_advertising_data_length;
+} bt_local_le_features_t;
+
+/*
typedef struct {
uint8_t local_privacy_enabled;
uint8_t max_adv_instance;
uint8_t scan_result_storage_size_lobyte;
uint8_t scan_result_storage_size_hibyte;
uint8_t activity_energy_info_supported;
-} bt_local_le_features_t;
+} bt_local_le_features_t;*/
/* Bluetooth Adapter and Remote Device property types */
typedef enum {
EVENT(OAL_EVENT_BLE_DISCOVERY_STARTED) /* NULL */\
EVENT(OAL_EVENT_BLE_DISCOVERY_STOPPED) /* NULL */\
EVENT(OAL_EVENT_BLE_REMOTE_DEVICE_FOUND) /* event_ble_scan_result_info */\
+ EVENT(OAL_EVENT_BLE_LOCAL_FEATURES) /* adapter le features */\
EVENT(OAL_EVENT_GATTS_SERVICE_ADDED) /* gatts Service Added */\
EVENT(OAL_EVENT_GATTS_INCLUDED_SERVICE_ADDED) /* gatts Included Service Added */\
EVENT(OAL_EVENT_GATTS_SERVICE_STARTED) /* gatts Service Started */\
} event_adapter_services_t;
typedef struct {
+ /* TODO Add more features */
+ uint8_t max_adv_instance;
+ uint8_t rpa_offloading;
+ uint8_t max_adv_filter;
+ uint8_t le_2m_phy_support;
+ uint8_t le_coded_phy_support;
+} event_adapter_le_features_t;
+
+typedef struct {
remote_device_t device_info;
uint8_t adv_data[62];
int adv_len;
CHECK_OAL_INITIALIZED();
API_TRACE();
-
ret = blued_api->get_adapter_property(BT_PROPERTY_UUIDS);
if (ret != BT_STATUS_SUCCESS) {
BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
return convert_to_oal_status(ret);
}
-
return OAL_STATUS_SUCCESS;
}
BT_DBG("status: %d, count: %d", status, num_properties);
+ print_bt_properties(num_properties, properties);
+
if (status != BT_STATUS_SUCCESS) {
if (num_properties == 1) {
BT_ERR("Adapter Prop failed: status: [%s], count: %d, prop: %d",
event_data, (sizeof(event_device_list_t) + num_bonded * sizeof(bt_bdaddr_t)));
break;
}
+ case BT_PROPERTY_LOCAL_LE_FEATURES: {
+ event_adapter_le_features_t *le_features;
+
+ le_features = g_malloc(sizeof(event_adapter_le_features_t));
+
+ le_features->max_adv_instance = ((bt_local_le_features_t *)(properties[i].val))->max_adv_instance;
+ le_features->rpa_offloading = ((bt_local_le_features_t *)(properties[i].val))->rpa_offload_supported;
+ le_features->max_adv_filter = ((bt_local_le_features_t *)(properties[i].val))->max_adv_filter_supported;
+ le_features->le_2m_phy_support = ((bt_local_le_features_t *)(properties[i].val))->le_2m_phy_supported;
+ le_features->le_coded_phy_support = ((bt_local_le_features_t *)(properties[i].val))->le_2m_phy_supported;
+
+ BT_INFO("LE 2M PHY Support (%d)", le_features->le_2m_phy_support);
+ BT_INFO("LE CODED PHY Support (%d)", le_features->le_coded_phy_support);
+
+ send_event(OAL_EVENT_BLE_LOCAL_FEATURES,
+ le_features,
+ sizeof(event_adapter_le_features_t));
+ break;
+ }
default:
BT_WARN("Unhandled property: %d", properties[i].type);
break;
};
typedef struct {
+ int adv_inst_max;
+ int rpa_offloading;
+ int max_filter;
+ int le_2m_phy;
+ int le_coded_phy;
+} bt_adapter_le_feature_info_t;
+
+/* Set Default values */
+static bt_adapter_le_feature_info_t le_feature_info = {1, 0, 0, 0, 0};
+
+typedef struct {
int adv_handle;
char *sender;
int data_len;
g_gatt_client_id = gattc_event->client_if;
break;
}
+ case OAL_EVENT_BLE_LOCAL_FEATURES: {
+ event_adapter_le_features_t *le_features = event_data;
+
+ le_feature_info.le_2m_phy = le_features->le_2m_phy_support;
+ le_feature_info.le_coded_phy = le_features->le_coded_phy_support;
+
+ BT_INFO("Adapter LE 2M PHY Support [%s]", le_feature_info.le_2m_phy ? "TRUE" : "FALSE");
+ BT_INFO("Adapter LE CODED PHY Support [%s]", le_feature_info.le_coded_phy ? "TRUE" : "FALSE");
+
+ break;
+ }
default:
break;
}
case OAL_EVENT_BLE_DISCOVERY_STARTED:
case OAL_EVENT_BLE_DISCOVERY_STOPPED:
case OAL_EVENT_BLE_REMOTE_DEVICE_FOUND:
+ case OAL_EVENT_BLE_LOCAL_FEATURES:
if (adapter_le_cb)
adapter_le_cb(event_type, event_data);
break;