summaryrefslogtreecommitdiff
path: root/lib/bt/host/bluedroid/device/controller.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bt/host/bluedroid/device/controller.c')
-rw-r--r--lib/bt/host/bluedroid/device/controller.c75
1 files changed, 67 insertions, 8 deletions
diff --git a/lib/bt/host/bluedroid/device/controller.c b/lib/bt/host/bluedroid/device/controller.c
index beb7d676..4b68eb93 100644
--- a/lib/bt/host/bluedroid/device/controller.c
+++ b/lib/bt/host/bluedroid/device/controller.c
@@ -31,10 +31,10 @@
#include "osi/future.h"
#include "config/stack_config.h"
#if (BLE_50_FEATURE_SUPPORT == TRUE)
-const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\xff\xff\xff" };
+const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x07\xff\xff\xff\xff" };
#else
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
-#endif
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_INCLUDED)
const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT };
@@ -83,7 +83,12 @@ typedef struct {
bool simple_pairing_supported;
bool secure_connections_supported;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#if (BLE_50_EXTEND_ADV_EN == TRUE)
uint16_t ble_ext_adv_data_max_len;
+#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
+#if (BLE_50_EXTEND_SYNC_EN == TRUE)
+ uint16_t get_ble_periodic_advertiser_list_size;
+#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE)
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
} controller_local_param_t;
@@ -96,11 +101,16 @@ static controller_local_param_t *controller_param_ptr;
#define AWAIT_COMMAND(command) future_await(controller_param.hci->transmit_command_futured(command))
+static bool loaded = false;
// Module lifecycle functions
static void start_up(void)
{
BT_HDR *response;
+#if (BLE_FEAT_ISO_EN == TRUE)
+ uint16_t iso_pktlen = 0;
+ uint8_t iso_max_pkts = 0;
+#endif // #if (BLE_FEAT_ISO_EN == TRUE)
// Send the initial reset command
response = AWAIT_COMMAND(controller_param.packet_factory->make_reset());
@@ -119,11 +129,13 @@ static void start_up(void)
response = AWAIT_COMMAND(controller_param.packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
controller_param.packet_parser->parse_generic_command_complete(response);
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
+#if (BLE_42_SCAN_EN == TRUE)
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
// Enable adv flow control
response = AWAIT_COMMAND(controller_param.packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
controller_param.packet_parser->parse_generic_command_complete(response);
#endif
+#endif // #if (BLE_42_SCAN_EN == TRUE)
// Tell the controller about our buffer sizes and buffer counts next
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
response = AWAIT_COMMAND(
@@ -176,7 +188,7 @@ static void start_up(void)
// dependent on what we configure from page 0 and host SSP configuration
controller_param.simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(
controller_param.features_classic[0].as_array) &&
- (bluedriod_config_get()->get_ssp_enabled());
+ (bluedroid_config_get()->get_ssp_enabled());
if (controller_param.simple_pairing_supported) {
response = AWAIT_COMMAND(controller_param.packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED));
controller_param.packet_parser->parse_generic_command_complete(response);
@@ -211,13 +223,13 @@ static void start_up(void)
}
#endif
-#if (SC_MODE_INCLUDED == TRUE)
+if ((bluedroid_config_get()->get_sc_enabled())) {
controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array);
if (controller_param.secure_connections_supported) {
response = AWAIT_COMMAND(controller_param.packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED));
controller_param.packet_parser->parse_generic_command_complete(response);
}
-#endif
+}
#if (BLE_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED)
@@ -237,7 +249,19 @@ static void start_up(void)
&controller_param.acl_data_size_ble,
&controller_param.acl_buffer_count_ble
);
-
+#if (BLE_FEAT_ISO_EN == TRUE)
+ // Request the ble buffer size next
+ response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_buffer_size_v2());
+ controller_param.packet_parser->parse_ble_read_buffer_size_response_v2(
+ response,
+ &controller_param.acl_data_size_ble,
+ &controller_param.acl_buffer_count_ble,
+ &iso_pktlen,
+ &iso_max_pkts
+ );
+ extern int ble_hci_set_iso_buf_sz(uint16_t pktlen, uint8_t max_pkts);
+ ble_hci_set_iso_buf_sz(iso_pktlen, iso_max_pkts);
+#endif // #if (BLE_FEAT_ISO_EN == TRUE)
// Response of 0 indicates ble has the same buffer size as classic
if (controller_param.acl_data_size_ble == 0) {
controller_param.acl_data_size_ble = controller_param.acl_data_size_classic;
@@ -265,16 +289,26 @@ static void start_up(void)
&controller_param.ble_resolving_list_max_size);
}
#if BLE_50_FEATURE_SUPPORT == TRUE
+#if (BLE_50_EXTEND_ADV_EN == TRUE)
controller_param.ble_ext_adv_data_max_len = BLE_EXT_ADV_DATA_LEN_MAX;
+#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
- if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array)) {
+#if (BLE_50_EXTEND_ADV_EN == TRUE)
+ if (HCI_LE_EXT_ADV_SUPPORTED(controller_param.features_ble.as_array)) {
response = AWAIT_COMMAND(controller_param.packet_factory->make_read_max_adv_data_len());
controller_param.packet_parser->parse_ble_read_adv_max_len_response(
response,
&controller_param.ble_ext_adv_data_max_len);
}
+#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
+#if (BLE_50_EXTEND_SYNC_EN == TRUE)
+ response = AWAIT_COMMAND(controller_param.packet_factory->read_periodic_adv_list_size());
+ controller_param.packet_parser->parse_ble_read_periodic_adv_list_size_response(
+ response,
+ &controller_param.get_ble_periodic_advertiser_list_size);
+#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE)
#endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) {
@@ -315,6 +349,17 @@ static void shut_down(void)
controller_param.readable = false;
}
+#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
+void free_controller_param(void)
+{
+ if (controller_param_ptr) {
+ osi_free(controller_param_ptr);
+ controller_param_ptr = NULL;
+ loaded = false;
+ }
+}
+#endif
+
static bool get_is_ready(void)
{
return controller_param.readable;
@@ -508,6 +553,7 @@ static void set_ble_resolving_list_max_size(int resolving_list_max_size)
controller_param.ble_resolving_list_max_size = resolving_list_max_size;
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#if (BLE_50_EXTEND_ADV_EN == TRUE)
static uint16_t ble_get_ext_adv_data_max_len(void)
{
assert(controller_param.readable);
@@ -515,6 +561,15 @@ static uint16_t ble_get_ext_adv_data_max_len(void)
return controller_param.ble_ext_adv_data_max_len;
}
+#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
+#if (BLE_50_EXTEND_SYNC_EN == TRUE)
+static uint8_t get_ble_periodic_adv_list_size(void)
+{
+ assert(controller_param.readable);
+ assert(controller_param.ble_supported);
+ return controller_param.get_ble_periodic_advertiser_list_size;
+}
+#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE)
static uint8_t get_sco_data_size(void)
@@ -574,7 +629,12 @@ static const controller_t interface = {
get_ble_resolving_list_max_size,
set_ble_resolving_list_max_size,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#if (BLE_50_EXTEND_ADV_EN == TRUE)
ble_get_ext_adv_data_max_len,
+#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
+#if (BLE_50_EXTEND_SYNC_EN == TRUE)
+ get_ble_periodic_adv_list_size,
+#endif // (BLE_50_EXTEND_SYNC_EN == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE)
get_sco_data_size,
@@ -584,7 +644,6 @@ static const controller_t interface = {
const controller_t *controller_get_interface(void)
{
- static bool loaded = false;
if (!loaded) {
loaded = true;
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)